mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 02:58:05 +02:00
vulkan: Make the debug_report implementation internal
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
This commit is contained in:
parent
41318a5819
commit
23ba48a0c7
10 changed files with 82 additions and 127 deletions
|
|
@ -287,7 +287,7 @@ static void radv_spirv_nir_debug(void *private_data,
|
|||
snprintf(buffer, sizeof(buffer), "SPIR-V offset %lu: %s",
|
||||
(unsigned long)spirv_offset, message);
|
||||
|
||||
vk_debug_report(&instance->vk.debug_report, vk_flags[level],
|
||||
vk_debug_report(&instance->vk, vk_flags[level],
|
||||
&debug_data->module->base, 0, 0, "radv", buffer);
|
||||
}
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ static void radv_compiler_debug(void *private_data,
|
|||
/* VK_DEBUG_REPORT_DEBUG_BIT_EXT specifies diagnostic information
|
||||
* from the implementation and layers.
|
||||
*/
|
||||
vk_debug_report(&instance->vk.debug_report,
|
||||
vk_debug_report(&instance->vk,
|
||||
vk_flags[level] | VK_DEBUG_REPORT_DEBUG_BIT_EXT,
|
||||
&debug_data->module->base, 0, 0, "radv", message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,8 +113,7 @@ __vk_errorv(struct radv_instance *instance, const void *object,
|
|||
}
|
||||
|
||||
if (instance) {
|
||||
vk_debug_report(&instance->vk.debug_report,
|
||||
VK_DEBUG_REPORT_ERROR_BIT_EXT,
|
||||
vk_debug_report(&instance->vk, VK_DEBUG_REPORT_ERROR_BIT_EXT,
|
||||
object, line, 0, "radv", report);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ compiler_debug_log(void *data, const char *fmt, ...)
|
|||
(void) vsnprintf(str, MAX_DEBUG_MESSAGE_LENGTH, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
vk_debug_report(&instance->vk.debug_report,
|
||||
vk_debug_report(&instance->vk,
|
||||
VK_DEBUG_REPORT_DEBUG_BIT_EXT,
|
||||
NULL, 0, 0, "anv", str);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ static void anv_spirv_nir_debug(void *private_data,
|
|||
|
||||
snprintf(buffer, sizeof(buffer), "SPIR-V offset %lu: %s", (unsigned long) spirv_offset, message);
|
||||
|
||||
vk_debug_report(&instance->vk.debug_report, vk_flags[level],
|
||||
vk_debug_report(&instance->vk, vk_flags[level],
|
||||
&debug_data->module->base,
|
||||
0, 0, "anv", buffer);
|
||||
}
|
||||
|
|
@ -1402,7 +1402,7 @@ anv_pipeline_compile_graphics(struct anv_graphics_pipeline *pipeline,
|
|||
*/
|
||||
assert(found < __builtin_popcount(pipeline->active_stages));
|
||||
|
||||
vk_debug_report(&pipeline->base.device->physical->instance->vk.debug_report,
|
||||
vk_debug_report(&pipeline->base.device->physical->instance->vk,
|
||||
VK_DEBUG_REPORT_WARNING_BIT_EXT |
|
||||
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
|
||||
&cache->base, 0, 0, "anv",
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ __anv_perf_warn(struct anv_device *device,
|
|||
|
||||
snprintf(report, sizeof(report), "%s: %s", file, buffer);
|
||||
|
||||
vk_debug_report(&device->physical->instance->vk.debug_report,
|
||||
vk_debug_report(&device->physical->instance->vk,
|
||||
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
|
||||
object, line, 0, "anv", report);
|
||||
|
||||
|
|
@ -91,8 +91,7 @@ __vk_errorv(struct anv_instance *instance,
|
|||
}
|
||||
|
||||
if (instance) {
|
||||
vk_debug_report(&instance->vk.debug_report,
|
||||
VK_DEBUG_REPORT_ERROR_BIT_EXT,
|
||||
vk_debug_report(&instance->vk, VK_DEBUG_REPORT_ERROR_BIT_EXT,
|
||||
object, line, 0, "anv", report);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1231,7 +1231,7 @@ emit_cb_state(struct anv_graphics_pipeline *pipeline,
|
|||
is_dual_src_blend_factor(a->dstColorBlendFactor) ||
|
||||
is_dual_src_blend_factor(a->srcAlphaBlendFactor) ||
|
||||
is_dual_src_blend_factor(a->dstAlphaBlendFactor))) {
|
||||
vk_debug_report(&device->physical->instance->vk.debug_report,
|
||||
vk_debug_report(&device->physical->instance->vk,
|
||||
VK_DEBUG_REPORT_WARNING_BIT_EXT,
|
||||
&device->vk.base, 0, 0, "anv",
|
||||
"Enabled dual-src blend factors without writing both targets "
|
||||
|
|
|
|||
|
|
@ -28,32 +28,30 @@
|
|||
#include "vk_instance.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
VkResult vk_debug_report_instance_init(struct vk_debug_report_instance *instance)
|
||||
{
|
||||
if (mtx_init(&instance->callbacks_mutex, mtx_plain) != 0) {
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
struct vk_debug_report_callback {
|
||||
struct vk_object_base base;
|
||||
|
||||
list_inithead(&instance->callbacks);
|
||||
/* Link in the 'callbacks' list in anv_instance struct. */
|
||||
struct list_head link;
|
||||
VkDebugReportFlagsEXT flags;
|
||||
PFN_vkDebugReportCallbackEXT callback;
|
||||
void * data;
|
||||
};
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void vk_debug_report_instance_destroy(struct vk_debug_report_instance *instance)
|
||||
{
|
||||
mtx_destroy(&instance->callbacks_mutex);
|
||||
}
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(vk_debug_report_callback, base,
|
||||
VkDebugReportCallbackEXT,
|
||||
VK_OBJECT_TYPE_INSTANCE)
|
||||
|
||||
VkResult
|
||||
vk_create_debug_report_callback(struct vk_debug_report_instance *instance,
|
||||
const VkDebugReportCallbackCreateInfoEXT* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
const VkAllocationCallbacks* instance_allocator,
|
||||
VkDebugReportCallbackEXT* pCallback)
|
||||
vk_common_CreateDebugReportCallbackEXT(VkInstance _instance,
|
||||
const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkDebugReportCallbackEXT *pCallback)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_instance, instance, _instance);
|
||||
|
||||
struct vk_debug_report_callback *cb =
|
||||
vk_alloc2(instance_allocator, pAllocator,
|
||||
vk_alloc2(&instance->alloc, pAllocator,
|
||||
sizeof(struct vk_debug_report_callback), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
|
||||
|
|
@ -67,9 +65,9 @@ vk_create_debug_report_callback(struct vk_debug_report_instance *instance,
|
|||
cb->callback = pCreateInfo->pfnCallback;
|
||||
cb->data = pCreateInfo->pUserData;
|
||||
|
||||
mtx_lock(&instance->callbacks_mutex);
|
||||
list_addtail(&cb->link, &instance->callbacks);
|
||||
mtx_unlock(&instance->callbacks_mutex);
|
||||
mtx_lock(&instance->debug_report.callbacks_mutex);
|
||||
list_addtail(&cb->link, &instance->debug_report.callbacks);
|
||||
mtx_unlock(&instance->debug_report.callbacks_mutex);
|
||||
|
||||
*pCallback = vk_debug_report_callback_to_handle(cb);
|
||||
|
||||
|
|
@ -77,27 +75,27 @@ vk_create_debug_report_callback(struct vk_debug_report_instance *instance,
|
|||
}
|
||||
|
||||
void
|
||||
vk_destroy_debug_report_callback(struct vk_debug_report_instance *instance,
|
||||
VkDebugReportCallbackEXT _callback,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
const VkAllocationCallbacks* instance_allocator)
|
||||
vk_common_DestroyDebugReportCallbackEXT(VkInstance _instance,
|
||||
VkDebugReportCallbackEXT _callback,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_instance, instance, _instance);
|
||||
VK_FROM_HANDLE(vk_debug_report_callback, callback, _callback);
|
||||
|
||||
if (callback == NULL)
|
||||
return;
|
||||
|
||||
/* Remove from list and destroy given callback. */
|
||||
mtx_lock(&instance->callbacks_mutex);
|
||||
mtx_lock(&instance->debug_report.callbacks_mutex);
|
||||
list_del(&callback->link);
|
||||
vk_free2(instance_allocator, pAllocator, callback);
|
||||
mtx_unlock(&instance->callbacks_mutex);
|
||||
vk_free2(&instance->alloc, pAllocator, callback);
|
||||
mtx_unlock(&instance->debug_report.callbacks_mutex);
|
||||
|
||||
vk_object_base_finish(&callback->base);
|
||||
}
|
||||
|
||||
static void
|
||||
debug_report(struct vk_debug_report_instance *instance,
|
||||
debug_report(struct vk_instance *instance,
|
||||
VkDebugReportFlagsEXT flags,
|
||||
VkDebugReportObjectTypeEXT object_type,
|
||||
uint64_t handle,
|
||||
|
|
@ -107,10 +105,10 @@ debug_report(struct vk_debug_report_instance *instance,
|
|||
const char *pMessage)
|
||||
{
|
||||
/* Allow NULL for convinience, return if no callbacks registered. */
|
||||
if (!instance || list_is_empty(&instance->callbacks))
|
||||
if (!instance || list_is_empty(&instance->debug_report.callbacks))
|
||||
return;
|
||||
|
||||
mtx_lock(&instance->callbacks_mutex);
|
||||
mtx_lock(&instance->debug_report.callbacks_mutex);
|
||||
|
||||
/* Section 33.2 of the Vulkan 1.0.59 spec says:
|
||||
*
|
||||
|
|
@ -120,51 +118,13 @@ debug_report(struct vk_debug_report_instance *instance,
|
|||
* is active."
|
||||
*/
|
||||
list_for_each_entry(struct vk_debug_report_callback, cb,
|
||||
&instance->callbacks, link) {
|
||||
&instance->debug_report.callbacks, link) {
|
||||
if (cb->flags & flags)
|
||||
cb->callback(flags, object_type, handle, location, messageCode,
|
||||
pLayerPrefix, pMessage, cb->data);
|
||||
}
|
||||
|
||||
mtx_unlock(&instance->callbacks_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
vk_debug_report(struct vk_debug_report_instance *instance,
|
||||
VkDebugReportFlagsEXT flags,
|
||||
const struct vk_object_base *object,
|
||||
size_t location,
|
||||
int32_t messageCode,
|
||||
const char* pLayerPrefix,
|
||||
const char *pMessage)
|
||||
{
|
||||
VkDebugReportObjectTypeEXT object_type =
|
||||
object ? object->type : VK_OBJECT_TYPE_UNKNOWN;
|
||||
debug_report(instance, flags, object_type, (uint64_t)(uintptr_t)object,
|
||||
location, messageCode, pLayerPrefix, pMessage);
|
||||
}
|
||||
|
||||
VkResult
|
||||
vk_common_CreateDebugReportCallbackEXT(VkInstance _instance,
|
||||
const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkDebugReportCallbackEXT *pCallback)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_instance, instance, _instance);
|
||||
return vk_create_debug_report_callback(&instance->debug_report,
|
||||
pCreateInfo, pAllocator,
|
||||
&instance->alloc,
|
||||
pCallback);
|
||||
}
|
||||
|
||||
void
|
||||
vk_common_DestroyDebugReportCallbackEXT(VkInstance _instance,
|
||||
VkDebugReportCallbackEXT callback,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_instance, instance, _instance);
|
||||
vk_destroy_debug_report_callback(&instance->debug_report, callback,
|
||||
pAllocator, &instance->alloc);
|
||||
mtx_unlock(&instance->debug_report.callbacks_mutex);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -178,6 +138,21 @@ vk_common_DebugReportMessageEXT(VkInstance _instance,
|
|||
const char* pMessage)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_instance, instance, _instance);
|
||||
debug_report(&instance->debug_report, flags, objectType,
|
||||
debug_report(instance, flags, objectType,
|
||||
object, location, messageCode, pLayerPrefix, pMessage);
|
||||
}
|
||||
|
||||
void
|
||||
vk_debug_report(struct vk_instance *instance,
|
||||
VkDebugReportFlagsEXT flags,
|
||||
const struct vk_object_base *object,
|
||||
size_t location,
|
||||
int32_t messageCode,
|
||||
const char* pLayerPrefix,
|
||||
const char *pMessage)
|
||||
{
|
||||
VkDebugReportObjectTypeEXT object_type =
|
||||
object ? object->type : VK_OBJECT_TYPE_UNKNOWN;
|
||||
debug_report(instance, flags, object_type, (uint64_t)(uintptr_t)object,
|
||||
location, messageCode, pLayerPrefix, pMessage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,52 +26,23 @@
|
|||
#ifndef VK_DEBUG_REPORT_H
|
||||
#define VK_DEBUG_REPORT_H
|
||||
|
||||
#include "vk_object.h"
|
||||
#include "vk_instance.h"
|
||||
|
||||
#include "c11/threads.h"
|
||||
#include "util/list.h"
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
struct vk_debug_report_callback {
|
||||
struct vk_object_base base;
|
||||
|
||||
/* Link in the 'callbacks' list in anv_instance struct. */
|
||||
struct list_head link;
|
||||
VkDebugReportFlagsEXT flags;
|
||||
PFN_vkDebugReportCallbackEXT callback;
|
||||
void * data;
|
||||
};
|
||||
|
||||
VK_DEFINE_HANDLE_CASTS(vk_debug_report_callback, base, VkDebugReportCallbackEXT,
|
||||
VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT)
|
||||
|
||||
struct vk_debug_report_instance {
|
||||
/* VK_EXT_debug_report debug callbacks */
|
||||
mtx_t callbacks_mutex;
|
||||
struct list_head callbacks;
|
||||
};
|
||||
|
||||
VkResult vk_debug_report_instance_init(struct vk_debug_report_instance *instance);
|
||||
void vk_debug_report_instance_destroy(struct vk_debug_report_instance *instance);
|
||||
|
||||
VkResult
|
||||
vk_create_debug_report_callback(struct vk_debug_report_instance *instance,
|
||||
const VkDebugReportCallbackCreateInfoEXT* pCreateInfo,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
const VkAllocationCallbacks* instance_allocator,
|
||||
VkDebugReportCallbackEXT* pCallback);
|
||||
void
|
||||
vk_destroy_debug_report_callback(struct vk_debug_report_instance *instance,
|
||||
VkDebugReportCallbackEXT _callback,
|
||||
const VkAllocationCallbacks* pAllocator,
|
||||
const VkAllocationCallbacks* instance_allocator);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void
|
||||
vk_debug_report(struct vk_debug_report_instance *instance,
|
||||
vk_debug_report(struct vk_instance *instance,
|
||||
VkDebugReportFlagsEXT flags,
|
||||
const struct vk_object_base *object,
|
||||
size_t location,
|
||||
int32_t messageCode,
|
||||
const char* pLayerPrefix,
|
||||
const char *pMessage);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* VK_DEBUG_REPORT_H */
|
||||
|
|
|
|||
|
|
@ -84,13 +84,18 @@ vk_instance_init(struct vk_instance *instance,
|
|||
&instance->dispatch_table, &vk_common_instance_entrypoints, false);
|
||||
}
|
||||
|
||||
return vk_debug_report_instance_init(&instance->debug_report);
|
||||
if (mtx_init(&instance->debug_report.callbacks_mutex, mtx_plain) != 0)
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
|
||||
list_inithead(&instance->debug_report.callbacks);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
vk_instance_finish(struct vk_instance *instance)
|
||||
{
|
||||
vk_debug_report_instance_destroy(&instance->debug_report);
|
||||
mtx_destroy(&instance->debug_report.callbacks_mutex);
|
||||
vk_free(&instance->alloc, (char *)instance->app_info.app_name);
|
||||
vk_free(&instance->alloc, (char *)instance->app_info.engine_name);
|
||||
vk_object_base_finish(&instance->base);
|
||||
|
|
|
|||
|
|
@ -23,11 +23,13 @@
|
|||
#ifndef VK_INSTANCE_H
|
||||
#define VK_INSTANCE_H
|
||||
|
||||
#include "vk_debug_report.h"
|
||||
#include "vk_dispatch_table.h"
|
||||
#include "vk_extensions.h"
|
||||
#include "vk_object.h"
|
||||
|
||||
#include "c11/threads.h"
|
||||
#include "util/list.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -49,7 +51,11 @@ struct vk_instance {
|
|||
|
||||
struct vk_instance_dispatch_table dispatch_table;
|
||||
|
||||
struct vk_debug_report_instance debug_report;
|
||||
/* VK_EXT_debug_report debug callbacks */
|
||||
struct {
|
||||
mtx_t callbacks_mutex;
|
||||
struct list_head callbacks;
|
||||
} debug_report;
|
||||
};
|
||||
|
||||
VK_DEFINE_HANDLE_CASTS(vk_instance, base, VkInstance,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue