Commit c41eaf0a authored by Jason Ekstrand's avatar Jason Ekstrand Committed by Marge Bot
Browse files

anv: Use vk_object_base::type for debug_report



This is way better than the giant macro thing we had before.
Reviewed-by: Lionel Landwerlin's avatarLionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen's avatarBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <!8676>
parent bd1705a4
......@@ -208,7 +208,7 @@ anv_state_table_expand_range(struct anv_state_table *table, uint32_t size)
map = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_POPULATE, table->fd, 0);
if (map == MAP_FAILED) {
return vk_errorf(table->device, table->device,
return vk_errorf(table->device, &table->device->vk.base,
VK_ERROR_OUT_OF_HOST_MEMORY, "mmap failed: %m");
}
......@@ -520,7 +520,7 @@ anv_block_pool_expand_range(struct anv_block_pool *pool,
MAP_SHARED | MAP_POPULATE, pool->fd,
BLOCK_POOL_MEMFD_CENTER - center_bo_offset);
if (map == MAP_FAILED)
return vk_errorf(pool->device, pool->device,
return vk_errorf(pool->device, &pool->device->vk.base,
VK_ERROR_MEMORY_MAP_FAILED, "mmap failed: %m");
struct anv_bo *new_bo;
......
......@@ -3134,8 +3134,7 @@ _anv_device_report_lost(struct anv_device *device)
for (uint32_t i = 0; i < device->queue_count; i++) {
struct anv_queue *queue = &device->queues[i];
if (queue->lost) {
__vk_errorf(device->physical->instance, device,
VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
__vk_errorf(device->physical->instance, &device->vk.base,
VK_ERROR_DEVICE_LOST,
queue->error_file, queue->error_line,
"%s", queue->error_msg);
......@@ -3158,8 +3157,7 @@ _anv_device_set_lost(struct anv_device *device,
device->lost_reported = true;
va_start(ap, msg);
err = __vk_errorv(device->physical->instance, device,
VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
err = __vk_errorv(device->physical->instance, &device->vk.base,
VK_ERROR_DEVICE_LOST, file, line, msg, ap);
va_end(ap);
......@@ -3515,7 +3513,8 @@ VkResult anv_AllocateMemory(
* this sort of attack but only if it can trust the buffer size.
*/
if (mem->bo->size < aligned_alloc_size) {
result = vk_errorf(device, device, VK_ERROR_INVALID_EXTERNAL_HANDLE,
result = vk_errorf(device, &device->vk.base,
VK_ERROR_INVALID_EXTERNAL_HANDLE,
"aligned allocationSize too large for "
"VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT: "
"%"PRIu64"B > %"PRIu64"B",
......@@ -3581,7 +3580,8 @@ VkResult anv_AllocateMemory(
i915_tiling);
if (ret) {
anv_device_release_bo(device, mem->bo);
result = vk_errorf(device, device, VK_ERROR_OUT_OF_DEVICE_MEMORY,
result = vk_errorf(device, &device->vk.base,
VK_ERROR_OUT_OF_DEVICE_MEMORY,
"failed to set BO tiling: %m");
goto fail;
}
......@@ -3593,7 +3593,8 @@ VkResult anv_AllocateMemory(
if (mem_heap_used > mem_heap->size) {
p_atomic_add(&mem_heap->used, -mem->bo->size);
anv_device_release_bo(device, mem->bo);
result = vk_errorf(device, device, VK_ERROR_OUT_OF_DEVICE_MEMORY,
result = vk_errorf(device, &device->vk.base,
VK_ERROR_OUT_OF_DEVICE_MEMORY,
"Out of heap memory");
goto fail;
}
......
......@@ -986,7 +986,8 @@ anv_get_image_format_properties(
* non-mipmapped single-sample) 2D images.
*/
if (info->type != VK_IMAGE_TYPE_2D) {
vk_errorfi(instance, physical_device, VK_ERROR_FORMAT_NOT_SUPPORTED,
vk_errorfi(instance, &physical_device->vk.base,
VK_ERROR_FORMAT_NOT_SUPPORTED,
"VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT "
"requires VK_IMAGE_TYPE_2D");
goto unsupported;
......@@ -1364,7 +1365,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2(
* and therefore requires explicit memory layout.
*/
if (!tiling_has_explicit_layout) {
result = vk_errorfi(instance, physical_device,
result = vk_errorfi(instance, &physical_device->vk.base,
VK_ERROR_FORMAT_NOT_SUPPORTED,
"VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT "
"requires VK_IMAGE_TILING_LINEAR or "
......@@ -1384,7 +1385,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2(
* and therefore requires explicit memory layout.
*/
if (!tiling_has_explicit_layout) {
result = vk_errorfi(instance, physical_device,
result = vk_errorfi(instance, &physical_device->vk.base,
VK_ERROR_FORMAT_NOT_SUPPORTED,
"VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT "
"requires VK_IMAGE_TILING_LINEAR or "
......@@ -1414,7 +1415,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2(
* vkGetPhysicalDeviceImageFormatProperties2 returns
* VK_ERROR_FORMAT_NOT_SUPPORTED.
*/
result = vk_errorfi(physical_device->instance, physical_device,
result = vk_errorfi(instance, &physical_device->vk.base,
VK_ERROR_FORMAT_NOT_SUPPORTED,
"unsupported VkExternalMemoryTypeFlagBits 0x%x",
external_info->handleType);
......
......@@ -395,17 +395,17 @@ add_aux_surface_if_supported(struct anv_device *device,
}
if (device->info.gen == 7) {
anv_perf_warn(device, image, "Implement gen7 HiZ");
anv_perf_warn(device, &image->base, "Implement gen7 HiZ");
return VK_SUCCESS;
}
if (image->levels > 1) {
anv_perf_warn(device, image, "Enable multi-LOD HiZ");
anv_perf_warn(device, &image->base, "Enable multi-LOD HiZ");
return VK_SUCCESS;
}
if (device->info.gen == 8 && image->samples > 1) {
anv_perf_warn(device, image, "Enable gen8 multisampled HiZ");
anv_perf_warn(device, &image->base, "Enable gen8 multisampled HiZ");
return VK_SUCCESS;
}
......@@ -470,7 +470,7 @@ add_aux_surface_if_supported(struct anv_device *device,
* CCS for this case, we currently don't have things hooked up to get
* it working.
*/
anv_perf_warn(device, image,
anv_perf_warn(device, &image->base,
"This image format doesn't support rendering. "
"Not allocating an CCS buffer.");
return VK_SUCCESS;
......@@ -483,7 +483,7 @@ add_aux_surface_if_supported(struct anv_device *device,
* slice unfortunately. Disable CCS until anv gains more clear color
* tracking abilities.
*/
anv_perf_warn(device, image,
anv_perf_warn(device, &image->base,
"HW may put fast-clear blocks on more slices than SW "
"currently tracks. Not allocating a CCS buffer.");
return VK_SUCCESS;
......@@ -516,7 +516,7 @@ add_aux_surface_if_supported(struct anv_device *device,
*/
image->planes[plane].aux_usage = ISL_AUX_USAGE_CCS_E;
} else if (device->info.gen >= 12) {
anv_perf_warn(device, image,
anv_perf_warn(device, &image->base,
"The CCS_D aux mode is not yet handled on "
"Gen12+. Not allocating a CCS buffer.");
image->planes[plane].aux_surface.isl.size_B = 0;
......
......@@ -82,7 +82,7 @@ VkResult anv_CreateDmaBufImageINTEL(
VkDeviceSize aligned_image_size = align_u64(image->size, 4096);
if (mem->bo->size < aligned_image_size) {
result = vk_errorf(device, device, VK_ERROR_INVALID_EXTERNAL_HANDLE,
result = vk_errorf(device, NULL, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"dma-buf too small for image in "
"vkCreateDmaBufImageINTEL: %"PRIu64"B < %"PRIu64"B",
mem->bo->size, aligned_image_size);
......
......@@ -362,128 +362,25 @@ static inline uintptr_t anv_pack_ptr(void *ptr, int bits, int flags)
(b) = __builtin_ffs(__dword) - 1, __dword; \
__dword &= ~(1 << (b)))
/* Mapping from anv object to VkDebugReportObjectTypeEXT. New types need
* to be added here in order to utilize mapping in debug/error/perf macros.
*/
#define REPORT_OBJECT_TYPE(o) \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_instance*), \
VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_physical_device*), \
VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_device*), \
VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), const struct anv_device*), \
VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_queue*), \
VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_semaphore*), \
VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_cmd_buffer*), \
VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_fence*), \
VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_device_memory*), \
VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_buffer*), \
VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_image*), \
VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), const struct anv_image*), \
VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_event*), \
VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_query_pool*), \
VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_buffer_view*), \
VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_image_view*), \
VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_shader_module*), \
VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_pipeline_cache*), \
VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_pipeline_layout*), \
VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_render_pass*), \
VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_pipeline*), \
VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_descriptor_set_layout*), \
VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_sampler*), \
VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_descriptor_pool*), \
VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_descriptor_set*), \
VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_framebuffer*), \
VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_cmd_pool*), \
VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct anv_surface*), \
VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct wsi_swapchain*), \
VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), struct vk_debug_callback*), \
VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT, \
__builtin_choose_expr ( \
__builtin_types_compatible_p (__typeof (o), void*), \
VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, \
/* The void expression results in a compile-time error \
when assigning the result to something. */ \
(void)0)))))))))))))))))))))))))))))))
/* Whenever we generate an error, pass it through this function. Useful for
* debugging, where we can break on it. Only call at error site, not when
* propagating errors. Might be useful to plug in a stack trace here.
*/
VkResult __vk_errorv(struct anv_instance *instance, const void *object,
VkDebugReportObjectTypeEXT type, VkResult error,
VkResult __vk_errorv(struct anv_instance *instance,
const struct vk_object_base *object, VkResult error,
const char *file, int line, const char *format,
va_list args);
VkResult __vk_errorf(struct anv_instance *instance, const void *object,
VkDebugReportObjectTypeEXT type, VkResult error,
VkResult __vk_errorf(struct anv_instance *instance,
const struct vk_object_base *object, VkResult error,
const char *file, int line, const char *format, ...)
anv_printflike(7, 8);
anv_printflike(6, 7);
#ifdef DEBUG
#define vk_error(error) __vk_errorf(NULL, NULL,\
VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,\
error, __FILE__, __LINE__, NULL)
#define vk_error(error) __vk_errorf(NULL, NULL, error, __FILE__, __LINE__, NULL)
#define vk_errorfi(instance, obj, error, format, ...)\
__vk_errorf(instance, obj, REPORT_OBJECT_TYPE(obj), error,\
__vk_errorf(instance, obj, error,\
__FILE__, __LINE__, format, ## __VA_ARGS__)
#define vk_errorf(device, obj, error, format, ...)\
vk_errorfi(anv_device_instance_or_null(device),\
......@@ -518,10 +415,10 @@ static inline VkResult __dummy_vk_error(VkResult error, UNUSED const void *ignor
#define anv_debug_ignored_stype(sType) \
mesa_logd("%s: ignored VkStructureType %u\n", __func__, (sType))
void __anv_perf_warn(struct anv_device *device, const void *object,
VkDebugReportObjectTypeEXT type, const char *file,
int line, const char *format, ...)
anv_printflike(6, 7);
void __anv_perf_warn(struct anv_device *device,
const struct vk_object_base *object,
const char *file, int line, const char *format, ...)
anv_printflike(5, 6);
void anv_loge(const char *format, ...) anv_printflike(1, 2);
void anv_loge_v(const char *format, va_list va);
......@@ -545,7 +442,7 @@ void anv_loge_v(const char *format, va_list va);
do { \
static bool reported = false; \
if (!reported && (INTEL_DEBUG & DEBUG_PERF)) { \
__anv_perf_warn(instance, obj, REPORT_OBJECT_TYPE(obj), __FILE__, __LINE__,\
__anv_perf_warn(instance, obj, __FILE__, __LINE__,\
format, ##__VA_ARGS__); \
reported = true; \
} \
......
......@@ -49,9 +49,9 @@ anv_loge_v(const char *format, va_list va)
mesa_loge_v(format, va);
}
void anv_printflike(6, 7)
__anv_perf_warn(struct anv_device *device, const void *object,
VkDebugReportObjectTypeEXT type,
void
__anv_perf_warn(struct anv_device *device,
const struct vk_object_base *object,
const char *file, int line, const char *format, ...)
{
va_list ap;
......@@ -64,21 +64,18 @@ __anv_perf_warn(struct anv_device *device, const void *object,
snprintf(report, sizeof(report), "%s: %s", file, buffer);
VkObjectType object_type = object ? object->type : VK_OBJECT_TYPE_UNKNOWN;
vk_debug_report(&device->physical->instance->vk.debug_report,
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
type,
(uint64_t) (uintptr_t) object,
line,
0,
"anv",
report);
object_type, (uint64_t)(uintptr_t)object,
line, 0, "anv", report);
mesa_logw("%s:%d: PERF: %s", file, line, buffer);
}
VkResult
__vk_errorv(struct anv_instance *instance, const void *object,
VkDebugReportObjectTypeEXT type, VkResult error,
__vk_errorv(struct anv_instance *instance,
const struct vk_object_base *object, VkResult error,
const char *file, int line, const char *format, va_list ap)
{
char buffer[256];
......@@ -96,14 +93,11 @@ __vk_errorv(struct anv_instance *instance, const void *object,
}
if (instance) {
VkObjectType object_type = object ? object->type : VK_OBJECT_TYPE_UNKNOWN;
vk_debug_report(&instance->vk.debug_report,
VK_DEBUG_REPORT_ERROR_BIT_EXT,
type,
(uint64_t) (uintptr_t) object,
line,
0,
"anv",
report);
object_type, (uint64_t)(uintptr_t)object,
line, 0, "anv", report);
}
mesa_loge("%s", report);
......@@ -112,14 +106,14 @@ __vk_errorv(struct anv_instance *instance, const void *object,
}
VkResult
__vk_errorf(struct anv_instance *instance, const void *object,
VkDebugReportObjectTypeEXT type, VkResult error,
__vk_errorf(struct anv_instance *instance,
const struct vk_object_base *object, VkResult error,
const char *file, int line, const char *format, ...)
{
va_list ap;
va_start(ap, format);
__vk_errorv(instance, object, type, error, file, line, format, ap);
__vk_errorv(instance, object, error, file, line, format, ap);
va_end(ap);
return error;
......
......@@ -367,7 +367,7 @@ anv_can_fast_clear_color_view(struct anv_device * device,
if (isl_color_value_requires_conversion(clear_color,
&iview->image->planes[0].surface.isl,
&iview->planes[0].isl)) {
anv_perf_warn(device, iview,
anv_perf_warn(device, &iview->base,
"Cannot fast-clear to colors which would require "
"format conversion on resolve");
return false;
......@@ -382,7 +382,7 @@ anv_can_fast_clear_color_view(struct anv_device * device,
*/
if (iview->planes[0].isl.base_level > 0 ||
iview->planes[0].isl.base_array_layer > 0) {
anv_perf_warn(device, iview->image,
anv_perf_warn(device, &iview->image->base,
"Rendering with multi-lod or multi-layer framebuffer "
"with LOAD_OP_LOAD and baseMipLevel > 0 or "
"baseArrayLayer > 0. Not fast clearing.");
......@@ -390,7 +390,7 @@ anv_can_fast_clear_color_view(struct anv_device * device,
}
if (num_layers > 1) {
anv_perf_warn(device, iview->image,
anv_perf_warn(device, &iview->image->base,
"Rendering to a multi-layer framebuffer with "
"LOAD_OP_CLEAR. Only fast-clearing the first slice");
}
......@@ -1258,7 +1258,7 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
}
} else {
if (image->samples == 4 || image->samples == 16) {
anv_perf_warn(cmd_buffer->device, image,
anv_perf_warn(cmd_buffer->device, &image->base,
"Doing a potentially unnecessary fast-clear to "
"define an MCS buffer.");
}
......@@ -4507,7 +4507,7 @@ verify_cmd_parser(const struct anv_device *device,
const char *function)
{
if (device->physical->cmd_parser_version < required_version) {
return vk_errorf(device, device->physical,
return vk_errorf(device, &device->physical->vk.base,
VK_ERROR_FEATURE_NOT_PRESENT,
"cmd parser version %d is required for %s",
required_version, function);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment