diff --git a/include/private/vkd3d_test.h b/include/private/vkd3d_test.h index e1b9b969..93b41172 100644 --- a/include/private/vkd3d_test.h +++ b/include/private/vkd3d_test.h @@ -43,53 +43,58 @@ static void vkd3d_test_end_todo(void); * Use assert_that() for conditions that should always be true. * todo_if() and bug_if() do not influence assert_that(). */ -#define assert_that assert_that_(__LINE__) +#define assert_that assert_that_(__FILE__, __LINE__) -#define ok ok_(__LINE__) +#define ok ok_(__FILE__, __LINE__) -#define skip skip_(__LINE__) +#define skip skip_(__FILE__, __LINE__) -#define trace trace_(__LINE__) +#define trace trace_(__FILE__, __LINE__) -#define assert_that_(line) \ +#define assert_that_(file, line) \ do { \ + const char *vkd3d_file = file; \ unsigned int vkd3d_line = line; \ VKD3D_TEST_ASSERT_THAT #define VKD3D_TEST_ASSERT_THAT(...) \ - vkd3d_test_assert_that(vkd3d_line, __VA_ARGS__); } while (0) + vkd3d_test_assert_that(vkd3d_file, vkd3d_line, __VA_ARGS__); } while (0) -#define ok_(line) \ +#define ok_(file, line) \ do { \ + const char *vkd3d_file = file; \ unsigned int vkd3d_line = line; \ VKD3D_TEST_OK #define VKD3D_TEST_OK(...) \ - vkd3d_test_ok(vkd3d_line, __VA_ARGS__); } while (0) + vkd3d_test_ok(vkd3d_file, vkd3d_line, __VA_ARGS__); } while (0) -#define todo_(line) \ +#define todo_(file, line) \ do { \ + const char *vkd3d_file = file; \ unsigned int vkd3d_line = line; \ VKD3D_TEST_TODO #define VKD3D_TEST_TODO(...) \ - vkd3d_test_todo(vkd3d_line, __VA_ARGS__); } while (0) + vkd3d_test_todo(vkd3d_file, vkd3d_line, __VA_ARGS__); } while (0) -#define skip_(line) \ +#define skip_(file, line) \ do { \ + const char *vkd3d_file = file; \ unsigned int vkd3d_line = line; \ VKD3D_TEST_SKIP #define VKD3D_TEST_SKIP(...) \ - vkd3d_test_skip(vkd3d_line, __VA_ARGS__); } while (0) + vkd3d_test_skip(vkd3d_file, vkd3d_line, __VA_ARGS__); } while (0) -#define trace_(line) \ +#define trace_(file, line) \ do { \ + const char *vkd3d_file = file; \ unsigned int vkd3d_line = line; \ VKD3D_TEST_TRACE #define VKD3D_TEST_TRACE(...) \ - vkd3d_test_trace(vkd3d_line, __VA_ARGS__); } while (0) + vkd3d_test_trace(vkd3d_file, vkd3d_line, __VA_ARGS__); } while (0) #define todo_if(is_todo) \ for (vkd3d_test_start_todo(is_todo); vkd3d_test_loop_todo(); vkd3d_test_end_todo()) @@ -135,45 +140,59 @@ broken(bool condition) return condition && vkd3d_test_platform_is_windows(); } -static void vkd3d_test_printf(unsigned int line, const char *msg) +/* basename() is not reentrant, basename_r() is not standard and this simple + * implementation should be enough for us. */ +static const char *vkd3d_basename(const char *filename) +{ + const char *p; + + if ((p = strrchr(filename, '/'))) + filename = ++p; + if ((p = strrchr(filename, '\\'))) + filename = ++p; + + return filename; +} + +static void vkd3d_test_printf(const char *file, unsigned int line, const char *msg) { unsigned int i; - printf("%s:%u: ", vkd3d_test_name, line); + printf("%s:%u: ", vkd3d_basename(file), line); for (i = 0; i < vkd3d_test_state.context_count; ++i) printf("%s: ", vkd3d_test_state.context[i]); printf("%s", msg); } static void -vkd3d_test_check_assert_that(unsigned int line, bool result, const char *fmt, va_list args) +vkd3d_test_check_assert_that(const char *file, unsigned int line, bool result, const char *fmt, va_list args) { if (result) { vkd3d_atomic_increment_u32(&vkd3d_test_state.success_count); if (vkd3d_test_state.debug_level > 1) - vkd3d_test_printf(line, "Test succeeded.\n"); + vkd3d_test_printf(file, line, "Test succeeded.\n"); } else { vkd3d_atomic_increment_u32(&vkd3d_test_state.failure_count); - vkd3d_test_printf(line, "Test failed: "); + vkd3d_test_printf(file, line, "Test failed: "); vprintf(fmt, args); } } -static void VKD3D_PRINTF_FUNC(3, 4) VKD3D_UNUSED -vkd3d_test_assert_that(unsigned int line, bool result, const char *fmt, ...) +static void VKD3D_PRINTF_FUNC(4, 5) VKD3D_UNUSED +vkd3d_test_assert_that(const char *file, unsigned int line, bool result, const char *fmt, ...) { va_list args; va_start(args, fmt); - vkd3d_test_check_assert_that(line, result, fmt, args); + vkd3d_test_check_assert_that(file, line, result, fmt, args); va_end(args); } static void -vkd3d_test_check_ok(unsigned int line, bool result, const char *fmt, va_list args) +vkd3d_test_check_ok(const char *file, unsigned int line, bool result, const char *fmt, va_list args) { bool is_todo = vkd3d_test_state.todo_level && !vkd3d_test_platform_is_windows(); bool is_bug = vkd3d_test_state.bug_level && !vkd3d_test_platform_is_windows(); @@ -184,9 +203,9 @@ vkd3d_test_check_ok(unsigned int line, bool result, const char *fmt, va_list arg if (is_todo) result = !result; if (result) - vkd3d_test_printf(line, "Fixed bug: "); + vkd3d_test_printf(file, line, "Fixed bug: "); else - vkd3d_test_printf(line, "Bug: "); + vkd3d_test_printf(file, line, "Bug: "); vprintf(fmt, args); } else if (is_todo) @@ -194,48 +213,48 @@ vkd3d_test_check_ok(unsigned int line, bool result, const char *fmt, va_list arg if (result) { vkd3d_atomic_increment_u32(&vkd3d_test_state.todo_success_count); - vkd3d_test_printf(line, "Todo succeeded: "); + vkd3d_test_printf(file, line, "Todo succeeded: "); } else { vkd3d_atomic_increment_u32(&vkd3d_test_state.todo_count); - vkd3d_test_printf(line, "Todo: "); + vkd3d_test_printf(file, line, "Todo: "); } vprintf(fmt, args); } else { - vkd3d_test_check_assert_that(line, result, fmt, args); + vkd3d_test_check_assert_that(file, line, result, fmt, args); } } -static void VKD3D_PRINTF_FUNC(3, 4) VKD3D_UNUSED -vkd3d_test_ok(unsigned int line, bool result, const char *fmt, ...) +static void VKD3D_PRINTF_FUNC(4, 5) VKD3D_UNUSED +vkd3d_test_ok(const char *file, unsigned int line, bool result, const char *fmt, ...) { va_list args; va_start(args, fmt); - vkd3d_test_check_ok(line, result, fmt, args); + vkd3d_test_check_ok(file, line, result, fmt, args); va_end(args); } -static void VKD3D_PRINTF_FUNC(2, 3) VKD3D_UNUSED -vkd3d_test_skip(unsigned int line, const char *fmt, ...) +static void VKD3D_PRINTF_FUNC(3, 4) VKD3D_UNUSED +vkd3d_test_skip(const char *file, unsigned int line, const char *fmt, ...) { va_list args; va_start(args, fmt); - vkd3d_test_printf(line, "Test skipped: "); + vkd3d_test_printf(file, line, "Test skipped: "); vprintf(fmt, args); va_end(args); vkd3d_atomic_increment_u32(&vkd3d_test_state.skip_count); } -static void VKD3D_PRINTF_FUNC(2, 3) VKD3D_UNUSED -vkd3d_test_trace(unsigned int line, const char *fmt, ...) +static void VKD3D_PRINTF_FUNC(3, 4) VKD3D_UNUSED +vkd3d_test_trace(const char *file, unsigned int line, const char *fmt, ...) { va_list args; va_start(args, fmt); - vkd3d_test_printf(line, ""); + vkd3d_test_printf(file, line, ""); vprintf(fmt, args); va_end(args); } diff --git a/tests/d3d12.c b/tests/d3d12.c index 54d1efa3..ee0e7bf6 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -61,8 +61,8 @@ static ULONG get_refcount(void *iface) return IUnknown_Release(unk); } -#define check_interface(a, b, c) check_interface_(__LINE__, (IUnknown *)a, b, c) -static void check_interface_(unsigned int line, IUnknown *iface, REFIID riid, bool supported) +#define check_interface(a, b, c) check_interface_(__FILE__, __LINE__, (IUnknown *)a, b, c) +static void check_interface_(const char *file, unsigned int line, IUnknown *iface, REFIID riid, bool supported) { HRESULT hr, expected_hr; IUnknown *unk; @@ -70,13 +70,13 @@ static void check_interface_(unsigned int line, IUnknown *iface, REFIID riid, bo expected_hr = supported ? S_OK : E_NOINTERFACE; hr = IUnknown_QueryInterface(iface, riid, (void **)&unk); - ok_(line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr); + ok_(file, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr); if (SUCCEEDED(hr)) IUnknown_Release(unk); } -#define check_heap_properties(a, b) check_heap_properties_(__LINE__, a, b) -static void check_heap_properties_(unsigned int line, +#define check_heap_properties(a, b) check_heap_properties_(__FILE__, __LINE__, a, b) +static void check_heap_properties_(const char *file, unsigned int line, const D3D12_HEAP_PROPERTIES *properties, const D3D12_HEAP_PROPERTIES *expected_properties) { D3D12_HEAP_PROPERTIES expected = *expected_properties; @@ -86,24 +86,24 @@ static void check_heap_properties_(unsigned int line, if (!expected.VisibleNodeMask) expected.VisibleNodeMask = 0x1; - ok_(line)(properties->Type == expected.Type, + ok_(file, line)(properties->Type == expected.Type, "Got type %#x, expected %#x.\n", properties->Type, expected.Type); - ok_(line)(properties->CPUPageProperty == expected.CPUPageProperty, + ok_(file, line)(properties->CPUPageProperty == expected.CPUPageProperty, "Got CPU page properties %#x, expected %#x.\n", properties->CPUPageProperty, expected.CPUPageProperty); - ok_(line)(properties->MemoryPoolPreference == expected.MemoryPoolPreference, + ok_(file, line)(properties->MemoryPoolPreference == expected.MemoryPoolPreference, "Got memory pool %#x, expected %#x.\n", properties->MemoryPoolPreference, expected.MemoryPoolPreference); - ok_(line)(properties->CreationNodeMask == expected.CreationNodeMask, + ok_(file, line)(properties->CreationNodeMask == expected.CreationNodeMask, "Got creation node mask %#x, expected %#x.\n", properties->CreationNodeMask, expected.CreationNodeMask); - ok_(line)(properties->VisibleNodeMask == expected.VisibleNodeMask, + ok_(file, line)(properties->VisibleNodeMask == expected.VisibleNodeMask, "Got visible node mask %#x, expected %#x.\n", properties->VisibleNodeMask, expected.VisibleNodeMask); } -#define check_heap_desc(a, b) check_heap_desc_(__LINE__, a, b) -static void check_heap_desc_(unsigned int line, const D3D12_HEAP_DESC *desc, +#define check_heap_desc(a, b) check_heap_desc_(__FILE__, __LINE__, a, b) +static void check_heap_desc_(const char *file, unsigned int line, const D3D12_HEAP_DESC *desc, const D3D12_HEAP_DESC *expected_desc) { D3D12_HEAP_DESC expected = *expected_desc; @@ -111,22 +111,22 @@ static void check_heap_desc_(unsigned int line, const D3D12_HEAP_DESC *desc, if (!expected.Alignment) expected.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; - ok_(line)(desc->SizeInBytes == expected.SizeInBytes, + ok_(file, line)(desc->SizeInBytes == expected.SizeInBytes, "Got size %"PRIu64", expected %"PRIu64".\n", desc->SizeInBytes, expected.SizeInBytes); - check_heap_properties_(line, &desc->Properties, &expected.Properties); - ok_(line)(desc->Alignment == expected.Alignment, + check_heap_properties_(file, line, &desc->Properties, &expected.Properties); + ok_(file, line)(desc->Alignment == expected.Alignment, "Got alignment %"PRIu64", expected %"PRIu64".\n", desc->Alignment, expected.Alignment); - ok_(line)(desc->Flags == expected.Flags, + ok_(file, line)(desc->Flags == expected.Flags, "Got flags %#x, expected %#x.\n", desc->Flags, expected.Flags); } -#define check_alignment(a, b) check_alignment_(__LINE__, a, b) -static void check_alignment_(unsigned int line, uint64_t size, uint64_t alignment) +#define check_alignment(a, b) check_alignment_(__FILE__, __LINE__, a, b) +static void check_alignment_(const char *file, unsigned int line, uint64_t size, uint64_t alignment) { uint64_t aligned_size = align(size, alignment); - ok_(line)(aligned_size == size, "Got unaligned size %"PRIu64", expected %"PRIu64".\n", + ok_(file, line)(aligned_size == size, "Got unaligned size %"PRIu64", expected %"PRIu64".\n", size, aligned_size); } @@ -228,20 +228,20 @@ static uint16_t get_readback_uint16(struct resource_readback *rb, unsigned int x return *(uint16_t *)get_readback_data(rb, x, y, 0, sizeof(uint16_t)); } -#define check_sub_resource_float(a, b, c, d, e, f) check_sub_resource_float_(__LINE__, a, b, c, d, e, f) -static void check_sub_resource_float_(unsigned int line, ID3D12Resource *resource, +#define check_sub_resource_float(a, b, c, d, e, f) check_sub_resource_float_(__FILE__, __LINE__, a, b, c, d, e, f) +static void check_sub_resource_float_(const char *file, unsigned int line, ID3D12Resource *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, float expected, unsigned int max_diff) { struct d3d12_resource_readback rb; get_resource_readback_with_command_list(resource, sub_resource_idx, &rb, queue, command_list); - check_readback_data_float_(line, &rb.rb, NULL, expected, max_diff); + check_readback_data_float_(file, line, &rb.rb, NULL, expected, max_diff); release_resource_readback(&rb); } -#define check_readback_data_uint8(a, b, c, d) check_readback_data_uint8_(__LINE__, a, b, c, d) -static void check_readback_data_uint8_(unsigned int line, struct resource_readback *rb, +#define check_readback_data_uint8(a, b, c, d) check_readback_data_uint8_(__FILE__, __LINE__, a, b, c, d) +static void check_readback_data_uint8_(const char *file, unsigned int line, struct resource_readback *rb, const RECT *rect, uint8_t expected, unsigned int max_diff) { RECT r = {0, 0, rb->width, rb->height}; @@ -266,23 +266,23 @@ static void check_readback_data_uint8_(unsigned int line, struct resource_readba if (!all_match) break; } - ok_(line)(all_match, "Got 0x%02x, expected 0x%02x at (%u, %u).\n", got, expected, x, y); + ok_(file, line)(all_match, "Got 0x%02x, expected 0x%02x at (%u, %u).\n", got, expected, x, y); } -#define check_sub_resource_uint8(a, b, c, d, e, f) check_sub_resource_uint8_(__LINE__, a, b, c, d, e, f) -static void check_sub_resource_uint8_(unsigned int line, ID3D12Resource *resource, +#define check_sub_resource_uint8(a, b, c, d, e, f) check_sub_resource_uint8_(__FILE__, __LINE__, a, b, c, d, e, f) +static void check_sub_resource_uint8_(const char *file, unsigned int line, ID3D12Resource *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, uint8_t expected, unsigned int max_diff) { struct d3d12_resource_readback rb; get_resource_readback_with_command_list(resource, sub_resource_idx, &rb, queue, command_list); - check_readback_data_uint8_(line, &rb.rb, NULL, expected, max_diff); + check_readback_data_uint8_(file, line, &rb.rb, NULL, expected, max_diff); release_resource_readback(&rb); } -#define check_readback_data_uint16(a, b, c, d) check_readback_data_uint16_(__LINE__, a, b, c, d) -static void check_readback_data_uint16_(unsigned int line, struct resource_readback *rb, +#define check_readback_data_uint16(a, b, c, d) check_readback_data_uint16_(__FILE__, __LINE__, a, b, c, d) +static void check_readback_data_uint16_(const char *file, unsigned int line, struct resource_readback *rb, const RECT *rect, uint16_t expected, unsigned int max_diff) { RECT r = {0, 0, rb->width, rb->height}; @@ -307,35 +307,35 @@ static void check_readback_data_uint16_(unsigned int line, struct resource_readb if (!all_match) break; } - ok_(line)(all_match, "Got 0x%04x, expected 0x%04x at (%u, %u).\n", got, expected, x, y); + ok_(file, line)(all_match, "Got 0x%04x, expected 0x%04x at (%u, %u).\n", got, expected, x, y); } -#define check_sub_resource_uint16(a, b, c, d, e, f) check_sub_resource_uint16_(__LINE__, a, b, c, d, e, f) -static void check_sub_resource_uint16_(unsigned int line, ID3D12Resource *resource, +#define check_sub_resource_uint16(a, b, c, d, e, f) check_sub_resource_uint16_(__FILE__, __LINE__, a, b, c, d, e, f) +static void check_sub_resource_uint16_(const char *file, unsigned int line, ID3D12Resource *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, uint16_t expected, unsigned int max_diff) { struct d3d12_resource_readback rb; get_resource_readback_with_command_list(resource, sub_resource_idx, &rb, queue, command_list); - check_readback_data_uint16_(line, &rb.rb, NULL, expected, max_diff); + check_readback_data_uint16_(file, line, &rb.rb, NULL, expected, max_diff); release_resource_readback(&rb); } -#define check_sub_resource_uint64(a, b, c, d, e, f) check_sub_resource_uint64_(__LINE__, a, b, c, d, e, f) -static void check_sub_resource_uint64_(unsigned int line, ID3D12Resource *resource, +#define check_sub_resource_uint64(a, b, c, d, e, f) check_sub_resource_uint64_(__FILE__, __LINE__, a, b, c, d, e, f) +static void check_sub_resource_uint64_(const char *file, unsigned int line, ID3D12Resource *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, uint64_t expected, unsigned int max_diff) { struct d3d12_resource_readback rb; get_resource_readback_with_command_list(resource, sub_resource_idx, &rb, queue, command_list); - check_readback_data_uint64_(line, &rb.rb, NULL, expected, max_diff); + check_readback_data_uint64_(file, line, &rb.rb, NULL, expected, max_diff); release_resource_readback(&rb); } -#define check_sub_resource_uvec4(a, b, c, d, e) check_sub_resource_uvec4_(__LINE__, a, b, c, d, e) -static void check_sub_resource_uvec4_(unsigned int line, ID3D12Resource *resource, +#define check_sub_resource_uvec4(a, b, c, d, e) check_sub_resource_uvec4_(__FILE__, __LINE__, a, b, c, d, e) +static void check_sub_resource_uvec4_(const char *file, unsigned int line, ID3D12Resource *resource, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, const struct uvec4 *expected_value) { @@ -361,21 +361,21 @@ static void check_sub_resource_uvec4_(unsigned int line, ID3D12Resource *resourc } release_resource_readback(&rb); - ok_(line)(all_match, + ok_(file, line)(all_match, "Got {0x%08x, 0x%08x, 0x%08x, 0x%08x}, expected {0x%08x, 0x%08x, 0x%08x, 0x%08x} at (%u, %u).\n", value.x, value.y, value.z, value.w, expected_value->x, expected_value->y, expected_value->z, expected_value->w, x, y); } -#define check_buffer_uint(a, b, c, d, e) check_buffer_uint_(__LINE__, a, b, c, d, e) -static void check_buffer_uint_(unsigned int line, ID3D12Resource *buffer, +#define check_buffer_uint(a, b, c, d, e) check_buffer_uint_(__FILE__, __LINE__, a, b, c, d, e) +static void check_buffer_uint_(const char *file, unsigned int line, ID3D12Resource *buffer, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, unsigned int expected, unsigned int max_diff) { struct d3d12_resource_readback rb; get_buffer_readback_with_command_list(buffer, DXGI_FORMAT_R32_UINT, &rb, queue, command_list); - check_readback_data_uint_(line, &rb.rb, NULL, expected, max_diff); + check_readback_data_uint_(file, line, &rb.rb, NULL, expected, max_diff); release_resource_readback(&rb); } @@ -577,8 +577,8 @@ static bool are_unaligned_block_textures_supported(ID3D12Device *device) return options.UnalignedBlockTexturesSupported; } -#define create_cb_root_signature(a, b, c, e) create_cb_root_signature_(__LINE__, a, b, c, e) -static ID3D12RootSignature *create_cb_root_signature_(unsigned int line, +#define create_cb_root_signature(a, b, c, e) create_cb_root_signature_(__FILE__, __LINE__, a, b, c, e) +static ID3D12RootSignature *create_cb_root_signature_(const char *file, unsigned int line, ID3D12Device *device, unsigned int reg_idx, D3D12_SHADER_VISIBILITY shader_visibility, D3D12_ROOT_SIGNATURE_FLAGS flags) { @@ -597,13 +597,13 @@ static ID3D12RootSignature *create_cb_root_signature_(unsigned int line, root_signature_desc.pParameters = &root_parameter; root_signature_desc.Flags = flags; hr = create_root_signature(device, &root_signature_desc, &root_signature); - ok_(line)(SUCCEEDED(hr), "Failed to create root signature, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create root signature, hr %#x.\n", hr); return root_signature; } -#define create_texture_root_signature(a, b, c, d) create_texture_root_signature_(__LINE__, a, b, c, d, NULL) -static ID3D12RootSignature *create_texture_root_signature_(unsigned int line, +#define create_texture_root_signature(a, b, c, d) create_texture_root_signature_(__FILE__, __LINE__, a, b, c, d, NULL) +static ID3D12RootSignature *create_texture_root_signature_(const char *file, unsigned int line, ID3D12Device *device, D3D12_SHADER_VISIBILITY shader_visibility, unsigned int constant_count, D3D12_ROOT_SIGNATURE_FLAGS flags, const D3D12_STATIC_SAMPLER_DESC *sampler_desc) @@ -656,13 +656,13 @@ static ID3D12RootSignature *create_texture_root_signature_(unsigned int line, root_signature_desc.Flags = flags; hr = create_root_signature(device, &root_signature_desc, &root_signature); - ok_(line)(SUCCEEDED(hr), "Failed to create root signature, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create root signature, hr %#x.\n", hr); return root_signature; } -#define create_command_signature(a, b) create_command_signature_(__LINE__, a, b) -static ID3D12CommandSignature *create_command_signature_(unsigned int line, +#define create_command_signature(a, b) create_command_signature_(__FILE__, __LINE__, a, b) +static ID3D12CommandSignature *create_command_signature_(const char *file, unsigned int line, ID3D12Device *device, D3D12_INDIRECT_ARGUMENT_TYPE argument_type) { D3D12_COMMAND_SIGNATURE_DESC signature_desc; @@ -692,7 +692,7 @@ static ID3D12CommandSignature *create_command_signature_(unsigned int line, signature_desc.NodeMask = 0; hr = ID3D12Device_CreateCommandSignature(device, &signature_desc, NULL, &IID_ID3D12CommandSignature, (void **)&command_signature); - ok_(line)(hr == S_OK, "Failed to create command signature, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to create command signature, hr %#x.\n", hr); return command_signature; } @@ -704,10 +704,10 @@ struct depth_stencil_resource D3D12_CPU_DESCRIPTOR_HANDLE dsv_handle; }; -#define init_depth_stencil(a, b, c, d, e, f, g, h, i) init_depth_stencil_(__LINE__, a, b, c, d, e, f, g, h, i) -static void init_depth_stencil_(unsigned int line, struct depth_stencil_resource *ds, - ID3D12Device *device, unsigned int width, unsigned int height, unsigned int array_size, unsigned int level_count, - DXGI_FORMAT format, DXGI_FORMAT view_format, const D3D12_CLEAR_VALUE *clear_value) +#define init_depth_stencil(a, b, c, d, e, f, g, h, i) init_depth_stencil_(__FILE__, __LINE__, a, b, c, d, e, f, g, h, i) +static void init_depth_stencil_(const char *file, unsigned int line, struct depth_stencil_resource *ds, + ID3D12Device *device, unsigned int width, unsigned int height, unsigned int array_size, + unsigned int level_count, DXGI_FORMAT format, DXGI_FORMAT view_format, const D3D12_CLEAR_VALUE *clear_value) { D3D12_DEPTH_STENCIL_VIEW_DESC dsv_desc, *view_desc; D3D12_HEAP_PROPERTIES heap_properties; @@ -734,7 +734,7 @@ static void init_depth_stencil_(unsigned int line, struct depth_stencil_resource hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_DEPTH_WRITE, clear_value, &IID_ID3D12Resource, (void **)&ds->texture); - ok_(line)(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); view_desc = NULL; if (view_format) @@ -748,8 +748,8 @@ static void init_depth_stencil_(unsigned int line, struct depth_stencil_resource ID3D12Device_CreateDepthStencilView(device, ds->texture, view_desc, ds->dsv_handle); } -#define destroy_depth_stencil(depth_stencil) destroy_depth_stencil_(__LINE__, depth_stencil) -static void destroy_depth_stencil_(unsigned int line, struct depth_stencil_resource *ds) +#define destroy_depth_stencil(depth_stencil) destroy_depth_stencil_(__FILE__, __LINE__, depth_stencil) +static void destroy_depth_stencil_(const char *file, unsigned int line, struct depth_stencil_resource *ds) { ID3D12DescriptorHeap_Release(ds->heap); ID3D12Resource_Release(ds->texture); @@ -12092,47 +12092,47 @@ static void test_shader_input_output_components(void) destroy_test_context(&context); } -static void check_descriptor_range_(unsigned int line, const D3D12_DESCRIPTOR_RANGE *range, +static void check_descriptor_range_(const char *file, unsigned int line, const D3D12_DESCRIPTOR_RANGE *range, const D3D12_DESCRIPTOR_RANGE *expected_range) { - ok_(line)(range->RangeType == expected_range->RangeType, + ok_(file, line)(range->RangeType == expected_range->RangeType, "Got range type %#x, expected %#x.\n", range->RangeType, expected_range->RangeType); - ok_(line)(range->NumDescriptors == expected_range->NumDescriptors, + ok_(file, line)(range->NumDescriptors == expected_range->NumDescriptors, "Got descriptor count %u, expected %u.\n", range->NumDescriptors, expected_range->NumDescriptors); - ok_(line)(range->BaseShaderRegister == expected_range->BaseShaderRegister, + ok_(file, line)(range->BaseShaderRegister == expected_range->BaseShaderRegister, "Got base shader register %u, expected %u.\n", range->BaseShaderRegister, expected_range->BaseShaderRegister); - ok_(line)(range->RegisterSpace == expected_range->RegisterSpace, + ok_(file, line)(range->RegisterSpace == expected_range->RegisterSpace, "Got register space %u, expected %u.\n", range->RegisterSpace, expected_range->RegisterSpace); - ok_(line)(range->OffsetInDescriptorsFromTableStart == expected_range->OffsetInDescriptorsFromTableStart, + ok_(file, line)(range->OffsetInDescriptorsFromTableStart == expected_range->OffsetInDescriptorsFromTableStart, "Got offset %u, expected %u.\n", range->OffsetInDescriptorsFromTableStart, expected_range->OffsetInDescriptorsFromTableStart); } -static void check_descriptor_range1_(unsigned int line, const D3D12_DESCRIPTOR_RANGE1 *range, +static void check_descriptor_range1_(const char *file, unsigned int line, const D3D12_DESCRIPTOR_RANGE1 *range, const D3D12_DESCRIPTOR_RANGE1 *expected_range, bool converted) { unsigned int expected_flags = converted ? D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE | D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE : expected_range->Flags; - ok_(line)(range->RangeType == expected_range->RangeType, + ok_(file, line)(range->RangeType == expected_range->RangeType, "Got range type %#x, expected %#x.\n", range->RangeType, expected_range->RangeType); - ok_(line)(range->NumDescriptors == expected_range->NumDescriptors, + ok_(file, line)(range->NumDescriptors == expected_range->NumDescriptors, "Got descriptor count %u, expected %u.\n", range->NumDescriptors, expected_range->NumDescriptors); - ok_(line)(range->BaseShaderRegister == expected_range->BaseShaderRegister, + ok_(file, line)(range->BaseShaderRegister == expected_range->BaseShaderRegister, "Got base shader register %u, expected %u.\n", range->BaseShaderRegister, expected_range->BaseShaderRegister); - ok_(line)(range->RegisterSpace == expected_range->RegisterSpace, + ok_(file, line)(range->RegisterSpace == expected_range->RegisterSpace, "Got register space %u, expected %u.\n", range->RegisterSpace, expected_range->RegisterSpace); - ok_(line)(range->Flags == expected_flags, + ok_(file, line)(range->Flags == expected_flags, "Got descriptor range flags %#x, expected %#x.\n", range->Flags, expected_flags); - ok_(line)(range->OffsetInDescriptorsFromTableStart == expected_range->OffsetInDescriptorsFromTableStart, + ok_(file, line)(range->OffsetInDescriptorsFromTableStart == expected_range->OffsetInDescriptorsFromTableStart, "Got offset %u, expected %u.\n", range->OffsetInDescriptorsFromTableStart, expected_range->OffsetInDescriptorsFromTableStart); } -static void check_root_parameter_(unsigned int line, const D3D12_ROOT_PARAMETER *parameter, +static void check_root_parameter_(const char *file, unsigned int line, const D3D12_ROOT_PARAMETER *parameter, const D3D12_ROOT_PARAMETER *expected_parameter) { const D3D12_ROOT_DESCRIPTOR *descriptor, *expected_descriptor; @@ -12140,7 +12140,7 @@ static void check_root_parameter_(unsigned int line, const D3D12_ROOT_PARAMETER const D3D12_ROOT_CONSTANTS *constants, *expected_constants; unsigned int i; - ok_(line)(parameter->ParameterType == expected_parameter->ParameterType, + ok_(file, line)(parameter->ParameterType == expected_parameter->ParameterType, "Got type %#x, expected %#x.\n", parameter->ParameterType, expected_parameter->ParameterType); if (parameter->ParameterType != expected_parameter->ParameterType) return; @@ -12150,26 +12150,26 @@ static void check_root_parameter_(unsigned int line, const D3D12_ROOT_PARAMETER case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: table = ¶meter->DescriptorTable; expected_table = &expected_parameter->DescriptorTable; - ok_(line)(table->NumDescriptorRanges == expected_table->NumDescriptorRanges, + ok_(file, line)(table->NumDescriptorRanges == expected_table->NumDescriptorRanges, "Got range count %u, expected %u.\n", table->NumDescriptorRanges, expected_table->NumDescriptorRanges); if (table->NumDescriptorRanges == expected_table->NumDescriptorRanges) { for (i = 0; i < table->NumDescriptorRanges; ++i) - check_descriptor_range_(line, &table->pDescriptorRanges[i], + check_descriptor_range_(file, line, &table->pDescriptorRanges[i], &expected_table->pDescriptorRanges[i]); } break; case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: constants = ¶meter->Constants; expected_constants = &expected_parameter->Constants; - ok_(line)(constants->ShaderRegister == expected_constants->ShaderRegister, + ok_(file, line)(constants->ShaderRegister == expected_constants->ShaderRegister, "Got shader register %u, expected %u.\n", constants->ShaderRegister, expected_constants->ShaderRegister); - ok_(line)(constants->RegisterSpace == expected_constants->RegisterSpace, + ok_(file, line)(constants->RegisterSpace == expected_constants->RegisterSpace, "Got register space %u, expected %u.\n", constants->RegisterSpace, expected_constants->RegisterSpace); - ok_(line)(constants->Num32BitValues == expected_constants->Num32BitValues, + ok_(file, line)(constants->Num32BitValues == expected_constants->Num32BitValues, "Got 32-bit value count %u, expected %u.\n", constants->Num32BitValues, expected_constants->Num32BitValues); break; @@ -12178,10 +12178,10 @@ static void check_root_parameter_(unsigned int line, const D3D12_ROOT_PARAMETER case D3D12_ROOT_PARAMETER_TYPE_UAV: descriptor = ¶meter->Descriptor; expected_descriptor = &expected_parameter->Descriptor; - ok_(line)(descriptor->ShaderRegister == expected_descriptor->ShaderRegister, + ok_(file, line)(descriptor->ShaderRegister == expected_descriptor->ShaderRegister, "Got shader register %u, expected %u.\n", descriptor->ShaderRegister, expected_descriptor->ShaderRegister); - ok_(line)(descriptor->RegisterSpace == expected_descriptor->RegisterSpace, + ok_(file, line)(descriptor->RegisterSpace == expected_descriptor->RegisterSpace, "Got register space %u, expected %u.\n", descriptor->RegisterSpace, expected_descriptor->RegisterSpace); break; @@ -12189,12 +12189,12 @@ static void check_root_parameter_(unsigned int line, const D3D12_ROOT_PARAMETER trace("Unhandled type %#x.\n", parameter->ParameterType); } - ok_(line)(parameter->ShaderVisibility == expected_parameter->ShaderVisibility, + ok_(file, line)(parameter->ShaderVisibility == expected_parameter->ShaderVisibility, "Got shader visibility %#x, expected %#x.\n", parameter->ShaderVisibility, expected_parameter->ShaderVisibility); } -static void check_root_parameter1_(unsigned int line, const D3D12_ROOT_PARAMETER1 *parameter, +static void check_root_parameter1_(const char *file, unsigned int line, const D3D12_ROOT_PARAMETER1 *parameter, const D3D12_ROOT_PARAMETER1 *expected_parameter, bool converted) { const D3D12_ROOT_DESCRIPTOR1 *descriptor, *expected_descriptor; @@ -12203,7 +12203,7 @@ static void check_root_parameter1_(unsigned int line, const D3D12_ROOT_PARAMETER unsigned int expected_flags; unsigned int i; - ok_(line)(parameter->ParameterType == expected_parameter->ParameterType, + ok_(file, line)(parameter->ParameterType == expected_parameter->ParameterType, "Got type %#x, expected %#x.\n", parameter->ParameterType, expected_parameter->ParameterType); if (parameter->ParameterType != expected_parameter->ParameterType) return; @@ -12213,26 +12213,26 @@ static void check_root_parameter1_(unsigned int line, const D3D12_ROOT_PARAMETER case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: table = ¶meter->DescriptorTable; expected_table = &expected_parameter->DescriptorTable; - ok_(line)(table->NumDescriptorRanges == expected_table->NumDescriptorRanges, + ok_(file, line)(table->NumDescriptorRanges == expected_table->NumDescriptorRanges, "Got range count %u, expected %u.\n", table->NumDescriptorRanges, expected_table->NumDescriptorRanges); if (table->NumDescriptorRanges == expected_table->NumDescriptorRanges) { for (i = 0; i < table->NumDescriptorRanges; ++i) - check_descriptor_range1_(line, &table->pDescriptorRanges[i], + check_descriptor_range1_(file, line, &table->pDescriptorRanges[i], &expected_table->pDescriptorRanges[i], converted); } break; case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: constants = ¶meter->Constants; expected_constants = &expected_parameter->Constants; - ok_(line)(constants->ShaderRegister == expected_constants->ShaderRegister, + ok_(file, line)(constants->ShaderRegister == expected_constants->ShaderRegister, "Got shader register %u, expected %u.\n", constants->ShaderRegister, expected_constants->ShaderRegister); - ok_(line)(constants->RegisterSpace == expected_constants->RegisterSpace, + ok_(file, line)(constants->RegisterSpace == expected_constants->RegisterSpace, "Got register space %u, expected %u.\n", constants->RegisterSpace, expected_constants->RegisterSpace); - ok_(line)(constants->Num32BitValues == expected_constants->Num32BitValues, + ok_(file, line)(constants->Num32BitValues == expected_constants->Num32BitValues, "Got 32-bit value count %u, expected %u.\n", constants->Num32BitValues, expected_constants->Num32BitValues); break; @@ -12241,14 +12241,14 @@ static void check_root_parameter1_(unsigned int line, const D3D12_ROOT_PARAMETER case D3D12_ROOT_PARAMETER_TYPE_UAV: descriptor = ¶meter->Descriptor; expected_descriptor = &expected_parameter->Descriptor; - ok_(line)(descriptor->ShaderRegister == expected_descriptor->ShaderRegister, + ok_(file, line)(descriptor->ShaderRegister == expected_descriptor->ShaderRegister, "Got shader register %u, expected %u.\n", descriptor->ShaderRegister, expected_descriptor->ShaderRegister); - ok_(line)(descriptor->RegisterSpace == expected_descriptor->RegisterSpace, + ok_(file, line)(descriptor->RegisterSpace == expected_descriptor->RegisterSpace, "Got register space %u, expected %u.\n", descriptor->RegisterSpace, expected_descriptor->RegisterSpace); expected_flags = converted ? D3D12_ROOT_DESCRIPTOR_FLAG_DATA_VOLATILE : expected_descriptor->Flags; - ok_(line)(descriptor->Flags == expected_flags, + ok_(file, line)(descriptor->Flags == expected_flags, "Got root descriptor flags %#x, expected %#x.\n", descriptor->Flags, expected_flags); break; @@ -12256,114 +12256,115 @@ static void check_root_parameter1_(unsigned int line, const D3D12_ROOT_PARAMETER trace("Unhandled type %#x.\n", parameter->ParameterType); } - ok_(line)(parameter->ShaderVisibility == expected_parameter->ShaderVisibility, + ok_(file, line)(parameter->ShaderVisibility == expected_parameter->ShaderVisibility, "Got shader visibility %#x, expected %#x.\n", parameter->ShaderVisibility, expected_parameter->ShaderVisibility); } -static void check_static_sampler_(unsigned int line, const D3D12_STATIC_SAMPLER_DESC *sampler, +static void check_static_sampler_(const char *file, unsigned int line, const D3D12_STATIC_SAMPLER_DESC *sampler, const D3D12_STATIC_SAMPLER_DESC *expected_sampler) { - ok_(line)(sampler->Filter == expected_sampler->Filter, + ok_(file, line)(sampler->Filter == expected_sampler->Filter, "Got filter %#x, expected %#x.\n", sampler->Filter, expected_sampler->Filter); - ok_(line)(sampler->AddressU == expected_sampler->AddressU, + ok_(file, line)(sampler->AddressU == expected_sampler->AddressU, "Got address U %#x, expected %#x.\n", sampler->AddressU, expected_sampler->AddressU); - ok_(line)(sampler->AddressV == expected_sampler->AddressV, + ok_(file, line)(sampler->AddressV == expected_sampler->AddressV, "Got address V %#x, expected %#x.\n", sampler->AddressV, expected_sampler->AddressV); - ok_(line)(sampler->AddressW == expected_sampler->AddressW, + ok_(file, line)(sampler->AddressW == expected_sampler->AddressW, "Got address W %#x, expected %#x.\n", sampler->AddressW, expected_sampler->AddressW); - ok_(line)(sampler->MipLODBias == expected_sampler->MipLODBias, + ok_(file, line)(sampler->MipLODBias == expected_sampler->MipLODBias, "Got mip LOD bias %.8e, expected %.8e.\n", sampler->MipLODBias, expected_sampler->MipLODBias); - ok_(line)(sampler->MaxAnisotropy == expected_sampler->MaxAnisotropy, + ok_(file, line)(sampler->MaxAnisotropy == expected_sampler->MaxAnisotropy, "Got max anisotropy %u, expected %u.\n", sampler->MaxAnisotropy, expected_sampler->MaxAnisotropy); - ok_(line)(sampler->ComparisonFunc == expected_sampler->ComparisonFunc, + ok_(file, line)(sampler->ComparisonFunc == expected_sampler->ComparisonFunc, "Got comparison func %#x, expected %#x.\n", sampler->ComparisonFunc, expected_sampler->ComparisonFunc); - ok_(line)(sampler->BorderColor == expected_sampler->BorderColor, + ok_(file, line)(sampler->BorderColor == expected_sampler->BorderColor, "Got border color %#x, expected %#x.\n", sampler->BorderColor, expected_sampler->BorderColor); - ok_(line)(sampler->MinLOD == expected_sampler->MinLOD, + ok_(file, line)(sampler->MinLOD == expected_sampler->MinLOD, "Got min LOD %.8e, expected %.8e.\n", sampler->MinLOD, expected_sampler->MinLOD); - ok_(line)(sampler->MaxLOD == expected_sampler->MaxLOD, + ok_(file, line)(sampler->MaxLOD == expected_sampler->MaxLOD, "Got max LOD %.8e, expected %.8e.\n", sampler->MaxLOD, expected_sampler->MaxLOD); - ok_(line)(sampler->ShaderRegister == expected_sampler->ShaderRegister, + ok_(file, line)(sampler->ShaderRegister == expected_sampler->ShaderRegister, "Got shader register %u, expected %u.\n", sampler->ShaderRegister, expected_sampler->ShaderRegister); - ok_(line)(sampler->RegisterSpace == expected_sampler->RegisterSpace, + ok_(file, line)(sampler->RegisterSpace == expected_sampler->RegisterSpace, "Got register space %u, expected %u.\n", sampler->RegisterSpace, expected_sampler->RegisterSpace); - ok_(line)(sampler->ShaderVisibility == expected_sampler->ShaderVisibility, + ok_(file, line)(sampler->ShaderVisibility == expected_sampler->ShaderVisibility, "Got shader visibility %#x, expected %#x.\n", sampler->ShaderVisibility, expected_sampler->ShaderVisibility); } -#define check_root_signature_desc(desc, expected) check_root_signature_desc_(__LINE__, desc, expected) -static void check_root_signature_desc_(unsigned int line, const D3D12_ROOT_SIGNATURE_DESC *desc, +#define check_root_signature_desc(desc, expected) check_root_signature_desc_(__FILE__, __LINE__, desc, expected) +static void check_root_signature_desc_(const char *file, unsigned int line, const D3D12_ROOT_SIGNATURE_DESC *desc, const D3D12_ROOT_SIGNATURE_DESC *expected_desc) { unsigned int i; - ok_(line)(desc->NumParameters == expected_desc->NumParameters, + ok_(file, line)(desc->NumParameters == expected_desc->NumParameters, "Got parameter count %u, expected %u.\n", desc->NumParameters, expected_desc->NumParameters); if (!expected_desc->pParameters) { - ok_(line)(!desc->pParameters, "Got unexpected parameters %p.\n", desc->pParameters); + ok_(file, line)(!desc->pParameters, "Got unexpected parameters %p.\n", desc->pParameters); } else if (desc->NumParameters == expected_desc->NumParameters) { for (i = 0; i < desc->NumParameters; ++i) - check_root_parameter_(line, &desc->pParameters[i], &expected_desc->pParameters[i]); + check_root_parameter_(file, line, &desc->pParameters[i], &expected_desc->pParameters[i]); } - ok_(line)(desc->NumStaticSamplers == expected_desc->NumStaticSamplers, + ok_(file, line)(desc->NumStaticSamplers == expected_desc->NumStaticSamplers, "Got static sampler count %u, expected %u.\n", desc->NumStaticSamplers, expected_desc->NumStaticSamplers); if (!expected_desc->pStaticSamplers) { - ok_(line)(!desc->pStaticSamplers, "Got unexpected static samplers %p.\n", desc->pStaticSamplers); + ok_(file, line)(!desc->pStaticSamplers, "Got unexpected static samplers %p.\n", desc->pStaticSamplers); } else if (desc->NumStaticSamplers == expected_desc->NumStaticSamplers) { for (i = 0; i < desc->NumStaticSamplers; ++i) - check_static_sampler_(line, &desc->pStaticSamplers[i], &expected_desc->pStaticSamplers[i]); + check_static_sampler_(file, line, &desc->pStaticSamplers[i], &expected_desc->pStaticSamplers[i]); } - ok_(line)(desc->Flags == expected_desc->Flags, "Got flags %#x, expected %#x.\n", + ok_(file, line)(desc->Flags == expected_desc->Flags, "Got flags %#x, expected %#x.\n", desc->Flags, expected_desc->Flags); } -#define check_root_signature_desc1(a, b, c) check_root_signature_desc1_(__LINE__, a, b, c) -static void check_root_signature_desc1_(unsigned int line, const D3D12_ROOT_SIGNATURE_DESC1 *desc, +#define check_root_signature_desc1(a, b, c) check_root_signature_desc1_(__FILE__, __LINE__, a, b, c) +static void check_root_signature_desc1_(const char *file, unsigned int line, const D3D12_ROOT_SIGNATURE_DESC1 *desc, const D3D12_ROOT_SIGNATURE_DESC1 *expected_desc, bool converted) { unsigned int i; - ok_(line)(desc->NumParameters == expected_desc->NumParameters, + ok_(file, line)(desc->NumParameters == expected_desc->NumParameters, "Got parameter count %u, expected %u.\n", desc->NumParameters, expected_desc->NumParameters); if (!expected_desc->pParameters) { - ok_(line)(!desc->pParameters, "Got unexpected parameters %p.\n", desc->pParameters); + ok_(file, line)(!desc->pParameters, "Got unexpected parameters %p.\n", desc->pParameters); } else if (desc->NumParameters == expected_desc->NumParameters) { for (i = 0; i < desc->NumParameters; ++i) - check_root_parameter1_(line, &desc->pParameters[i], &expected_desc->pParameters[i], converted); + check_root_parameter1_(file, line, &desc->pParameters[i], &expected_desc->pParameters[i], converted); } - ok_(line)(desc->NumStaticSamplers == expected_desc->NumStaticSamplers, + ok_(file, line)(desc->NumStaticSamplers == expected_desc->NumStaticSamplers, "Got static sampler count %u, expected %u.\n", desc->NumStaticSamplers, expected_desc->NumStaticSamplers); if (!expected_desc->pStaticSamplers) { - ok_(line)(!desc->pStaticSamplers, "Got unexpected static samplers %p.\n", desc->pStaticSamplers); + ok_(file, line)(!desc->pStaticSamplers, "Got unexpected static samplers %p.\n", desc->pStaticSamplers); } else if (desc->NumStaticSamplers == expected_desc->NumStaticSamplers) { for (i = 0; i < desc->NumStaticSamplers; ++i) - check_static_sampler_(line, &desc->pStaticSamplers[i], &expected_desc->pStaticSamplers[i]); + check_static_sampler_(file, line, &desc->pStaticSamplers[i], &expected_desc->pStaticSamplers[i]); } - ok_(line)(desc->Flags == expected_desc->Flags, "Got flags %#x, expected %#x.\n", + ok_(file, line)(desc->Flags == expected_desc->Flags, "Got flags %#x, expected %#x.\n", desc->Flags, expected_desc->Flags); } -#define check_root_signature_deserialization(a, b, c) check_root_signature_deserialization_(__LINE__, a, b, c) -static void check_root_signature_deserialization_(unsigned int line, const D3D12_SHADER_BYTECODE *code, - const D3D12_ROOT_SIGNATURE_DESC *expected_desc, const D3D12_ROOT_SIGNATURE_DESC1 *expected_desc1) +#define check_root_signature_deserialization(a, b, c) check_root_signature_deserialization_(__FILE__, __LINE__, a, b, c) +static void check_root_signature_deserialization_(const char *file, unsigned int line, + const D3D12_SHADER_BYTECODE *code, const D3D12_ROOT_SIGNATURE_DESC *expected_desc, + const D3D12_ROOT_SIGNATURE_DESC1 *expected_desc1) { const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *versioned_desc, *versioned_desc2; ID3D12VersionedRootSignatureDeserializer *versioned_deserializer; @@ -12377,46 +12378,49 @@ static void check_root_signature_deserialization_(unsigned int line, const D3D12 hr = D3D12CreateRootSignatureDeserializer(code->pShaderBytecode, code->BytecodeLength, &IID_ID3D12RootSignatureDeserializer, (void **)&deserializer); - ok_(line)(hr == S_OK, "Failed to create deserializer, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to create deserializer, hr %#x.\n", hr); desc = ID3D12RootSignatureDeserializer_GetRootSignatureDesc(deserializer); ok(desc, "Got NULL root signature desc.\n"); - check_root_signature_desc_(line, desc, expected_desc); + check_root_signature_desc_(file, line, desc, expected_desc); refcount = ID3D12RootSignatureDeserializer_Release(deserializer); - ok_(line)(!refcount, "ID3D12RootSignatureDeserializer has %u references left.\n", (unsigned int)refcount); + ok_(file, line)(!refcount, "ID3D12RootSignatureDeserializer has %u references left.\n", (unsigned int)refcount); if (!pfn_D3D12CreateVersionedRootSignatureDeserializer) return; hr = pfn_D3D12CreateVersionedRootSignatureDeserializer(code->pShaderBytecode, code->BytecodeLength, &IID_ID3D12VersionedRootSignatureDeserializer, (void **)&versioned_deserializer); - ok_(line)(hr == S_OK, "Failed to create versioned deserializer, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to create versioned deserializer, hr %#x.\n", hr); versioned_desc = ID3D12VersionedRootSignatureDeserializer_GetUnconvertedRootSignatureDesc(versioned_deserializer); ok(versioned_desc, "Got NULL root signature desc.\n"); ok(versioned_desc->Version == D3D_ROOT_SIGNATURE_VERSION_1_0, "Got unexpected version %#x.\n", versioned_desc->Version); - check_root_signature_desc_(line, &versioned_desc->Desc_1_0, expected_desc); + check_root_signature_desc_(file, line, &versioned_desc->Desc_1_0, expected_desc); hr = ID3D12VersionedRootSignatureDeserializer_GetRootSignatureDescAtVersion(versioned_deserializer, D3D_ROOT_SIGNATURE_VERSION_1_0, &versioned_desc2); - ok_(line)(hr == S_OK, "Failed to get root signature 1.0, hr %#x.\n", hr); - ok_(line)(versioned_desc2 == versioned_desc, "Got unexpected pointer %p.\n", versioned_desc2); + ok_(file, line)(hr == S_OK, "Failed to get root signature 1.0, hr %#x.\n", hr); + ok_(file, line)(versioned_desc2 == versioned_desc, "Got unexpected pointer %p.\n", versioned_desc2); hr = ID3D12VersionedRootSignatureDeserializer_GetRootSignatureDescAtVersion(versioned_deserializer, D3D_ROOT_SIGNATURE_VERSION_1_1, &versioned_desc); - ok_(line)(hr == S_OK, "Failed to get root signature 1.0, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to get root signature 1.0, hr %#x.\n", hr); ok(versioned_desc, "Got NULL root signature desc.\n"); ok(versioned_desc->Version == D3D_ROOT_SIGNATURE_VERSION_1_1, "Got unexpected version %#x.\n", versioned_desc->Version); - check_root_signature_desc1_(line, &versioned_desc->Desc_1_1, expected_desc1, true); + check_root_signature_desc1_(file, line, &versioned_desc->Desc_1_1, expected_desc1, true); refcount = ID3D12VersionedRootSignatureDeserializer_Release(versioned_deserializer); - ok_(line)(!refcount, "ID3D12VersionedRootSignatureDeserializer has %u references left.\n", (unsigned int)refcount); + ok_(file, line)(!refcount, "ID3D12VersionedRootSignatureDeserializer has %u references left.\n", + (unsigned int)refcount); } -#define check_root_signature_deserialization1(a, b, c) check_root_signature_deserialization1_(__LINE__, a, b, c) -static void check_root_signature_deserialization1_(unsigned int line, const D3D12_SHADER_BYTECODE *code, - const D3D12_ROOT_SIGNATURE_DESC *expected_desc, const D3D12_ROOT_SIGNATURE_DESC1 *expected_desc1) +#define check_root_signature_deserialization1(a, b, c) \ + check_root_signature_deserialization1_(__FILE__, __LINE__, a, b, c) +static void check_root_signature_deserialization1_(const char *file, unsigned int line, + const D3D12_SHADER_BYTECODE *code, const D3D12_ROOT_SIGNATURE_DESC *expected_desc, + const D3D12_ROOT_SIGNATURE_DESC1 *expected_desc1) { const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *versioned_desc, *versioned_desc2; ID3D12VersionedRootSignatureDeserializer *versioned_deserializer; @@ -12427,43 +12431,44 @@ static void check_root_signature_deserialization1_(unsigned int line, const D3D1 hr = pfn_D3D12CreateVersionedRootSignatureDeserializer(code->pShaderBytecode, code->BytecodeLength, &IID_ID3D12VersionedRootSignatureDeserializer, (void **)&versioned_deserializer); - ok_(line)(hr == S_OK, "Failed to create deserializer, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to create deserializer, hr %#x.\n", hr); versioned_desc = ID3D12VersionedRootSignatureDeserializer_GetUnconvertedRootSignatureDesc(versioned_deserializer); ok(versioned_desc, "Got NULL root signature desc.\n"); ok(versioned_desc->Version == D3D_ROOT_SIGNATURE_VERSION_1_1, "Got unexpected version %#x.\n", versioned_desc->Version); - check_root_signature_desc1_(line, &versioned_desc->Desc_1_1, expected_desc1, false); + check_root_signature_desc1_(file, line, &versioned_desc->Desc_1_1, expected_desc1, false); hr = ID3D12VersionedRootSignatureDeserializer_GetRootSignatureDescAtVersion(versioned_deserializer, D3D_ROOT_SIGNATURE_VERSION_1_1, &versioned_desc2); - ok_(line)(hr == S_OK, "Failed to get root signature 1.1, hr %#x.\n", hr); - ok_(line)(versioned_desc2 == versioned_desc, "Got unexpected pointer %p.\n", versioned_desc2); + ok_(file, line)(hr == S_OK, "Failed to get root signature 1.1, hr %#x.\n", hr); + ok_(file, line)(versioned_desc2 == versioned_desc, "Got unexpected pointer %p.\n", versioned_desc2); hr = ID3D12VersionedRootSignatureDeserializer_GetRootSignatureDescAtVersion(versioned_deserializer, D3D_ROOT_SIGNATURE_VERSION_1_0, &versioned_desc); - ok_(line)(hr == S_OK, "Failed to get root signature 1.0, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to get root signature 1.0, hr %#x.\n", hr); ok(versioned_desc, "Got NULL root signature desc.\n"); ok(versioned_desc->Version == D3D_ROOT_SIGNATURE_VERSION_1_0, "Got unexpected version %#x.\n", versioned_desc->Version); - check_root_signature_desc_(line, &versioned_desc->Desc_1_0, expected_desc); + check_root_signature_desc_(file, line, &versioned_desc->Desc_1_0, expected_desc); refcount = ID3D12VersionedRootSignatureDeserializer_Release(versioned_deserializer); - ok_(line)(!refcount, "ID3D12VersionedRootSignatureDeserializer has %u references left.\n", (unsigned int)refcount); + ok_(file, line)(!refcount, "ID3D12VersionedRootSignatureDeserializer has %u references left.\n", + (unsigned int)refcount); hr = D3D12CreateRootSignatureDeserializer(code->pShaderBytecode, code->BytecodeLength, &IID_ID3D12RootSignatureDeserializer, (void **)&deserializer); - ok_(line)(hr == S_OK, "Failed to create deserializer, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to create deserializer, hr %#x.\n", hr); desc = ID3D12RootSignatureDeserializer_GetRootSignatureDesc(deserializer); ok(desc, "Got NULL root signature desc.\n"); - check_root_signature_desc_(line, desc, expected_desc); + check_root_signature_desc_(file, line, desc, expected_desc); refcount = ID3D12RootSignatureDeserializer_Release(deserializer); - ok_(line)(!refcount, "ID3D12RootSignatureDeserializer has %u references left.\n", (unsigned int)refcount); + ok_(file, line)(!refcount, "ID3D12RootSignatureDeserializer has %u references left.\n", (unsigned int)refcount); } -#define check_root_signature_serialization(a, b) check_root_signature_serialization_(__LINE__, a, b) -static void check_root_signature_serialization_(unsigned int line, const D3D12_SHADER_BYTECODE *bytecode, - const D3D12_ROOT_SIGNATURE_DESC *desc) +#define check_root_signature_serialization(a, b) check_root_signature_serialization_(__FILE__, __LINE__, a, b) +static void check_root_signature_serialization_(const char *file, unsigned int line, + const D3D12_SHADER_BYTECODE *bytecode, const D3D12_ROOT_SIGNATURE_DESC *desc) { const DWORD *code = bytecode->pShaderBytecode; ID3DBlob *blob, *error_blob; @@ -12477,26 +12482,26 @@ static void check_root_signature_serialization_(unsigned int line, const D3D12_S error_blob = (ID3DBlob *)0xdeadbeef; hr = D3D12SerializeRootSignature(desc, D3D_ROOT_SIGNATURE_VERSION_1_0, &blob, &error_blob); - ok_(line)(hr == S_OK, "Failed to serialize root signature, hr %#x.\n", hr); - ok_(line)(!error_blob, "Got unexpected error blob %p.\n", error_blob); + ok_(file, line)(hr == S_OK, "Failed to serialize root signature, hr %#x.\n", hr); + ok_(file, line)(!error_blob, "Got unexpected error blob %p.\n", error_blob); blob_buffer = ID3D10Blob_GetBufferPointer(blob); blob_size = ID3D10Blob_GetBufferSize(blob); - ok_(line)(blob_size == bytecode->BytecodeLength, "Got size %u, expected %u.\n", + ok_(file, line)(blob_size == bytecode->BytecodeLength, "Got size %u, expected %u.\n", (unsigned int)blob_size, (unsigned int)bytecode->BytecodeLength); for (i = 0; i < bytecode->BytecodeLength / sizeof(*code); ++i) { - ok_(line)(blob_buffer[i] == code[i], "Got dword %#x, expected %#x at %u.\n", + ok_(file, line)(blob_buffer[i] == code[i], "Got dword %#x, expected %#x at %u.\n", (unsigned int)blob_buffer[i], (unsigned int)code[i], i); } ID3D10Blob_Release(blob); } -#define check_root_signature_serialization1(a, b) check_root_signature_serialization1_(__LINE__, a, b) -static void check_root_signature_serialization1_(unsigned int line, const D3D12_SHADER_BYTECODE *bytecode, - const D3D12_ROOT_SIGNATURE_DESC1 *desc) +#define check_root_signature_serialization1(a, b) check_root_signature_serialization1_(__FILE__, __LINE__, a, b) +static void check_root_signature_serialization1_(const char *file, unsigned int line, + const D3D12_SHADER_BYTECODE *bytecode, const D3D12_ROOT_SIGNATURE_DESC1 *desc) { D3D12_VERSIONED_ROOT_SIGNATURE_DESC versioned_desc; const DWORD *code = bytecode->pShaderBytecode; @@ -12511,17 +12516,17 @@ static void check_root_signature_serialization1_(unsigned int line, const D3D12_ error_blob = (ID3DBlob *)0xdeadbeef; hr = pfn_D3D12SerializeVersionedRootSignature(&versioned_desc, &blob, &error_blob); - ok_(line)(hr == S_OK, "Failed to serialize root signature, hr %#x.\n", hr); - ok_(line)(!error_blob, "Got unexpected error blob %p.\n", error_blob); + ok_(file, line)(hr == S_OK, "Failed to serialize root signature, hr %#x.\n", hr); + ok_(file, line)(!error_blob, "Got unexpected error blob %p.\n", error_blob); blob_buffer = ID3D10Blob_GetBufferPointer(blob); blob_size = ID3D10Blob_GetBufferSize(blob); - ok_(line)(blob_size == bytecode->BytecodeLength, "Got size %u, expected %u.\n", + ok_(file, line)(blob_size == bytecode->BytecodeLength, "Got size %u, expected %u.\n", (unsigned int)blob_size, (unsigned int)bytecode->BytecodeLength); for (i = 0; i < bytecode->BytecodeLength / sizeof(*code); ++i) { - ok_(line)(blob_buffer[i] == code[i], "Got dword %#x, expected %#x at %u.\n", + ok_(file, line)(blob_buffer[i] == code[i], "Got dword %#x, expected %#x at %u.\n", (unsigned int)blob_buffer[i], (unsigned int)code[i], i); } @@ -15105,7 +15110,7 @@ static void test_gather_c(void) command_list = context.list; queue = context.queue; - context.root_signature = create_texture_root_signature_(__LINE__, context.device, + context.root_signature = create_texture_root_signature_(__FILE__, __LINE__, context.device, D3D12_SHADER_VISIBILITY_PIXEL, 5, 0, &sampler_desc); heap = create_gpu_descriptor_heap(context.device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 1); @@ -15529,7 +15534,7 @@ static void test_sample_c_lz(void) command_list = context.list; queue = context.queue; - context.root_signature = create_texture_root_signature_(__LINE__, device, + context.root_signature = create_texture_root_signature_(__FILE__, __LINE__, device, D3D12_SHADER_VISIBILITY_PIXEL, 4, 0, &sampler_desc); heap = create_gpu_descriptor_heap(context.device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 6); @@ -20256,8 +20261,8 @@ static void test_null_vbv(void) } #define check_copyable_footprints(a, b, c, d, e, f, g, h) \ - check_copyable_footprints_(__LINE__, a, b, c, d, e, f, g, h) -static void check_copyable_footprints_(unsigned int line, const D3D12_RESOURCE_DESC *desc, + check_copyable_footprints_(__FILE__, __LINE__, a, b, c, d, e, f, g, h) +static void check_copyable_footprints_(const char *file, unsigned int line, const D3D12_RESOURCE_DESC *desc, unsigned int sub_resource_idx, unsigned int sub_resource_count, uint64_t base_offset, const D3D12_PLACED_SUBRESOURCE_FOOTPRINT *layouts, const UINT *row_counts, const uint64_t *row_sizes, uint64_t *total_size) @@ -20295,24 +20300,26 @@ static void check_copyable_footprints_(unsigned int line, const D3D12_RESOURCE_D const D3D12_SUBRESOURCE_FOOTPRINT *f = &l->Footprint; todo_if(format_is_ds && l->Offset != base_offset + offset) - ok_(line)(l->Offset == base_offset + offset, + ok_(file, line)(l->Offset == base_offset + offset, "Got offset %"PRIu64", expected %"PRIu64".\n", l->Offset, base_offset + offset); todo_if(format_is_ds) - ok_(line)(f->Format == expected_format, "Got format %#x, expected %#x.\n", f->Format, expected_format); - ok_(line)(f->Width == width, "Got width %u, expected %u.\n", f->Width, width); - ok_(line)(f->Height == height, "Got height %u, expected %u.\n", f->Height, height); - ok_(line)(f->Depth == depth, "Got depth %u, expected %u.\n", f->Depth, depth); + ok_(file, line)(f->Format == expected_format, "Got format %#x, expected %#x.\n", + f->Format, expected_format); + ok_(file, line)(f->Width == width, "Got width %u, expected %u.\n", f->Width, width); + ok_(file, line)(f->Height == height, "Got height %u, expected %u.\n", f->Height, height); + ok_(file, line)(f->Depth == depth, "Got depth %u, expected %u.\n", f->Depth, depth); todo_if(format_is_ds) - ok_(line)(f->RowPitch == row_pitch, "Got row pitch %u, expected %u.\n", f->RowPitch, row_pitch); + ok_(file, line)(f->RowPitch == row_pitch, "Got row pitch %u, expected %u.\n", f->RowPitch, row_pitch); } if (row_counts) - ok_(line)(row_counts[i] == row_count, "Got row count %u, expected %u.\n", row_counts[i], row_count); + ok_(file, line)(row_counts[i] == row_count, "Got row count %u, expected %u.\n", row_counts[i], row_count); if (row_sizes) { todo_if(format_is_ds && (plane_idx || format_size(desc->Format) > 4)) - ok_(line)(row_sizes[i] == row_size, "Got row size %"PRIu64", expected %u.\n", row_sizes[i], row_size); + ok_(file, line)(row_sizes[i] == row_size, "Got row size %"PRIu64", expected %u.\n", + row_sizes[i], row_size); } size = max(0, row_count - 1) * row_pitch + row_size; @@ -20325,7 +20332,7 @@ static void check_copyable_footprints_(unsigned int line, const D3D12_RESOURCE_D if (total_size) { todo_if(format_is_ds && *total_size != total) - ok_(line)(*total_size == total, "Got total size %"PRIu64", expected %"PRIu64".\n", *total_size, total); + ok_(file, line)(*total_size == total, "Got total size %"PRIu64", expected %"PRIu64".\n", *total_size, total); } } @@ -20771,7 +20778,7 @@ static void test_depth_clip(void) command_list = context.list; queue = context.queue; - context.root_signature = create_32bit_constants_root_signature_(__LINE__, context.device, + context.root_signature = create_32bit_constants_root_signature_(__FILE__, __LINE__, context.device, 0, 4, D3D12_SHADER_VISIBILITY_PIXEL, D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT); init_depth_stencil(&ds, context.device, 32, 32, 1, 1, DXGI_FORMAT_D32_FLOAT, 0, NULL); @@ -20904,11 +20911,10 @@ static void test_depth_clip(void) } #define check_depth_stencil_sampling(a, b, c, d, e, f, g, h) \ - check_depth_stencil_sampling_(__LINE__, a, b, c, d, e, f, g, h) -static void check_depth_stencil_sampling_(unsigned int line, struct test_context *context, - ID3D12PipelineState *pso, ID3D12Resource *cb, ID3D12Resource *texture, - D3D12_CPU_DESCRIPTOR_HANDLE dsv_handle, ID3D12DescriptorHeap *srv_heap, - float expected_value, bool is_bug) + check_depth_stencil_sampling_(__FILE__, __LINE__, a, b, c, d, e, f, g, h) +static void check_depth_stencil_sampling_(const char *file, unsigned int line, + struct test_context *context, ID3D12PipelineState *pso, ID3D12Resource *cb, ID3D12Resource *texture, + D3D12_CPU_DESCRIPTOR_HANDLE dsv_handle, ID3D12DescriptorHeap *srv_heap, float expected_value, bool is_bug) { static const float black[] = {0.0f, 0.0f, 0.0f, 0.0f}; ID3D12GraphicsCommandList *command_list; @@ -20940,7 +20946,7 @@ static void check_depth_stencil_sampling_(unsigned int line, struct test_context transition_sub_resource_state(command_list, context->render_target, 0, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); bug_if(is_bug) - check_sub_resource_float_(line, context->render_target, 0, queue, command_list, expected_value, 2); + check_sub_resource_float_(file, line, context->render_target, 0, queue, command_list, expected_value, 2); reset_command_list(command_list, context->allocator); transition_sub_resource_state(command_list, context->render_target, 0, @@ -20948,7 +20954,7 @@ static void check_depth_stencil_sampling_(unsigned int line, struct test_context transition_sub_resource_state(command_list, texture, 0, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_DEPTH_WRITE); hr = ID3D12GraphicsCommandList_Close(command_list); - ok_(line)(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr); exec_command_list(queue, command_list); wait_queue_idle(context->device, queue); } @@ -29048,8 +29054,8 @@ struct triangle struct vec4 v[3]; }; -#define check_triangles(a, b, c) check_triangles_(__LINE__, a, b, c) -static void check_triangles_(unsigned int line, struct resource_readback *rb, +#define check_triangles(a, b, c) check_triangles_(__FILE__, __LINE__, a, b, c) +static void check_triangles_(const char *file, unsigned int line, struct resource_readback *rb, const struct triangle *triangles, unsigned int triangle_count) { const struct triangle *current, *expected; @@ -29089,7 +29095,7 @@ static void check_triangles_(unsigned int line, struct resource_readback *rb, break; } - ok_(line)(all_match, "Triangle %u vertices {%.8e, %.8e, %.8e, %.8e}, " + ok_(file, line)(all_match, "Triangle %u vertices {%.8e, %.8e, %.8e, %.8e}, " "{%.8e, %.8e, %.8e, %.8e}, {%.8e, %.8e, %.8e, %.8e} " "do not match {%.8e, %.8e, %.8e, %.8e}, {%.8e, %.8e, %.8e, %.8e}, " "{%.8e, %.8e, %.8e, %.8e}.\n", i, @@ -29342,7 +29348,7 @@ static void test_quad_tessellation(void) } ok(hr == S_OK, "Failed to create query heap, hr %#x.\n", hr); - context.root_signature = create_32bit_constants_root_signature_(__LINE__, + context.root_signature = create_32bit_constants_root_signature_(__FILE__, __LINE__, device, 0, 6, D3D12_SHADER_VISIBILITY_HULL, D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT); diff --git a/tests/d3d12_crosstest.h b/tests/d3d12_crosstest.h index 8e168313..e82bb06a 100644 --- a/tests/d3d12_crosstest.h +++ b/tests/d3d12_crosstest.h @@ -241,19 +241,19 @@ static HRESULT wait_for_fence(ID3D12Fence *fence, uint64_t value) return ret == WAIT_OBJECT_0 ? S_OK : E_FAIL; } -static void wait_queue_idle_(unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue) +static void wait_queue_idle_(const char *file, unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue) { ID3D12Fence *fence; HRESULT hr; hr = ID3D12Device_CreateFence(device, 0, D3D12_FENCE_FLAG_NONE, &IID_ID3D12Fence, (void **)&fence); - assert_that_(line)(hr == S_OK, "Failed to create fence, hr %#x.\n", hr); + assert_that_(file, line)(hr == S_OK, "Failed to create fence, hr %#x.\n", hr); hr = ID3D12CommandQueue_Signal(queue, fence, 1); - assert_that_(line)(hr == S_OK, "Failed to signal fence, hr %#x.\n", hr); + assert_that_(file, line)(hr == S_OK, "Failed to signal fence, hr %#x.\n", hr); hr = wait_for_fence(fence, 1); - assert_that_(line)(hr == S_OK, "Failed to wait for fence, hr %#x.\n", hr); + assert_that_(file, line)(hr == S_OK, "Failed to wait for fence, hr %#x.\n", hr); ID3D12Fence_Release(fence); } diff --git a/tests/d3d12_invalid_usage.c b/tests/d3d12_invalid_usage.c index 3e95d527..6ccd372c 100644 --- a/tests/d3d12_invalid_usage.c +++ b/tests/d3d12_invalid_usage.c @@ -22,18 +22,18 @@ VKD3D_AGILITY_SDK_EXPORTS struct test_options test_options = {0}; -#define recreate_command_list(a, b, c) recreate_command_list_(__LINE__, a, b, c) -static void recreate_command_list_(unsigned int line, ID3D12Device *device, +#define recreate_command_list(a, b, c) recreate_command_list_(__FILE__, __LINE__, a, b, c) +static void recreate_command_list_(const char *file, unsigned int line, ID3D12Device *device, ID3D12CommandAllocator *allocator, ID3D12GraphicsCommandList **command_list) { HRESULT hr; hr = ID3D12CommandAllocator_Reset(allocator); - ok_(line)(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr); ID3D12GraphicsCommandList_Release(*command_list); hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)command_list); - ok_(line)(hr == S_OK, "Failed to create command list, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to create command list, hr %#x.\n", hr); } static void test_invalid_resource_barriers(void) diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h index fb6857e6..bef922ad 100644 --- a/tests/d3d12_test_utils.h +++ b/tests/d3d12_test_utils.h @@ -129,8 +129,8 @@ struct d3d12_view_instancing_subobject D3D12_VIEW_INSTANCING_DESC view_instancing_desc; }; -#define wait_queue_idle(a, b) wait_queue_idle_(__LINE__, a, b) -static void wait_queue_idle_(unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue); +#define wait_queue_idle(a, b) wait_queue_idle_(__FILE__, __LINE__, a, b) +static void wait_queue_idle_(const char *file, unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue); static ID3D12Device *create_device(void); static inline HRESULT wait_for_fence_no_event(ID3D12Fence *fence, uint64_t value) @@ -142,20 +142,21 @@ static inline HRESULT wait_for_fence_no_event(ID3D12Fence *fence, uint64_t value return ID3D12Fence_SetEventOnCompletion(fence, value, NULL); } -#define wait_queue_idle_no_event(a, b) wait_queue_idle_no_event_(__LINE__, a, b) -static inline void wait_queue_idle_no_event_(unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue) +#define wait_queue_idle_no_event(a, b) wait_queue_idle_no_event_(__FILE__, __LINE__, a, b) +static inline void wait_queue_idle_no_event_(const char *file, + unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue) { ID3D12Fence *fence; HRESULT hr; hr = ID3D12Device_CreateFence(device, 0, D3D12_FENCE_FLAG_NONE, - &IID_ID3D12Fence, (void **)&fence); - assert_that_(line)(hr == S_OK, "Failed to create fence, hr %#x.\n", hr); + &IID_ID3D12Fence, (void **)&fence); + assert_that_(file, line)(hr == S_OK, "Failed to create fence, hr %#x.\n", hr); hr = ID3D12CommandQueue_Signal(queue, fence, 1); - assert_that_(line)(hr == S_OK, "Failed to signal fence, hr %#x.\n", hr); + assert_that_(file, line)(hr == S_OK, "Failed to signal fence, hr %#x.\n", hr); hr = wait_for_fence_no_event(fence, 1); - assert_that_(line)(hr == S_OK, "Failed to wait for fence, hr %#x.\n", hr); + assert_that_(file, line)(hr == S_OK, "Failed to wait for fence, hr %#x.\n", hr); ID3D12Fence_Release(fence); } @@ -199,38 +200,40 @@ static void exec_command_list(ID3D12CommandQueue *queue, ID3D12GraphicsCommandLi ID3D12CommandQueue_ExecuteCommandLists(queue, 1, lists); } -#define reset_command_list(a, b) reset_command_list_(__LINE__, a, b) -static inline void reset_command_list_(unsigned int line, +#define reset_command_list(a, b) reset_command_list_(__FILE__, __LINE__, a, b) +static inline void reset_command_list_(const char *file, unsigned int line, ID3D12GraphicsCommandList *list, ID3D12CommandAllocator *allocator) { HRESULT hr; hr = ID3D12CommandAllocator_Reset(allocator); - assert_that_(line)(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr); + assert_that_(file, line)(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr); hr = ID3D12GraphicsCommandList_Reset(list, allocator, NULL); - assert_that_(line)(hr == S_OK, "Failed to reset command list, hr %#x.\n", hr); + assert_that_(file, line)(hr == S_OK, "Failed to reset command list, hr %#x.\n", hr); } -#define queue_signal(a, b, c) queue_signal_(__LINE__, a, b, c) -static inline void queue_signal_(unsigned int line, ID3D12CommandQueue *queue, ID3D12Fence *fence, uint64_t value) +#define queue_signal(a, b, c) queue_signal_(__FILE__, __LINE__, a, b, c) +static inline void queue_signal_(const char *file, unsigned int line, + ID3D12CommandQueue *queue, ID3D12Fence *fence, uint64_t value) { HRESULT hr; hr = ID3D12CommandQueue_Signal(queue, fence, value); - ok_(line)(hr == S_OK, "Failed to submit signal operation to queue, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to submit signal operation to queue, hr %#x.\n", hr); } -#define queue_wait(a, b, c) queue_wait_(__LINE__, a, b, c) -static inline void queue_wait_(unsigned int line, ID3D12CommandQueue *queue, ID3D12Fence *fence, uint64_t value) +#define queue_wait(a, b, c) queue_wait_(__FILE__, __LINE__, a, b, c) +static inline void queue_wait_(const char *file, unsigned int line, + ID3D12CommandQueue *queue, ID3D12Fence *fence, uint64_t value) { HRESULT hr; hr = ID3D12CommandQueue_Wait(queue, fence, value); - ok_(line)(hr == S_OK, "Failed to submit wait operation to queue, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to submit wait operation to queue, hr %#x.\n", hr); } -#define create_placed_buffer(a, b, c, d, e, f) create_placed_buffer_(__LINE__, a, b, c, d, e, f) -static inline ID3D12Resource *create_placed_buffer_(unsigned int line, ID3D12Device *device, +#define create_placed_buffer(a, b, c, d, e, f) create_placed_buffer_(__FILE__, __LINE__, a, b, c, d, e, f) +static inline ID3D12Resource *create_placed_buffer_(const char *file, unsigned int line, ID3D12Device *device, ID3D12Heap *heap, size_t offset, size_t size, D3D12_RESOURCE_FLAGS resource_flags, D3D12_RESOURCE_STATES initial_resource_state) { @@ -252,12 +255,12 @@ static inline ID3D12Resource *create_placed_buffer_(unsigned int line, ID3D12Dev hr = ID3D12Device_CreatePlacedResource(device, heap, offset, &resource_desc, initial_resource_state, NULL, &IID_ID3D12Resource, (void **)&buffer); - assert_that_(line)(SUCCEEDED(hr), "Failed to create buffer, hr %#x.\n", hr); + assert_that_(file, line)(SUCCEEDED(hr), "Failed to create buffer, hr %#x.\n", hr); return buffer; } -#define create_buffer(a, b, c, d, e) create_buffer_(__LINE__, a, b, c, d, e) -static ID3D12Resource *create_buffer_(unsigned int line, ID3D12Device *device, +#define create_buffer(a, b, c, d, e) create_buffer_(__FILE__, __LINE__, a, b, c, d, e) +static ID3D12Resource *create_buffer_(const char *file, unsigned int line, ID3D12Device *device, D3D12_HEAP_TYPE heap_type, size_t size, D3D12_RESOURCE_FLAGS resource_flags, D3D12_RESOURCE_STATES initial_resource_state) { @@ -284,20 +287,20 @@ static ID3D12Resource *create_buffer_(unsigned int line, ID3D12Device *device, hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, initial_resource_state, NULL, &IID_ID3D12Resource, (void **)&buffer); - assert_that_(line)(SUCCEEDED(hr), "Failed to create buffer, hr %#x.\n", hr); + assert_that_(file, line)(SUCCEEDED(hr), "Failed to create buffer, hr %#x.\n", hr); return buffer; } -#define create_readback_buffer(a, b) create_readback_buffer_(__LINE__, a, b) -static ID3D12Resource *create_readback_buffer_(unsigned int line, ID3D12Device *device, +#define create_readback_buffer(a, b) create_readback_buffer_(__FILE__, __LINE__, a, b) +static ID3D12Resource *create_readback_buffer_(const char *file, unsigned int line, ID3D12Device *device, size_t size) { - return create_buffer_(line, device, D3D12_HEAP_TYPE_READBACK, size, + return create_buffer_(file, line, device, D3D12_HEAP_TYPE_READBACK, size, D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_DEST); } -#define update_buffer_data(a, b, c, d) update_buffer_data_(__LINE__, a, b, c, d) -static inline void update_buffer_data_(unsigned int line, ID3D12Resource *buffer, +#define update_buffer_data(a, b, c, d) update_buffer_data_(__FILE__, __LINE__, a, b, c, d) +static inline void update_buffer_data_(const char *file, unsigned int line, ID3D12Resource *buffer, size_t offset, size_t size, const void *data) { D3D12_RANGE range; @@ -306,27 +309,27 @@ static inline void update_buffer_data_(unsigned int line, ID3D12Resource *buffer range.Begin = range.End = 0; hr = ID3D12Resource_Map(buffer, 0, &range, &ptr); - ok_(line)(hr == S_OK, "Failed to map buffer, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to map buffer, hr %#x.\n", hr); memcpy((BYTE *)ptr + offset, data, size); ID3D12Resource_Unmap(buffer, 0, NULL); } -#define create_upload_buffer(a, b, c) create_upload_buffer_(__LINE__, a, b, c) -static inline ID3D12Resource *create_upload_buffer_(unsigned int line, ID3D12Device *device, +#define create_upload_buffer(a, b, c) create_upload_buffer_(__FILE__, __LINE__, a, b, c) +static inline ID3D12Resource *create_upload_buffer_(const char *file, unsigned int line, ID3D12Device *device, size_t size, const void *data) { ID3D12Resource *buffer; - buffer = create_buffer_(line, device, D3D12_HEAP_TYPE_UPLOAD, size, + buffer = create_buffer_(file, line, device, D3D12_HEAP_TYPE_UPLOAD, size, D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_GENERIC_READ); if (data) - update_buffer_data_(line, buffer, 0, size, data); + update_buffer_data_(file, line, buffer, 0, size, data); return buffer; } -#define create_cpu_descriptor_heap(a, b, c) create_cpu_descriptor_heap_(__LINE__, a, b, c) -static inline ID3D12DescriptorHeap *create_cpu_descriptor_heap_(unsigned int line, ID3D12Device *device, - D3D12_DESCRIPTOR_HEAP_TYPE heap_type, unsigned int descriptor_count) +#define create_cpu_descriptor_heap(a, b, c) create_cpu_descriptor_heap_(__FILE__, __LINE__, a, b, c) +static inline ID3D12DescriptorHeap *create_cpu_descriptor_heap_(const char *file, unsigned int line, + ID3D12Device *device, D3D12_DESCRIPTOR_HEAP_TYPE heap_type, unsigned int descriptor_count) { D3D12_DESCRIPTOR_HEAP_DESC heap_desc; ID3D12DescriptorHeap *descriptor_heap; @@ -338,14 +341,14 @@ static inline ID3D12DescriptorHeap *create_cpu_descriptor_heap_(unsigned int lin heap_desc.NodeMask = 0; hr = ID3D12Device_CreateDescriptorHeap(device, &heap_desc, &IID_ID3D12DescriptorHeap, (void **)&descriptor_heap); - ok_(line)(SUCCEEDED(hr), "Failed to create descriptor heap, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create descriptor heap, hr %#x.\n", hr); return descriptor_heap; } -#define create_gpu_descriptor_heap(a, b, c) create_gpu_descriptor_heap_(__LINE__, a, b, c) -static inline ID3D12DescriptorHeap *create_gpu_descriptor_heap_(unsigned int line, ID3D12Device *device, - D3D12_DESCRIPTOR_HEAP_TYPE heap_type, unsigned int descriptor_count) +#define create_gpu_descriptor_heap(a, b, c) create_gpu_descriptor_heap_(__FILE__, __LINE__, a, b, c) +static inline ID3D12DescriptorHeap *create_gpu_descriptor_heap_(const char *file, unsigned int line, + ID3D12Device *device, D3D12_DESCRIPTOR_HEAP_TYPE heap_type, unsigned int descriptor_count) { D3D12_DESCRIPTOR_HEAP_DESC heap_desc; ID3D12DescriptorHeap *descriptor_heap; @@ -357,7 +360,7 @@ static inline ID3D12DescriptorHeap *create_gpu_descriptor_heap_(unsigned int lin heap_desc.NodeMask = 0; hr = ID3D12Device_CreateDescriptorHeap(device, &heap_desc, &IID_ID3D12DescriptorHeap, (void **)&descriptor_heap); - ok_(line)(SUCCEEDED(hr), "Failed to create descriptor heap, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create descriptor heap, hr %#x.\n", hr); return descriptor_heap; } @@ -388,8 +391,8 @@ static inline void uav_barrier(ID3D12GraphicsCommandList *list, ID3D12Resource * ID3D12GraphicsCommandList_ResourceBarrier(list, 1, &barrier); } -#define create_command_queue(a, b, c) create_command_queue_(__LINE__, a, b, c) -static inline ID3D12CommandQueue *create_command_queue_(unsigned int line, ID3D12Device *device, +#define create_command_queue(a, b, c) create_command_queue_(__FILE__, __LINE__, a, b, c) +static inline ID3D12CommandQueue *create_command_queue_(const char *file, unsigned int line, ID3D12Device *device, D3D12_COMMAND_LIST_TYPE type, int priority) { D3D12_COMMAND_QUEUE_DESC queue_desc; @@ -401,7 +404,7 @@ static inline ID3D12CommandQueue *create_command_queue_(unsigned int line, ID3D1 queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queue_desc.NodeMask = 0; hr = ID3D12Device_CreateCommandQueue(device, &queue_desc, &IID_ID3D12CommandQueue, (void **)&queue); - ok_(line)(hr == S_OK, "Failed to create command queue, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to create command queue, hr %#x.\n", hr); return queue; } @@ -689,51 +692,52 @@ static void release_resource_readback(struct d3d12_resource_readback *rb) ID3D12Resource_Release(rb->resource); } -#define check_sub_resource_uint(a, b, c, d, e, f) check_sub_resource_uint_(__LINE__, a, b, c, d, e, f) -static inline void check_sub_resource_uint_(unsigned int line, ID3D12Resource *texture, +#define check_sub_resource_uint(a, b, c, d, e, f) check_sub_resource_uint_(__FILE__, __LINE__, a, b, c, d, e, f) +static inline void check_sub_resource_uint_(const char *file, unsigned int line, ID3D12Resource *texture, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, unsigned int expected, unsigned int max_diff) { struct d3d12_resource_readback rb; get_resource_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list); - check_readback_data_uint_(line, &rb.rb, NULL, expected, max_diff); + check_readback_data_uint_(file, line, &rb.rb, NULL, expected, max_diff); release_resource_readback(&rb); } -#define check_sub_resource_uint_with_box(a, b, c, d, e, f, g) check_sub_resource_uint_with_box_(__LINE__, a, b, c, d, e, f, g) -static inline void check_sub_resource_uint_with_box_(unsigned int line, ID3D12Resource *texture, +#define check_sub_resource_uint_with_box(a, b, c, d, e, f, g) \ + check_sub_resource_uint_with_box_(__FILE__, __LINE__, a, b, c, d, e, f, g) +static inline void check_sub_resource_uint_with_box_(const char *file, unsigned int line, ID3D12Resource *texture, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, const D3D12_BOX *box, unsigned int expected, unsigned int max_diff) { struct d3d12_resource_readback rb; get_resource_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list); - check_readback_data_uint_(line, &rb.rb, box, expected, max_diff); + check_readback_data_uint_(file, line, &rb.rb, box, expected, max_diff); release_resource_readback(&rb); } -#define check_sub_resource_vec4(a, b, c, d, e, f) check_sub_resource_vec4_(__LINE__, a, b, c, d, e, f) -static inline void check_sub_resource_vec4_(unsigned int line, ID3D12Resource *texture, +#define check_sub_resource_vec4(a, b, c, d, e, f) check_sub_resource_vec4_(__FILE__, __LINE__, a, b, c, d, e, f) +static inline void check_sub_resource_vec4_(const char *file, unsigned int line, ID3D12Resource *texture, unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, const struct vec4 *expected, unsigned int max_diff) { struct d3d12_resource_readback rb; get_resource_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list); - check_readback_data_vec_(line, &rb.rb, NULL, expected, max_diff, 4); + check_readback_data_vec_(file, line, &rb.rb, NULL, expected, max_diff, 4); release_resource_readback(&rb); } -#define create_default_buffer(a, b, c, d) create_default_buffer_(__LINE__, a, b, c, d) -static inline ID3D12Resource *create_default_buffer_(unsigned int line, ID3D12Device *device, +#define create_default_buffer(a, b, c, d) create_default_buffer_(__FILE__, __LINE__, a, b, c, d) +static inline ID3D12Resource *create_default_buffer_(const char *file, unsigned int line, ID3D12Device *device, size_t size, D3D12_RESOURCE_FLAGS resource_flags, D3D12_RESOURCE_STATES initial_resource_state) { - return create_buffer_(line, device, D3D12_HEAP_TYPE_DEFAULT, size, + return create_buffer_(file, line, device, D3D12_HEAP_TYPE_DEFAULT, size, resource_flags, initial_resource_state); } -static ID3D12Resource *create_default_texture_(unsigned int line, ID3D12Device *device, +static ID3D12Resource *create_default_texture_(const char *file, unsigned int line, ID3D12Device *device, D3D12_RESOURCE_DIMENSION dimension, unsigned int width, unsigned int height, unsigned int depth_or_array_size, unsigned int miplevel_count, unsigned int sample_count, DXGI_FORMAT format, D3D12_RESOURCE_FLAGS flags, D3D12_RESOURCE_STATES initial_state) @@ -759,27 +763,29 @@ static ID3D12Resource *create_default_texture_(unsigned int line, ID3D12Device * resource_desc.Flags = flags; hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, initial_state, NULL, &IID_ID3D12Resource, (void **)&texture); - ok_(line)(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); return texture; } -#define create_default_texture(a, b, c, d, e, f) create_default_texture2d_(__LINE__, a, b, c, 1, 1, d, e, f) -#define create_default_texture2d(a, b, c, d, e, f, g, h) create_default_texture2d_(__LINE__, a, b, c, d, e, f, g, h) -static inline ID3D12Resource *create_default_texture2d_(unsigned int line, ID3D12Device *device, +#define create_default_texture(a, b, c, d, e, f) create_default_texture2d_(__FILE__, __LINE__, a, b, c, 1, 1, d, e, f) +#define create_default_texture2d(a, b, c, d, e, f, g, h) \ + create_default_texture2d_(__FILE__, __LINE__, a, b, c, d, e, f, g, h) +static inline ID3D12Resource *create_default_texture2d_(const char *file, unsigned int line, ID3D12Device *device, unsigned int width, unsigned int height, unsigned int array_size, unsigned int miplevel_count, DXGI_FORMAT format, D3D12_RESOURCE_FLAGS flags, D3D12_RESOURCE_STATES initial_state) { - return create_default_texture_(line, device, D3D12_RESOURCE_DIMENSION_TEXTURE2D, + return create_default_texture_(file, line, device, D3D12_RESOURCE_DIMENSION_TEXTURE2D, width, height, array_size, miplevel_count, 1, format, flags, initial_state); } -#define create_default_texture3d(a, b, c, d, e, f, g, h) create_default_texture3d_(__LINE__, a, b, c, d, e, f, g, h) -static inline ID3D12Resource *create_default_texture3d_(unsigned int line, ID3D12Device *device, +#define create_default_texture3d(a, b, c, d, e, f, g, h) \ + create_default_texture3d_(__FILE__, __LINE__, a, b, c, d, e, f, g, h) +static inline ID3D12Resource *create_default_texture3d_(const char *file, unsigned int line, ID3D12Device *device, unsigned int width, unsigned int height, unsigned int depth, unsigned int miplevel_count, DXGI_FORMAT format, D3D12_RESOURCE_FLAGS flags, D3D12_RESOURCE_STATES initial_state) { - return create_default_texture_(line, device, D3D12_RESOURCE_DIMENSION_TEXTURE3D, + return create_default_texture_(file, line, device, D3D12_RESOURCE_DIMENSION_TEXTURE3D, width, height, depth, miplevel_count, 1, format, flags, initial_state); } @@ -799,9 +805,10 @@ static void copy_sub_resource_data(const D3D12_MEMCPY_DEST *dst, const D3D12_SUB } } -#define upload_texture_data_with_states(a, b, c, d, e, f, g) upload_texture_data_with_states_(__LINE__, a, b, c, d, e, f, g) -static inline void upload_texture_data_with_states_(unsigned int line, ID3D12Resource *texture, - const D3D12_SUBRESOURCE_DATA *data, unsigned int sub_resource_count, +#define upload_texture_data_with_states(a, b, c, d, e, f, g) \ + upload_texture_data_with_states_(__FILE__, __LINE__, a, b, c, d, e, f, g) +static inline void upload_texture_data_with_states_(const char *file, unsigned int line, + ID3D12Resource *texture, const D3D12_SUBRESOURCE_DATA *data, unsigned int sub_resource_count, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, D3D12_RESOURCE_STATES initial_state, D3D12_RESOURCE_STATES final_state) { @@ -826,15 +833,15 @@ static inline void upload_texture_data_with_states_(unsigned int line, ID3D12Res resource_desc = ID3D12Resource_GetDesc(texture); hr = ID3D12Resource_GetDevice(texture, &IID_ID3D12Device, (void **)&device); - ok_(line)(SUCCEEDED(hr), "Failed to get device, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to get device, hr %#x.\n", hr); ID3D12Device_GetCopyableFootprints(device, &resource_desc, 0, sub_resource_count, 0, layouts, row_counts, row_sizes, &required_size); - upload_buffer = create_upload_buffer_(line, device, required_size, NULL); + upload_buffer = create_upload_buffer_(file, line, device, required_size, NULL); hr = ID3D12Resource_Map(upload_buffer, 0, NULL, (void **)&ptr); - ok_(line)(SUCCEEDED(hr), "Failed to map upload buffer, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to map upload buffer, hr %#x.\n", hr); for (i = 0; i < sub_resource_count; ++i) { dst_data.pData = (BYTE *)ptr + layouts[i].Offset; @@ -879,7 +886,7 @@ static inline void upload_texture_data_with_states_(unsigned int line, ID3D12Res } hr = ID3D12GraphicsCommandList_Close(command_list); - ok_(line)(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr); exec_command_list(queue, command_list); wait_queue_idle(device, queue); @@ -892,18 +899,20 @@ static inline void upload_texture_data_with_states_(unsigned int line, ID3D12Res free(row_sizes); } -#define upload_texture_data(a, b, c, d, e) upload_texture_data_(__LINE__, a, b, c, d, e) -static inline void upload_texture_data_(unsigned int line, ID3D12Resource *texture, +#define upload_texture_data(a, b, c, d, e) upload_texture_data_(__FILE__, __LINE__, a, b, c, d, e) +static inline void upload_texture_data_(const char *file, unsigned int line, ID3D12Resource *texture, const D3D12_SUBRESOURCE_DATA *data, unsigned int sub_resource_count, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list) { - return upload_texture_data_with_states_(line, texture, data, sub_resource_count, queue, command_list, + return upload_texture_data_with_states_(file, line, texture, data, sub_resource_count, queue, command_list, RESOURCE_STATE_DO_NOT_CHANGE, RESOURCE_STATE_DO_NOT_CHANGE); } -#define upload_buffer_data_with_states(a, b, c, d, e, f, g, h) upload_buffer_data_with_states_(__LINE__, a, b, c, d, e, f, g, h) -static inline void upload_buffer_data_with_states_(unsigned int line, ID3D12Resource *buffer, size_t offset, - size_t size, const void *data, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, +#define upload_buffer_data_with_states(a, b, c, d, e, f, g, h) \ + upload_buffer_data_with_states_(__FILE__, __LINE__, a, b, c, d, e, f, g, h) +static inline void upload_buffer_data_with_states_(const char *file, unsigned int line, + ID3D12Resource *buffer, size_t offset, size_t size, const void *data, + ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list, D3D12_RESOURCE_STATES initial_state, D3D12_RESOURCE_STATES final_state) { ID3D12Resource *upload_buffer; @@ -911,9 +920,9 @@ static inline void upload_buffer_data_with_states_(unsigned int line, ID3D12Reso HRESULT hr; hr = ID3D12Resource_GetDevice(buffer, &IID_ID3D12Device, (void **)&device); - ok_(line)(SUCCEEDED(hr), "Failed to get device, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to get device, hr %#x.\n", hr); - upload_buffer = create_upload_buffer_(line, device, size, data); + upload_buffer = create_upload_buffer_(file, line, device, size, data); if (initial_state != RESOURCE_STATE_DO_NOT_CHANGE) transition_resource_state(command_list, buffer, initial_state, D3D12_RESOURCE_STATE_COPY_DEST); @@ -925,7 +934,7 @@ static inline void upload_buffer_data_with_states_(unsigned int line, ID3D12Reso transition_resource_state(command_list, buffer, D3D12_RESOURCE_STATE_COPY_DEST, final_state); hr = ID3D12GraphicsCommandList_Close(command_list); - ok_(line)(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr); exec_command_list(queue, command_list); wait_queue_idle(device, queue); @@ -933,11 +942,11 @@ static inline void upload_buffer_data_with_states_(unsigned int line, ID3D12Reso ID3D12Device_Release(device); } -#define upload_buffer_data(a, b, c, d, e, f) upload_buffer_data_(__LINE__, a, b, c, d, e, f) -static inline void upload_buffer_data_(unsigned int line, ID3D12Resource *buffer, size_t offset, +#define upload_buffer_data(a, b, c, d, e, f) upload_buffer_data_(__FILE__, __LINE__, a, b, c, d, e, f) +static inline void upload_buffer_data_(const char *file, unsigned int line, ID3D12Resource *buffer, size_t offset, size_t size, const void *data, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list) { - return upload_buffer_data_with_states_(line, buffer, offset, size, data, queue, command_list, + return upload_buffer_data_with_states_(file, line, buffer, offset, size, data, queue, command_list, RESOURCE_STATE_DO_NOT_CHANGE, RESOURCE_STATE_DO_NOT_CHANGE); } @@ -956,9 +965,9 @@ static HRESULT create_root_signature(ID3D12Device *device, const D3D12_ROOT_SIGN return hr; } -#define create_empty_root_signature(device, flags) create_empty_root_signature_(__LINE__, device, flags) -static ID3D12RootSignature *create_empty_root_signature_(unsigned int line, - ID3D12Device *device, D3D12_ROOT_SIGNATURE_FLAGS flags) +#define create_empty_root_signature(device, flags) create_empty_root_signature_(__FILE__, __LINE__, device, flags) +static ID3D12RootSignature *create_empty_root_signature_(const char *file, + unsigned int line, ID3D12Device *device, D3D12_ROOT_SIGNATURE_FLAGS flags) { D3D12_ROOT_SIGNATURE_DESC root_signature_desc; ID3D12RootSignature *root_signature = NULL; @@ -970,15 +979,15 @@ static ID3D12RootSignature *create_empty_root_signature_(unsigned int line, root_signature_desc.pStaticSamplers = NULL; root_signature_desc.Flags = flags; hr = create_root_signature(device, &root_signature_desc, &root_signature); - ok_(line)(SUCCEEDED(hr), "Failed to create root signature, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create root signature, hr %#x.\n", hr); return root_signature; } #define create_32bit_constants_root_signature(a, b, c, e) \ - create_32bit_constants_root_signature_(__LINE__, a, b, c, e, 0) -static inline ID3D12RootSignature *create_32bit_constants_root_signature_(unsigned int line, - ID3D12Device *device, unsigned int reg_idx, unsigned int element_count, + create_32bit_constants_root_signature_(__FILE__, __LINE__, a, b, c, e, 0) +static inline ID3D12RootSignature *create_32bit_constants_root_signature_(const char *file, + unsigned int line, ID3D12Device *device, unsigned int reg_idx, unsigned int element_count, D3D12_SHADER_VISIBILITY shader_visibility, D3D12_ROOT_SIGNATURE_FLAGS flags) { D3D12_ROOT_SIGNATURE_DESC root_signature_desc; @@ -997,7 +1006,7 @@ static inline ID3D12RootSignature *create_32bit_constants_root_signature_(unsign root_signature_desc.pParameters = &root_parameter; root_signature_desc.Flags = flags; hr = create_root_signature(device, &root_signature_desc, &root_signature); - ok_(line)(SUCCEEDED(hr), "Failed to create root signature, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create root signature, hr %#x.\n", hr); return root_signature; } @@ -1073,11 +1082,10 @@ static void init_pipeline_state_desc(D3D12_GRAPHICS_PIPELINE_STATE_DESC *desc, desc->SampleDesc.Count = 1; } -#define create_pipeline_state(a, b, c, d, e, f) create_pipeline_state_(__LINE__, a, b, c, d, e, f) -static ID3D12PipelineState *create_pipeline_state_(unsigned int line, ID3D12Device *device, - ID3D12RootSignature *root_signature, DXGI_FORMAT rt_format, - const D3D12_SHADER_BYTECODE *vs, const D3D12_SHADER_BYTECODE *ps, - const D3D12_INPUT_LAYOUT_DESC *input_layout) +#define create_pipeline_state(a, b, c, d, e, f) create_pipeline_state_(__FILE__, __LINE__, a, b, c, d, e, f) +static ID3D12PipelineState *create_pipeline_state_(const char *file, unsigned int line, ID3D12Device *device, + ID3D12RootSignature *root_signature, DXGI_FORMAT rt_format, const D3D12_SHADER_BYTECODE *vs, + const D3D12_SHADER_BYTECODE *ps, const D3D12_INPUT_LAYOUT_DESC *input_layout) { D3D12_GRAPHICS_PIPELINE_STATE_DESC pipeline_state_desc; ID3D12PipelineState *pipeline_state = NULL; @@ -1086,14 +1094,14 @@ static ID3D12PipelineState *create_pipeline_state_(unsigned int line, ID3D12Devi init_pipeline_state_desc(&pipeline_state_desc, root_signature, rt_format, vs, ps, input_layout); hr = ID3D12Device_CreateGraphicsPipelineState(device, &pipeline_state_desc, &IID_ID3D12PipelineState, (void **)&pipeline_state); - ok_(line)(SUCCEEDED(hr), "Failed to create graphics pipeline state, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create graphics pipeline state, hr %#x.\n", hr); return SUCCEEDED(hr) ? pipeline_state : NULL; } -#define create_compute_pipeline_state(a, b, c) create_compute_pipeline_state_(__LINE__, a, b, c) -static inline ID3D12PipelineState *create_compute_pipeline_state_(unsigned int line, ID3D12Device *device, - ID3D12RootSignature *root_signature, const D3D12_SHADER_BYTECODE cs) +#define create_compute_pipeline_state(a, b, c) create_compute_pipeline_state_(__FILE__, __LINE__, a, b, c) +static inline ID3D12PipelineState *create_compute_pipeline_state_(const char *file, unsigned int line, + ID3D12Device *device, ID3D12RootSignature *root_signature, const D3D12_SHADER_BYTECODE cs) { D3D12_COMPUTE_PIPELINE_STATE_DESC pipeline_state_desc; ID3D12PipelineState *pipeline_state = NULL; @@ -1106,7 +1114,7 @@ static inline ID3D12PipelineState *create_compute_pipeline_state_(unsigned int l pipeline_state_desc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE; hr = ID3D12Device_CreateComputePipelineState(device, &pipeline_state_desc, &IID_ID3D12PipelineState, (void **)&pipeline_state); - ok_(line)(SUCCEEDED(hr), "Failed to create compute pipeline state, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create compute pipeline state, hr %#x.\n", hr); return pipeline_state; } @@ -1151,9 +1159,9 @@ struct test_context RECT scissor_rect; }; -#define check_multisample_support(a, b, c) check_multisample_support_(__LINE__, a, b, c) -static unsigned int check_multisample_support_(unsigned int line, ID3D12Device *device, - DXGI_FORMAT format, unsigned int sample_count) +#define check_multisample_support(a, b, c) check_multisample_support_(__FILE__, __LINE__, a, b, c) +static unsigned int check_multisample_support_(const char *file, unsigned int line, + ID3D12Device *device, DXGI_FORMAT format, unsigned int sample_count) { D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS format_support = { @@ -1164,18 +1172,18 @@ static unsigned int check_multisample_support_(unsigned int line, ID3D12Device * hr = ID3D12Device_CheckFeatureSupport(device, D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS, &format_support, sizeof(format_support)); - ok_(line)(hr == S_OK, "Cannot check feature support, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Cannot check feature support, hr %#x.\n", hr); return format_support.NumQualityLevels; } -#define create_render_target(context, a, b, c) create_render_target_(__LINE__, context, a, b, c) -static void create_render_target_(unsigned int line, struct test_context *context, - const struct test_context_desc *desc, ID3D12Resource **render_target, - const D3D12_CPU_DESCRIPTOR_HANDLE *rtv) +#define create_render_target(context, a, b, c) create_render_target_(__FILE__, __LINE__, context, a, b, c) +static void create_render_target_(const char *file, unsigned int line, struct test_context *context, + const struct test_context_desc *desc, ID3D12Resource **render_target, const D3D12_CPU_DESCRIPTOR_HANDLE *rtv) { D3D12_HEAP_PROPERTIES heap_properties; D3D12_RESOURCE_DESC resource_desc; + unsigned int quality_level_count; D3D12_CLEAR_VALUE clear_value; HRESULT hr; @@ -1203,10 +1211,8 @@ static void create_render_target_(unsigned int line, struct test_context *contex { for (; resource_desc.SampleDesc.Count != 1; resource_desc.SampleDesc.Count /= 2) { - unsigned int quality_level_count = check_multisample_support_(line, context->device, - resource_desc.Format, resource_desc.SampleDesc.Count); - - if (quality_level_count != 0) + if ((quality_level_count = check_multisample_support_(file, line, + context->device, resource_desc.Format, resource_desc.SampleDesc.Count))) { resource_desc.SampleDesc.Quality = min(resource_desc.SampleDesc.Quality, quality_level_count - 1); break; @@ -1218,7 +1224,7 @@ static void create_render_target_(unsigned int line, struct test_context *contex &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_RENDER_TARGET, &clear_value, &IID_ID3D12Resource, (void **)render_target); - ok_(line)(hr == S_OK, "Failed to create texture, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to create texture, hr %#x.\n", hr); context->render_target_desc = resource_desc; @@ -1226,9 +1232,9 @@ static void create_render_target_(unsigned int line, struct test_context *contex ID3D12Device_CreateRenderTargetView(context->device, *render_target, NULL, *rtv); } -#define init_test_context(context, desc) init_test_context_(__LINE__, context, desc) -static inline bool init_test_context_(unsigned int line, struct test_context *context, - const struct test_context_desc *desc) +#define init_test_context(context, desc) init_test_context_(__FILE__, __LINE__, context, desc) +static inline bool init_test_context_(const char *file, unsigned int line, + struct test_context *context, const struct test_context_desc *desc) { D3D12_DESCRIPTOR_HEAP_DESC rtv_heap_desc; ID3D12Device *device; @@ -1238,7 +1244,7 @@ static inline bool init_test_context_(unsigned int line, struct test_context *co if (!(context->device = create_device())) { - skip_(line)("Failed to create device.\n"); + skip_(file, line)("Failed to create device.\n"); return false; } device = context->device; @@ -1246,15 +1252,16 @@ static inline bool init_test_context_(unsigned int line, struct test_context *co if (FAILED(hr = ID3D12Device_QueryInterface(device, &IID_ID3D12Device2, (void **)&context->device2))) context->device2 = NULL; - context->queue = create_command_queue_(line, device, D3D12_COMMAND_LIST_TYPE_DIRECT, D3D12_COMMAND_QUEUE_PRIORITY_NORMAL); + context->queue = create_command_queue_(file, line, device, + D3D12_COMMAND_LIST_TYPE_DIRECT, D3D12_COMMAND_QUEUE_PRIORITY_NORMAL); hr = ID3D12Device_CreateCommandAllocator(device, D3D12_COMMAND_LIST_TYPE_DIRECT, &IID_ID3D12CommandAllocator, (void **)&context->allocator); - ok_(line)(SUCCEEDED(hr), "Failed to create command allocator, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create command allocator, hr %#x.\n", hr); hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, context->allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&context->list); - ok_(line)(SUCCEEDED(hr), "Failed to create command list, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create command list, hr %#x.\n", hr); if (FAILED(hr = ID3D12GraphicsCommandList_QueryInterface(context->list, &IID_ID3D12GraphicsCommandList1, (void**)&context->list1))) @@ -1269,11 +1276,11 @@ static inline bool init_test_context_(unsigned int line, struct test_context *co rtv_heap_desc.NodeMask = 0; hr = ID3D12Device_CreateDescriptorHeap(device, &rtv_heap_desc, &IID_ID3D12DescriptorHeap, (void **)&context->rtv_heap); - ok_(line)(SUCCEEDED(hr), "Failed to create descriptor heap, hr %#x.\n", hr); + ok_(file, line)(SUCCEEDED(hr), "Failed to create descriptor heap, hr %#x.\n", hr); context->rtv = ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(context->rtv_heap); - create_render_target_(line, context, desc, &context->render_target, &context->rtv); + create_render_target_(file, line, context, desc, &context->render_target, &context->rtv); set_viewport(&context->viewport, 0.0f, 0.0f, context->render_target_desc.Width, context->render_target_desc.Height, 0.0f, 1.0f); @@ -1283,21 +1290,21 @@ static inline bool init_test_context_(unsigned int line, struct test_context *co if (desc && desc->no_root_signature) return true; - context->root_signature = create_empty_root_signature_(line, + context->root_signature = create_empty_root_signature_(file, line, device, desc ? desc->root_signature_flags : D3D12_ROOT_SIGNATURE_FLAG_NONE); if (desc && desc->no_pipeline) return true; - context->pipeline_state = create_pipeline_state_(line, device, + context->pipeline_state = create_pipeline_state_(file, line, device, context->root_signature, context->render_target_desc.Format, desc ? desc->vs : NULL, desc ? desc->ps : NULL, NULL); return true; } -#define init_compute_test_context(context) init_compute_test_context_(__LINE__, context) -static inline bool init_compute_test_context_(unsigned int line, struct test_context *context) +#define init_compute_test_context(context) init_compute_test_context_(__FILE__, __LINE__, context) +static inline bool init_compute_test_context_(const char *file, unsigned int line, struct test_context *context) { ID3D12Device *device; HRESULT hr; @@ -1306,21 +1313,21 @@ static inline bool init_compute_test_context_(unsigned int line, struct test_con if (!(context->device = create_device())) { - skip_(line)("Failed to create device.\n"); + skip_(file, line)("Failed to create device.\n"); return false; } device = context->device; - context->queue = create_command_queue_(line, device, + context->queue = create_command_queue_(file, line, device, D3D12_COMMAND_LIST_TYPE_COMPUTE, D3D12_COMMAND_QUEUE_PRIORITY_NORMAL); hr = ID3D12Device_CreateCommandAllocator(device, D3D12_COMMAND_LIST_TYPE_COMPUTE, &IID_ID3D12CommandAllocator, (void **)&context->allocator); - ok_(line)(hr == S_OK, "Failed to create command allocator, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to create command allocator, hr %#x.\n", hr); hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_COMPUTE, context->allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&context->list); - ok_(line)(hr == S_OK, "Failed to create command list, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to create command list, hr %#x.\n", hr); return true; } @@ -1334,8 +1341,8 @@ static inline void destroy_pipeline_state_objects(struct test_context *context) context->pso_count = 0; } -#define destroy_test_context(context) destroy_test_context_(__LINE__, context) -static inline void destroy_test_context_(unsigned int line, struct test_context *context) +#define destroy_test_context(context) destroy_test_context_(__FILE__, __LINE__, context) +static inline void destroy_test_context_(const char *file, unsigned int line, struct test_context *context) { ULONG refcount; @@ -1361,7 +1368,7 @@ static inline void destroy_test_context_(unsigned int line, struct test_context ID3D12Device2_Release(context->device2); refcount = ID3D12Device_Release(context->device); - ok_(line)(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount); + ok_(file, line)(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount); } static inline D3D12_CPU_DESCRIPTOR_HANDLE get_cpu_handle(ID3D12Device *device, diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c index 51979a3b..5539a27c 100644 --- a/tests/hlsl_d3d12.c +++ b/tests/hlsl_d3d12.c @@ -29,9 +29,9 @@ VKD3D_AGILITY_SDK_EXPORTS struct test_options test_options = {0}; -#define check_preprocess(a, b, c, d, e) check_preprocess_(__LINE__, a, b, c, d, e) -static void check_preprocess_(int line, const char *source, const D3D_SHADER_MACRO *macros, - ID3DInclude *include, const char *present, const char *absent) +#define check_preprocess(a, b, c, d, e) check_preprocess_(__FILE__, __LINE__, a, b, c, d, e) +static void check_preprocess_(const char *file, int line, const char *source, + const D3D_SHADER_MACRO *macros, ID3DInclude *include, const char *present, const char *absent) { ID3D10Blob *blob, *errors; const char *code; @@ -39,20 +39,20 @@ static void check_preprocess_(int line, const char *source, const D3D_SHADER_MAC HRESULT hr; hr = D3DPreprocess(source, strlen(source), NULL, macros, include, &blob, &errors); - assert_that_(line)(hr == S_OK, "Failed to preprocess shader, hr %#x.\n", hr); + assert_that_(file, line)(hr == S_OK, "Failed to preprocess shader, hr %#x.\n", hr); if (errors) { if (vkd3d_test_state.debug_level) - trace_(line)("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors)); + trace_(file, line)("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors)); ID3D10Blob_Release(errors); } code = ID3D10Blob_GetBufferPointer(blob); size = ID3D10Blob_GetBufferSize(blob); if (present) - ok_(line)(vkd3d_memmem(code, size, present, strlen(present)), + ok_(file, line)(vkd3d_memmem(code, size, present, strlen(present)), "\"%s\" not found in preprocessed shader.\n", present); if (absent) - ok_(line)(!vkd3d_memmem(code, size, absent, strlen(absent)), + ok_(file, line)(!vkd3d_memmem(code, size, absent, strlen(absent)), "\"%s\" found in preprocessed shader.\n", absent); ID3D10Blob_Release(blob); } @@ -464,19 +464,20 @@ static void test_preprocess(void) ID3D10Blob_Release(errors); } -#define compile_shader(a, b) compile_shader_(__LINE__, a, b, 0) -#define compile_shader_flags(a, b, c) compile_shader_(__LINE__, a, b, c) -static ID3D10Blob *compile_shader_(unsigned int line, const char *source, const char *target, UINT flags) +#define compile_shader(a, b) compile_shader_(__FILE__, __LINE__, a, b, 0) +#define compile_shader_flags(a, b, c) compile_shader_(__FILE__, __LINE__, a, b, c) +static ID3D10Blob *compile_shader_(const char *file, unsigned int line, + const char *source, const char *target, UINT flags) { ID3D10Blob *blob = NULL, *errors = NULL; HRESULT hr; hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", target, flags, 0, &blob, &errors); - ok_(line)(hr == S_OK, "Failed to compile shader, hr %#x.\n", hr); + ok_(file, line)(hr == S_OK, "Failed to compile shader, hr %#x.\n", hr); if (errors) { if (vkd3d_test_state.debug_level) - trace_(line)("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors)); + trace_(file, line)("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors)); ID3D10Blob_Release(errors); } return blob; @@ -1371,18 +1372,19 @@ static void test_get_blob_part(void) ok(!refcount, "Got refcount %u.\n", refcount); } -static void check_type_desc_(int line, const D3D12_SHADER_TYPE_DESC *type, const D3D12_SHADER_TYPE_DESC *expect) +#define check_type_desc(a, b) check_type_desc_(__FILE__, __LINE__, a, b) +static void check_type_desc_(const char *file, int line, + const D3D12_SHADER_TYPE_DESC *type, const D3D12_SHADER_TYPE_DESC *expect) { - ok_(line)(type->Class == expect->Class, "Got class %#x.\n", type->Class); - ok_(line)(type->Type == expect->Type, "Got type %#x.\n", type->Type); - ok_(line)(type->Rows == expect->Rows, "Got %u rows.\n", type->Rows); - ok_(line)(type->Columns == expect->Columns, "Got %u columns.\n", type->Columns); - ok_(line)(type->Elements == expect->Elements, "Got %u elements.\n", type->Elements); - ok_(line)(type->Members == expect->Members, "Got %u members.\n", type->Members); - ok_(line)(type->Offset == expect->Offset, "Got offset %u.\n", type->Offset); - ok_(line)(!strcmp(type->Name, expect->Name), "Got name \"%s\".\n", type->Name); + ok_(file, line)(type->Class == expect->Class, "Got class %#x.\n", type->Class); + ok_(file, line)(type->Type == expect->Type, "Got type %#x.\n", type->Type); + ok_(file, line)(type->Rows == expect->Rows, "Got %u rows.\n", type->Rows); + ok_(file, line)(type->Columns == expect->Columns, "Got %u columns.\n", type->Columns); + ok_(file, line)(type->Elements == expect->Elements, "Got %u elements.\n", type->Elements); + ok_(file, line)(type->Members == expect->Members, "Got %u members.\n", type->Members); + ok_(file, line)(type->Offset == expect->Offset, "Got offset %u.\n", type->Offset); + ok_(file, line)(!strcmp(type->Name, expect->Name), "Got name \"%s\".\n", type->Name); } -#define check_type_desc(a, b) check_type_desc_(__LINE__, a, b) static void test_reflection(void) { @@ -2023,27 +2025,27 @@ static void test_default_values_reflection(void) } } -static void check_signature_element_(int line, const D3D12_SIGNATURE_PARAMETER_DESC *desc, +#define check_signature_element(a, b, c) check_signature_element_(__FILE__, __LINE__, a, b, c) +static void check_signature_element_(const char *file, int line, const D3D12_SIGNATURE_PARAMETER_DESC *desc, const D3D12_SIGNATURE_PARAMETER_DESC *expect, bool is_todo) { todo_if(is_todo && strcmp(desc->SemanticName, expect->SemanticName)) - ok_(line)(!strcmp(desc->SemanticName, expect->SemanticName), "Got name \"%s\".\n", desc->SemanticName); + ok_(file, line)(!strcmp(desc->SemanticName, expect->SemanticName), "Got name \"%s\".\n", desc->SemanticName); todo_if(is_todo && desc->SemanticIndex != expect->SemanticIndex) - ok_(line)(desc->SemanticIndex == expect->SemanticIndex, "Got index %u.\n", desc->SemanticIndex); + ok_(file, line)(desc->SemanticIndex == expect->SemanticIndex, "Got index %u.\n", desc->SemanticIndex); todo_if(is_todo && desc->Register != expect->Register) - ok_(line)(desc->Register == expect->Register, "Got register %u.\n", desc->Register); + ok_(file, line)(desc->Register == expect->Register, "Got register %u.\n", desc->Register); todo_if(is_todo && desc->SystemValueType != expect->SystemValueType) - ok_(line)(desc->SystemValueType == expect->SystemValueType, "Got sysval %u.\n", desc->SystemValueType); + ok_(file, line)(desc->SystemValueType == expect->SystemValueType, "Got sysval %u.\n", desc->SystemValueType); todo_if(is_todo && desc->ComponentType != expect->ComponentType) - ok_(line)(desc->ComponentType == expect->ComponentType, "Got data type %u.\n", desc->ComponentType); + ok_(file, line)(desc->ComponentType == expect->ComponentType, "Got data type %u.\n", desc->ComponentType); todo_if(is_todo && desc->Mask != expect->Mask) - ok_(line)(desc->Mask == expect->Mask, "Got mask %#x.\n", desc->Mask); + ok_(file, line)(desc->Mask == expect->Mask, "Got mask %#x.\n", desc->Mask); todo_if(desc->ReadWriteMask != expect->ReadWriteMask) - ok_(line)(desc->ReadWriteMask == expect->ReadWriteMask, "Got used mask %#x.\n", desc->ReadWriteMask); + ok_(file, line)(desc->ReadWriteMask == expect->ReadWriteMask, "Got used mask %#x.\n", desc->ReadWriteMask); todo_if(is_todo && desc->Stream != expect->Stream) - ok_(line)(desc->Stream == expect->Stream, "Got stream %u.\n", desc->Stream); + ok_(file, line)(desc->Stream == expect->Stream, "Got stream %u.\n", desc->Stream); } -#define check_signature_element(a, b, c) check_signature_element_(__LINE__, a, b, c) static void test_signature_reflection(void) { diff --git a/tests/shader_runner_d3d12.c b/tests/shader_runner_d3d12.c index 543d2225..6a2300e2 100644 --- a/tests/shader_runner_d3d12.c +++ b/tests/shader_runner_d3d12.c @@ -120,7 +120,7 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co if (params->desc.sample_count > 1 && params->desc.level_count > 1) fatal_error("Multisampled texture has multiple levels.\n"); - resource->resource = create_default_texture_(__LINE__, device, D3D12_RESOURCE_DIMENSION_TEXTURE2D, + resource->resource = create_default_texture_(__FILE__, __LINE__, device, D3D12_RESOURCE_DIMENSION_TEXTURE2D, params->desc.width, params->desc.height, 1, params->desc.level_count, params->desc.sample_count, params->desc.format, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, initial_state); ID3D12Device_CreateRenderTargetView(device, resource->resource, @@ -169,9 +169,9 @@ static struct resource *d3d12_runner_create_resource(struct shader_runner *r, co if (params->desc.sample_count > 1 && params->desc.level_count > 1) fatal_error("Multisampled texture has multiple levels.\n"); - resource->resource = create_default_texture_(__LINE__, device, D3D12_RESOURCE_DIMENSION_TEXTURE2D, - params->desc.width, params->desc.height, 1, params->desc.level_count, - params->desc.sample_count, params->desc.format, + resource->resource = create_default_texture_(__FILE__, __LINE__, device, + D3D12_RESOURCE_DIMENSION_TEXTURE2D, params->desc.width, params->desc.height, 1, + params->desc.level_count, params->desc.sample_count, params->desc.format, /* Multisampled textures must have ALLOW_RENDER_TARGET set. */ (params->desc.sample_count > 1) ? D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET : 0, initial_state); if (params->data) diff --git a/tests/shader_runner_gl.c b/tests/shader_runner_gl.c index da986783..ba2a5e7d 100644 --- a/tests/shader_runner_gl.c +++ b/tests/shader_runner_gl.c @@ -1419,13 +1419,8 @@ static void run_tests(enum shading_language language) void run_shader_tests_gl(void) { - const char *test_name; - - test_name = vkd3d_test_name; - vkd3d_test_name = "shader_runner_gl"; run_tests(SPIR_V); run_tests(GLSL); - vkd3d_test_name = test_name; } #endif diff --git a/tests/utils.h b/tests/utils.h index 82f7ec16..3fbfda72 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -267,9 +267,9 @@ static const struct uvec4 *get_readback_uvec4(const struct resource_readback *rb return get_readback_data(rb, x, y, 0, sizeof(struct uvec4)); } -#define check_readback_data_float(a, b, c, d) check_readback_data_float_(__LINE__, a, b, c, d) -static inline void check_readback_data_float_(unsigned int line, const struct resource_readback *rb, - const RECT *rect, float expected, unsigned int max_diff) +#define check_readback_data_float(a, b, c, d) check_readback_data_float_(__FILE__, __LINE__, a, b, c, d) +static inline void check_readback_data_float_(const char *file, unsigned int line, + const struct resource_readback *rb, const RECT *rect, float expected, unsigned int max_diff) { RECT r = {0, 0, rb->width, rb->height}; unsigned int x = 0, y; @@ -293,12 +293,12 @@ static inline void check_readback_data_float_(unsigned int line, const struct re if (!all_match) break; } - ok_(line)(all_match, "Got %.8e, expected %.8e at (%u, %u).\n", got, expected, x, y); + ok_(file, line)(all_match, "Got %.8e, expected %.8e at (%u, %u).\n", got, expected, x, y); } -#define check_readback_data_double(a, b, c, d) check_readback_data_double_(__LINE__, a, b, c, d) -static inline void check_readback_data_double_(unsigned int line, const struct resource_readback *rb, - const RECT *rect, double expected, unsigned int max_diff) +#define check_readback_data_double(a, b, c, d) check_readback_data_double_(__FILE__, __LINE__, a, b, c, d) +static inline void check_readback_data_double_(const char *file, unsigned int line, + const struct resource_readback *rb, const RECT *rect, double expected, unsigned int max_diff) { RECT r = {0, 0, rb->width, rb->height}; unsigned int x = 0, y; @@ -322,12 +322,12 @@ static inline void check_readback_data_double_(unsigned int line, const struct r if (!all_match) break; } - ok_(line)(all_match, "Got %.15le, expected %.15le at (%u, %u).\n", got, expected, x, y); + ok_(file, line)(all_match, "Got %.15le, expected %.15le at (%u, %u).\n", got, expected, x, y); } -#define check_readback_data_uint(a, b, c, d) check_readback_data_uint_(__LINE__, a, b, c, d) -static inline void check_readback_data_uint_(unsigned int line, struct resource_readback *rb, - const D3D12_BOX *box, unsigned int expected, unsigned int max_diff) +#define check_readback_data_uint(a, b, c, d) check_readback_data_uint_(__FILE__, __LINE__, a, b, c, d) +static inline void check_readback_data_uint_(const char *file, unsigned int line, + struct resource_readback *rb, const D3D12_BOX *box, unsigned int expected, unsigned int max_diff) { D3D12_BOX b = {0, 0, 0, rb->width, rb->height, rb->depth}; unsigned int x = 0, y = 0, z; @@ -356,12 +356,12 @@ static inline void check_readback_data_uint_(unsigned int line, struct resource_ if (!all_match) break; } - ok_(line)(all_match, "Got 0x%08x, expected 0x%08x at (%u, %u, %u).\n", got, expected, x, y, z); + ok_(file, line)(all_match, "Got 0x%08x, expected 0x%08x at (%u, %u, %u).\n", got, expected, x, y, z); } -#define check_readback_data_uint64(a, b, c, d) check_readback_data_uint64_(__LINE__, a, b, c, d) -static inline void check_readback_data_uint64_(unsigned int line, struct resource_readback *rb, - const D3D12_BOX *box, uint64_t expected, unsigned int max_diff) +#define check_readback_data_uint64(a, b, c, d) check_readback_data_uint64_(__FILE__, __LINE__, a, b, c, d) +static inline void check_readback_data_uint64_(const char *file, unsigned int line, + struct resource_readback *rb, const D3D12_BOX *box, uint64_t expected, unsigned int max_diff) { D3D12_BOX b = {0, 0, 0, rb->width, rb->height, rb->depth}; unsigned int x = 0, y = 0; @@ -385,12 +385,12 @@ static inline void check_readback_data_uint64_(unsigned int line, struct resourc if (!all_match) break; } - ok_(line)(all_match, "Got 0x%016"PRIx64", expected 0x%016"PRIx64" at (%u, %u).\n", got, expected, x, y); + ok_(file, line)(all_match, "Got 0x%016"PRIx64", expected 0x%016"PRIx64" at (%u, %u).\n", got, expected, x, y); } -#define check_readback_data_vec2(a, b, c, d) check_readback_data_vec_(__LINE__, a, b, c, d, 2) -#define check_readback_data_vec4(a, b, c, d) check_readback_data_vec_(__LINE__, a, b, c, d, 4) -static inline void check_readback_data_vec_(unsigned int line, const struct resource_readback *rb, +#define check_readback_data_vec2(a, b, c, d) check_readback_data_vec_(__FILE__, __LINE__, a, b, c, d, 2) +#define check_readback_data_vec4(a, b, c, d) check_readback_data_vec_(__FILE__, __LINE__, a, b, c, d, 4) +static inline void check_readback_data_vec_(const char *file, unsigned int line, const struct resource_readback *rb, const RECT *rect, const struct vec4 *expected, unsigned int max_diff, unsigned component_count) { RECT r = {0, 0, rb->width, rb->height}; @@ -415,14 +415,15 @@ static inline void check_readback_data_vec_(unsigned int line, const struct reso if (!all_match) break; } - ok_(line)(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n", + ok_(file, line)(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n", got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y); } -#define check_readback_data_ivec4(a, b, c) check_readback_data_uvec4_(__LINE__, a, b, (const struct uvec4 *)(c)) -#define check_readback_data_uvec4(a, b, c) check_readback_data_uvec4_(__LINE__, a, b, c) -static inline void check_readback_data_uvec4_(unsigned int line, const struct resource_readback *rb, - const RECT *rect, const struct uvec4 *expected) +#define check_readback_data_ivec4(a, b, c) \ + check_readback_data_uvec4_(__FILE__, __LINE__, a, b, (const struct uvec4 *)(c)) +#define check_readback_data_uvec4(a, b, c) check_readback_data_uvec4_(__FILE__, __LINE__, a, b, c) +static inline void check_readback_data_uvec4_(const char *file, unsigned int line, + const struct resource_readback *rb, const RECT *rect, const struct uvec4 *expected) { RECT r = {0, 0, rb->width, rb->height}; unsigned int x = 0, y = 0; @@ -446,7 +447,8 @@ static inline void check_readback_data_uvec4_(unsigned int line, const struct re if (!all_match) break; } - ok_(line)(all_match, "Got {0x%08x, 0x%08x, 0x%08x, 0x%08x}, expected {0x%08x, 0x%08x, 0x%08x, 0x%08x} at (%u, %u).\n", + ok_(file, line)(all_match, + "Got {0x%08x, 0x%08x, 0x%08x, 0x%08x}, expected {0x%08x, 0x%08x, 0x%08x, 0x%08x} at (%u, %u).\n", got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y); } diff --git a/tests/vkd3d_api.c b/tests/vkd3d_api.c index 62e30b47..284cb9c7 100644 --- a/tests/vkd3d_api.c +++ b/tests/vkd3d_api.c @@ -55,7 +55,7 @@ HRESULT WINAPI D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *root return vkd3d_serialize_root_signature(root_signature_desc, version, blob, error_blob); } -static void wait_queue_idle_(unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue) +static void wait_queue_idle_(const char *file, unsigned int line, ID3D12Device *device, ID3D12CommandQueue *queue) { VkQueue vk_queue;