From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d/device.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 57b94b64239d..0dc13cb1abb8 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -1682,8 +1682,8 @@ static void STDMETHODCALLTYPE d3d12_device_CopyDescriptors(ID3D12Device *iface, { struct d3d12_device *device = impl_from_ID3D12Device(iface); unsigned int dst_range_idx, dst_idx, src_range_idx, src_idx; + unsigned int dst_range_size, src_range_size; const struct d3d12_desc *src; - unsigned int src_range_size; struct d3d12_desc *dst;
TRACE("iface %p, dst_descriptor_range_count %u, dst_descriptor_range_offsets %p, " @@ -1703,21 +1703,23 @@ static void STDMETHODCALLTYPE d3d12_device_CopyDescriptors(ID3D12Device *iface,
dst_range_idx = dst_idx = 0; dst = d3d12_desc_from_cpu_handle(dst_descriptor_range_offsets[0]); + dst_range_size = dst_descriptor_range_sizes ? dst_descriptor_range_sizes[0] : 1; for (src_range_idx = 0; src_range_idx < src_descriptor_range_count; ++src_range_idx) { src = d3d12_desc_from_cpu_handle(src_descriptor_range_offsets[src_range_idx]); src_range_size = src_descriptor_range_sizes ? src_descriptor_range_sizes[src_range_idx] : 1; for (src_idx = 0; src_idx < src_range_size; ++src_idx) { - if (dst_idx >= dst_descriptor_range_sizes[dst_range_idx]) + if (dst_idx >= dst_range_size) { + dst_idx = 0; ++dst_range_idx; dst = d3d12_desc_from_cpu_handle(dst_descriptor_range_offsets[dst_range_idx]); - dst_idx = 0; + dst_range_size = dst_descriptor_range_sizes ? dst_descriptor_range_sizes[dst_range_idx] : 1; }
assert(dst_range_idx < dst_descriptor_range_count); - assert(dst_idx < dst_descriptor_range_sizes[dst_range_idx]); + assert(dst_idx < dst_range_size);
d3d12_desc_copy(dst++, src++, device);
@@ -1725,7 +1727,7 @@ static void STDMETHODCALLTYPE d3d12_device_CopyDescriptors(ID3D12Device *iface, } }
- assert(dst_idx == dst_descriptor_range_sizes[dst_range_idx]); + assert(dst_idx == dst_range_size); assert(dst_range_idx == dst_descriptor_range_count - 1); }
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- tests/d3d12.c | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c index 0f858ff985d1..7dfee875ab0b 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -10836,6 +10836,170 @@ static void test_copy_descriptors(void) destroy_test_context(&context); }
+static void test_copy_descriptors_range_sizes(void) +{ + D3D12_CPU_DESCRIPTOR_HANDLE dst_handles[1], src_handles[1]; + D3D12_CPU_DESCRIPTOR_HANDLE green_handle, blue_handle; + ID3D12Resource *green_texture, *blue_texture; + UINT dst_range_sizes[1], src_range_sizes[1]; + ID3D12GraphicsCommandList *command_list; + ID3D12DescriptorHeap *cpu_heap; + struct test_context_desc desc; + D3D12_SUBRESOURCE_DATA data; + struct resource_readback rb; + struct test_context context; + ID3D12DescriptorHeap *heap; + ID3D12CommandQueue *queue; + ID3D12Device *device; + unsigned int i; + RECT rect; + + static const DWORD ps_code[] = + { +#if 0 + Texture2D t; + SamplerState s; + + float4 main(float4 position : SV_POSITION) : SV_Target + { + float2 p; + + p.x = position.x / 32.0f; + p.y = position.y / 32.0f; + return t.Sample(s, p); + } +#endif + 0x43425844, 0x7a0c3929, 0x75ff3ca4, 0xccb318b2, 0xe6965b4c, 0x00000001, 0x00000140, 0x00000003, + 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000a4, 0x00000050, + 0x00000029, 0x0100086a, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, + 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, + 0x02000068, 0x00000001, 0x0a000038, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x00004002, + 0x3d000000, 0x3d000000, 0x00000000, 0x00000000, 0x8b000045, 0x800000c2, 0x00155543, 0x001020f2, + 0x00000000, 0x00100046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)}; + static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; + static const struct vec4 green = {0.0f, 1.0f, 0.0f, 1.0f}; + static const struct vec4 blue = {0.0f, 0.0f, 1.0f, 1.0f}; + + memset(&desc, 0, sizeof(desc)); + desc.rt_width = desc.rt_height = 6; + desc.no_root_signature = true; + if (!init_test_context(&context, &desc)) + return; + device = context.device; + command_list = context.list; + queue = context.queue; + + cpu_heap = create_cpu_descriptor_heap(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 10); + heap = create_gpu_descriptor_heap(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 8); + + green_handle = get_cpu_descriptor_handle(&context, cpu_heap, 0); + blue_handle = get_cpu_descriptor_handle(&context, cpu_heap, 1); + + green_texture = create_texture(context.device, + 1, 1, DXGI_FORMAT_R32G32B32A32_FLOAT, D3D12_RESOURCE_STATE_COPY_DEST); + data.pData = &green; + data.RowPitch = sizeof(green); + data.SlicePitch = data.RowPitch; + upload_texture_data(green_texture, &data, 1, queue, command_list); + reset_command_list(command_list, context.allocator); + transition_resource_state(command_list, green_texture, + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); + ID3D12Device_CreateShaderResourceView(device, green_texture, NULL, green_handle); + + blue_texture = create_texture(context.device, + 1, 1, DXGI_FORMAT_R32G32B32A32_FLOAT, D3D12_RESOURCE_STATE_COPY_DEST); + data.pData = &blue; + data.RowPitch = sizeof(blue); + data.SlicePitch = data.RowPitch; + upload_texture_data(blue_texture, &data, 1, queue, command_list); + reset_command_list(command_list, context.allocator); + transition_resource_state(command_list, blue_texture, + D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); + ID3D12Device_CreateShaderResourceView(device, blue_texture, NULL, blue_handle); + + context.root_signature = create_texture_root_signature(context.device, + D3D12_SHADER_VISIBILITY_PIXEL, 0, 0); + context.pipeline_state = create_pipeline_state(context.device, + context.root_signature, context.render_target_desc.Format, NULL, &ps, NULL); + + /* copy descriptors */ + dst_handles[0] = get_cpu_descriptor_handle(&context, heap, 1); + dst_range_sizes[0] = 1; + src_handles[0] = blue_handle; + src_range_sizes[0] = 1; + ID3D12Device_CopyDescriptors(device, 1, dst_handles, dst_range_sizes, + 1, src_handles, src_range_sizes, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + + dst_handles[0] = get_cpu_descriptor_handle(&context, heap, 2); + dst_range_sizes[0] = 1; + src_handles[0] = green_handle; + src_range_sizes[0] = 1; + ID3D12Device_CopyDescriptors(device, 1, dst_handles, dst_range_sizes, + 1, src_handles, src_range_sizes, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + + dst_handles[0] = get_cpu_descriptor_handle(&context, heap, 3); + src_handles[0] = blue_handle; + src_range_sizes[0] = 1; + ID3D12Device_CopyDescriptors(device, 1, dst_handles, NULL, + 1, src_handles, src_range_sizes, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + + dst_handles[0] = get_cpu_descriptor_handle(&context, heap, 4); + src_handles[0] = green_handle; + src_range_sizes[0] = 1; + ID3D12Device_CopyDescriptors(device, 1, dst_handles, NULL, + 1, src_handles, src_range_sizes, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + + dst_handles[0] = get_cpu_descriptor_handle(&context, heap, 5); + src_handles[0] = blue_handle; + ID3D12Device_CopyDescriptors(device, 1, dst_handles, NULL, + 1, src_handles, NULL, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + + dst_handles[0] = get_cpu_descriptor_handle(&context, heap, 0); + src_handles[0] = green_handle; + ID3D12Device_CopyDescriptors(device, 1, dst_handles, NULL, + 1, src_handles, NULL, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL); + + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, FALSE, NULL); + ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); + ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state); + ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &heap); + ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect); + + for (i = 0; i < desc.rt_width; ++i) + { + ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 0, + get_gpu_descriptor_handle(&context, heap, i)); + set_viewport(&context.viewport, i, 0.0f, 1.0f, desc.rt_height, 0.0f, 1.0f); + ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport); + ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0); + } + + transition_resource_state(command_list, context.render_target, + D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); + + get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + for (i = 0; i < desc.rt_width; ++i) + { + set_rect(&rect, i, 0, i + 1, desc.rt_height); + check_readback_data_uint(&rb, &rect, i % 2 ? 0xffff0000 : 0xff00ff00, 0); + } + release_resource_readback(&rb); + + ID3D12DescriptorHeap_Release(cpu_heap); + ID3D12DescriptorHeap_Release(heap); + ID3D12Resource_Release(blue_texture); + ID3D12Resource_Release(green_texture); + destroy_test_context(&context); +} + static void test_descriptors_visibility(void) { ID3D12Resource *vs_raw_buffer, *ps_raw_buffer; @@ -16991,6 +17155,7 @@ START_TEST(d3d12) run_test(test_update_descriptor_heap_after_closing_command_list); run_test(test_update_compute_descriptor_tables); run_test(test_copy_descriptors); + run_test(test_copy_descriptors_range_sizes); run_test(test_descriptors_visibility); run_test(test_null_descriptors); run_test(test_get_copyable_footprints);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 12 +++++++++--- libs/vkd3d-shader/vkd3d_shader_private.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 49e2c5020fee..0b5c3cf38076 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -1808,7 +1808,7 @@ static const char *shader_get_string(const char *data, size_t data_size, DWORD o return data + offset; }
-static int parse_dxbc(const char *data, SIZE_T data_size, +static int parse_dxbc(const char *data, size_t data_size, int (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) { const char *ptr = data; @@ -1819,6 +1819,12 @@ static int parse_dxbc(const char *data, SIZE_T data_size, DWORD version; DWORD tag;
+ if (data_size < VKD3D_DXBC_HEADER_SIZE) + { + WARN("Invalid data size %zu.\n", data_size); + return VKD3D_ERROR_INVALID_ARGUMENT; + } + read_dword(&ptr, &tag); TRACE("tag: %#x.\n", tag);
@@ -1856,7 +1862,7 @@ static int parse_dxbc(const char *data, SIZE_T data_size,
if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size)) { - WARN("Invalid chunk offset %#x (data size %#lx).\n", chunk_offset, data_size); + WARN("Invalid chunk offset %#x (data size %zu).\n", chunk_offset, data_size); return VKD3D_ERROR_INVALID_ARGUMENT; }
@@ -1867,7 +1873,7 @@ static int parse_dxbc(const char *data, SIZE_T data_size,
if (!require_space(chunk_ptr - data, 1, chunk_size, data_size)) { - WARN("Invalid chunk size %#x (data size %#lx, chunk offset %#x).\n", + WARN("Invalid chunk size %#x (data size %zu, chunk offset %#x).\n", chunk_size, data_size, chunk_offset); return VKD3D_ERROR_INVALID_ARGUMENT; } diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 9c43a461f29b..04e6b0961281 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -858,5 +858,6 @@ static inline unsigned int vkd3d_swizzle_get_component(DWORD swizzle, }
#define VKD3D_DXBC_MAX_SOURCE_COUNT 6 +#define VKD3D_DXBC_HEADER_SIZE (8 * sizeof(uint32_t))
#endif /* __VKD3D_SHADER_PRIVATE_H */
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
For debug messages from Vulkan drivers.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d/device.c | 74 +++++++++++++++++++++++++++++++++++++++------- libs/vkd3d/utils.c | 5 +++- libs/vkd3d/vkd3d_private.h | 6 +++- libs/vkd3d/vulkan_procs.h | 8 +++++ 4 files changed, 80 insertions(+), 13 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 0dc13cb1abb8..805d477f89b0 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -24,12 +24,14 @@ struct vkd3d_optional_extension_info { const char *extension_name; ptrdiff_t vulkan_info_offset; + bool is_debug_only; };
static const struct vkd3d_optional_extension_info optional_instance_extensions[] = { {VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, KHR_get_physical_device_properties2)}, + {VK_EXT_DEBUG_REPORT_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_debug_report), true}, };
static const char * const required_device_extensions[] = @@ -59,7 +61,7 @@ static bool is_extension_disabled(const char *extension_name) }
static bool has_extension(const VkExtensionProperties *extensions, - unsigned int count, const char *extension_name) + unsigned int count, const char *extension_name, bool is_debug_only) { unsigned int i;
@@ -72,6 +74,11 @@ static bool has_extension(const VkExtensionProperties *extensions, WARN("Extension %s is disabled.\n", debugstr_a(extension_name)); continue; } + if (is_debug_only && vkd3d_dbg_get_level() < VKD3D_DBG_LEVEL_WARN) + { + TRACE("Skipping debug-only extension %s.\n", debugstr_a(extension_name)); + continue; + } return true; } return false; @@ -88,7 +95,7 @@ static unsigned int vkd3d_check_extensions(const VkExtensionProperties *extensio
for (i = 0; i < required_extension_count; ++i) { - if (!has_extension(extensions, count, required_extensions[i])) + if (!has_extension(extensions, count, required_extensions[i], false)) ERR("Required %s extension %s is not supported.\n", extension_type, debugstr_a(required_extensions[i])); ++extension_count; @@ -98,9 +105,10 @@ static unsigned int vkd3d_check_extensions(const VkExtensionProperties *extensio { const char *extension_name = optional_extensions[i].extension_name; ptrdiff_t offset = optional_extensions[i].vulkan_info_offset; + bool is_debug_only = optional_extensions[i].is_debug_only; bool *supported = (void *)((uintptr_t)vulkan_info + offset);
- if ((*supported = has_extension(extensions, count, extension_name))) + if ((*supported = has_extension(extensions, count, extension_name, is_debug_only))) { TRACE("Found %s extension.\n", debugstr_a(extension_name)); ++extension_count; @@ -109,7 +117,7 @@ static unsigned int vkd3d_check_extensions(const VkExtensionProperties *extensio
for (i = 0; i < user_extension_count; ++i) { - if (!has_extension(extensions, count, user_extensions[i])) + if (!has_extension(extensions, count, user_extensions[i], false)) ERR("Required user %s extension %s is not supported.\n", extension_type, debugstr_a(user_extensions[i])); ++extension_count; @@ -234,6 +242,36 @@ static HRESULT vkd3d_init_vk_global_procs(struct vkd3d_instance *instance, return S_OK; }
+static VkBool32 VKAPI_PTR vkd3d_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 vkd3d_init_debug_report(struct vkd3d_instance *instance) +{ + const struct vkd3d_vk_instance_procs *vk_procs = &instance->vk_procs; + VkDebugReportCallbackCreateInfoEXT callback_info; + VkInstance vk_instance = instance->vk_instance; + 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 = vkd3d_debug_report_callback; + callback_info.pUserData = NULL; + if ((vr = VK_CALL(vkCreateDebugReportCallbackEXT(vk_instance, &callback_info, NULL, &callback)) < 0)) + { + WARN("Failed to create debug report callback, vr %d.\n", vr); + return; + } + + instance->vk_debug_callback = callback; +} + static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance, const struct vkd3d_instance_create_info *create_info) { @@ -333,6 +371,10 @@ static HRESULT vkd3d_instance_init(struct vkd3d_instance *instance,
instance->refcount = 1;
+ instance->vk_debug_callback = VK_NULL_HANDLE; + if (instance->vk_info.EXT_debug_report) + vkd3d_init_debug_report(instance); + return S_OK; }
@@ -370,6 +412,22 @@ HRESULT vkd3d_create_instance(const struct vkd3d_instance_create_info *create_in return S_OK; }
+static void vkd3d_destroy_instance(struct vkd3d_instance *instance) +{ + const struct vkd3d_vk_instance_procs *vk_procs = &instance->vk_procs; + VkInstance vk_instance = instance->vk_instance; + + if (instance->vk_debug_callback) + VK_CALL(vkDestroyDebugReportCallbackEXT(vk_instance, instance->vk_debug_callback, NULL)); + + VK_CALL(vkDestroyInstance(vk_instance, NULL)); + + if (instance->libvulkan) + dlclose(instance->libvulkan); + + vkd3d_free(instance); +} + ULONG vkd3d_instance_incref(struct vkd3d_instance *instance) { ULONG refcount = InterlockedIncrement(&instance->refcount); @@ -386,13 +444,7 @@ ULONG vkd3d_instance_decref(struct vkd3d_instance *instance) TRACE("%p decreasing refcount to %u.\n", instance, refcount);
if (!refcount) - { - const struct vkd3d_vk_instance_procs *vk_procs = &instance->vk_procs; - VK_CALL(vkDestroyInstance(instance->vk_instance, NULL)); - if (instance->libvulkan) - dlclose(instance->libvulkan); - vkd3d_free(instance); - } + vkd3d_destroy_instance(instance);
return refcount; } diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c index a62a74677981..43c8356203f5 100644 --- a/libs/vkd3d/utils.c +++ b/libs/vkd3d/utils.c @@ -399,13 +399,16 @@ HRESULT vkd3d_load_vk_global_procs(struct vkd3d_vk_global_procs *procs, ERR("Could not get instance proc addr for '" #name "'.\n"); \ return E_FAIL; \ } +#define LOAD_INSTANCE_OPTIONAL_PFN(name) \ + procs->name = (void *)global_procs->vkGetInstanceProcAddr(instance, #name);
HRESULT vkd3d_load_vk_instance_procs(struct vkd3d_vk_instance_procs *procs, const struct vkd3d_vk_global_procs *global_procs, VkInstance instance) { memset(procs, 0, sizeof(*procs));
-#define VK_INSTANCE_PFN LOAD_INSTANCE_PFN +#define VK_INSTANCE_PFN LOAD_INSTANCE_PFN +#define VK_INSTANCE_EXT_PFN LOAD_INSTANCE_OPTIONAL_PFN #include "vulkan_procs.h"
TRACE("Loaded procs for VkInstance %p.\n", instance); diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index cf3112e845b3..246c42bed937 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -58,7 +58,8 @@ struct vkd3d_vk_global_procs #define DECLARE_VK_PFN(name) PFN_##name name; struct vkd3d_vk_instance_procs { -#define VK_INSTANCE_PFN DECLARE_VK_PFN +#define VK_INSTANCE_PFN DECLARE_VK_PFN +#define VK_INSTANCE_EXT_PFN DECLARE_VK_PFN #include "vulkan_procs.h" };
@@ -75,6 +76,7 @@ struct vkd3d_vulkan_info { /* instance extensions */ bool KHR_get_physical_device_properties2; + bool EXT_debug_report; /* device extensions */ bool KHR_push_descriptor;
@@ -96,6 +98,8 @@ struct vkd3d_instance struct vkd3d_vk_global_procs vk_global_procs; void *libvulkan;
+ VkDebugReportCallbackEXT vk_debug_callback; + LONG refcount; };
diff --git a/libs/vkd3d/vulkan_procs.h b/libs/vkd3d/vulkan_procs.h index cbdcda80f2c7..690a1a2b5acf 100644 --- a/libs/vkd3d/vulkan_procs.h +++ b/libs/vkd3d/vulkan_procs.h @@ -20,6 +20,10 @@ # define VK_INSTANCE_PFN(x) #endif
+#ifndef VK_INSTANCE_EXT_PFN +# define VK_INSTANCE_EXT_PFN(x) +#endif + #ifndef VK_DEVICE_PFN # define VK_DEVICE_PFN(x) #endif @@ -42,6 +46,9 @@ VK_INSTANCE_PFN(vkGetPhysicalDeviceMemoryProperties) VK_INSTANCE_PFN(vkGetPhysicalDeviceProperties) VK_INSTANCE_PFN(vkGetPhysicalDeviceQueueFamilyProperties) VK_INSTANCE_PFN(vkGetPhysicalDeviceSparseImageFormatProperties) +/* VK_EXT_debug_report */ +VK_INSTANCE_EXT_PFN(vkCreateDebugReportCallbackEXT) +VK_INSTANCE_EXT_PFN(vkDestroyDebugReportCallbackEXT)
/* Device functions (obtained by vkGetDeviceProcAddr). */ VK_DEVICE_PFN(vkDestroyDevice) /* Load vkDestroyDevice() first. */ @@ -168,5 +175,6 @@ VK_DEVICE_PFN(vkWaitForFences) VK_DEVICE_EXT_PFN(vkCmdPushDescriptorSetKHR)
#undef VK_INSTANCE_PFN +#undef VK_INSTANCE_EXT_PFN #undef VK_DEVICE_PFN #undef VK_DEVICE_EXT_PFN
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
For consitency.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- include/vkd3d.h | 6 ++---- include/vkd3d_utils.h | 2 +- libs/vkd3d-utils/vkd3d_utils_main.c | 6 +++--- libs/vkd3d/command.c | 5 +++-- programs/vkd3d-compiler/main.c | 1 + tests/vkd3d_api.c | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/include/vkd3d.h b/include/vkd3d.h index 7c5f6441e9d9..d089ada56b72 100644 --- a/include/vkd3d.h +++ b/include/vkd3d.h @@ -28,8 +28,6 @@ # include <vulkan/vulkan.h> #endif /* VKD3D_NO_VULKAN_H */
-#include <stdbool.h> - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -45,12 +43,12 @@ enum vkd3d_structure_type VKD3D_FORCE_32_BIT_ENUM(VKD3D_STRUCTURE_TYPE), };
-typedef bool (*PFN_vkd3d_signal_event)(HANDLE event); +typedef HRESULT (*PFN_vkd3d_signal_event)(HANDLE event);
typedef void * (*PFN_vkd3d_thread)(void *data);
typedef void * (*PFN_vkd3d_create_thread)(PFN_vkd3d_thread thread_main, void *data); -typedef bool (*PFN_vkd3d_join_thread)(void *thread); +typedef HRESULT (*PFN_vkd3d_join_thread)(void *thread);
struct vkd3d_instance;
diff --git a/include/vkd3d_utils.h b/include/vkd3d_utils.h index 06b01fc9bf80..676d3330ed5e 100644 --- a/include/vkd3d_utils.h +++ b/include/vkd3d_utils.h @@ -31,7 +31,7 @@ extern "C" { #define INFINITE (~0u)
HANDLE vkd3d_create_event(void); -bool vkd3d_signal_event(HANDLE event); +HRESULT vkd3d_signal_event(HANDLE event); unsigned int vkd3d_wait_event(HANDLE event, unsigned int milliseconds); void vkd3d_destroy_event(HANDLE event);
diff --git a/libs/vkd3d-utils/vkd3d_utils_main.c b/libs/vkd3d-utils/vkd3d_utils_main.c index adafb00bddc8..3c0d13971b6c 100644 --- a/libs/vkd3d-utils/vkd3d_utils_main.c +++ b/libs/vkd3d-utils/vkd3d_utils_main.c @@ -159,7 +159,7 @@ unsigned int vkd3d_wait_event(HANDLE event, unsigned int milliseconds) return WAIT_FAILED; }
-bool vkd3d_signal_event(HANDLE event) +HRESULT vkd3d_signal_event(HANDLE event) { struct vkd3d_event *impl = event; int rc; @@ -169,13 +169,13 @@ bool vkd3d_signal_event(HANDLE event) if ((rc = pthread_mutex_lock(&impl->mutex))) { ERR("Failed to lock mutex, error %d.\n", rc); - return false; + return E_FAIL; } impl->is_signaled = true; pthread_cond_signal(&impl->cond); pthread_mutex_unlock(&impl->mutex);
- return true; + return S_OK; }
void vkd3d_destroy_event(HANDLE event) diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 39094c24e913..d9ad8f3460b8 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -288,6 +288,7 @@ HRESULT vkd3d_fence_worker_start(struct vkd3d_fence_worker *worker, HRESULT vkd3d_fence_worker_stop(struct vkd3d_fence_worker *worker, struct d3d12_device *device) { + HRESULT hr; int rc;
TRACE("worker %p.\n", worker); @@ -305,9 +306,9 @@ HRESULT vkd3d_fence_worker_stop(struct vkd3d_fence_worker *worker,
if (device->join_thread) { - if (!device->join_thread(worker->u.handle)) + if (FAILED(hr = device->join_thread(worker->u.handle))) { - ERR("Failed to join fence worker thread.\n"); + ERR("Failed to join fence worker thread, hr %#x.\n", hr); return E_FAIL; } } diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index 89778b8838bf..2e6566882a66 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -17,6 +17,7 @@ */
#include <fcntl.h> +#include <stdbool.h> #include <stdio.h> #include <sys/stat.h> #include <unistd.h> diff --git a/tests/vkd3d_api.c b/tests/vkd3d_api.c index 439cb6364eb8..e2d9d014125a 100644 --- a/tests/vkd3d_api.c +++ b/tests/vkd3d_api.c @@ -54,10 +54,10 @@ static ULONG resource_get_internal_refcount(ID3D12Resource *resource) return vkd3d_resource_decref(resource); }
-static bool signal_event(HANDLE event) +static HRESULT signal_event(HANDLE event) { trace("Signal event %p.\n", event); - return true; + return S_OK; }
static const struct vkd3d_instance_create_info instance_default_create_info =
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com