Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/adapter_vk.c | 60 +++++++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d_vk.h | 6 ++++ 2 files changed, 66 insertions(+)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 7303c994eb4..e7ef721703c 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -271,6 +271,9 @@ static void adapter_vk_destroy(struct wined3d_adapter *adapter) struct wined3d_adapter_vk *adapter_vk = wined3d_adapter_vk(adapter); struct wined3d_vk_info *vk_info = &adapter_vk->vk_info;
+ if (vk_info->debug_callback) + VK_CALL(vkDestroyDebugReportCallbackEXT(vk_info->instance, vk_info->debug_callback, NULL)); + VK_CALL(vkDestroyInstance(vk_info->instance, NULL)); wined3d_unload_vulkan(vk_info); wined3d_adapter_cleanup(&adapter_vk->a); @@ -1827,6 +1830,7 @@ static const struct } vulkan_instance_extensions[] = { + {VK_EXT_DEBUG_REPORT_EXTENSION_NAME, ~0u, FALSE}, {VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, VK_API_VERSION_1_1, FALSE}, {VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, VK_API_VERSION_1_1, FALSE}, {VK_KHR_SURFACE_EXTENSION_NAME, ~0u, TRUE}, @@ -1904,6 +1908,34 @@ done: return success; }
+static VkBool32 VKAPI_PTR debug_report_callback(VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT object_type, uint64_t object, size_t location, + int32_t message_code, const char *layer_prefix, const char *message, void *user_data) +{ + FIXME("%s\n", debugstr_a(message)); + return VK_FALSE; +} + +static void init_debug_report(struct wined3d_vk_info *vk_info) +{ + VkDebugReportCallbackCreateInfoEXT callback_info; + VkDebugReportCallbackEXT callback; + VkResult vr; + + callback_info.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; + callback_info.pNext = NULL; + callback_info.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT; + callback_info.pfnCallback = debug_report_callback; + callback_info.pUserData = NULL; + if ((vr = VK_CALL(vkCreateDebugReportCallbackEXT(vk_info->instance, &callback_info, NULL, &callback))) < 0) + { + WARN("Failed to create debug report callback, vr %d.\n", vr); + return; + } + + vk_info->debug_callback = callback; +} + static BOOL wined3d_init_vulkan(struct wined3d_vk_info *vk_info) { const char *enabled_instance_extensions[ARRAY_SIZE(vulkan_instance_extensions)]; @@ -1914,8 +1946,19 @@ static BOOL wined3d_init_vulkan(struct wined3d_vk_info *vk_info) VkApplicationInfo app_info; uint32_t api_version = 0; char app_name[MAX_PATH]; + unsigned int i, j; VkResult vr;
+ static const struct + { + const char *name; + enum wined3d_vk_extension extension; + } + map[] = + { + {VK_EXT_DEBUG_REPORT_EXTENSION_NAME, WINED3D_VK_EXT_DEBUG_REPORT}, + }; + if (!wined3d_load_vulkan(vk_info)) return FALSE;
@@ -1953,6 +1996,18 @@ static BOOL wined3d_init_vulkan(struct wined3d_vk_info *vk_info) memset(vk_info->supported, 0, sizeof(vk_info->supported)); vk_info->supported[WINED3D_VK_EXT_NONE] = TRUE;
+ for (i = 0; i < ARRAY_SIZE(map); ++i) + { + for (j = 0; j < instance_info.enabledExtensionCount; ++j) + { + if (!strcmp(enabled_instance_extensions[j], map[i].name)) + { + vk_info->supported[map[i].extension] = TRUE; + break; + } + } + } + if ((vr = VK_CALL(vkCreateInstance(&instance_info, NULL, &instance))) < 0) { WARN("Failed to create Vulkan instance, vr %s.\n", wined3d_debug_vkresult(vr)); @@ -1989,6 +2044,9 @@ static BOOL wined3d_init_vulkan(struct wined3d_vk_info *vk_info)
vk_info->instance = instance;
+ if (vk_info->supported[WINED3D_VK_EXT_DEBUG_REPORT]) + init_debug_report(vk_info); + return TRUE;
fail: @@ -2366,6 +2424,8 @@ fail: wined3d_adapter_cleanup(adapter); heap_free(adapter_vk->device_extensions); fail_vulkan: + if (vk_info->debug_callback) + VK_CALL(vkDestroyDebugReportCallbackEXT(vk_info->instance, vk_info->debug_callback, NULL)); VK_CALL(vkDestroyInstance(vk_info->instance, NULL)); wined3d_unload_vulkan(vk_info); return FALSE; diff --git a/dlls/wined3d/wined3d_vk.h b/dlls/wined3d/wined3d_vk.h index a417a795901..d9d7faa55f6 100644 --- a/dlls/wined3d/wined3d_vk.h +++ b/dlls/wined3d/wined3d_vk.h @@ -42,6 +42,9 @@ /* Vulkan 1.1 */ \ VK_INSTANCE_EXT_PFN(vkGetPhysicalDeviceFeatures2) \ VK_INSTANCE_EXT_PFN(vkGetPhysicalDeviceProperties2) \ + /* VK_EXT_debug_report */ \ + VK_INSTANCE_EXT_PFN(vkCreateDebugReportCallbackEXT) \ + VK_INSTANCE_EXT_PFN(vkDestroyDebugReportCallbackEXT) \ /* VK_KHR_surface */ \ VK_INSTANCE_PFN(vkDestroySurfaceKHR) \ VK_INSTANCE_PFN(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) \ @@ -208,6 +211,7 @@ enum wined3d_vk_extension { WINED3D_VK_EXT_NONE,
+ WINED3D_VK_EXT_DEBUG_REPORT, WINED3D_VK_EXT_TRANSFORM_FEEDBACK, WINED3D_VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE,
@@ -225,6 +229,8 @@ struct wined3d_vk_info #ifdef USE_WIN32_VULKAN HMODULE vulkan_lib; #endif + + VkDebugReportCallbackEXT debug_callback; };
#define VK_CALL(f) (vk_info->vk_ops.f)
This extension is deprecated.
https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_EXT...
- Joshie 🐸✨
On 4/5/21 11:20 PM, Zebediah Figura wrote:
Signed-off-by: Zebediah Figura z.figura12@gmail.com
dlls/wined3d/adapter_vk.c | 60 +++++++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d_vk.h | 6 ++++ 2 files changed, 66 insertions(+)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 7303c994eb4..e7ef721703c 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -271,6 +271,9 @@ static void adapter_vk_destroy(struct wined3d_adapter *adapter) struct wined3d_adapter_vk *adapter_vk = wined3d_adapter_vk(adapter); struct wined3d_vk_info *vk_info = &adapter_vk->vk_info;
- if (vk_info->debug_callback)
VK_CALL(vkDestroyDebugReportCallbackEXT(vk_info->instance, vk_info->debug_callback, NULL));
VK_CALL(vkDestroyInstance(vk_info->instance, NULL)); wined3d_unload_vulkan(vk_info); wined3d_adapter_cleanup(&adapter_vk->a);
@@ -1827,6 +1830,7 @@ static const struct } vulkan_instance_extensions[] = {
- {VK_EXT_DEBUG_REPORT_EXTENSION_NAME, ~0u, FALSE}, {VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, VK_API_VERSION_1_1, FALSE}, {VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, VK_API_VERSION_1_1, FALSE}, {VK_KHR_SURFACE_EXTENSION_NAME, ~0u, TRUE},
@@ -1904,6 +1908,34 @@ done: return success; }
+static VkBool32 VKAPI_PTR debug_report_callback(VkDebugReportFlagsEXT flags,
VkDebugReportObjectTypeEXT object_type, uint64_t object, size_t location,
int32_t message_code, const char *layer_prefix, const char *message, void *user_data)
+{
- FIXME("%s\n", debugstr_a(message));
- return VK_FALSE;
+}
+static void init_debug_report(struct wined3d_vk_info *vk_info) +{
- VkDebugReportCallbackCreateInfoEXT callback_info;
- VkDebugReportCallbackEXT callback;
- VkResult vr;
- callback_info.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
- callback_info.pNext = NULL;
- callback_info.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT;
- callback_info.pfnCallback = debug_report_callback;
- callback_info.pUserData = NULL;
- if ((vr = VK_CALL(vkCreateDebugReportCallbackEXT(vk_info->instance, &callback_info, NULL, &callback))) < 0)
- {
WARN("Failed to create debug report callback, vr %d.\n", vr);
return;
- }
- vk_info->debug_callback = callback;
+}
- static BOOL wined3d_init_vulkan(struct wined3d_vk_info *vk_info) { const char *enabled_instance_extensions[ARRAY_SIZE(vulkan_instance_extensions)];
@@ -1914,8 +1946,19 @@ static BOOL wined3d_init_vulkan(struct wined3d_vk_info *vk_info) VkApplicationInfo app_info; uint32_t api_version = 0; char app_name[MAX_PATH];
unsigned int i, j; VkResult vr;
static const struct
{
const char *name;
enum wined3d_vk_extension extension;
}
map[] =
{
{VK_EXT_DEBUG_REPORT_EXTENSION_NAME, WINED3D_VK_EXT_DEBUG_REPORT},
};
if (!wined3d_load_vulkan(vk_info)) return FALSE;
@@ -1953,6 +1996,18 @@ static BOOL wined3d_init_vulkan(struct wined3d_vk_info *vk_info) memset(vk_info->supported, 0, sizeof(vk_info->supported)); vk_info->supported[WINED3D_VK_EXT_NONE] = TRUE;
- for (i = 0; i < ARRAY_SIZE(map); ++i)
- {
for (j = 0; j < instance_info.enabledExtensionCount; ++j)
{
if (!strcmp(enabled_instance_extensions[j], map[i].name))
{
vk_info->supported[map[i].extension] = TRUE;
break;
}
}
- }
if ((vr = VK_CALL(vkCreateInstance(&instance_info, NULL, &instance))) < 0) { WARN("Failed to create Vulkan instance, vr %s.\n", wined3d_debug_vkresult(vr));
@@ -1989,6 +2044,9 @@ static BOOL wined3d_init_vulkan(struct wined3d_vk_info *vk_info)
vk_info->instance = instance;
if (vk_info->supported[WINED3D_VK_EXT_DEBUG_REPORT])
init_debug_report(vk_info);
return TRUE;
fail:
@@ -2366,6 +2424,8 @@ fail: wined3d_adapter_cleanup(adapter); heap_free(adapter_vk->device_extensions); fail_vulkan:
- if (vk_info->debug_callback)
VK_CALL(vkDestroyDebugReportCallbackEXT(vk_info->instance, vk_info->debug_callback, NULL)); VK_CALL(vkDestroyInstance(vk_info->instance, NULL)); wined3d_unload_vulkan(vk_info); return FALSE;
diff --git a/dlls/wined3d/wined3d_vk.h b/dlls/wined3d/wined3d_vk.h index a417a795901..d9d7faa55f6 100644 --- a/dlls/wined3d/wined3d_vk.h +++ b/dlls/wined3d/wined3d_vk.h @@ -42,6 +42,9 @@ /* Vulkan 1.1 */ \ VK_INSTANCE_EXT_PFN(vkGetPhysicalDeviceFeatures2) \ VK_INSTANCE_EXT_PFN(vkGetPhysicalDeviceProperties2) \
- /* VK_EXT_debug_report */ \
- VK_INSTANCE_EXT_PFN(vkCreateDebugReportCallbackEXT) \
- VK_INSTANCE_EXT_PFN(vkDestroyDebugReportCallbackEXT) \ /* VK_KHR_surface */ \ VK_INSTANCE_PFN(vkDestroySurfaceKHR) \ VK_INSTANCE_PFN(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) \
@@ -208,6 +211,7 @@ enum wined3d_vk_extension { WINED3D_VK_EXT_NONE,
- WINED3D_VK_EXT_DEBUG_REPORT, WINED3D_VK_EXT_TRANSFORM_FEEDBACK, WINED3D_VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE,
@@ -225,6 +229,8 @@ struct wined3d_vk_info #ifdef USE_WIN32_VULKAN HMODULE vulkan_lib; #endif
VkDebugReportCallbackEXT debug_callback; };
#define VK_CALL(f) (vk_info->vk_ops.f)