From: Giovanni Mascellani gmascellani@codeweavers.com
--- tests/d3d12.c | 40 ++++++++++++++++++++++++++++------------ tests/d3d12_test_utils.h | 5 +++++ 2 files changed, 33 insertions(+), 12 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index 586b8222..6a1b6869 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -28,6 +28,20 @@ struct test_options test_options = {0}; static PFN_D3D12_CREATE_VERSIONED_ROOT_SIGNATURE_DESERIALIZER pfn_D3D12CreateVersionedRootSignatureDeserializer; static PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE pfn_D3D12SerializeVersionedRootSignature;
+static ID3D10Blob *compile_shader(const char *source, size_t len, const char *profile) +{ + ID3D10Blob *bytecode = NULL, *errors = NULL; + HRESULT hr; + + hr = D3DCompile(source, len, NULL, NULL, NULL, "main", profile, 0, 0, &bytecode, &errors); + ok(hr == S_OK, "Cannot compile shader, hr %#x.\n", hr); + ok(!!bytecode, "Compilation didn't produce any bytecode.\n"); + if (errors) + ID3D10Blob_Release(errors); + + return bytecode; +} + struct dvec2 { double x, y; @@ -2885,24 +2899,23 @@ static void test_create_compute_pipeline_state(void) ID3D12RootSignature *root_signature; ID3D12PipelineState *pipeline_state; ID3D12Device *device, *tmp_device; + ID3D10Blob *bytecode; ULONG refcount; HRESULT hr;
- static const DWORD dxbc_code[] = - { -#if 0 - [numthreads(1, 1, 1)] - void main() { } -#endif - 0x43425844, 0x1acc3ad0, 0x71c7b057, 0xc72c4306, 0xf432cb57, 0x00000001, 0x00000074, 0x00000003, - 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, - 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000020, 0x00050050, 0x00000008, 0x0100086a, - 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x0100003e, - }; + static const char shader_code[] = + "[numthreads(1, 1, 1)]\n" + "void main() { }\n"; + + bytecode = compile_shader(shader_code, sizeof(shader_code) - 1, "cs_4_0");
if (!(device = create_device())) { skip("Failed to create device.\n"); + + refcount = ID3D10Blob_Release(bytecode); + ok(!refcount, "ID3D10Block has %u references left.\n", (unsigned int)refcount); + return; }
@@ -2919,7 +2932,7 @@ static void test_create_compute_pipeline_state(void)
memset(&pipeline_state_desc, 0, sizeof(pipeline_state_desc)); pipeline_state_desc.pRootSignature = root_signature; - pipeline_state_desc.CS = shader_bytecode(dxbc_code, sizeof(dxbc_code)); + pipeline_state_desc.CS = shader_bytecode_from_blob(bytecode); pipeline_state_desc.NodeMask = 0; pipeline_state_desc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;
@@ -2951,6 +2964,9 @@ static void test_create_compute_pipeline_state(void)
refcount = ID3D12Device_Release(device); ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount); + + refcount = ID3D10Blob_Release(bytecode); + ok(!refcount, "ID3D10Block has %u references left.\n", (unsigned int)refcount); }
static void test_create_graphics_pipeline_state(void) diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h index ec5ba5c5..9df50c56 100644 --- a/tests/d3d12_test_utils.h +++ b/tests/d3d12_test_utils.h @@ -88,6 +88,11 @@ static D3D12_SHADER_BYTECODE shader_bytecode(const DWORD *code, size_t size) return shader_bytecode; }
+static inline D3D12_SHADER_BYTECODE shader_bytecode_from_blob(ID3D10Blob *blob) +{ + return shader_bytecode(ID3D10Blob_GetBufferPointer(blob), ID3D10Blob_GetBufferSize(blob)); +} + static void exec_command_list(ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *list) { ID3D12CommandList *lists[] = {(ID3D12CommandList *)list};
From: Giovanni Mascellani gmascellani@codeweavers.com
--- tests/d3d12.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index 6a1b6869..ee59b06b 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -5474,39 +5474,32 @@ static void test_multiple_render_targets(void) struct test_context_desc desc; struct test_context context; ID3D12CommandQueue *queue; + D3D12_SHADER_BYTECODE ps; + ID3D10Blob *bytecode; unsigned int i; HRESULT hr;
- static const DWORD ps_code[] = - { -#if 0 - void main(out float4 target0 : SV_Target0, out float4 target1 : SV_Target1, - out float4 target2 : SV_Target2) - { - target0 = float4(1.0f, 0.0f, 0.0f, 1.0f); - target1 = float4(2.0f, 0.0f, 0.0f, 1.0f); - target2 = float4(3.0f, 0.0f, 0.0f, 1.0f); - } -#endif - 0x43425844, 0xc4325131, 0x8ba4a693, 0x08d15431, 0xcb990885, 0x00000001, 0x0000013c, 0x00000003, - 0x0000002c, 0x0000003c, 0x000000a0, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, - 0x0000005c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000, - 0x0000000f, 0x00000050, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000050, - 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, - 0x58454853, 0x00000094, 0x00000050, 0x00000025, 0x0100086a, 0x03000065, 0x001020f2, 0x00000000, - 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x08000036, 0x001020f2, - 0x00000000, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x3f800000, 0x08000036, 0x001020f2, - 0x00000001, 0x00004002, 0x40000000, 0x00000000, 0x00000000, 0x3f800000, 0x08000036, 0x001020f2, - 0x00000002, 0x00004002, 0x40400000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, - }; - static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)}; + static const char ps_code[] = + "void main(out float4 target0 : SV_Target0, out float4 target1 : SV_Target1,\n" + " out float4 target2 : SV_Target2)\n" + "{\n" + " target0 = float4(1.0f, 0.0f, 0.0f, 1.0f);\n" + " target1 = float4(2.0f, 0.0f, 0.0f, 1.0f);\n" + " target2 = float4(3.0f, 0.0f, 0.0f, 1.0f);\n" + "}\n"; + + bytecode = compile_shader(ps_code, sizeof(ps_code) - 1, "ps_4_0"); + ps = shader_bytecode_from_blob(bytecode);
memset(&desc, 0, sizeof(desc)); desc.rt_format = DXGI_FORMAT_R32G32B32A32_FLOAT; desc.rt_descriptor_count = ARRAY_SIZE(rtvs); desc.no_pipeline = true; if (!init_test_context(&context, &desc)) + { + ID3D10Blob_Release(bytecode); return; + } command_list = context.list; queue = context.queue;
@@ -5588,6 +5581,8 @@ static void test_multiple_render_targets(void) for (i = 0; i < ARRAY_SIZE(render_targets); ++i) ID3D12Resource_Release(render_targets[i]); destroy_test_context(&context); + + ID3D10Blob_Release(bytecode); }
static void test_unknown_rtv_format(void)
From: Giovanni Mascellani gmascellani@codeweavers.com
--- tests/d3d12.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index ee59b06b..f7107c1d 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -5598,35 +5598,30 @@ static void test_unknown_rtv_format(void) struct test_context_desc desc; struct test_context context; ID3D12CommandQueue *queue; + D3D12_SHADER_BYTECODE ps; + ID3D10Blob *bytecode; unsigned int i; HRESULT hr;
- static const DWORD ps_code[] = - { -#if 0 - void main(out float4 target1 : SV_Target1, out float4 target2 : SV_Target2) - { - target1 = float4(2.0f, 0.0f, 0.0f, 1.0f); - target2 = float4(3.0f, 0.0f, 0.0f, 1.0f); - } -#endif - 0x43425844, 0x980554be, 0xb8743fb0, 0xf5bb8deb, 0x639feaf8, 0x00000001, 0x000000f4, 0x00000003, - 0x0000002c, 0x0000003c, 0x00000088, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, - 0x00000044, 0x00000002, 0x00000008, 0x00000038, 0x00000001, 0x00000000, 0x00000003, 0x00000001, - 0x0000000f, 0x00000038, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x545f5653, - 0x65677261, 0xabab0074, 0x52444853, 0x00000064, 0x00000040, 0x00000019, 0x03000065, 0x001020f2, - 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, - 0x40000000, 0x00000000, 0x00000000, 0x3f800000, 0x08000036, 0x001020f2, 0x00000002, 0x00004002, - 0x40400000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, - }; - static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)}; + static const char ps_code[] = + "void main(out float4 target1 : SV_Target1, out float4 target2 : SV_Target2)\n" + "{\n" + " target1 = float4(2.0f, 0.0f, 0.0f, 1.0f);\n" + " target2 = float4(3.0f, 0.0f, 0.0f, 1.0f);\n" + "}\n"; + + bytecode = compile_shader(ps_code, sizeof(ps_code) - 1, "ps_4_0"); + ps = shader_bytecode_from_blob(bytecode);
memset(&desc, 0, sizeof(desc)); desc.rt_format = DXGI_FORMAT_R32G32B32A32_FLOAT; desc.rt_descriptor_count = 16; desc.no_pipeline = true; if (!init_test_context(&context, &desc)) + { + ID3D10Blob_Release(bytecode); return; + } command_list = context.list; queue = context.queue;
@@ -5696,6 +5691,8 @@ static void test_unknown_rtv_format(void) ID3D12Resource_Release(render_targets[i]); destroy_depth_stencil(&ds); destroy_test_context(&context); + + ID3D10Blob_Release(bytecode); }
static void test_unknown_dsv_format(void)
From: Giovanni Mascellani gmascellani@codeweavers.com
--- tests/d3d12.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index f7107c1d..0c162be2 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -5700,40 +5700,37 @@ static void test_unknown_dsv_format(void) D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc; ID3D12GraphicsCommandList *command_list; struct depth_stencil_resource ds; + D3D12_SHADER_BYTECODE ps_color; D3D12_CLEAR_VALUE clear_value; struct test_context_desc desc; struct test_context context; ID3D12CommandQueue *queue; + ID3D10Blob *bytecode; HRESULT hr;
- static const DWORD ps_color_code[] = - { -#if 0 - float4 color; + static const char ps_color_code[] = + "float4 color;\n" + "\n" + "float4 main(float4 position : SV_POSITION) : SV_Target\n" + "{\n" + " return color;\n" + "}\n";
- float4 main(float4 position : SV_POSITION) : SV_Target - { - return color; - } -#endif - 0x43425844, 0xd18ead43, 0x8b8264c1, 0x9c0a062d, 0xfc843226, 0x00000001, 0x000000e0, 0x00000003, - 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, - 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, - 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, - 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000044, 0x00000050, - 0x00000011, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, - 0x00000000, 0x06000036, 0x001020f2, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x0100003e, - }; - static const D3D12_SHADER_BYTECODE ps_color = {ps_color_code, sizeof(ps_color_code)}; static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; static const struct vec4 green = {0.0f, 1.0f, 0.0f, 1.0f}; static const struct vec4 red = {1.0f, 0.0f, 0.0f, 1.0f};
+ bytecode = compile_shader(ps_color_code, sizeof(ps_color_code) - 1, "ps_4_0"); + ps_color = shader_bytecode_from_blob(bytecode); + memset(&desc, 0, sizeof(desc)); desc.rt_format = DXGI_FORMAT_R32G32B32A32_FLOAT; desc.no_root_signature = true; if (!init_test_context(&context, &desc)) + { + ID3D10Blob_Release(bytecode); return; + } command_list = context.list; queue = context.queue;
@@ -5895,6 +5892,8 @@ static void test_unknown_dsv_format(void)
destroy_depth_stencil(&ds); destroy_test_context(&context); + + ID3D10Blob_Release(bytecode); }
static void test_append_aligned_element(void)
+ refcount = ID3D10Blob_Release(bytecode); + ok(!refcount, "ID3D10Block has %u references left.\n", (unsigned int)refcount);
ID3D10Blob, not ID3D10Block. :)
I don't think we're too worried about the blob refcounts though, so I wouldn't mind just dropping these refcount checks here like in the other patches either. In any case, thanks for taking care of this.
ID3D10Blob, not ID3D10Block. :)
Ugh, I mistyped that thing tens of times, I don't know why. And of course I forgot to fix only the one which couldn't be caught by the compiler.
I don't think we're too worried about the blob refcounts though, so I wouldn't mind just dropping these refcount checks here like in the other patches either. In any case, thanks for taking care of this.
I'm not particularly worried about it, and I wouldn't stress too much over it. But given that in this case it's essentially free, I'd leave it.