vkd3d-shader/hlsl: Use a block in hlsl_normalize_binary_exprs().
[vkd3d.git] / tests / hlsl_d3d12.c
blob7b60d0b19f0cbe760eb95075a38c5b1dfdae10a0
1 /*
2 * Copyright (C) 2020 Zebediah Figura for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
20 #include "d3d12_crosstest.h"
21 #include "vkd3d_common.h"
22 #include "vkd3d_d3d12shader.h"
24 VKD3D_AGILITY_SDK_EXPORTS
26 #ifndef D3DERR_INVALIDCALL
27 #define D3DERR_INVALIDCALL 0x8876086c
28 #endif
30 struct test_options test_options = {0};
32 #define check_preprocess(a, b, c, d, e) check_preprocess_(__FILE__, __LINE__, a, b, c, d, e)
33 static void check_preprocess_(const char *file, int line, const char *source,
34 const D3D_SHADER_MACRO *macros, ID3DInclude *include, const char *present, const char *absent)
36 ID3D10Blob *blob, *errors;
37 const char *code;
38 SIZE_T size;
39 HRESULT hr;
41 hr = D3DPreprocess(source, strlen(source), NULL, macros, include, &blob, &errors);
42 assert_that_(file, line)(hr == S_OK, "Failed to preprocess shader, hr %#x.\n", hr);
43 if (errors)
45 if (vkd3d_test_state.debug_level)
46 trace_(file, line)("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors));
47 ID3D10Blob_Release(errors);
49 code = ID3D10Blob_GetBufferPointer(blob);
50 size = ID3D10Blob_GetBufferSize(blob);
51 if (present)
52 ok_(file, line)(vkd3d_memmem(code, size, present, strlen(present)),
53 "\"%s\" not found in preprocessed shader.\n", present);
54 if (absent)
55 ok_(file, line)(!vkd3d_memmem(code, size, absent, strlen(absent)),
56 "\"%s\" found in preprocessed shader.\n", absent);
57 ID3D10Blob_Release(blob);
60 static const char test_include_top[] =
61 "#include \"file1\"\n"
62 "#include < file2 >\n"
63 "ARGES\n";
65 static const char test_include_file1[] =
66 "#define BRONTES\n"
67 "#include \"file3\"\n"
68 "#ifndef BRONTES\n"
69 "#define STEROPES\n"
70 "#endif";
72 static const char test_include_file2[] =
73 "#ifdef STEROPES\n"
74 "#define ARGES pass\n"
75 "#undef STEROPES\n"
76 "#include < file2 >\n"
77 "#endif";
79 static const char test_include_file3[] =
80 "#undef BRONTES";
82 static const char test_include2_top[] =
83 "#define FUNC(a, b) a ## b\n"
84 "#include \"file4\"\n"
85 ",ss)";
87 static const char test_include2_file4[] =
88 "FUNC(pa";
90 static unsigned int refcount_file1, refcount_file2, refcount_file3, include_count_file2;
92 static HRESULT WINAPI test_include_Open(ID3DInclude *iface, D3D_INCLUDE_TYPE type,
93 const char *filename, const void *parent_data, const void **code, UINT *size)
95 ok(!*code, "Data pointer should be zeroed.\n");
96 ok(!*size, "Size pointer should be zeroed.\n");
97 if (!strcmp(filename, "file1"))
99 ok(type == D3D_INCLUDE_LOCAL, "Got type %#x.\n", type);
100 ok(!parent_data, "Got parent data %p.\n", parent_data);
101 *code = test_include_file1;
102 *size = strlen(test_include_file1);
103 ++refcount_file1;
105 else if (!strcmp(filename, " file2 "))
107 ok(type == D3D_INCLUDE_SYSTEM, "Got type %#x.\n", type);
108 if (!include_count_file2++)
109 ok(!parent_data, "Got parent data %p.\n", parent_data);
110 else
111 ok(parent_data == test_include_file2, "Got parent data %p.\n", parent_data);
112 *code = test_include_file2;
113 *size = strlen(test_include_file2);
114 ++refcount_file2;
116 else if (!strcmp(filename, "file3"))
118 ok(type == D3D_INCLUDE_LOCAL, "Got type %#x.\n", type);
119 ok(parent_data == test_include_file1, "Got parent data %p.\n", parent_data);
120 *code = test_include_file3;
121 *size = strlen(test_include_file3);
122 ++refcount_file3;
124 else if (!strcmp(filename, "file4"))
126 ok(type == D3D_INCLUDE_LOCAL, "Got type %#x.\n", type);
127 ok(!parent_data, "Got parent data %p.\n", parent_data);
128 *code = test_include2_file4;
129 *size = strlen(test_include2_file4);
131 else
133 ok(0, "Unexpected filename \"%s\".\n", filename);
135 return S_FALSE;
138 static HRESULT WINAPI test_include_Close(ID3DInclude *iface, const void *code)
140 if (code == test_include_file1)
141 --refcount_file1;
142 else if (code == test_include_file2)
143 --refcount_file2;
144 else if (code == test_include_file3)
145 --refcount_file3;
146 return E_FAIL;
149 static const struct ID3DIncludeVtbl test_include_vtbl =
151 test_include_Open,
152 test_include_Close,
155 static HRESULT WINAPI test_include_fail_Open(ID3DInclude *iface, D3D_INCLUDE_TYPE type,
156 const char *filename, const void *parent_data, const void **code, UINT *size)
158 return 0xdeadbeef;
161 static HRESULT WINAPI test_include_fail_Close(ID3DInclude *iface, const void *code)
163 ok(0, "Unexpected call.\n");
164 return E_FAIL;
167 static const struct ID3DIncludeVtbl test_include_fail_vtbl =
169 test_include_fail_Open,
170 test_include_fail_Close,
173 static void test_preprocess(void)
175 ID3DInclude test_include_fail = {&test_include_fail_vtbl};
176 ID3DInclude test_include = {&test_include_vtbl};
177 D3D_SHADER_MACRO macros[3];
178 ID3D10Blob *blob, *errors;
179 unsigned int i;
180 HRESULT hr;
182 static const struct
184 const char *source;
185 const char *present;
186 const char *absent;
188 tests[] =
190 /* Stringification. */
192 "#define KEY(a) #a\n"
193 "KEY(apple)",
195 "\"apple\"",
198 "#define KEY(a) # a\n"
199 "KEY(apple)",
201 "\"apple\"",
204 "#define KEY(a) #a\n"
205 "KEY( \t\r\n apple \t\r\n )",
207 "\"apple\"",
210 "#define KEY(if) #if\n"
211 "KEY(apple)",
213 "\"apple\"",
216 "#define KEY(a) #a\n"
217 "KEY(\"apple\")",
219 "\"\\\"apple\\\"\"",
222 "#define KEY(a) #b\n"
223 "KEY(apple)",
225 "\"b\"",
228 "#define KEY(a) a\n"
229 "KEY(banana #apple)",
231 "#",
232 "\"apple\"",
235 "#define KEY #apple\n"
236 "KEY",
238 "apple",
239 "\"apple\"",
242 "banana #apple\n",
244 "apple",
245 "\"apple\"",
248 "banana #apple\n",
250 "#",
253 "#define KEY2(x) x\n"
254 "#define KEY(a) KEY2(#a)\n"
255 "KEY(apple)",
257 "\"apple\"",
260 "#define KEY2(x) #x\n"
261 "#define KEY(a) KEY2(#a)\n"
262 "KEY(apple)",
264 "\"\\\"apple\\\"\"",
267 "#define KEY2(x) #x\n"
268 "#define KEY(a) KEY2(#x)\n"
269 "KEY(apple)",
271 "\"\\\"x\\\"\"",
274 /* #pragma is preserved. */
276 "#pragma pack_matrix(column_major)\n"
277 "text",
279 "#pragma pack_matrix(column_major)\n",
282 /* DOS-style newlines. */
284 "#define KEY(a, b) \\\r\n"
285 " a ## b\r\n"
286 "KEY(pa,\r\n"
287 "ss\r\n"
288 ")\r\n"
289 "#ifndef KEY\r\n"
290 "fail\r\n"
291 "#endif\r\n",
293 "pass",
294 "fail",
297 "#define KEY(a, b) \\\r\n"
298 " a ## b\n"
299 "KEY(pa,\r\n"
300 "ss\n"
301 ")\r\n"
302 "#ifndef KEY\n"
303 "fail\r\n"
304 "#endif\n",
306 "pass",
307 "fail",
310 /* Pre-defined macros. */
312 "__LINE__",
313 "1",
314 "__LINE__",
317 "\n"
318 "__LINE__",
319 "2",
320 "__LINE__",
323 "#define KEY __LINE__\n"
324 "KEY",
325 "2",
328 /* Tokens which must be preserved verbatim for HLSL (i.e. which cannot
329 * be broken up with spaces). */
330 {"<<", "<<"},
331 {">>", ">>"},
332 {"++", "++"},
333 {"--", "--"},
334 {"+=", "+="},
335 {"-=", "-="},
336 {"*=", "*="},
337 {"/=", "/="},
338 {"%=", "%="},
339 {"&=", "&="},
340 {"|=", "|="},
341 {"^=", "^="},
342 {"<<=", "<<="},
343 {">>=", ">>="},
344 {"0.0", "0.0"},
345 {".0", ".0"},
346 {"0.", "0."},
347 {"1e1", "1e1"},
348 {"1E1", "1E1"},
349 {"1e+1", "1e+1"},
350 {"1e-1", "1e-1"},
351 {".0f", ".0f"},
352 {".0F", ".0F"},
353 {".0h", ".0h"},
354 {".0H", ".0H"},
355 {"0.f", "0.f"},
356 {"1.1e-1f", "1.1e-1f"},
358 /* Parentheses are emitted for object-like macros invoked like
359 * function-like macros. */
361 "#define KEY value\n"
362 "KEY(apple)",
364 "(",
367 /* Function-like macro with no parentheses and no following tokens (a
368 * corner case in our implementation). */
370 "#define pass(a) fail\n"
371 "pass",
373 "pass",
374 "fail",
377 /* A single-line comment not terminated by a newline. */
379 "pass // fail",
381 "pass",
382 "fail",
385 /* CRs are treated as whitespace. */
387 "#define\rKEY(a,\rb)\ra##b\r\n"
388 "KEY(pa,\rss)\r\n"
389 "#ifndef\rKEY\r\n"
390 "fail\r\n"
391 "#endif\r\n",
393 "pass",
394 "fail",
398 for (i = 0; i < ARRAY_SIZE(tests); ++i)
400 vkd3d_test_push_context("Source \"%s\"", tests[i].source);
401 check_preprocess(tests[i].source, NULL, NULL, tests[i].present, tests[i].absent);
402 vkd3d_test_pop_context();
405 macros[0].Name = "KEY";
406 macros[0].Definition = "value";
407 macros[1].Name = NULL;
408 macros[1].Definition = NULL;
409 check_preprocess("KEY", macros, NULL, "value", "KEY");
411 check_preprocess("#undef KEY\nKEY", macros, NULL, "KEY", "value");
413 macros[0].Name = NULL;
414 check_preprocess("KEY", macros, NULL, "KEY", "value");
416 macros[0].Name = "KEY";
417 macros[0].Definition = NULL;
418 check_preprocess("KEY", macros, NULL, NULL, "KEY");
420 macros[0].Name = "0";
421 macros[0].Definition = "value";
422 check_preprocess("0", macros, NULL, "0", "value");
424 macros[0].Name = "KEY(a)";
425 macros[0].Definition = "value";
426 check_preprocess("KEY(a)", macros, NULL, "KEY", "value");
428 macros[0].Name = "KEY";
429 macros[0].Definition = "value1";
430 macros[1].Name = "KEY";
431 macros[1].Definition = "value2";
432 macros[2].Name = NULL;
433 macros[2].Definition = NULL;
434 check_preprocess("KEY", macros, NULL, "value2", NULL);
436 macros[0].Name = "KEY";
437 macros[0].Definition = "KEY2";
438 macros[1].Name = "KEY2";
439 macros[1].Definition = "value";
440 check_preprocess("KEY", macros, NULL, "value", NULL);
442 macros[0].Name = "KEY2";
443 macros[0].Definition = "value";
444 macros[1].Name = "KEY";
445 macros[1].Definition = "KEY2";
446 check_preprocess("KEY", macros, NULL, "value", NULL);
448 check_preprocess(test_include_top, NULL, &test_include, "pass", "fail");
449 ok(!refcount_file1, "Got %d references to file1.\n", refcount_file1);
450 ok(!refcount_file2, "Got %d references to file1.\n", refcount_file2);
451 ok(!refcount_file3, "Got %d references to file1.\n", refcount_file3);
452 ok(include_count_file2 == 2, "file2 was included %u times.\n", include_count_file2);
454 /* Macro invocation spread across multiple files. */
455 check_preprocess(test_include2_top, NULL, &test_include, "pass", NULL);
457 blob = errors = (ID3D10Blob *)0xdeadbeef;
458 hr = D3DPreprocess(test_include_top, strlen(test_include_top), NULL, NULL, &test_include_fail, &blob, &errors);
459 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
460 ok(blob == (ID3D10Blob *)0xdeadbeef, "Expected no compiled shader blob.\n");
461 ok(!!errors, "Expected non-NULL error blob.\n");
462 if (vkd3d_test_state.debug_level)
463 trace("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors));
464 ID3D10Blob_Release(errors);
467 #define compile_shader(a, b) compile_shader_(__FILE__, __LINE__, a, b, 0)
468 #define compile_shader_flags(a, b, c) compile_shader_(__FILE__, __LINE__, a, b, c)
469 static ID3D10Blob *compile_shader_(const char *file, unsigned int line,
470 const char *source, const char *target, UINT flags)
472 ID3D10Blob *blob = NULL, *errors = NULL;
473 HRESULT hr;
475 hr = D3DCompile(source, strlen(source), NULL, NULL, NULL, "main", target, flags, 0, &blob, &errors);
476 ok_(file, line)(hr == S_OK, "Failed to compile shader, hr %#x.\n", hr);
477 if (errors)
479 if (vkd3d_test_state.debug_level)
480 trace_(file, line)("%s\n", (char *)ID3D10Blob_GetBufferPointer(errors));
481 ID3D10Blob_Release(errors);
483 return blob;
486 static void test_thread_id(void)
488 struct d3d12_resource_readback rb, rb_threadid;
489 ID3D12GraphicsCommandList *command_list;
490 struct test_context context;
491 ID3D12Resource *textures[4];
492 ID3D12DescriptorHeap *heap;
493 unsigned int i, x, y, z;
494 ID3D12Device *device;
495 ID3D10Blob *cs_code;
496 HRESULT hr;
498 static const char cs_source[] =
499 "RWTexture3D<uint4> group_uav, thread_uav, dispatch_uav, threadindex_uav;\n"
500 "[numthreads(5, 3, 2)]\n"
501 "void main(uint3 group : sv_groupid, uint3 thread : sv_groupthreadid, uint3 dispatch : sv_dispatchthreadid,"
502 " uint threadindex : sv_groupindex)\n"
503 "{\n"
504 " group_uav[dispatch] = uint4(group, 1);\n"
505 " thread_uav[dispatch] = uint4(thread, 2);\n"
506 " dispatch_uav[dispatch] = uint4(dispatch, 3);\n"
507 " threadindex_uav[dispatch] = uint4(threadindex, 0, 0, 4);\n"
508 "}";
510 static const D3D12_DESCRIPTOR_RANGE descriptor_range = {D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 4, 0, 0, 0};
512 static const D3D12_ROOT_PARAMETER root_parameter =
514 .ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE,
515 .DescriptorTable = {1, &descriptor_range},
518 static const D3D12_ROOT_SIGNATURE_DESC root_signature_desc =
520 .NumParameters = 1,
521 .pParameters = &root_parameter,
524 if (!init_compute_test_context(&context))
525 return;
526 command_list = context.list;
527 device = context.device;
529 hr = create_root_signature(device, &root_signature_desc, &context.root_signature);
530 ok(hr == S_OK, "Failed to create root signature, hr %#x.\n", hr);
532 heap = create_gpu_descriptor_heap(device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 4);
534 for (i = 0; i < 4; ++i)
536 const UINT clear_value[4] = {0};
538 textures[i] = create_default_texture3d(device, 16, 8, 8, 1, DXGI_FORMAT_R32G32B32A32_UINT,
539 D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
540 ID3D12Device_CreateUnorderedAccessView(device, textures[i], NULL, NULL,
541 get_cpu_descriptor_handle(&context, heap, i));
542 ID3D12GraphicsCommandList_ClearUnorderedAccessViewUint(command_list,
543 get_gpu_descriptor_handle(&context, heap, i),
544 get_cpu_descriptor_handle(&context, heap, i),
545 textures[i], clear_value, 0, NULL);
546 uav_barrier(command_list, textures[i]);
549 cs_code = compile_shader(cs_source, "cs_5_0");
550 context.pipeline_state = create_compute_pipeline_state(device, context.root_signature,
551 shader_bytecode(ID3D10Blob_GetBufferPointer(cs_code), ID3D10Blob_GetBufferSize(cs_code)));
552 ID3D10Blob_Release(cs_code);
554 ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state);
555 ID3D12GraphicsCommandList_SetComputeRootSignature(command_list, context.root_signature);
556 ID3D12GraphicsCommandList_SetComputeRootDescriptorTable(command_list,
557 0, get_gpu_descriptor_handle(&context, heap, 0));
558 ID3D12GraphicsCommandList_Dispatch(command_list, 2, 2, 2);
560 transition_resource_state(command_list, textures[0],
561 D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
562 get_resource_readback_with_command_list(textures[0], 0, &rb, context.queue, command_list);
563 for (x = 0; x < 16; ++x)
565 for (y = 0; y < 8; ++y)
567 for (z = 0; z < 8; ++z)
569 const struct uvec4 *v = get_readback_data(&rb.rb, x, y, z, sizeof(struct uvec4));
570 struct uvec4 expect = {x / 5, y / 3, z / 2, 1};
572 if (x >= 10 || y >= 6 || z >= 4)
573 memset(&expect, 0, sizeof(expect));
575 ok(compare_uvec4(v, &expect), "Got {%u, %u, %u, %u} at (%u, %u, %u).\n",
576 v->x, v->y, v->z, v->w, x, y, z);
580 release_resource_readback(&rb);
581 reset_command_list(command_list, context.allocator);
583 transition_resource_state(command_list, textures[1],
584 D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
585 get_resource_readback_with_command_list(textures[1], 0, &rb, context.queue, command_list);
586 for (x = 0; x < 16; ++x)
588 for (y = 0; y < 8; ++y)
590 for (z = 0; z < 8; ++z)
592 const struct uvec4 *v = get_readback_data(&rb.rb, x, y, z, sizeof(struct uvec4));
593 struct uvec4 expect = {x % 5, y % 3, z % 2, 2};
595 if (x >= 10 || y >= 6 || z >= 4)
596 memset(&expect, 0, sizeof(expect));
598 ok(compare_uvec4(v, &expect), "Got {%u, %u, %u, %u} at (%u, %u, %u).\n",
599 v->x, v->y, v->z, v->w, x, y, z);
603 release_resource_readback(&rb);
604 reset_command_list(command_list, context.allocator);
606 transition_resource_state(command_list, textures[2],
607 D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
608 get_resource_readback_with_command_list(textures[2], 0, &rb, context.queue, command_list);
609 for (x = 0; x < 16; ++x)
611 for (y = 0; y < 8; ++y)
613 for (z = 0; z < 8; ++z)
615 const struct uvec4 *v = get_readback_data(&rb.rb, x, y, z, sizeof(struct uvec4));
616 struct uvec4 expect = {x, y, z, 3};
618 if (x >= 10 || y >= 6 || z >= 4)
619 memset(&expect, 0, sizeof(expect));
621 ok(compare_uvec4(v, &expect), "Got {%u, %u, %u, %u} at (%u, %u, %u).\n",
622 v->x, v->y, v->z, v->w, x, y, z);
626 release_resource_readback(&rb);
627 reset_command_list(command_list, context.allocator);
629 /* Verify SV_GroupIndex using SV_GroupThreadId. */
630 transition_resource_state(command_list, textures[1],
631 D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
632 get_resource_readback_with_command_list(textures[1], 0, &rb_threadid, context.queue, command_list);
633 reset_command_list(command_list, context.allocator);
634 transition_resource_state(command_list, textures[3],
635 D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
636 get_resource_readback_with_command_list(textures[3], 0, &rb, context.queue, command_list);
637 for (x = 0; x < 16; ++x)
639 for (y = 0; y < 8; ++y)
641 for (z = 0; z < 8; ++z)
643 const struct uvec4 *v = get_readback_data(&rb.rb, x, y, z, sizeof(struct uvec4));
644 const struct uvec4 *tid = get_readback_data(&rb_threadid.rb, x, y, z, sizeof(struct uvec4));
645 struct uvec4 expect = {tid->z * 5 * 3 + tid->y * 5 + tid->x, 0, 0, 4};
647 if (x >= 10 || y >= 6 || z >= 4)
648 memset(&expect, 0, sizeof(expect));
650 ok(compare_uvec4(v, &expect), "Got {%u, %u, %u, %u} at (%u, %u, %u).\n",
651 v->x, v->y, v->z, v->w, x, y, z);
655 release_resource_readback(&rb);
656 release_resource_readback(&rb_threadid);
657 reset_command_list(command_list, context.allocator);
659 for (i = 0; i < 4; ++i)
660 ID3D12Resource_Release(textures[i]);
661 ID3D12DescriptorHeap_Release(heap);
662 destroy_test_context(&context);
665 static void test_create_blob(void)
667 unsigned int refcount;
668 ID3D10Blob *blob;
669 HRESULT hr;
671 hr = D3DCreateBlob(1, NULL);
672 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
674 hr = D3DCreateBlob(0, NULL);
675 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
677 hr = D3DCreateBlob(0, &blob);
678 ok(hr == S_OK, "Got hr %#x.\n", hr);
680 refcount = ID3D10Blob_Release(blob);
681 ok(!refcount, "Got refcount %u.\n", refcount);
684 static void test_get_blob_part(void)
686 static uint32_t test_blob_part[] =
688 /* test_blob_part - fxc.exe /E VS /Tvs_4_0_level_9_0 /Fx */
689 #if 0
690 float4 VS(float4 position : POSITION, float4 pos : SV_POSITION) : SV_POSITION
692 return position;
694 #endif
695 0x43425844, 0x0ef2a70f, 0x6a548011, 0x91ff9409, 0x9973a43d, 0x00000001, 0x000002e0, 0x00000008,
696 0x00000040, 0x0000008c, 0x000000d8, 0x0000013c, 0x00000180, 0x000001fc, 0x00000254, 0x000002ac,
697 0x53414e58, 0x00000044, 0x00000044, 0xfffe0200, 0x00000020, 0x00000024, 0x00240000, 0x00240000,
698 0x00240000, 0x00240000, 0x00240000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x02000001,
699 0xc00f0000, 0x80e40000, 0x0000ffff, 0x50414e58, 0x00000044, 0x00000044, 0xfffe0200, 0x00000020,
700 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0xfffe0200, 0x0200001f,
701 0x80000005, 0x900f0000, 0x02000001, 0xc00f0000, 0x80e40000, 0x0000ffff, 0x396e6f41, 0x0000005c,
702 0x0000005c, 0xfffe0200, 0x00000034, 0x00000028, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
703 0x00240001, 0x00000000, 0xfffe0200, 0x0200001f, 0x80000005, 0x900f0000, 0x04000004, 0xc0030000,
704 0x90ff0000, 0xa0e40000, 0x90e40000, 0x02000001, 0xc00c0000, 0x90e40000, 0x0000ffff, 0x52444853,
705 0x0000003c, 0x00010040, 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2,
706 0x00000000, 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
707 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000,
708 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
709 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
710 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452,
711 0x00000050, 0x00000000, 0x00000000, 0x00000000, 0x0000001c, 0xfffe0400, 0x00000100, 0x0000001c,
712 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d,
713 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000050, 0x00000002,
714 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041,
715 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x49534f50, 0x4e4f4954, 0x5f565300,
716 0x49534f50, 0x4e4f4954, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
717 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
720 static uint32_t test_blob_part2[] =
722 /* test_blob_part2 - fxc.exe /E BHS /Ths_5_0 /Zi */
723 #if 0
724 struct VSO { float3 p : POSITION; };
725 struct HSDO { float e[4] : SV_TessFactor; float i[2] : SV_InsideTessFactor; };
726 struct HSO { float3 p : BEZIERPOS; };
727 HSDO BCHS( InputPatch<VSO, 8> ip, uint PatchID : SV_PrimitiveID )
729 HSDO res;
730 res.e[0] = res.e[1] = res.e[2] = res.e[3] = 1.0f;
731 res.i[0] = res.i[1] = 1.0f;
732 return res;
734 [domain("quad")]
735 [partitioning("integer")]
736 [outputtopology("triangle_cw")]
737 [outputcontrolpoints(8)]
738 [patchconstantfunc("BCHS")]
739 HSO BHS( InputPatch<VSO, 8> p, uint i : SV_OutputControlPointID, uint PatchID : SV_PrimitiveID )
741 HSO res;
742 res.p = p[i].p;
743 return res;
745 #endif
746 0x43425844, 0xa9d455ae, 0x4cf9c0df, 0x4cf806dc, 0xc57a8c2c, 0x00000001, 0x0000139b, 0x00000007,
747 0x0000003c, 0x000000b4, 0x000000e8, 0x0000011c, 0x000001e0, 0x00000320, 0x000003bc, 0x46454452,
748 0x00000070, 0x00000000, 0x00000000, 0x00000000, 0x0000003c, 0x48530500, 0x00000101, 0x0000003c,
749 0x31314452, 0x0000003c, 0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000000,
750 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d,
751 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x0000002c, 0x00000001,
752 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x49534f50,
753 0x4e4f4954, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000,
754 0x00000000, 0x00000003, 0x00000000, 0x00000807, 0x495a4542, 0x4f505245, 0xabab0053, 0x47534350,
755 0x000000bc, 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x0000000b, 0x00000003, 0x00000000,
756 0x00000e01, 0x00000098, 0x00000001, 0x0000000b, 0x00000003, 0x00000001, 0x00000e01, 0x00000098,
757 0x00000002, 0x0000000b, 0x00000003, 0x00000002, 0x00000e01, 0x00000098, 0x00000003, 0x0000000b,
758 0x00000003, 0x00000003, 0x00000e01, 0x000000a6, 0x00000000, 0x0000000c, 0x00000003, 0x00000004,
759 0x00000e01, 0x000000a6, 0x00000001, 0x0000000c, 0x00000003, 0x00000005, 0x00000e01, 0x545f5653,
760 0x46737365, 0x6f746361, 0x56530072, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0xabab0072,
761 0x58454853, 0x00000138, 0x00030050, 0x0000004e, 0x01000071, 0x01004093, 0x01004094, 0x01001895,
762 0x01000896, 0x01001897, 0x0100086a, 0x01000073, 0x02000099, 0x00000004, 0x0200005f, 0x00017000,
763 0x04000067, 0x00102012, 0x00000000, 0x0000000b, 0x04000067, 0x00102012, 0x00000001, 0x0000000c,
764 0x04000067, 0x00102012, 0x00000002, 0x0000000d, 0x04000067, 0x00102012, 0x00000003, 0x0000000e,
765 0x02000068, 0x00000001, 0x0400005b, 0x00102012, 0x00000000, 0x00000004, 0x04000036, 0x00100012,
766 0x00000000, 0x0001700a, 0x06000036, 0x00902012, 0x0010000a, 0x00000000, 0x00004001, 0x3f800000,
767 0x0100003e, 0x01000073, 0x02000099, 0x00000002, 0x0200005f, 0x00017000, 0x04000067, 0x00102012,
768 0x00000004, 0x0000000f, 0x04000067, 0x00102012, 0x00000005, 0x00000010, 0x02000068, 0x00000001,
769 0x0400005b, 0x00102012, 0x00000004, 0x00000002, 0x04000036, 0x00100012, 0x00000000, 0x0001700a,
770 0x07000036, 0x00d02012, 0x00000004, 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x0100003e,
771 0x54415453, 0x00000094, 0x00000006, 0x00000001, 0x00000000, 0x00000005, 0x00000000, 0x00000000,
772 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
773 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
774 0x00000000, 0x0000000f, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
775 0x00000008, 0x00000003, 0x00000001, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x47424453,
776 0x00000fd7, 0x00000054, 0x000002d5, 0x00000306, 0x0000030a, 0x00000101, 0x00000001, 0x00000000,
777 0x00000006, 0x00000010, 0x00000006, 0x00000958, 0x00000000, 0x000009e8, 0x00000008, 0x000009e8,
778 0x00000006, 0x00000a88, 0x00000007, 0x00000b00, 0x00000c34, 0x00000c64, 0x00000000, 0x0000004a,
779 0x0000004a, 0x0000026a, 0x00000000, 0x00000036, 0x00000001, 0x00000004, 0x00000000, 0xffffffff,
780 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 0x00000003, 0x00000000,
781 0x00000003, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000,
782 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000,
783 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
784 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
785 0xffffffff, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
786 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
787 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
788 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
789 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000,
790 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000007,
791 0x00000000, 0x00000003, 0x00000024, 0x00000000, 0x00000000, 0x00000001, 0x00000036, 0x00000001,
792 0x00000001, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000,
793 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x00000000, 0x00000000,
794 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
795 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
796 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
797 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000,
798 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000,
799 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000,
800 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000,
801 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
802 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
803 0x00000000, 0x00000000, 0x00000007, 0x00000000, 0x00000003, 0x00000024, 0x00000000, 0x00000000,
804 0x00000002, 0x0000003e, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000,
805 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
806 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
807 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000,
808 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000,
809 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
810 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
811 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
812 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
813 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
814 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
815 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000007, 0x00000000, 0x00000003,
816 0x00000024, 0x00000000, 0x00000000, 0x00000003, 0x00000036, 0x00000001, 0x00000004, 0x00000000,
817 0xffffffff, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 0x00000001,
818 0x00000000, 0x00000001, 0x80000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000,
819 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
820 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
821 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
822 0x00000000, 0xffffffff, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000,
823 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
824 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
825 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000,
826 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000,
827 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
828 0x00000007, 0x00000000, 0x00000003, 0x00000024, 0x00000000, 0x00000000, 0x00000004, 0x00000036,
829 0x00000001, 0x00000001, 0x00000004, 0xffffffff, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff,
830 0x00000004, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, 0x00000000,
831 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
832 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
833 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
834 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
835 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000,
836 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000,
837 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff,
838 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
839 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
840 0x00000000, 0x00000000, 0x00000000, 0x00000007, 0x00000000, 0x00000003, 0x00000024, 0x00000000,
841 0x00000000, 0x00000005, 0x0000003e, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000,
842 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
843 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000,
844 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000,
845 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000,
846 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
847 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
848 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
849 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
850 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
851 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
852 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000007, 0x00000000,
853 0x00000003, 0x00000024, 0x00000000, 0x00000000, 0x00000006, 0x00000003, 0xffffffff, 0xffffffff,
854 0x00000003, 0x00000000, 0x00000006, 0x00000003, 0xffffffff, 0xffffffff, 0x00000003, 0x00000001,
855 0x00000006, 0x00000003, 0xffffffff, 0xffffffff, 0x00000003, 0x00000002, 0x00000006, 0x00000003,
856 0xffffffff, 0xffffffff, 0x00000003, 0x00000003, 0x00000006, 0x00000003, 0xffffffff, 0xffffffff,
857 0x00000003, 0x00000004, 0x00000006, 0x00000003, 0xffffffff, 0xffffffff, 0x00000003, 0x00000005,
858 0x00000000, 0x00000002, 0x00000014, 0x00000007, 0x000002c1, 0x00000000, 0x00000002, 0x00000030,
859 0x00000007, 0x000002c8, 0x00000000, 0x00000004, 0x0000001e, 0x00000002, 0x00000102, 0x00000000,
860 0x00000004, 0x00000027, 0x00000007, 0x0000010b, 0x00000000, 0x00000006, 0x00000009, 0x00000003,
861 0x00000131, 0x00000000, 0x00000001, 0x00000014, 0x00000006, 0x000002cf, 0x00000000, 0x00000004,
862 0x00000005, 0x00000004, 0x000000e9, 0x00000000, 0x00000009, 0x00000004, 0x00000000, 0x00000000,
863 0x00000003, 0x00000051, 0x00000003, 0x00000001, 0x00000000, 0x00000003, 0x00000076, 0x00000004,
864 0x00000002, 0x00000004, 0x00000000, 0x000002b4, 0x00000007, 0x00000001, 0x0000000c, 0x00000003,
865 0x00000076, 0x00000004, 0x00000002, 0x00000004, 0x00000001, 0x000002bb, 0x00000006, 0x00000001,
866 0x00000010, 0x00000004, 0x000000e9, 0x00000004, 0x00000003, 0x00000014, 0x00000005, 0x00000000,
867 0x00000001, 0x00000001, 0x00000003, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000003,
868 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0xffffffff, 0x00000001,
869 0x00000014, 0x00000004, 0x00000004, 0xffffffff, 0x00000001, 0x00000000, 0x00000000, 0x00000001,
870 0x00000001, 0xffffffff, 0x00000001, 0x00000008, 0x00000004, 0x00000002, 0xffffffff, 0x00000006,
871 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
872 0x00000006, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
873 0x00000001, 0x00000020, 0x0000000c, 0x00000018, 0xffffffff, 0x00000003, 0x00000000, 0x00000000,
874 0x00000001, 0x00000001, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0xffffffff,
875 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000,
876 0x00000000, 0x00000006, 0xffffffff, 0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000006,
877 0x00000004, 0x00000005, 0x00000006, 0x00000008, 0x00000004, 0x00000005, 0x00000002, 0x505c3a43,
878 0x72676f72, 0x656d6d61, 0x63694d5c, 0x6f736f72, 0x44207466, 0x63657269, 0x53205874, 0x28204b44,
879 0x656e754a, 0x31303220, 0x555c2930, 0x696c6974, 0x73656974, 0x6e69625c, 0x3638785c, 0x6165685c,
880 0x2e726564, 0x74737866, 0x74637572, 0x4f535620, 0x66207b20, 0x74616f6c, 0x20702033, 0x4f50203a,
881 0x49544953, 0x203b4e4f, 0x730a3b7d, 0x63757274, 0x53482074, 0x7b204f44, 0x6f6c6620, 0x65207461,
882 0x205d345b, 0x5653203a, 0x7365545f, 0x63614673, 0x3b726f74, 0x6f6c6620, 0x69207461, 0x205d325b,
883 0x5653203a, 0x736e495f, 0x54656469, 0x46737365, 0x6f746361, 0x7d203b72, 0x74730a3b, 0x74637572,
884 0x4f534820, 0x66207b20, 0x74616f6c, 0x20702033, 0x4542203a, 0x5245495a, 0x3b534f50, 0x0a3b7d20,
885 0x4f445348, 0x48434220, 0x49202853, 0x7475706e, 0x63746150, 0x53563c68, 0x38202c4f, 0x7069203e,
886 0x6975202c, 0x5020746e, 0x68637461, 0x3a204449, 0x5f565320, 0x6d697250, 0x76697469, 0x20444965,
887 0x0a7b0a29, 0x20202020, 0x4f445348, 0x73657220, 0x20200a3b, 0x65722020, 0x5b652e73, 0x3d205d30,
888 0x73657220, 0x315b652e, 0x203d205d, 0x2e736572, 0x5d325b65, 0x72203d20, 0x652e7365, 0x205d335b,
889 0x2e31203d, 0x0a3b6630, 0x20202020, 0x2e736572, 0x5d305b69, 0x72203d20, 0x692e7365, 0x205d315b,
890 0x2e31203d, 0x0a3b6630, 0x20202020, 0x75746572, 0x72206e72, 0x0a3b7365, 0x645b0a7d, 0x69616d6f,
891 0x7122286e, 0x22646175, 0x5b0a5d29, 0x74726170, 0x6f697469, 0x676e696e, 0x6e692228, 0x65676574,
892 0x5d292272, 0x756f5b0a, 0x74757074, 0x6f706f74, 0x79676f6c, 0x72742228, 0x676e6169, 0x635f656c,
893 0x5d292277, 0x756f5b0a, 0x74757074, 0x746e6f63, 0x706c6f72, 0x746e696f, 0x29382873, 0x705b0a5d,
894 0x68637461, 0x736e6f63, 0x746e6174, 0x636e7566, 0x43422228, 0x29225348, 0x53480a5d, 0x4842204f,
895 0x49202853, 0x7475706e, 0x63746150, 0x53563c68, 0x38202c4f, 0x2c70203e, 0x6e697520, 0x20692074,
896 0x5653203a, 0x74754f5f, 0x43747570, 0x72746e6f, 0x6f506c6f, 0x49746e69, 0x75202c44, 0x20746e69,
897 0x63746150, 0x20444968, 0x5653203a, 0x6972505f, 0x6974696d, 0x44496576, 0x7b0a2920, 0x2020200a,
898 0x4f534820, 0x73657220, 0x20200a3b, 0x65722020, 0x20702e73, 0x5b70203d, 0x702e5d69, 0x20200a3b,
899 0x65722020, 0x6e727574, 0x73657220, 0x0a7d0a3b, 0x626f6c47, 0x4c736c61, 0x6c61636f, 0x44534873,
900 0x653a3a4f, 0x4f445348, 0x56693a3a, 0x3a3a4f53, 0x63694d70, 0x6f736f72, 0x28207466, 0x48202952,
901 0x204c534c, 0x64616853, 0x43207265, 0x69706d6f, 0x2072656c, 0x39322e39, 0x3235392e, 0x3131332e,
902 0x48420031, 0x73680053, 0x305f355f, 0x6e6f6320, 0x6c6f7274, 0x696f7020, 0x0000746e,
905 static const D3D_BLOB_PART parts[] =
907 D3D_BLOB_INPUT_SIGNATURE_BLOB,
908 D3D_BLOB_OUTPUT_SIGNATURE_BLOB,
909 D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB,
910 D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB,
911 D3D_BLOB_ALL_SIGNATURE_BLOB,
912 D3D_BLOB_DEBUG_INFO,
913 D3D_BLOB_LEGACY_SHADER,
914 D3D_BLOB_XNA_PREPASS_SHADER,
915 D3D_BLOB_XNA_SHADER,
916 D3D_BLOB_TEST_ALTERNATE_SHADER,
917 D3D_BLOB_TEST_COMPILE_DETAILS,
918 D3D_BLOB_TEST_COMPILE_PERF,
921 unsigned int refcount, size, i;
922 ID3DBlob *blob, *blob2;
923 uint32_t *u32;
924 HRESULT hr;
926 hr = D3DCreateBlob(1, &blob2);
927 ok(hr == S_OK, "Got hr %#x.\n", hr);
928 blob = blob2;
930 /* Invalid cases. */
931 hr = D3DGetBlobPart(NULL, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
932 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
933 ok(blob == blob2, "Got blob %p, expected %p.\n", blob, blob2);
935 hr = D3DGetBlobPart(NULL, 0, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
936 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
937 ok(blob == blob2, "Got blob %p, expected %p.\n", blob, blob2);
939 hr = D3DGetBlobPart(NULL, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, NULL);
940 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
942 hr = D3DGetBlobPart(NULL, 0, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, NULL);
943 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
945 hr = D3DGetBlobPart(test_blob_part, 0, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
946 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
947 ok(blob == blob2, "Got blob %p, expected %p.\n", blob, blob2);
949 hr = D3DGetBlobPart(test_blob_part, 7 * sizeof(DWORD), D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
950 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
951 ok(blob == blob2, "Got blob %p, expected %p.\n", blob, blob2);
953 hr = D3DGetBlobPart(test_blob_part, 8 * sizeof(DWORD), D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
954 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
955 ok(blob == blob2, "Got blob %p, expected %p.\n", blob, blob2);
957 hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, NULL);
958 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
960 hr = D3DGetBlobPart(test_blob_part, 0, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, NULL);
961 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
963 hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 1, &blob);
964 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
965 ok(blob2 == blob, "D3DGetBlobPart failed got %p, expected %p\n", blob, blob2);
967 hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], 0xffffffff, 0, &blob);
968 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
969 ok(blob == blob2, "Got blob %p, expected %p.\n", blob, blob2);
971 refcount = ID3D10Blob_Release(blob2);
972 ok(!refcount, "Got refcount %u.\n", refcount);
974 /* D3D_BLOB_INPUT_SIGNATURE_BLOB */
975 hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, &blob);
976 ok(hr == S_OK, "Got hr %#x.\n", hr);
978 size = ID3D10Blob_GetBufferSize(blob);
979 ok(size == 124, "Got size %u.\n", size);
981 u32 = ID3D10Blob_GetBufferPointer(blob);
982 ok(u32[0] == TAG_DXBC, "Got u32[0] 0x%08x, expected 0x%08x.\n", u32[0], TAG_DXBC);
983 ok(u32[9] == TAG_ISGN, "Got u32[9] 0x%08x, expected 0x%08x.\n", u32[9], TAG_ISGN);
985 for (i = 0; i < ARRAY_SIZE(parts); ++i)
987 vkd3d_test_push_context("Part %#x", parts[i]);
988 hr = D3DGetBlobPart(u32, size, parts[i], 0, &blob2);
990 if (parts[i] == D3D_BLOB_INPUT_SIGNATURE_BLOB)
992 ok(hr == S_OK, "Got hr %#x.\n", hr);
994 refcount = ID3D10Blob_Release(blob2);
995 ok(!refcount, "Got refcount %u.\n", refcount);
997 else
999 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1001 vkd3d_test_pop_context();
1004 refcount = ID3D10Blob_Release(blob);
1005 ok(!refcount, "Got refcount %u.\n", refcount);
1007 /* D3D_BLOB_OUTPUT_SIGNATURE_BLOB */
1008 hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_OUTPUT_SIGNATURE_BLOB, 0, &blob);
1009 ok(hr == S_OK, "Got hr %#x.\n", hr);
1011 size = ID3D10Blob_GetBufferSize(blob);
1012 ok(size == 88, "Got size %u.\n", size);
1014 u32 = ID3D10Blob_GetBufferPointer(blob);
1015 ok(u32[0] == TAG_DXBC, "Got u32[0] 0x%08x, expected 0x%08x.\n", u32[0], TAG_DXBC);
1016 ok(u32[9] == TAG_OSGN, "Got u32[9] 0x%08x, expected 0x%08x.\n", u32[9], TAG_OSGN);
1018 for (i = 0; i < ARRAY_SIZE(parts); ++i)
1020 vkd3d_test_push_context("Part %#x", parts[i]);
1021 hr = D3DGetBlobPart(u32, size, parts[i], 0, &blob2);
1023 if (parts[i] == D3D_BLOB_OUTPUT_SIGNATURE_BLOB)
1025 ok(hr == S_OK, "Got hr %#x.\n", hr);
1027 refcount = ID3D10Blob_Release(blob2);
1028 ok(!refcount, "Got refcount %u.\n", refcount);
1030 else
1032 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1034 vkd3d_test_pop_context();
1037 refcount = ID3D10Blob_Release(blob);
1038 ok(!refcount, "Got refcount %u.\n", refcount);
1040 /* D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB */
1041 hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB, 0, &blob);
1042 ok(hr == S_OK, "Got hr %#x.\n", hr);
1044 size = ID3D10Blob_GetBufferSize(blob);
1045 ok(size == 180, "Got size %u.\n", size);
1047 u32 = ID3D10Blob_GetBufferPointer(blob);
1048 ok(u32[0] == TAG_DXBC, "Got u32[0] 0x%08x, expected 0x%08x.\n", u32[0], TAG_DXBC);
1049 ok(u32[10] == TAG_ISGN, "Got u32[10] 0x%08x, expected 0x%08x.\n", u32[10], TAG_ISGN);
1050 ok(u32[32] == TAG_OSGN, "Got u32[32] 0x%08x, expected 0x%08x.\n", u32[10], TAG_OSGN);
1052 for (i = 0; i < ARRAY_SIZE(parts); ++i)
1054 vkd3d_test_push_context("Part %#x", parts[i]);
1055 hr = D3DGetBlobPart(u32, size, parts[i], 0, &blob2);
1057 if (parts[i] == D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB
1058 || parts[i] == D3D_BLOB_INPUT_SIGNATURE_BLOB
1059 || parts[i] == D3D_BLOB_OUTPUT_SIGNATURE_BLOB)
1061 ok(hr == S_OK, "Got hr %#x.\n", hr);
1063 refcount = ID3D10Blob_Release(blob2);
1064 ok(!refcount, "Got refcount %u.\n", refcount);
1066 else
1068 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1070 vkd3d_test_pop_context();
1073 refcount = ID3D10Blob_Release(blob);
1074 ok(!refcount, "Got refcount %u.\n", refcount);
1076 /* D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB */
1077 hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB, 0, &blob);
1078 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1080 /* D3D_BLOB_ALL_SIGNATURE_BLOB */
1081 hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_ALL_SIGNATURE_BLOB, 0, &blob);
1082 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1084 /* D3D_BLOB_DEBUG_INFO */
1085 hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_DEBUG_INFO, 0, &blob);
1086 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1088 /* D3D_BLOB_LEGACY_SHADER */
1089 hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_LEGACY_SHADER, 0, &blob);
1090 ok(hr == S_OK, "Got hr %#x.\n", hr);
1092 size = ID3D10Blob_GetBufferSize(blob);
1093 ok(size == 92, "Got size %u.\n", size);
1095 u32 = ID3D10Blob_GetBufferPointer(blob);
1096 ok(u32[0] != TAG_DXBC, "Got u32[0] 0x%08x.\n", u32[0]);
1098 for (i = 0; i < ARRAY_SIZE(parts); ++i)
1100 vkd3d_test_push_context("Part %#x", parts[i]);
1101 /* D3D_BLOB_LEGACY_SHADER doesn't return a full DXBC blob. */
1102 hr = D3DGetBlobPart(u32, size, parts[i], 0, &blob2);
1103 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
1104 vkd3d_test_pop_context();
1107 refcount = ID3D10Blob_Release(blob);
1108 ok(!refcount, "Got refcount %u.\n", refcount);
1110 /* D3D_BLOB_XNA_PREPASS_SHADER */
1111 hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_XNA_PREPASS_SHADER, 0, &blob);
1112 ok(hr == S_OK, "Got hr %#x.\n", hr);
1114 size = ID3D10Blob_GetBufferSize(blob);
1115 ok(size == 68, "Got size %u.\n", size);
1117 u32 = ID3D10Blob_GetBufferPointer(blob);
1118 ok(u32[0] != TAG_DXBC, "Got u32[0] 0x%08x.\n", u32[0]);
1120 for (i = 0; i < ARRAY_SIZE(parts); ++i)
1122 vkd3d_test_push_context("Part %#x", parts[i]);
1123 /* D3D_BLOB_XNA_PREPASS_SHADER doesn't return a full DXBC blob. */
1124 hr = D3DGetBlobPart(u32, size, parts[i], 0, &blob2);
1125 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
1126 vkd3d_test_pop_context();
1129 refcount = ID3D10Blob_Release(blob);
1130 ok(!refcount, "Got refcount %u.\n", refcount);
1132 /* D3D_BLOB_XNA_SHADER */
1133 hr = D3DGetBlobPart(test_blob_part, test_blob_part[6], D3D_BLOB_XNA_SHADER, 0, &blob);
1134 ok(hr == S_OK, "Got hr %#x.\n", hr);
1136 size = ID3D10Blob_GetBufferSize(blob);
1137 ok(size == 68, "Got size %u.\n", size);
1139 u32 = ID3D10Blob_GetBufferPointer(blob);
1140 ok(u32[0] != TAG_DXBC, "Got u32[0] 0x%08x.\n", u32[0]);
1142 for (i = 0; i < ARRAY_SIZE(parts); ++i)
1144 vkd3d_test_push_context("Part %#x", parts[i]);
1145 /* D3D_BLOB_XNA_SHADER doesn't return a full DXBC blob. */
1146 hr = D3DGetBlobPart(u32, size, parts[i], 0, &blob2);
1147 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
1148 vkd3d_test_pop_context();
1151 refcount = ID3D10Blob_Release(blob);
1152 ok(!refcount, "Got refcount %u.\n", refcount);
1154 /* D3DStripShader() corner cases. */
1155 hr = D3DStripShader(test_blob_part, test_blob_part[6], 0xffffffff, &blob);
1156 ok(hr == S_OK, "Got hr %#x.\n", hr);
1158 refcount = ID3D10Blob_Release(blob);
1159 ok(!refcount, "Got refcount %u.\n", refcount);
1161 hr = D3DStripShader(test_blob_part, test_blob_part[6], 0, &blob);
1162 ok(hr == S_OK, "Got hr %#x.\n", hr);
1164 refcount = ID3D10Blob_Release(blob);
1165 ok(!refcount, "Got refcount %u.\n", refcount);
1167 hr = D3DStripShader(NULL, test_blob_part[6], 0, &blob);
1168 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
1170 hr = D3DStripShader(test_blob_part, 7 * sizeof(DWORD), 0, &blob);
1171 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
1173 hr = D3DStripShader(test_blob_part, 8 * sizeof(DWORD), 0, &blob);
1174 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
1176 hr = D3DStripShader(test_blob_part, test_blob_part[6], 0, NULL);
1177 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1179 hr = D3DStripShader(NULL, test_blob_part[6], 0, NULL);
1180 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1182 hr = D3DStripShader(test_blob_part, 0, 0, NULL);
1183 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1185 /* D3DCOMPILER_STRIP_DEBUG_INFO */
1186 hr = D3DStripShader(test_blob_part, test_blob_part[6], D3DCOMPILER_STRIP_DEBUG_INFO, &blob);
1187 ok(hr == S_OK, "Got hr %#x.\n", hr);
1189 size = ID3D10Blob_GetBufferSize(blob);
1190 ok(size == 736, "Got size %u.\n", size);
1192 u32 = ID3D10Blob_GetBufferPointer(blob);
1193 ok(u32[0] == TAG_DXBC, "Got u32[0] 0x%08x, expected 0x%08x.\n", u32[0], TAG_DXBC);
1194 ok(u32[16] == TAG_XNAS, "Got u32[16] 0x%08x, expected 0x%08x.\n", u32[16], TAG_XNAS);
1195 ok(u32[35] == TAG_XNAP, "Got u32[35] 0x%08x, expected 0x%08x.\n", u32[35], TAG_XNAP);
1196 ok(u32[54] == TAG_AON9, "Got u32[54] 0x%08x, expected 0x%08x.\n", u32[54], TAG_AON9);
1197 ok(u32[79] == TAG_SHDR, "Got u32[79] 0x%08x, expected 0x%08x.\n", u32[79], TAG_SHDR);
1198 ok(u32[96] == TAG_STAT, "Got u32[96] 0x%08x, expected 0x%08x.\n", u32[96], TAG_STAT);
1199 ok(u32[127] == TAG_RDEF, "Got u32[127] 0x%08x, expected 0x%08x.\n", u32[127], TAG_RDEF);
1200 ok(u32[149] == TAG_ISGN, "Got u32[149] 0x%08x, expected 0x%08x.\n", u32[149], TAG_ISGN);
1201 ok(u32[171] == TAG_OSGN, "Got u32[171] 0x%08x, expected 0x%08x.\n", u32[171], TAG_OSGN);
1203 hr = D3DGetBlobPart(u32, size, D3D_BLOB_DEBUG_INFO, 0, &blob2);
1204 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1206 refcount = ID3D10Blob_Release(blob);
1207 ok(!refcount, "Got refcount %u.\n", refcount);
1209 /* D3DCOMPILER_STRIP_REFLECTION_DATA */
1210 hr = D3DStripShader(test_blob_part, test_blob_part[6], D3DCOMPILER_STRIP_REFLECTION_DATA, &blob);
1211 ok(hr == S_OK, "Got hr %#x.\n", hr);
1213 size = ID3D10Blob_GetBufferSize(blob);
1214 ok(size == 516, "Got size %u.\n", size);
1216 u32 = ID3D10Blob_GetBufferPointer(blob);
1217 ok(u32[0] == TAG_DXBC, "Got u32[0] 0x%08x, expected 0x%08x.\n", u32[0], TAG_DXBC);
1218 ok(u32[14] == TAG_XNAS, "Got u32[14] 0x%08x, expected 0x%08x.\n", u32[14], TAG_XNAS);
1219 ok(u32[33] == TAG_XNAP, "Got u32[33] 0x%08x, expected 0x%08x.\n", u32[33], TAG_XNAP);
1220 ok(u32[52] == TAG_AON9, "Got u32[52] 0x%08x, expected 0x%08x.\n", u32[52], TAG_AON9);
1221 ok(u32[77] == TAG_SHDR, "Got u32[77] 0x%08x, expected 0x%08x.\n", u32[77], TAG_SHDR);
1222 ok(u32[94] == TAG_ISGN, "Got u32[94] 0x%08x, expected 0x%08x.\n", u32[94], TAG_ISGN);
1223 ok(u32[116] == TAG_OSGN, "Got u32[116] 0x%08x, expected 0x%08x.\n", u32[116], TAG_OSGN);
1225 refcount = ID3D10Blob_Release(blob);
1226 ok(!refcount, "Got refcount %u.\n", refcount);
1228 /* D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB */
1229 hr = D3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB, 0, &blob);
1230 ok(hr == S_OK, "Got hr %#x.\n", hr);
1232 size = ID3D10Blob_GetBufferSize(blob);
1233 ok(size == 232, "Got size %u.\n", size);
1235 u32 = ID3D10Blob_GetBufferPointer(blob);
1236 ok(u32[0] == TAG_DXBC, "Got u32[0] 0x%08x, expected 0x%08x.\n", u32[0], TAG_DXBC);
1237 ok(u32[9] == TAG_PCSG, "Got u32[9] 0x%08x, expected 0x%08x.\n", u32[9], TAG_PCSG);
1239 for (i = 0; i < ARRAY_SIZE(parts); ++i)
1241 vkd3d_test_push_context("Part %#x", parts[i]);
1242 hr = D3DGetBlobPart(u32, size, parts[i], 0, &blob2);
1244 if (parts[i] == D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB)
1246 ok(hr == S_OK, "Got hr %#x.\n", hr);
1248 refcount = ID3D10Blob_Release(blob2);
1249 ok(!refcount, "Got refcount %u.\n", refcount);
1251 else
1253 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1255 vkd3d_test_pop_context();
1258 refcount = ID3D10Blob_Release(blob);
1259 ok(!refcount, "Got refcount %u.\n", refcount);
1261 /* D3D_BLOB_ALL_SIGNATURE_BLOB */
1262 hr = D3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_ALL_SIGNATURE_BLOB, 0, &blob);
1263 ok(hr == S_OK, "Got hr %#x.\n", hr);
1265 size = ID3D10Blob_GetBufferSize(blob);
1266 ok(size == 344, "Got size %u.\n", size);
1268 u32 = ID3D10Blob_GetBufferPointer(blob);
1269 ok(u32[0] == TAG_DXBC, "Got u32[0] 0x%08x, expected 0x%08x.\n", u32[0], TAG_DXBC);
1270 ok(u32[11] == TAG_ISGN, "Got u32[11] 0x%08x, expected 0x%08x.\n", u32[11], TAG_ISGN);
1271 ok(u32[24] == TAG_OSGN, "Got u32[24] 0x%08x, expected 0x%08x.\n", u32[24], TAG_OSGN);
1272 ok(u32[37] == TAG_PCSG, "Got u32[37] 0x%08x, expected 0x%08x.\n", u32[37], TAG_PCSG);
1274 for (i = 0; i < ARRAY_SIZE(parts); ++i)
1276 vkd3d_test_push_context("Part %#x", parts[i]);
1277 hr = D3DGetBlobPart(u32, size, parts[i], 0, &blob2);
1279 if (parts[i] == D3D_BLOB_ALL_SIGNATURE_BLOB
1280 || parts[i] == D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB
1281 || parts[i] == D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB
1282 || parts[i] == D3D_BLOB_INPUT_SIGNATURE_BLOB
1283 || parts[i] == D3D_BLOB_OUTPUT_SIGNATURE_BLOB)
1285 ok(hr == S_OK, "Got hr %#x.\n", hr);
1287 refcount = ID3D10Blob_Release(blob2);
1288 ok(!refcount, "Got refcount %u.\n", refcount);
1290 else
1292 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1294 vkd3d_test_pop_context();
1297 refcount = ID3D10Blob_Release(blob);
1298 ok(!refcount, "Got refcount %u.\n", refcount);
1300 /* D3D_BLOB_DEBUG_INFO */
1301 hr = D3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_DEBUG_INFO, 0, &blob);
1302 ok(hr == S_OK, "Got hr %#x.\n", hr);
1304 size = ID3D10Blob_GetBufferSize(blob);
1305 ok(size == 4055, "Got size %u.\n", size);
1307 u32 = ID3D10Blob_GetBufferPointer(blob);
1308 ok(u32[0] != TAG_DXBC, "Got u32[0] 0x%08x.\n", u32[0]);
1310 for (i = 0; i < ARRAY_SIZE(parts); ++i)
1312 vkd3d_test_push_context("Part %#x", parts[i]);
1313 /* D3D_BLOB_DEBUG_INFO doesn't return a full DXBC blob. */
1314 hr = D3DGetBlobPart(u32, size, parts[i], 0, &blob2);
1315 ok(hr == D3DERR_INVALIDCALL, "Got hr %#x.\n", hr);
1316 vkd3d_test_pop_context();
1319 refcount = ID3D10Blob_Release(blob);
1320 ok(!refcount, "Got refcount %u.\n", refcount);
1322 /* D3D_BLOB_LEGACY_SHADER */
1323 hr = D3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_LEGACY_SHADER, 0, &blob);
1324 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1326 /* D3D_BLOB_XNA_PREPASS_SHADER */
1327 hr = D3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_XNA_PREPASS_SHADER, 0, &blob);
1328 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1330 /* D3D_BLOB_XNA_SHADER */
1331 hr = D3DGetBlobPart(test_blob_part2, test_blob_part2[6], D3D_BLOB_XNA_SHADER, 0, &blob);
1332 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1334 /* D3DCOMPILER_STRIP_DEBUG_INFO */
1335 hr = D3DStripShader(test_blob_part2, test_blob_part2[6], D3DCOMPILER_STRIP_DEBUG_INFO, &blob);
1336 ok(hr == S_OK, "Got hr %#x.\n", hr);
1338 size = ID3D10Blob_GetBufferSize(blob);
1339 ok(size == 952, "Got size %u.\n", size);
1341 u32 = ID3D10Blob_GetBufferPointer(blob);
1342 ok(u32[0] == TAG_DXBC, "Got u32[0] 0x%08x, expected 0x%08x.\n", u32[0], TAG_DXBC);
1343 ok(u32[14] == TAG_RDEF, "Got u32[14] 0x%08x, expected 0x%08x.\n", u32[14], TAG_RDEF);
1344 ok(u32[44] == TAG_ISGN, "Got u32[44] 0x%08x, expected 0x%08x.\n", u32[44], TAG_ISGN);
1345 ok(u32[57] == TAG_OSGN, "Got u32[57] 0x%08x, expected 0x%08x.\n", u32[57], TAG_OSGN);
1346 ok(u32[70] == TAG_PCSG, "Got u32[70] 0x%08x, expected 0x%08x.\n", u32[70], TAG_PCSG);
1347 ok(u32[119] == TAG_SHEX, "Got u32[119] 0x%08x, expected 0x%08x.\n", u32[119], TAG_SHEX);
1348 ok(u32[199] == TAG_STAT, "Got u32[199] 0x%08x, expected 0x%08x.\n", u32[199], TAG_STAT);
1350 hr = D3DGetBlobPart(u32, size, D3D_BLOB_DEBUG_INFO, 0, &blob2);
1351 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1353 refcount = ID3D10Blob_Release(blob);
1354 ok(!refcount, "Got refcount %u.\n", refcount);
1356 /* D3DCOMPILER_STRIP_REFLECTION_DATA */
1357 hr = D3DStripShader(test_blob_part2, test_blob_part2[6], D3DCOMPILER_STRIP_REFLECTION_DATA, &blob);
1358 ok(hr == S_OK, "Got hr %#x.\n", hr);
1360 size = ID3D10Blob_GetBufferSize(blob);
1361 ok(size == 4735, "Got size %u.\n", size);
1363 u32 = ID3D10Blob_GetBufferPointer(blob);
1364 ok(u32[0] == TAG_DXBC, "Got u32[0] 0x%08x, expected 0x%08x.\n", u32[0], TAG_DXBC);
1365 ok(u32[13] == TAG_ISGN, "Got u32[13] 0x%08x, expected 0x%08x.\n", u32[13], TAG_ISGN);
1366 ok(u32[26] == TAG_OSGN, "Got u32[26] 0x%08x, expected 0x%08x.\n", u32[26], TAG_OSGN);
1367 ok(u32[39] == TAG_PCSG, "Got u32[39] 0x%08x, expected 0x%08x.\n", u32[39], TAG_PCSG);
1368 ok(u32[88] == TAG_SHEX, "Got u32[88] 0x%08x, expected 0x%08x.\n", u32[88], TAG_SHEX);
1369 ok(u32[168] == TAG_SDBG, "Got u32[168] 0x%08x, expected 0x%08x.\n", u32[168], TAG_SDBG);
1371 refcount = ID3D10Blob_Release(blob);
1372 ok(!refcount, "Got refcount %u.\n", refcount);
1375 #define check_type_desc(a, b) check_type_desc_(__FILE__, __LINE__, a, b)
1376 static void check_type_desc_(const char *file, int line,
1377 const D3D12_SHADER_TYPE_DESC *type, const D3D12_SHADER_TYPE_DESC *expect)
1379 ok_(file, line)(type->Class == expect->Class, "Got class %#x.\n", type->Class);
1380 ok_(file, line)(type->Type == expect->Type, "Got type %#x.\n", type->Type);
1381 ok_(file, line)(type->Rows == expect->Rows, "Got %u rows.\n", type->Rows);
1382 ok_(file, line)(type->Columns == expect->Columns, "Got %u columns.\n", type->Columns);
1383 ok_(file, line)(type->Elements == expect->Elements, "Got %u elements.\n", type->Elements);
1384 ok_(file, line)(type->Members == expect->Members, "Got %u members.\n", type->Members);
1385 ok_(file, line)(type->Offset == expect->Offset, "Got offset %u.\n", type->Offset);
1386 ok_(file, line)((!type->Name && !expect->Name) || !strcmp(type->Name, expect->Name), "Got name \"%s\".\n", type->Name);
1389 static void test_reflection(void)
1391 unsigned int refcount;
1392 HRESULT hr;
1394 static const char vs_source[] =
1395 "typedef uint uint_t;\n"
1396 "float m;\n"
1397 "\n"
1398 "cbuffer b1\n"
1399 "{\n"
1400 " float a;\n"
1401 " float2 b;\n"
1402 " float4 c;\n"
1403 " float d;\n"
1404 " struct\n"
1405 " {\n"
1406 " float4 a;\n"
1407 " float b;\n"
1408 " float c;\n"
1409 " } s;\n"
1410 /* In direct contradiction to the documentation, this does not align. */
1411 " bool g;\n"
1412 " float h[2];\n"
1413 " int i;\n"
1414 " uint_t j;\n"
1415 " float3x1 k;\n"
1416 " row_major float3x1 l;\n"
1417 "#pragma pack_matrix(row_major)\n"
1418 " float3x1 o;\n"
1419 " float4 p;\n"
1420 " float q;\n"
1421 " struct r_name {float a; float4 b;} r;\n"
1422 " column_major float3x1 t;\n"
1423 "};\n"
1424 "\n"
1425 "cbuffer b5 : register(b5)\n"
1426 "{\n"
1427 " float4 u;\n"
1428 "}\n"
1429 "\n"
1430 "float4 main(uniform float4 n) : SV_POSITION\n"
1431 "{\n"
1432 " return o._31 + m + n + u;\n"
1433 "}";
1435 struct shader_variable
1437 D3D12_SHADER_VARIABLE_DESC var_desc;
1438 D3D12_SHADER_TYPE_DESC type_desc;
1439 const D3D12_SHADER_TYPE_DESC *field_types;
1442 struct shader_buffer
1444 D3D12_SHADER_BUFFER_DESC desc;
1445 const struct shader_variable *vars;
1448 static const D3D12_SHADER_TYPE_DESC s_field_types[] =
1450 {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"},
1451 {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 16, "float"},
1452 {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 20, "float"},
1455 static const D3D12_SHADER_TYPE_DESC r_field_types[] =
1457 {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"},
1458 {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 16, "float4"},
1461 static const struct shader_variable globals_vars =
1462 {{"m", 0, 4, D3D_SVF_USED, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}};
1463 static const struct shader_variable params_vars =
1464 {{"n", 0, 16, D3D_SVF_USED, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}};
1465 static const struct shader_variable buffer_vars[] =
1467 {{"a", 0, 4, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}},
1468 {{"b", 4, 8, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 2, 0, 0, 0, "float2"}},
1469 {{"c", 16, 16, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}},
1470 {{"d", 32, 4, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}},
1471 {{"s", 48, 24, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 6, 0, ARRAY_SIZE(s_field_types), 0, "<unnamed>"}, s_field_types},
1472 {{"g", 72, 4, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_SCALAR, D3D_SVT_BOOL, 1, 1, 0, 0, 0, "bool"}},
1473 {{"h", 80, 20, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 2, 0, 0, "float"}},
1474 {{"i", 100, 4, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_SCALAR, D3D_SVT_INT, 1, 1, 0, 0, 0, "int"}},
1475 {{"j", 104, 4, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_SCALAR, D3D_SVT_UINT, 1, 1, 0, 0, 0, "uint_t"}},
1476 {{"k", 112, 12, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_MATRIX_COLUMNS, D3D_SVT_FLOAT, 3, 1, 0, 0, 0, "float3x1"}},
1477 {{"l", 128, 36, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_MATRIX_ROWS, D3D_SVT_FLOAT, 3, 1, 0, 0, 0, "float3x1"}},
1478 {{"o", 176, 36, D3D_SVF_USED, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_MATRIX_ROWS, D3D_SVT_FLOAT, 3, 1, 0, 0, 0, "float3x1"}},
1479 {{"p", 224, 16, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}},
1480 {{"q", 240, 4, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}},
1481 {{"r", 256, 32, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 5, 0, ARRAY_SIZE(r_field_types), 0, "r_name"}, r_field_types},
1482 {{"t", 288, 12, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_MATRIX_COLUMNS, D3D_SVT_FLOAT, 3, 1, 0, 0, 0, "float3x1"}},
1484 static const struct shader_variable b5_vars =
1485 {{"u", 0, 16, D3D_SVF_USED, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}};
1487 static const struct shader_buffer vs_buffers[] =
1489 {{"$Globals", D3D_CT_CBUFFER, 1, 16}, &globals_vars},
1490 {{"$Params", D3D_CT_CBUFFER, 1, 16}, &params_vars},
1491 {{"b1", D3D_CT_CBUFFER, ARRAY_SIZE(buffer_vars), 304}, buffer_vars},
1492 {{"b5", D3D_CT_CBUFFER, 1, 16}, &b5_vars},
1495 static const D3D12_SHADER_INPUT_BIND_DESC vs_bindings[] =
1497 {"$Globals", D3D_SIT_CBUFFER, 0, 1, .uID = 0},
1498 {"$Params", D3D_SIT_CBUFFER, 1, 1, .uID = 1},
1499 {"b1", D3D_SIT_CBUFFER, 2, 1, .uID = 2},
1500 {"b5", D3D_SIT_CBUFFER, 5, 1, D3D_SIF_USERPACKED, .uID = 5},
1503 static const char ps_source[] =
1504 "texture2D a;\n"
1505 "sampler c {};\n"
1506 "SamplerState d {};\n"
1507 "sampler e\n"
1508 "{\n"
1509 " Texture = a;\n"
1510 " foo = bar + 2;\n"
1511 "};\n"
1512 "SamplerState f\n"
1513 "{\n"
1514 " Texture = a;\n"
1515 " foo = bar + 2;\n"
1516 "};\n"
1517 "sampler2D g;\n"
1518 "sampler b : register(s7);\n"
1519 "struct\n"
1520 "{\n"
1521 " float a;\n"
1522 " Texture1D<int2> b;\n"
1523 " float c;\n"
1524 " Texture2D d;\n"
1525 "} h : register(t7);\n"
1526 "struct\n"
1527 "{\n"
1528 " float a;\n"
1529 " Texture2D b;\n"
1530 " SamplerState c;\n"
1531 "} i;\n"
1532 "struct\n"
1533 "{\n"
1534 " Texture2D b;\n"
1535 " SamplerState c;\n"
1536 "} j;\n"
1537 "struct\n"
1538 "{\n"
1539 " Texture2D a;\n"
1540 " Texture1DArray<float> b;\n"
1541 " struct { SamplerState a; } c;\n"
1542 "} k;\n"
1543 "struct\n"
1544 "{\n"
1545 " Texture2D<snorm float4> a;\n"
1546 " Texture2D<unorm float4> b;\n"
1547 " RWTexture2D<snorm float4> c;\n"
1548 " RWTexture2D<unorm float4> d;\n"
1549 "} l;\n"
1550 "cbuffer buf : register(b3[-1])\n"
1551 "{\n"
1552 " float4 v;\n"
1553 "};\n"
1554 "cbuffer buf2 : register(b[4])\n"
1555 "{\n"
1556 " float4 vv;\n"
1557 "};\n"
1558 "float4 main(float2 pos : texcoord) : SV_TARGET\n"
1559 "{\n"
1560 " l.c[uint2(0,0)] = 0;\n"
1561 " l.d[uint2(0,0)] = 0;\n"
1562 " return a.Sample(b, pos) + a.Sample(c, pos) + a.Sample(d, pos) + tex2D(f, pos) + tex2D(e, pos)"
1563 " + tex2D(g, pos) + h.b.Load(h.c).x + k.b.Sample(k.c.a, pos) + v + vv + l.a.Load(int3(0,0,0))"
1564 " + l.b.Load(int3(0,0,0));\n"
1565 "}";
1567 static const D3D12_SHADER_INPUT_BIND_DESC ps_bindings[] =
1569 {"c", D3D_SIT_SAMPLER, 0, 1, .uID = 0},
1570 {"d", D3D_SIT_SAMPLER, 1, 1, .uID = 1},
1571 {"e", D3D_SIT_SAMPLER, 2, 1, .uID = 2},
1572 {"f", D3D_SIT_SAMPLER, 3, 1, .uID = 3},
1573 {"g", D3D_SIT_SAMPLER, 4, 1, .uID = 4},
1574 {"k.c.a", D3D_SIT_SAMPLER, 5, 1, .uID = 5},
1575 {"b", D3D_SIT_SAMPLER, 7, 1, D3D_SIF_USERPACKED, .uID = 7},
1576 {"f", D3D_SIT_TEXTURE, 0, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, ~0u, 0, 0},
1577 {"e", D3D_SIT_TEXTURE, 1, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, ~0u, 0, 1},
1578 {"g", D3D_SIT_TEXTURE, 2, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, ~0u, 0, 2},
1579 {"a", D3D_SIT_TEXTURE, 3, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, ~0u, 0, 3},
1580 {"k.b", D3D_SIT_TEXTURE, 5, 1, 0, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE1DARRAY, ~0u, 0, 5},
1581 {"h.b", D3D_SIT_TEXTURE, 7, 1, D3D_SIF_USERPACKED | D3D_SIF_TEXTURE_COMPONENT_0, D3D_RETURN_TYPE_SINT, D3D_SRV_DIMENSION_TEXTURE1D, ~0u, 0, 7},
1582 {"l.a", D3D_SIT_TEXTURE, 9, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_SNORM, D3D_SRV_DIMENSION_TEXTURE2D, ~0u, 0, 9},
1583 {"l.b", D3D_SIT_TEXTURE, 10, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_UNORM, D3D_SRV_DIMENSION_TEXTURE2D, ~0u, 0, 10},
1584 {"l.c", D3D_SIT_UAV_RWTYPED, 1, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_SNORM, D3D_SRV_DIMENSION_TEXTURE2D, ~0u, 0, 1},
1585 {"l.d", D3D_SIT_UAV_RWTYPED, 2, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_UNORM, D3D_SRV_DIMENSION_TEXTURE2D, ~0u, 0, 2},
1586 {"buf2", D3D_SIT_CBUFFER, 0, 1, D3D_SIF_USERPACKED, .uID = 0},
1587 {"$Globals", D3D_SIT_CBUFFER, 1, 1, .uID = 1},
1588 {"buf", D3D_SIT_CBUFFER, 3, 1, D3D_SIF_USERPACKED, .uID = 3},
1591 static const D3D12_SHADER_TYPE_DESC ps_h_field_types[] =
1593 {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"},
1594 {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 4, "float"},
1597 static const D3D12_SHADER_TYPE_DESC ps_i_field_types[] =
1599 {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"},
1602 static const struct shader_variable ps_globals_vars[] =
1604 {{"h", 0, 8, D3D_SVF_USED, NULL, 7, 1, ~0u, 0}, {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 4, 0, ARRAY_SIZE(ps_h_field_types), 0, "<unnamed>"}, ps_h_field_types},
1605 {{"i", 16, 4, 0, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 3, 0, ARRAY_SIZE(ps_i_field_types), 0, "<unnamed>"}, ps_i_field_types},
1608 static const struct shader_variable ps_buf_vars[] =
1610 {{"v", 0, 16, D3D_SVF_USED, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}},
1613 static const struct shader_variable ps_buf2_vars[] =
1615 {{"vv", 0, 16, D3D_SVF_USED, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}},
1618 static const struct shader_buffer ps_buffers[] =
1620 {{"$Globals", D3D_CT_CBUFFER, ARRAY_SIZE(ps_globals_vars), 32}, ps_globals_vars},
1621 {{"buf", D3D_CT_CBUFFER, ARRAY_SIZE(ps_buf_vars), 16}, ps_buf_vars},
1622 {{"buf2", D3D_CT_CBUFFER, ARRAY_SIZE(ps_buf2_vars), 16}, ps_buf2_vars},
1625 static const char ps51_source[] =
1626 "cbuffer x : register(b0, space1) { float4 a; };\n"
1627 "cbuffer y : register(b0, space1) { float4 b; };\n"
1628 "cbuffer z : register(b0, space0) { float4 c; };\n"
1629 "float4 d;\n"
1630 "Texture2D e : register(t1, space1);\n"
1631 "Texture2D f : register(t1, space2);\n"
1632 "RWBuffer<float> g : register(u1, space1);\n"
1633 "SamplerState h : register(s1, space2147483647);\n"
1634 "SamplerState i : register(s2147483647, space1);\n"
1635 "cbuffer w : register(b3[-1]) { float4 j; };\n"
1636 "cbuffer v : register(b[4]) { float4 k; };\n"
1637 "float4 main(void) : SV_TARGET\n"
1638 "{\n"
1639 " g[0] = 0;\n"
1640 " return a + c + d + e.Sample(h, 0) + f.Sample(i, 0) + j + k;\n"
1641 "}";
1643 static const struct shader_variable ps51_x_vars =
1644 {{"a", 0, 16, D3D_SVF_USED, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}};
1645 static const struct shader_variable ps51_z_vars =
1646 {{"c", 0, 16, D3D_SVF_USED, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}};
1647 static const struct shader_variable ps51_globals_vars =
1648 {{"d", 0, 16, D3D_SVF_USED, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}};
1649 static const struct shader_variable ps51_w_vars =
1650 {{"j", 0, 16, D3D_SVF_USED, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}};
1651 static const struct shader_variable ps51_v_vars =
1652 {{"k", 0, 16, D3D_SVF_USED, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}};
1654 static const struct shader_buffer ps51_buffers[] =
1656 {{"$Globals", D3D_CT_CBUFFER, 1, 16}, &ps51_globals_vars},
1657 {{"x", D3D_CT_CBUFFER, 1, 16}, &ps51_x_vars},
1658 {{"z", D3D_CT_CBUFFER, 1, 16}, &ps51_z_vars},
1659 {{"w", D3D_CT_CBUFFER, 1, 16}, &ps51_w_vars},
1660 {{"v", D3D_CT_CBUFFER, 1, 16}, &ps51_v_vars},
1663 static const D3D12_SHADER_INPUT_BIND_DESC ps51_bindings[] =
1665 {"i", D3D_SIT_SAMPLER, 2147483647, 1, .Space = 1, .uID = 0},
1666 {"h", D3D_SIT_SAMPLER, 1, 1, .Space = 2147483647, .uID = 1},
1667 {"e", D3D_SIT_TEXTURE, 1, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, ~0u, 1, 0},
1668 {"f", D3D_SIT_TEXTURE, 1, 1, D3D_SIF_TEXTURE_COMPONENTS, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, ~0u, 2, 1},
1669 {"g", D3D_SIT_UAV_RWTYPED, 1, 1, 0, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_BUFFER, ~0u, 1, 0},
1670 {"z", D3D_SIT_CBUFFER, 0, 1, D3D_SIF_USERPACKED, .Space = 0, .uID = 0},
1671 {"$Globals", D3D_SIT_CBUFFER, 1, 1, .uID = 1},
1672 {"w", D3D_SIT_CBUFFER, 2, 1, D3D_SIF_USERPACKED, .uID = 2},
1673 {"v", D3D_SIT_CBUFFER, 4, 1, D3D_SIF_USERPACKED, .uID = 3},
1674 {"x", D3D_SIT_CBUFFER, 0, 1, D3D_SIF_USERPACKED, .Space = 1, .uID = 4},
1677 static const char ps4_source[] =
1678 "uniform float4 f;\n"
1679 "float4 main() : sv_target\n"
1680 "{\n"
1681 " return f;\n"
1682 "}";
1684 static const D3D12_SHADER_INPUT_BIND_DESC ps4_bindings[] =
1686 {"$Globals", D3D_SIT_CBUFFER, 0, 1},
1689 static const struct shader_variable ps4_globals_vars[] =
1691 {{"f", 0, 16, D3D_SVF_USED, NULL, ~0u, 0, ~0u, 0}, {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, NULL}},
1693 static const struct shader_buffer ps4_buffers[] =
1695 {{"$Globals", D3D_CT_CBUFFER, ARRAY_SIZE(ps4_globals_vars), 16}, ps4_globals_vars},
1698 static const struct
1700 const char *source;
1701 const char *profile;
1702 UINT version;
1703 const D3D12_SHADER_INPUT_BIND_DESC *bindings;
1704 size_t binding_count;
1705 const struct shader_buffer *buffers;
1706 size_t buffer_count;
1707 UINT flags;
1709 tests[] =
1711 {vs_source, "vs_5_0", 0x10050, vs_bindings, ARRAY_SIZE(vs_bindings), vs_buffers, ARRAY_SIZE(vs_buffers), D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY},
1712 {ps_source, "ps_5_0", 0x00050, ps_bindings, ARRAY_SIZE(ps_bindings), ps_buffers, ARRAY_SIZE(ps_buffers), D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY},
1713 {ps51_source, "ps_5_1", 0x00051, ps51_bindings, ARRAY_SIZE(ps51_bindings), ps51_buffers, ARRAY_SIZE(ps51_buffers), 0},
1714 {ps4_source, "ps_4_0", 0x00040, ps4_bindings, ARRAY_SIZE(ps4_bindings), ps4_buffers, ARRAY_SIZE(ps4_buffers), 0},
1717 for (unsigned int t = 0; t < ARRAY_SIZE(tests); ++t)
1719 ID3D10Blob *code = compile_shader_flags(tests[t].source,
1720 tests[t].profile, tests[t].flags);
1721 ID3D12ShaderReflectionConstantBuffer *cbuffer;
1722 D3D12_SHADER_TYPE_DESC type_desc, field_desc;
1723 D3D12_SHADER_INPUT_BIND_DESC binding_desc;
1724 ID3D12ShaderReflectionType *type, *field;
1725 D3D12_SHADER_BUFFER_DESC buffer_desc;
1726 ID3D12ShaderReflectionVariable *var;
1727 D3D12_SHADER_VARIABLE_DESC var_desc;
1728 ID3D12ShaderReflection *reflection;
1729 D3D12_SHADER_DESC shader_desc;
1731 hr = D3DReflect(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code),
1732 &IID_ID3D12ShaderReflection, (void **)&reflection);
1733 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
1735 hr = ID3D12ShaderReflection_GetDesc(reflection, &shader_desc);
1736 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
1737 ok(shader_desc.Version == tests[t].version, "Got version %#x.\n", shader_desc.Version);
1738 ok(shader_desc.ConstantBuffers == tests[t].buffer_count, "Got %u buffers.\n", shader_desc.ConstantBuffers);
1739 ok(shader_desc.BoundResources == tests[t].binding_count, "Got %u resources.\n", shader_desc.BoundResources);
1741 for (unsigned int i = 0; i < shader_desc.ConstantBuffers; ++i)
1743 const struct shader_buffer *expect_buffer = &tests[t].buffers[i];
1745 vkd3d_test_push_context("Buffer %u", i);
1747 cbuffer = ID3D12ShaderReflection_GetConstantBufferByIndex(reflection, i);
1748 hr = ID3D12ShaderReflectionConstantBuffer_GetDesc(cbuffer, &buffer_desc);
1749 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
1750 ok(!strcmp(buffer_desc.Name, expect_buffer->desc.Name), "Got name \"%s\".\n", buffer_desc.Name);
1751 ok(buffer_desc.Type == expect_buffer->desc.Type, "Got type %#x.\n", buffer_desc.Type);
1752 ok(buffer_desc.Variables == expect_buffer->desc.Variables, "Got %u variables.\n", buffer_desc.Variables);
1753 ok(buffer_desc.Size == expect_buffer->desc.Size, "Got size %u.\n", buffer_desc.Size);
1754 ok(buffer_desc.uFlags == expect_buffer->desc.uFlags, "Got flags %#x.\n", buffer_desc.uFlags);
1756 for (unsigned int j = 0; j < buffer_desc.Variables; ++j)
1758 const struct shader_variable *expect = &expect_buffer->vars[j];
1760 vkd3d_test_push_context("Variable %u", j);
1762 var = ID3D12ShaderReflectionConstantBuffer_GetVariableByIndex(cbuffer, j);
1763 hr = ID3D12ShaderReflectionVariable_GetDesc(var, &var_desc);
1764 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
1765 ok(!strcmp(var_desc.Name, expect->var_desc.Name), "Got name \"%s\".\n", var_desc.Name);
1766 ok(var_desc.StartOffset == expect->var_desc.StartOffset, "Got offset %u.\n", var_desc.StartOffset);
1767 ok(var_desc.Size == expect->var_desc.Size, "Got size %u.\n", var_desc.Size);
1768 ok(var_desc.uFlags == expect->var_desc.uFlags, "Got flags %#x.\n", var_desc.uFlags);
1769 ok(!var_desc.DefaultValue, "Got default value %p.\n", var_desc.DefaultValue);
1770 todo_if (t != 3) ok(var_desc.StartTexture == expect->var_desc.StartTexture,
1771 "Got texture offset %u.\n", var_desc.StartTexture);
1772 todo_if (expect->var_desc.TextureSize)
1773 ok(var_desc.TextureSize == expect->var_desc.TextureSize,
1774 "Got texture size %u.\n", var_desc.TextureSize);
1775 todo_if (t != 3) ok(var_desc.StartSampler == expect->var_desc.StartSampler,
1776 "Got sampler offset %u.\n", var_desc.StartSampler);
1777 ok(var_desc.SamplerSize == expect->var_desc.SamplerSize,
1778 "Got sampler size %u.\n", var_desc.SamplerSize);
1780 type = ID3D12ShaderReflectionVariable_GetType(var);
1781 hr = ID3D12ShaderReflectionType_GetDesc(type, &type_desc);
1782 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
1783 check_type_desc(&type_desc, &expect->type_desc);
1785 for (unsigned int k = 0; k < type_desc.Members; ++k)
1787 vkd3d_test_push_context("Field %u", k);
1789 field = ID3D12ShaderReflectionType_GetMemberTypeByIndex(type, k);
1790 hr = ID3D12ShaderReflectionType_GetDesc(field, &field_desc);
1791 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
1792 check_type_desc(&field_desc, &expect->field_types[k]);
1794 vkd3d_test_pop_context();
1797 field = ID3D12ShaderReflectionType_GetMemberTypeByIndex(type, type_desc.Members);
1798 hr = ID3D12ShaderReflectionType_GetDesc(field, &field_desc);
1799 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1801 vkd3d_test_pop_context();
1804 var = ID3D12ShaderReflectionConstantBuffer_GetVariableByIndex(cbuffer, buffer_desc.Variables);
1805 hr = ID3D12ShaderReflectionVariable_GetDesc(var, &var_desc);
1806 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1808 type = ID3D12ShaderReflectionVariable_GetType(var);
1809 hr = ID3D12ShaderReflectionType_GetDesc(type, &type_desc);
1810 ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
1811 field = ID3D12ShaderReflectionType_GetMemberTypeByIndex(type, 0);
1812 hr = ID3D12ShaderReflectionType_GetDesc(field, &type_desc);
1813 ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr);
1815 vkd3d_test_pop_context();
1818 cbuffer = ID3D12ShaderReflection_GetConstantBufferByIndex(reflection, shader_desc.ConstantBuffers);
1819 hr = ID3D12ShaderReflectionConstantBuffer_GetDesc(cbuffer, &buffer_desc);
1820 ok(hr == E_FAIL, "Got hr %#x.\n", hr);
1822 for (unsigned int i = 0; i < shader_desc.BoundResources; ++i)
1824 const D3D12_SHADER_INPUT_BIND_DESC *expect = &tests[t].bindings[i];
1826 vkd3d_test_push_context("Binding %u", i);
1828 hr = ID3D12ShaderReflection_GetResourceBindingDesc(reflection, i, &binding_desc);
1829 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
1831 ok(!strcmp(binding_desc.Name, expect->Name), "Got name \"%s\".\n", binding_desc.Name);
1832 ok(binding_desc.Type == expect->Type, "Got type %#x.\n", binding_desc.Type);
1833 ok(binding_desc.BindPoint == expect->BindPoint, "Got bind point %u.\n", binding_desc.BindPoint);
1834 ok(binding_desc.BindCount == expect->BindCount, "Got bind count %u.\n", binding_desc.BindCount);
1835 ok(binding_desc.uFlags == expect->uFlags, "Got flags %#x.\n", binding_desc.uFlags);
1836 ok(binding_desc.ReturnType == expect->ReturnType, "Got return type %#x.\n", binding_desc.ReturnType);
1837 ok(binding_desc.Dimension == expect->Dimension, "Got dimension %#x.\n", binding_desc.Dimension);
1838 ok(binding_desc.NumSamples == expect->NumSamples, "Got multisample count %u.\n", binding_desc.NumSamples);
1839 ok(binding_desc.Space == expect->Space, "Got space %u.\n", binding_desc.Space);
1840 todo_if (binding_desc.uID != expect->uID)
1841 ok(binding_desc.uID == expect->uID, "Got ID %u.\n", binding_desc.uID);
1843 vkd3d_test_pop_context();
1846 hr = ID3D12ShaderReflection_GetResourceBindingDesc(reflection, shader_desc.BoundResources, &binding_desc);
1847 ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
1849 ID3D10Blob_Release(code);
1850 refcount = ID3D12ShaderReflection_Release(reflection);
1851 ok(!refcount, "Got unexpected refcount %u.\n", refcount);
1855 static void test_default_values_reflection(void)
1857 unsigned int refcount;
1858 HRESULT hr;
1860 static const char ps1_source[] =
1861 "struct\n"
1862 "{\n"
1863 " float2 aa;\n"
1864 " float2x1 bb;\n"
1865 " int3 cc, dd;\n"
1866 " float2x3 ee;\n"
1867 " row_major float2x3 ff;\n"
1868 " struct {\n"
1869 " float2 aa[3];\n"
1870 " float3 bb;\n"
1871 " } gg;\n"
1872 "} st = {1, 2, 3, 4, 5, 6, 7, 8, float4(9.5, 10.6, 11, 12), 13, 14, 15, 16, 17, 18,\n"
1873 " 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};\n"
1874 "float2 unused = {1, 2};\n"
1875 "float3x2 another = {1, 2, 3, 4, 5, 6};\n"
1876 "cbuffer b1\n"
1877 "{\n"
1878 " float2 hh = {1, 2};\n"
1879 " float3x2 ii[2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};\n"
1880 "}\n"
1881 "cbuffer b2_unused\n"
1882 "{\n"
1883 " float jj = {5};\n"
1884 "}\n"
1885 "float nondefault_unused;\n"
1886 "float nondefault;\n"
1887 "float4 main() : sv_target\n"
1888 "{\n"
1889 " return another[0][1] + st.gg.aa[1].y + nondefault + hh.y;\n"
1890 "}";
1892 struct shader_variable
1894 D3D12_SHADER_VARIABLE_DESC var_desc;
1897 struct shader_buffer
1899 D3D12_SHADER_BUFFER_DESC desc;
1900 const struct shader_variable *vars;
1903 static const unsigned int ps1_globals_st_default_value[] =
1905 0x3f800000, 0x40000000, 0x40400000, 0x40800000,
1906 0x00000005, 0x00000006, 0x00000007, 0x00000000,
1907 0x00000008, 0x00000009, 0x0000000a, 0x00000000,
1908 0x41300000, 0x41400000, 0x00000000, 0x00000000,
1909 0x41500000, 0x41600000, 0x00000000, 0x00000000,
1910 0x41700000, 0x41800000, 0x00000000, 0x00000000,
1911 0x41880000, 0x41980000, 0x41a80000, 0x00000000,
1912 0x41900000, 0x41a00000, 0x41b00000, 0x00000000,
1913 0x41b80000, 0x41c00000, 0x00000000, 0x00000000,
1914 0x41c80000, 0x41d00000, 0x00000000, 0x00000000,
1915 0x41d80000, 0x41e00000, 0x00000000, 0x00000000,
1916 0x41e80000, 0x41f00000, 0x41f80000,
1919 static const unsigned int ps1_globals_unused_default_value[] =
1921 0x3f800000, 0x40000000,
1924 static const unsigned int ps1_globals_another_default_value[] =
1926 0x3f800000, 0x40000000, 0x40400000, 0x00000000,
1927 0x40800000, 0x40a00000, 0x40c00000,
1930 static const struct shader_variable ps1_globals_vars[] =
1932 {{"st", 0, 188, D3D_SVF_USED, (void *)ps1_globals_st_default_value}},
1933 {{"unused", 192, 8, 0, (void *)ps1_globals_unused_default_value}},
1934 {{"another", 208, 28, D3D_SVF_USED, (void *)ps1_globals_another_default_value}},
1935 {{"nondefault_unused", 236, 4, 0, NULL}},
1936 {{"nondefault", 240, 4, D3D_SVF_USED, NULL}},
1939 static const unsigned int ps1_b1_hh_default_value[] =
1941 0x3f800000, 0x40000000,
1944 static const unsigned int ps1_b1_ii_default_value[] =
1946 0x3f800000, 0x40000000, 0x40400000, 0x00000000,
1947 0x40800000, 0x40a00000, 0x40c00000, 0x00000000,
1948 0x40e00000, 0x41000000, 0x41100000, 0x00000000,
1949 0x41200000, 0x41300000, 0x41400000,
1952 static const struct shader_variable ps1_b1_vars[] =
1954 {{"hh", 0, 8, D3D_SVF_USED, (void *)ps1_b1_hh_default_value}},
1955 {{"ii", 16, 60, 0, (void *)ps1_b1_ii_default_value}},
1958 static const struct shader_buffer ps1_buffers[] =
1960 {{"$Globals", D3D_CT_CBUFFER, ARRAY_SIZE(ps1_globals_vars), 256}, ps1_globals_vars},
1961 {{"b1", D3D_CT_CBUFFER, ARRAY_SIZE(ps1_b1_vars), 80}, ps1_b1_vars},
1964 static const struct
1966 const char *source;
1967 const char *profile;
1968 const struct shader_buffer *buffers;
1969 size_t buffer_count;
1971 tests[] =
1973 {ps1_source, "ps_5_0", ps1_buffers, ARRAY_SIZE(ps1_buffers)},
1976 for (unsigned int t = 0; t < ARRAY_SIZE(tests); ++t)
1978 ID3D10Blob *code = compile_shader_flags(tests[t].source,
1979 tests[t].profile, D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY);
1980 ID3D12ShaderReflection *reflection;
1981 D3D12_SHADER_DESC shader_desc;
1983 hr = D3DReflect(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code),
1984 &IID_ID3D12ShaderReflection, (void **)&reflection);
1985 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
1987 hr = ID3D12ShaderReflection_GetDesc(reflection, &shader_desc);
1988 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
1989 ok(shader_desc.ConstantBuffers == tests[t].buffer_count, "Got %u buffers.\n", shader_desc.ConstantBuffers);
1991 for (unsigned int i = 0; i < shader_desc.ConstantBuffers; ++i)
1993 const struct shader_buffer *expect_buffer = &tests[t].buffers[i];
1994 ID3D12ShaderReflectionConstantBuffer *cbuffer;
1995 D3D12_SHADER_BUFFER_DESC buffer_desc;
1997 vkd3d_test_push_context("Buffer %u", i);
1999 cbuffer = ID3D12ShaderReflection_GetConstantBufferByIndex(reflection, i);
2000 hr = ID3D12ShaderReflectionConstantBuffer_GetDesc(cbuffer, &buffer_desc);
2001 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2002 ok(buffer_desc.Type == expect_buffer->desc.Type, "Got type %#x.\n", buffer_desc.Type);
2003 ok(buffer_desc.Variables == expect_buffer->desc.Variables, "Got %u variables.\n", buffer_desc.Variables);
2005 for (unsigned int j = 0; j < buffer_desc.Variables; ++j)
2007 const struct shader_variable *expect = &expect_buffer->vars[j];
2008 ID3D12ShaderReflectionVariable *var;
2009 D3D12_SHADER_VARIABLE_DESC var_desc;
2011 vkd3d_test_push_context("Variable %u", j);
2013 var = ID3D12ShaderReflectionConstantBuffer_GetVariableByIndex(cbuffer, j);
2014 hr = ID3D12ShaderReflectionVariable_GetDesc(var, &var_desc);
2015 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2016 ok(var_desc.Size == expect->var_desc.Size, "Got size %u.\n", var_desc.Size);
2018 if (expect->var_desc.DefaultValue)
2020 ok(var_desc.DefaultValue, "Didn't get default value.\n");
2022 if (var_desc.DefaultValue && var_desc.Size == expect->var_desc.Size)
2024 for (unsigned int k = 0; k < var_desc.Size/4; ++k)
2026 unsigned int var_val = *((unsigned int *)var_desc.DefaultValue + k);
2027 unsigned int expect_val = *((unsigned int *)expect->var_desc.DefaultValue + k);
2029 ok(var_val == expect_val, "Expected default value 0x%08x, but got 0x%08x, at offset %u.\n",
2030 expect_val, var_val, 4 * k);
2034 else
2036 ok(!var_desc.DefaultValue, "Got default value %p.\n", var_desc.DefaultValue);
2039 vkd3d_test_pop_context();
2041 vkd3d_test_pop_context();
2044 ID3D10Blob_Release(code);
2045 refcount = ID3D12ShaderReflection_Release(reflection);
2046 ok(!refcount, "Got unexpected refcount %u.\n", refcount);
2050 #define check_signature_element(a, b, c) check_signature_element_(__FILE__, __LINE__, a, b, c)
2051 static void check_signature_element_(const char *file, int line, const D3D12_SIGNATURE_PARAMETER_DESC *desc,
2052 const D3D12_SIGNATURE_PARAMETER_DESC *expect, bool is_todo)
2054 todo_if(is_todo && strcmp(desc->SemanticName, expect->SemanticName))
2055 ok_(file, line)(!strcmp(desc->SemanticName, expect->SemanticName), "Got name \"%s\".\n", desc->SemanticName);
2056 todo_if(is_todo && desc->SemanticIndex != expect->SemanticIndex)
2057 ok_(file, line)(desc->SemanticIndex == expect->SemanticIndex, "Got index %u.\n", desc->SemanticIndex);
2058 todo_if(is_todo && desc->Register != expect->Register)
2059 ok_(file, line)(desc->Register == expect->Register, "Got register %u.\n", desc->Register);
2060 todo_if(is_todo && desc->SystemValueType != expect->SystemValueType)
2061 ok_(file, line)(desc->SystemValueType == expect->SystemValueType, "Got sysval %u.\n", desc->SystemValueType);
2062 todo_if(is_todo && desc->ComponentType != expect->ComponentType)
2063 ok_(file, line)(desc->ComponentType == expect->ComponentType, "Got data type %u.\n", desc->ComponentType);
2064 todo_if(is_todo && desc->Mask != expect->Mask)
2065 ok_(file, line)(desc->Mask == expect->Mask, "Got mask %#x.\n", desc->Mask);
2066 todo_if(desc->ReadWriteMask != expect->ReadWriteMask)
2067 ok_(file, line)(desc->ReadWriteMask == expect->ReadWriteMask, "Got used mask %#x.\n", desc->ReadWriteMask);
2068 todo_if(is_todo && desc->Stream != expect->Stream)
2069 ok_(file, line)(desc->Stream == expect->Stream, "Got stream %u.\n", desc->Stream);
2072 static void test_signature_reflection(void)
2074 D3D12_SIGNATURE_PARAMETER_DESC desc;
2075 ID3D12ShaderReflection *reflection;
2076 D3D12_SHADER_DESC shader_desc;
2077 ID3D10Blob *code = NULL;
2078 unsigned int refcount;
2079 HRESULT hr;
2081 static const char vs1_source[] =
2082 "void main(\n"
2083 " in float4 a : apple,\n"
2084 " out float4 b : banana2,\n"
2085 " inout float4 c : color,\n"
2086 " inout float4 d : depth,\n"
2087 " inout float4 e : sv_position,\n"
2088 " in uint3 f : fruit,\n"
2089 " inout bool2 g : grape,\n"
2090 " in int h : honeydew,\n"
2091 " in uint i : sv_vertexid)\n"
2092 "{\n"
2093 " b.yw = a.xz;\n"
2094 "}";
2096 static const D3D12_SIGNATURE_PARAMETER_DESC vs1_inputs[] =
2098 {"apple", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x5},
2099 {"color", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf},
2100 {"depth", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf},
2101 {"sv_position", 0, 3, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf},
2102 {"fruit", 0, 4, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x7},
2103 {"grape", 0, 5, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x3, 0x3},
2104 {"honeydew", 0, 6, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_SINT32, 0x1},
2105 {"sv_vertexid", 0, 7, D3D_NAME_VERTEX_ID, D3D_REGISTER_COMPONENT_UINT32, 0x1},
2108 static const D3D12_SIGNATURE_PARAMETER_DESC vs1_outputs[] =
2110 {"banana", 2, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x5},
2111 {"color", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2112 {"depth", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2113 {"sv_position", 0, 3, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2114 {"grape", 0, 4, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x3, 0xc},
2117 static const char vs2_source[] =
2118 "void main(inout float4 pos : position)\n"
2119 "{\n"
2120 "}";
2122 static const D3D12_SIGNATURE_PARAMETER_DESC vs2_inputs[] =
2124 {"position", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf},
2127 static const D3D12_SIGNATURE_PARAMETER_DESC vs2_outputs[] =
2129 {"position", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2132 static const D3D12_SIGNATURE_PARAMETER_DESC vs2_legacy_outputs[] =
2134 {"SV_Position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2137 static const char ps1_source[] =
2138 "void main(\n"
2139 " in float2 a : apple,\n"
2140 " out float4 b : sv_target2,\n"
2141 " out uint c : sv_coverage,\n"
2142 " in float4 d : position,\n"
2143 " in float4 e : sv_position,\n"
2144 " out float f : sv_depth,\n"
2145 " in uint g : sv_sampleindex)\n"
2146 "{\n"
2147 " b = d;\n"
2148 " c = 0;\n"
2149 " f = 1;\n"
2150 "}";
2152 static const D3D12_SIGNATURE_PARAMETER_DESC ps1_inputs[] =
2154 {"apple", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3},
2155 {"position", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf},
2156 {"sv_position", 0, 2, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2157 {"sv_sampleindex", 0, 3, D3D_NAME_SAMPLE_INDEX, D3D_REGISTER_COMPONENT_UINT32, 0x1},
2160 static const D3D12_SIGNATURE_PARAMETER_DESC ps1_outputs[] =
2162 {"sv_target", 2, 2, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2163 {"sv_coverage", 0, ~0u, D3D_NAME_COVERAGE, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe},
2164 {"sv_depth", 0, ~0u, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2167 static const char ps2_source[] =
2168 "void main(\n"
2169 " inout float4 a : color2,\n"
2170 " inout float b : depth,\n"
2171 " in float4 c : position)\n"
2172 "{\n"
2173 "}";
2175 static const D3D12_SIGNATURE_PARAMETER_DESC ps2_inputs[] =
2177 {"color", 2, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf},
2178 {"depth", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0x1},
2179 {"SV_Position", 0, 2, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2182 static const D3D12_SIGNATURE_PARAMETER_DESC ps2_outputs[] =
2184 {"SV_Target", 2, 2, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2185 {"SV_Depth", 0, ~0u, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2188 static const char cs1_source[] =
2189 "[numthreads(1, 1, 1)]\n"
2190 "void main(in uint a : sv_dispatchthreadid)\n"
2191 "{\n"
2192 "}";
2194 /* The two floats share the same register */
2195 static const char ps3_source[] =
2196 "struct input\n"
2197 "{\n"
2198 " float t0 : TEXCOORD0;\n"
2199 " uint t1 : TEXCOORD1;\n"
2200 " float t2 : TEXCOORD2;\n"
2201 "};\n"
2202 "\n"
2203 "float4 main(in struct input s) : sv_target { return 0; }\n";
2205 static const D3D12_SIGNATURE_PARAMETER_DESC ps3_inputs[] =
2207 {"TEXCOORD", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2208 {"TEXCOORD", 2, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x2},
2209 {"TEXCOORD", 1, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1},
2212 /* The "uint" shares register with the "nointerpolation float", but not with the
2213 * "float" because it has a different interpolation mode. */
2214 static const char ps4_source[] =
2215 "struct input\n"
2216 "{\n"
2217 " nointerpolation float t0 : TEXCOORD0;\n"
2218 " float t1 : TEXCOORD1;\n"
2219 " uint t2 : TEXCOORD2;\n"
2220 "};\n"
2221 "\n"
2222 "float4 main(in struct input s) : sv_target { return 0; }\n";
2224 static const D3D12_SIGNATURE_PARAMETER_DESC ps4_inputs[] =
2226 {"TEXCOORD", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2227 {"TEXCOORD", 2, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x2},
2228 {"TEXCOORD", 1, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2231 static const char ps5_source[] =
2232 "struct input\n"
2233 "{\n"
2234 " uint2 t0 : TEXCOORD0;\n"
2235 " float3 t1 : TEXCOORD1;\n"
2236 " float t2 : TEXCOORD2;\n"
2237 " float t3: TEXCOORD3;\n"
2238 "};\n"
2239 "\n"
2240 "float4 main(in struct input s) : sv_target { return 0; }\n";
2242 static const D3D12_SIGNATURE_PARAMETER_DESC ps5_inputs[] =
2244 {"TEXCOORD", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x3},
2245 {"TEXCOORD", 1, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x7},
2246 {"TEXCOORD", 2, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x8},
2247 {"TEXCOORD", 3, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2250 /* Semantic names don't affect ordering, declaration order does. */
2251 static const char ps6_source[] =
2252 "struct input\n"
2253 "{\n"
2254 " float2 t2 : TEXCOORD2;\n"
2255 " float3 t3 : TEXCOORD3;\n"
2256 " float foobar : FOOBAR;\n"
2257 " nointerpolation float t0: TEXCOORD0;\n"
2258 "};\n"
2259 "\n"
2260 "float4 main(in struct input s) : sv_target { return 0; }\n";
2262 static const D3D12_SIGNATURE_PARAMETER_DESC ps6_inputs[] =
2264 {"TEXCOORD", 2, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3},
2265 {"FOOBAR", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x4},
2266 {"TEXCOORD", 3, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x7},
2267 {"TEXCOORD", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2270 static const char ps7_source[] =
2271 "struct input\n"
2272 "{\n"
2273 " float3 t0 : TEXCOORD0;\n"
2274 " float3 t1 : TEXCOORD1;\n"
2275 " float3 t2 : TEXCOORD2;\n"
2276 " float t3 : TEXCOORD3;\n"
2277 "};\n"
2278 "\n"
2279 "float4 main(in struct input s) : sv_target { return 0; }";
2281 static const D3D12_SIGNATURE_PARAMETER_DESC ps7_inputs[] =
2283 {"TEXCOORD", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x7},
2284 {"TEXCOORD", 3, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x8},
2285 {"TEXCOORD", 1, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x7},
2286 {"TEXCOORD", 2, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x7},
2289 /* Note how TEXCOORD2 prefers allocation on v2.z over v1.w. */
2290 static const char ps8_source[] =
2291 "struct input\n"
2292 "{\n"
2293 " float3 t0 : TEXCOORD0;\n"
2294 " float2 t1 : TEXCOORD1;\n"
2295 " float t2 : TEXCOORD2;\n"
2296 "};\n"
2297 "\n"
2298 "float4 main(in struct input s) : sv_target { return 0; }\n";
2300 static const D3D12_SIGNATURE_PARAMETER_DESC ps8_inputs[] =
2302 {"TEXCOORD", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x7},
2303 {"TEXCOORD", 1, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3},
2304 {"TEXCOORD", 2, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x4},
2307 static const char ps9_source[] =
2308 "struct input\n"
2309 "{\n"
2310 " float2 t0 : FOO;\n"
2311 " float2 t1 : TEXCOORD1;\n"
2312 " float3 t2 : TEXCOORD2;\n"
2313 " nointerpolation float CCC : TEXCOORD3;\n"
2314 " float4 position : SV_Position;\n"
2315 " float3 t4 : BAR;\n"
2316 " float2 t5 : BUZZ;\n"
2317 " float t6 : TEXCOORD4;\n"
2318 " uint2 t7 : FIZZ;\n"
2319 "};\n"
2320 "\n"
2321 "float4 main(in struct input s) : sv_target { return 0; }\n";
2323 static const D3D12_SIGNATURE_PARAMETER_DESC ps9_inputs[] =
2325 {"FOO", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3},
2326 {"TEXCOORD", 1, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xc},
2327 {"TEXCOORD", 2, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x7},
2328 {"TEXCOORD", 3, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2329 {"FIZZ", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x6},
2330 {"SV_Position", 0, 3, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2331 {"BAR", 0, 4, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x7},
2332 {"BUZZ", 0, 5, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3},
2333 {"TEXCOORD", 4, 5, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x4},
2336 static const D3D12_SIGNATURE_PARAMETER_DESC ps_outputs_simple[] =
2338 {"sv_target", 0, 0, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2341 static const char vs3_source[] =
2342 "struct st\n"
2343 "{\n"
2344 " float t0 : TEXCOORD0;\n"
2345 " uint t1 : TEXCOORD1;\n"
2346 " float t2 : TEXCOORD2;\n"
2347 "};\n"
2348 "\n"
2349 "void main(float4 pos : position, out struct st s, out float4 out_pos : sv_position)\n"
2350 "{\n"
2351 " out_pos = pos;\n"
2352 " s.t0 = 1;\n"
2353 " s.t1 = 11;\n"
2354 " s.t2 = 21;\n"
2355 "}\n";
2357 static const D3D12_SIGNATURE_PARAMETER_DESC vs3_inputs[] =
2359 {"position", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf},
2362 static const D3D12_SIGNATURE_PARAMETER_DESC vs3_outputs[] =
2364 {"TEXCOORD", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2365 {"TEXCOORD", 2, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x2, 0xd},
2366 {"TEXCOORD", 1, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe},
2367 {"sv_position", 0, 2, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0},
2370 /* Array elements are aligned and placed in consecutive registers.
2371 * Other elements can be allocated in this padding space. */
2372 static const char ps10_source[] =
2373 "struct input\n"
2374 "{\n"
2375 " float2 f1 : FOO1;\n"
2376 " float2 f2 : FOO2;\n"
2377 " float3 f3 : FOO3;\n"
2378 " float2 arr[3] : TEXCOORD0;\n"
2379 " float t3 : TEXCOORD3;\n"
2380 "};\n"
2381 "\n"
2382 "float4 main(in struct input s) : sv_target { return 0; }\n";
2384 static const D3D12_SIGNATURE_PARAMETER_DESC ps10_inputs[] =
2386 {"FOO", 1, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3},
2387 {"FOO", 2, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xc},
2388 {"FOO", 3, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x7},
2389 {"TEXCOORD", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3},
2390 {"TEXCOORD", 3, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x4},
2391 {"TEXCOORD", 1, 3, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3},
2392 {"TEXCOORD", 2, 4, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3},
2395 /* Note how t3 prefers to be allocated as v1.yz instead of v0.zw. */
2396 static const char ps11_source[] =
2397 "struct input\n"
2398 "{\n"
2399 " float2 foo : FOO;\n"
2400 " float1 arr[3] : TEXCOORD0;\n"
2401 " float2 t3 : TEXCOORD3;\n"
2402 "};\n"
2403 "\n"
2404 "float4 main(in struct input s) : sv_target { return 0; }\n";
2406 static const D3D12_SIGNATURE_PARAMETER_DESC ps11_inputs[] =
2408 {"FOO", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3},
2409 {"TEXCOORD", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2410 {"TEXCOORD", 3, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x6},
2411 {"TEXCOORD", 1, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2412 {"TEXCOORD", 2, 3, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2415 /* Only the first element of structs is aligned. */
2416 static const char ps12_source[] =
2417 "struct apple\n"
2418 "{\n"
2419 " float b : SEM_B; // Only this one is aligned.\n"
2420 " float c : SEM_C;\n"
2421 "};\n"
2422 "\n"
2423 " float4 main(float a : SEM_A, apple ap) : sv_target\n"
2424 "{\n"
2425 " return 0;\n"
2426 "}\n";
2428 static const D3D12_SIGNATURE_PARAMETER_DESC ps12_inputs[] =
2430 {"SEM_A", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2431 {"SEM_C", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x2},
2432 {"SEM_B", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2435 static const char vs4_source[] =
2436 "struct st\n"
2437 "{\n"
2438 " float2 t0 : TEXCOORD0;\n"
2439 " float2 t1 : TEXCOORD1;\n"
2440 " float3 t2 : TEXCOORD2;\n"
2441 " nointerpolation float t3 : TEXCOORD3;\n"
2442 " nointerpolation float2 t4 : TEXCOORD4;\n"
2443 " uint t5 : TEXCOORD5;\n"
2444 " float4 position : SV_Position;\n"
2445 " float2 t6[2] : TEXCOORD6;\n"
2446 " float t8 : TEXCOORD8;\n"
2447 "};\n"
2448 "\n"
2449 "void main(out struct st s_out)\n"
2450 "{\n"
2451 " s_out = (struct st)0;\n"
2452 "}\n";
2454 static const D3D12_SIGNATURE_PARAMETER_DESC vs4_inputs[] =
2458 static const D3D12_SIGNATURE_PARAMETER_DESC vs4_outputs[] =
2460 {"TEXCOORD", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3, 0xc},
2461 {"TEXCOORD", 1, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xc, 0x3},
2462 {"TEXCOORD", 2, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x7, 0x8},
2463 {"TEXCOORD", 3, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2464 {"TEXCOORD", 4, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x6, 0x9},
2465 {"TEXCOORD", 5, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x8, 0x7},
2466 {"SV_Position", 0, 3, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0},
2467 {"TEXCOORD", 6, 4, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3, 0xc},
2468 {"TEXCOORD", 8, 4, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x4, 0xb},
2469 {"TEXCOORD", 7, 5, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3, 0xc},
2472 static const char vs5_source[] =
2473 "struct output\n"
2474 "{\n"
2475 " nointerpolation float m1 : ALPHA;\n"
2476 " float3 m2 : BRAVO;\n"
2477 " float2 m3[2] : CHARLIE;\n"
2478 " float m4 : DELTA;\n"
2479 "};\n"
2480 "\n"
2481 "void main(out struct output s, inout float4 p : sv_position)\n"
2482 "{\n"
2483 " s.m1 = 0;\n"
2484 " s.m2 = 0;\n"
2485 " s.m3[0] = 0;\n"
2486 " s.m3[1] = 0;\n"
2487 " s.m4 = 0;\n"
2488 "}\n";
2490 static const D3D12_SIGNATURE_PARAMETER_DESC vs5_inputs[] =
2492 {"sv_position", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf},
2495 static const D3D12_SIGNATURE_PARAMETER_DESC vs5_outputs[] =
2497 {"ALPHA", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2498 {"BRAVO", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x7, 0x8},
2499 {"CHARLIE", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3, 0xc},
2500 {"DELTA", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x4, 0xb},
2501 {"CHARLIE", 1, 3, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3, 0xc},
2502 {"sv_position", 0, 4, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0},
2505 static const char vs6_source[] =
2506 "struct output\n"
2507 "{\n"
2508 " uint a : ALPHA; // Uses o0.x\n"
2509 " uint b : SV_RenderTargetArrayIndex; // Uses o0.y, but is special: it also reserves o0.zw\n"
2510 " uint c : CHARLIE; // Ends up in o1.x\n"
2511 " uint d : DELTA; // Ends up in o1.y\n"
2512 "};\n"
2513 "\n"
2514 "void main(out struct output s, inout float4 p : sv_position)\n"
2515 "{\n"
2516 " s.a = 0;\n"
2517 " s.b = 0;\n"
2518 " s.c = 0;\n"
2519 " s.d = 0;\n"
2520 "};\n";
2522 static const D3D12_SIGNATURE_PARAMETER_DESC vs6_inputs[] =
2524 {"sv_position", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf},
2527 static const D3D12_SIGNATURE_PARAMETER_DESC vs6_outputs[] =
2529 {"ALPHA", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe},
2530 {"SV_RenderTargetArrayIndex", 0, 0, D3D_NAME_RENDER_TARGET_ARRAY_INDEX, D3D_REGISTER_COMPONENT_UINT32, 0x2, 0xd},
2531 {"CHARLIE", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe},
2532 {"DELTA", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x2, 0xd},
2533 {"sv_position", 0, 2, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0},
2536 static const char ps13_source[] =
2537 "struct input\n"
2538 "{\n"
2539 " uint a : ALPHA;\n"
2540 " uint b : SV_ViewPortArrayIndex; // Uses v0.y but also reserves v0.zw\n"
2541 " uint c : CHARLIE;\n"
2542 " uint d : DELTA;\n"
2543 "};\n"
2544 "\n"
2545 "float4 main(struct input s) : sv_target\n"
2546 "{\n"
2547 " return s.a + s.b + s.c + s.d;\n"
2548 "};\n";
2550 static const D3D12_SIGNATURE_PARAMETER_DESC ps13_inputs[] =
2552 {"ALPHA", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x1},
2553 {"SV_ViewPortArrayIndex", 0, 0, D3D_NAME_VIEWPORT_ARRAY_INDEX, D3D_REGISTER_COMPONENT_UINT32, 0x2, 0x2},
2554 {"CHARLIE", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x1},
2555 {"DELTA", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x2, 0x2},
2558 static const char ps14_source[] =
2559 "struct input\n"
2560 "{\n"
2561 " uint a : ALPHA;\n"
2562 " float b : BRAVO;\n"
2563 " uint c : SV_RenderTargetArrayIndex; // Locks 'd', 'e', 'f', and 'h' away from the register.\n"
2564 " uint d : DELTA;\n"
2565 " uint e : ECHO;\n"
2566 " uint f : FOXTROT;\n"
2567 " uint g : SV_ViewPortArrayIndex; // Shares register with 'c'.\n"
2568 " uint h : HOTEL;\n"
2569 " uint i : SV_PrimitiveID; // Shares register with 'c' and 'g'.\n"
2570 "};\n"
2571 "\n"
2572 "float4 main(struct input s) : sv_target\n"
2573 "{\n"
2574 " return s.a + s.b + s.c + s.d + s.e + s.f + s.g + s.h + s.i;\n"
2575 "};\n";
2577 static const D3D12_SIGNATURE_PARAMETER_DESC ps14_inputs[] =
2579 {"ALPHA", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x1},
2580 {"SV_RenderTargetArrayIndex", 0, 0, D3D_NAME_RENDER_TARGET_ARRAY_INDEX, D3D_REGISTER_COMPONENT_UINT32, 0x2, 0x2},
2581 {"SV_ViewPortArrayIndex", 0, 0, D3D_NAME_VIEWPORT_ARRAY_INDEX, D3D_REGISTER_COMPONENT_UINT32, 0x4, 0x4},
2582 {"SV_PrimitiveID", 0, 0, D3D_NAME_PRIMITIVE_ID, D3D_REGISTER_COMPONENT_UINT32, 0x8, 0x8},
2583 {"BRAVO", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0x1},
2584 {"DELTA", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x1},
2585 {"ECHO", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x2, 0x2},
2586 {"FOXTROT", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x4, 0x4},
2587 {"HOTEL", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x8, 0x8},
2590 static const char ps15_source[] =
2591 "struct input\n"
2592 "{\n"
2593 " uint a : ALPHA;\n"
2594 " uint b : SV_PrimitiveID;\n"
2595 " uint c : SV_SampleIndex; // different interpolation mode.\n"
2596 " uint d : SV_IsFrontFace; // different interpolation mode.\n"
2597 " uint e : SV_RenderTargetArrayIndex;\n"
2598 "};\n"
2599 "\n"
2600 "float4 main(struct input s) : sv_target\n"
2601 "{\n"
2602 " return 0;\n"
2603 "};\n";
2605 static const D3D12_SIGNATURE_PARAMETER_DESC ps15_inputs[] =
2607 {"ALPHA", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1},
2608 {"SV_PrimitiveID", 0, 0, D3D_NAME_PRIMITIVE_ID, D3D_REGISTER_COMPONENT_UINT32, 0x2},
2609 {"SV_RenderTargetArrayIndex", 0, 0, D3D_NAME_RENDER_TARGET_ARRAY_INDEX, D3D_REGISTER_COMPONENT_UINT32, 0x4},
2610 {"SV_SampleIndex", 0, 1, D3D_NAME_SAMPLE_INDEX, D3D_REGISTER_COMPONENT_UINT32, 0x1},
2611 {"SV_IsFrontFace", 0, 1, D3D_NAME_IS_FRONT_FACE, D3D_REGISTER_COMPONENT_UINT32, 0x2},
2614 static const char hs1_source[] =
2615 "struct hs_data\n"
2616 "{\n"
2617 " float4 x : sv_position;\n"
2618 " float4 y : position;\n"
2619 "};\n"
2620 "struct patch_constant_data\n"
2621 "{\n"
2622 " float edges[4] : sv_tessfactor;\n"
2623 " float inside[2] : sv_insidetessfactor;\n"
2624 " float4 x : sv_position;\n"
2625 " float4 y : position;\n"
2626 " float4 apple : apple;\n"
2627 "};\n"
2628 "patch_constant_data patch_constant(\n"
2629 " in uint a : sv_primitiveid,\n"
2630 " in float4 b : sv_position)\n"
2631 "{\n"
2632 " return (patch_constant_data)0;\n"
2633 "}\n"
2634 "[domain(\"quad\")]\n"
2635 "[outputcontrolpoints(1)]\n"
2636 "[partitioning(\"integer\")]\n"
2637 "[outputtopology(\"point\")]\n"
2638 "[patchconstantfunc(\"patch_constant\")]\n"
2639 "hs_data main(\n"
2640 " in uint a : sv_outputcontrolpointid,\n"
2641 " in uint b : sv_primitiveid,\n"
2642 " in float4 c : sv_position)\n"
2643 "{\n"
2644 " return (hs_data)0;\n"
2645 "}\n";
2647 static const D3D12_SIGNATURE_PARAMETER_DESC hs1_outputs[] =
2649 {"sv_position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2650 {"position", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2653 static const D3D12_SIGNATURE_PARAMETER_DESC hs1_patch_constants[] =
2655 {"sv_tessfactor", 0, 0, D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2656 {"sv_tessfactor", 1, 1, D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2657 {"sv_tessfactor", 2, 2, D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2658 {"sv_tessfactor", 3, 3, D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2659 {"sv_insidetessfactor", 0, 4, D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2660 {"sv_insidetessfactor", 1, 5, D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2661 {"sv_position", 0, 6, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2662 {"position", 0, 7, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2663 {"apple", 0, 8, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2666 static const char hs2_source[] =
2667 "struct hs_data\n"
2668 "{\n"
2669 " float4 x : sv_position;\n"
2670 "};\n"
2671 "struct patch_constant_data\n"
2672 "{\n"
2673 " float edges[3] : sv_tessfactor;\n"
2674 " float inside : sv_insidetessfactor;\n"
2675 "};\n"
2676 "patch_constant_data patch_constant(in uint a : sv_primitiveid)\n"
2677 "{\n"
2678 " return (patch_constant_data)0;\n"
2679 "}\n"
2680 "[domain(\"tri\")]\n"
2681 "[outputcontrolpoints(1)]\n"
2682 "[partitioning(\"integer\")]\n"
2683 "[outputtopology(\"point\")]\n"
2684 "[patchconstantfunc(\"patch_constant\")]\n"
2685 "hs_data main(in uint a : sv_outputcontrolpointid)\n"
2686 "{\n"
2687 " return (hs_data)0;\n"
2688 "}\n";
2690 static const D3D12_SIGNATURE_PARAMETER_DESC hs2_outputs[] =
2692 {"sv_position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2695 static const D3D12_SIGNATURE_PARAMETER_DESC hs2_patch_constants[] =
2697 {"sv_tessfactor", 0, 0, D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2698 {"sv_tessfactor", 1, 1, D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2699 {"sv_tessfactor", 2, 2, D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2700 {"sv_insidetessfactor", 0, 3, D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2703 static const char hs3_source[] =
2704 "struct hs_data\n"
2705 "{\n"
2706 " float4 x : sv_position;\n"
2707 "};\n"
2708 "struct patch_constant_data\n"
2709 "{\n"
2710 " float edges[2] : sv_tessfactor;\n"
2711 "};\n"
2712 "patch_constant_data patch_constant(in uint a : sv_primitiveid)\n"
2713 "{\n"
2714 " return (patch_constant_data)0;\n"
2715 "}\n"
2716 "[domain(\"isoline\")]\n"
2717 "[outputcontrolpoints(1)]\n"
2718 "[partitioning(\"integer\")]\n"
2719 "[outputtopology(\"point\")]\n"
2720 "[patchconstantfunc(\"patch_constant\")]\n"
2721 "hs_data main(in uint a : sv_outputcontrolpointid)\n"
2722 "{\n"
2723 " return (hs_data)0;\n"
2724 "}\n";
2726 static const D3D12_SIGNATURE_PARAMETER_DESC hs3_outputs[] =
2728 {"sv_position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2731 static const D3D12_SIGNATURE_PARAMETER_DESC hs3_patch_constants[] =
2733 {"sv_tessfactor", 0, 0, D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2734 {"sv_tessfactor", 1, 1, D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2737 static const char hs4_source[] =
2738 "struct vs_data\n"
2739 "{\n"
2740 " float4 x : sv_position;\n"
2741 " float4 y : position;\n"
2742 " float4 apple : apple;\n"
2743 "};\n"
2744 "struct hs_data\n"
2745 "{\n"
2746 " float4 x : sv_position;\n"
2747 "};\n"
2748 "struct patch_constant_data\n"
2749 "{\n"
2750 " float edges[2] : sv_tessfactor;\n"
2751 "};\n"
2752 "patch_constant_data patch_constant(InputPatch<vs_data, 2> input, in uint a : sv_primitiveid)\n"
2753 "{\n"
2754 " return (patch_constant_data)(input[0].apple.x + input[0].apple.y + input[1].apple.z);\n"
2755 "}\n"
2756 "[domain(\"isoline\")]\n"
2757 "[outputcontrolpoints(2)]\n"
2758 "[partitioning(\"integer\")]\n"
2759 "[outputtopology(\"point\")]\n"
2760 "[patchconstantfunc(\"patch_constant\")]\n"
2761 "hs_data main(InputPatch<vs_data, 2> input, in uint a : sv_outputcontrolpointid)\n"
2762 "{\n"
2763 " hs_data ret;\n"
2764 " ret.x = input[0].x;\n"
2765 " return ret;\n"
2766 "}\n";
2768 static const D3D12_SIGNATURE_PARAMETER_DESC hs4_inputs[] =
2770 {"sv_position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf},
2771 {"position", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2772 {"apple", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x7},
2775 static const D3D12_SIGNATURE_PARAMETER_DESC hs4_outputs[] =
2777 {"sv_position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2780 static const D3D12_SIGNATURE_PARAMETER_DESC hs4_patch_constants[] =
2782 {"sv_tessfactor", 0, 0, D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2783 {"sv_tessfactor", 1, 1, D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe},
2786 static const char ds1_source[] =
2787 "struct hs_data\n"
2788 "{\n"
2789 " float edges[4] : sv_tessfactor;\n"
2790 " float inside[2] : sv_insidetessfactor;\n"
2791 " float4 x : sv_position;\n"
2792 " float4 y : position;\n"
2793 " float4 apple : apple;\n"
2794 "};\n"
2795 "\n"
2796 "struct ds_data\n"
2797 "{\n"
2798 " float4 x : sv_position;\n"
2799 " float4 y : position;\n"
2800 " float2 banana : banana;\n"
2801 "};\n"
2802 "\n"
2803 "[domain(\"quad\")]\n"
2804 "void main(\n"
2805 " in hs_data input,\n"
2806 " in uint a : sv_primitiveid,\n"
2807 " in float2 b : sv_domainlocation,\n"
2808 " out ds_data output)\n"
2809 "{\n"
2810 " output.x = output.y = input.apple;\n"
2811 " output.banana = float2(input.edges[0], input.inside[1]);\n"
2812 "}\n";
2814 static const D3D12_SIGNATURE_PARAMETER_DESC ds1_outputs[] =
2816 {"sv_position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2817 {"position", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2818 {"banana", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3, 0xc},
2821 static const D3D12_SIGNATURE_PARAMETER_DESC ds1_patch_constants[] =
2823 {"sv_tessfactor", 0, 0, D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0x1},
2824 {"sv_tessfactor", 1, 1, D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2825 {"sv_tessfactor", 2, 2, D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2826 {"sv_tessfactor", 3, 3, D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2827 {"sv_insidetessfactor", 0, 4, D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2828 {"sv_insidetessfactor", 1, 5, D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0x1},
2829 {"sv_position", 0, 6, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2830 {"position", 0, 7, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2831 {"apple", 0, 8, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf},
2834 static const char ds2_source[] =
2835 "struct hs_data\n"
2836 "{\n"
2837 " float edges[3] : sv_tessfactor;\n"
2838 " float inside : sv_insidetessfactor;\n"
2839 "};\n"
2840 "\n"
2841 "[domain(\"tri\")]\n"
2842 "float4 main(in hs_data input) : apple\n"
2843 "{\n"
2844 " return 0;\n"
2845 "}\n";
2847 static const D3D12_SIGNATURE_PARAMETER_DESC ds2_outputs[] =
2849 {"apple", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2852 static const D3D12_SIGNATURE_PARAMETER_DESC ds2_patch_constants[] =
2854 {"sv_tessfactor", 0, 0, D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2855 {"sv_tessfactor", 1, 1, D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2856 {"sv_tessfactor", 2, 2, D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2857 {"sv_insidetessfactor", 0, 3, D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2860 static const char ds3_source[] =
2861 "struct hs_data\n"
2862 "{\n"
2863 " float edges[2] : sv_tessfactor;\n"
2864 "};\n"
2865 "\n"
2866 "[domain(\"isoline\")]\n"
2867 "float4 main(in hs_data input) : apple\n"
2868 "{\n"
2869 " return 0;\n"
2870 "}\n";
2872 static const D3D12_SIGNATURE_PARAMETER_DESC ds3_outputs[] =
2874 {"apple", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2877 static const D3D12_SIGNATURE_PARAMETER_DESC ds3_patch_constants[] =
2879 {"sv_tessfactor", 0, 0, D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2880 {"sv_tessfactor", 1, 1, D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2883 static const char ds4_source[] =
2884 "struct hs_data\n"
2885 "{\n"
2886 " float4 x : sv_position;\n"
2887 " float4 y : position;\n"
2888 " float4 apple : apple;\n"
2889 "};\n"
2890 "struct hs_pc_data\n"
2891 "{\n"
2892 " float edges[2] : sv_tessfactor;\n"
2893 "};\n"
2894 "\n"
2895 "[domain(\"isoline\")]\n"
2896 "float4 main(in hs_pc_data input_pc, OutputPatch<hs_data, 2> input) : apple\n"
2897 "{\n"
2898 " return input[0].apple;\n"
2899 "}\n";
2901 static const D3D12_SIGNATURE_PARAMETER_DESC ds4_inputs[] =
2903 {"sv_position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2904 {"position", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2905 {"apple", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf},
2908 static const D3D12_SIGNATURE_PARAMETER_DESC ds4_outputs[] =
2910 {"apple", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf},
2913 static const D3D12_SIGNATURE_PARAMETER_DESC ds4_patch_constants[] =
2915 {"sv_tessfactor", 0, 0, D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2916 {"sv_tessfactor", 1, 1, D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR, D3D_REGISTER_COMPONENT_FLOAT32, 0x1},
2919 static const struct
2921 const char *source;
2922 const char *target;
2923 bool compat;
2924 const D3D12_SIGNATURE_PARAMETER_DESC *inputs;
2925 unsigned int input_count;
2926 const D3D12_SIGNATURE_PARAMETER_DESC *outputs;
2927 unsigned int output_count;
2928 const D3D12_SIGNATURE_PARAMETER_DESC *patch_constants;
2929 unsigned int patch_constant_count;
2930 bool signature_elements_todo;
2932 tests[] =
2934 {vs1_source, "vs_4_0", false, vs1_inputs, ARRAY_SIZE(vs1_inputs), vs1_outputs, ARRAY_SIZE(vs1_outputs)},
2935 {vs1_source, "vs_4_0", true, vs1_inputs, ARRAY_SIZE(vs1_inputs), vs1_outputs, ARRAY_SIZE(vs1_outputs)},
2936 {vs2_source, "vs_4_0", false, vs2_inputs, ARRAY_SIZE(vs2_inputs), vs2_outputs, ARRAY_SIZE(vs2_outputs)},
2937 {vs2_source, "vs_4_0", true, vs2_inputs, ARRAY_SIZE(vs2_inputs), vs2_legacy_outputs, ARRAY_SIZE(vs2_legacy_outputs)},
2938 {ps1_source, "ps_4_1", false, ps1_inputs, ARRAY_SIZE(ps1_inputs), ps1_outputs, ARRAY_SIZE(ps1_outputs)},
2939 {ps2_source, "ps_4_0", true, ps2_inputs, ARRAY_SIZE(ps2_inputs), ps2_outputs, ARRAY_SIZE(ps2_outputs)},
2940 {cs1_source, "cs_5_0"},
2941 {ps3_source, "ps_4_0", false, ps3_inputs, ARRAY_SIZE(ps3_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2942 {ps4_source, "ps_4_0", false, ps4_inputs, ARRAY_SIZE(ps4_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2943 {ps5_source, "ps_4_0", false, ps5_inputs, ARRAY_SIZE(ps5_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2944 {ps6_source, "ps_4_0", false, ps6_inputs, ARRAY_SIZE(ps6_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2945 {ps7_source, "ps_4_0", false, ps7_inputs, ARRAY_SIZE(ps7_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2946 {ps8_source, "ps_4_0", false, ps8_inputs, ARRAY_SIZE(ps8_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2947 {ps9_source, "ps_4_0", false, ps9_inputs, ARRAY_SIZE(ps9_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2948 {vs3_source, "vs_4_0", false, vs3_inputs, ARRAY_SIZE(vs3_inputs), vs3_outputs, ARRAY_SIZE(vs3_outputs)},
2949 {ps10_source, "ps_4_0", false, ps10_inputs, ARRAY_SIZE(ps10_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2950 {ps11_source, "ps_4_0", false, ps11_inputs, ARRAY_SIZE(ps11_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2951 {ps12_source, "ps_4_0", false, ps12_inputs, ARRAY_SIZE(ps12_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2952 {vs4_source, "vs_4_0", false, vs4_inputs, ARRAY_SIZE(vs4_inputs), vs4_outputs, ARRAY_SIZE(vs4_outputs)},
2953 {vs5_source, "vs_4_0", false, vs5_inputs, ARRAY_SIZE(vs5_inputs), vs5_outputs, ARRAY_SIZE(vs5_outputs)},
2954 {vs6_source, "vs_4_0", false, vs6_inputs, ARRAY_SIZE(vs6_inputs), vs6_outputs, ARRAY_SIZE(vs6_outputs)},
2955 {ps13_source, "ps_4_0", false, ps13_inputs, ARRAY_SIZE(ps13_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2956 {ps14_source, "ps_4_0", false, ps14_inputs, ARRAY_SIZE(ps14_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2957 {ps15_source, "ps_4_1", false, ps15_inputs, ARRAY_SIZE(ps15_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
2958 {hs1_source, "hs_5_0", false, NULL, 0, hs1_outputs, ARRAY_SIZE(hs1_outputs), hs1_patch_constants, ARRAY_SIZE(hs1_patch_constants)},
2959 {hs2_source, "hs_5_0", false, NULL, 0, hs2_outputs, ARRAY_SIZE(hs2_outputs), hs2_patch_constants, ARRAY_SIZE(hs2_patch_constants)},
2960 {hs3_source, "hs_5_0", false, NULL, 0, hs3_outputs, ARRAY_SIZE(hs3_outputs), hs3_patch_constants, ARRAY_SIZE(hs3_patch_constants)},
2961 {hs4_source, "hs_5_0", false, hs4_inputs, ARRAY_SIZE(hs4_inputs), hs4_outputs, ARRAY_SIZE(hs4_outputs), hs4_patch_constants, ARRAY_SIZE(hs4_patch_constants)},
2962 {ds1_source, "ds_5_0", false, NULL, 0, ds1_outputs, ARRAY_SIZE(ds1_outputs), ds1_patch_constants, ARRAY_SIZE(ds1_patch_constants)},
2963 {ds2_source, "ds_5_0", false, NULL, 0, ds2_outputs, ARRAY_SIZE(ds2_outputs), ds2_patch_constants, ARRAY_SIZE(ds2_patch_constants)},
2964 {ds3_source, "ds_5_0", false, NULL, 0, ds3_outputs, ARRAY_SIZE(ds3_outputs), ds3_patch_constants, ARRAY_SIZE(ds3_patch_constants)},
2965 {ds4_source, "ds_5_0", false, ds4_inputs, ARRAY_SIZE(ds4_inputs), ds4_outputs, ARRAY_SIZE(ds4_outputs), ds4_patch_constants, ARRAY_SIZE(ds4_patch_constants)},
2968 for (unsigned int i = 0; i < ARRAY_SIZE(tests); ++i)
2970 vkd3d_test_push_context("Test %u", i);
2972 code = compile_shader_flags(tests[i].source, tests[i].target,
2973 tests[i].compat ? D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY : 0);
2975 hr = D3DReflect(ID3D10Blob_GetBufferPointer(code), ID3D10Blob_GetBufferSize(code),
2976 &IID_ID3D12ShaderReflection, (void **)&reflection);
2977 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2979 hr = reflection->lpVtbl->GetDesc(reflection, &shader_desc);
2980 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2981 ok(shader_desc.InputParameters == tests[i].input_count,
2982 "Got %u input parameters.\n", shader_desc.InputParameters);
2983 ok(shader_desc.OutputParameters == tests[i].output_count,
2984 "Got %u output parameters.\n", shader_desc.OutputParameters);
2985 ok(shader_desc.PatchConstantParameters == tests[i].patch_constant_count,
2986 "Got %u patch constant parameters.\n", shader_desc.PatchConstantParameters);
2988 for (unsigned int j = 0; j < shader_desc.InputParameters; ++j)
2990 vkd3d_test_push_context("Input %u", j);
2991 hr = reflection->lpVtbl->GetInputParameterDesc(reflection, j, &desc);
2992 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2993 check_signature_element(&desc, &tests[i].inputs[j], tests[i].signature_elements_todo);
2994 vkd3d_test_pop_context();
2997 hr = reflection->lpVtbl->GetInputParameterDesc(reflection, shader_desc.InputParameters, &desc);
2998 ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
3000 for (unsigned int j = 0; j < shader_desc.OutputParameters; ++j)
3002 vkd3d_test_push_context("Output %u", j);
3003 hr = reflection->lpVtbl->GetOutputParameterDesc(reflection, j, &desc);
3004 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
3005 check_signature_element(&desc, &tests[i].outputs[j], tests[i].signature_elements_todo);
3006 vkd3d_test_pop_context();
3009 hr = reflection->lpVtbl->GetOutputParameterDesc(reflection, shader_desc.OutputParameters, &desc);
3010 ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
3012 for (unsigned int j = 0; j < shader_desc.PatchConstantParameters; ++j)
3014 vkd3d_test_push_context("Patch constant %u", j);
3015 hr = reflection->lpVtbl->GetPatchConstantParameterDesc(reflection, j, &desc);
3016 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
3017 check_signature_element(&desc, &tests[i].patch_constants[j], tests[i].signature_elements_todo);
3018 vkd3d_test_pop_context();
3021 hr = reflection->lpVtbl->GetPatchConstantParameterDesc(reflection, shader_desc.PatchConstantParameters, &desc);
3022 ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
3024 ID3D10Blob_Release(code);
3025 refcount = reflection->lpVtbl->Release(reflection);
3026 ok(!refcount, "Got unexpected refcount %u.\n", refcount);
3028 vkd3d_test_pop_context();
3032 static void test_disassemble_shader(void)
3034 ID3DBlob *blob;
3035 int hr;
3037 /* A Direct3D 8 vertex shader without dcl_ instructions. */
3038 static const uint32_t vs_1_1[] =
3040 0xfffe0101, /* vs_1_1 */
3041 0x00000005, 0x800f0000, 0x90000000, 0xa0e40000, /* mul r0, v0.x, c0 */
3042 0x00000004, 0x800f0000, 0x90550000, 0xa0e40001, 0x80e40000, /* mad r0, v0.y, c1, r0 */
3043 0x00000004, 0x800f0000, 0x90aa0000, 0xa0e40002, 0x80e40000, /* mad r0, v0.z, c2, r0 */
3044 0x00000004, 0xc00f0000, 0x90ff0000, 0xa0e40003, 0x80e40000, /* mad oPos, v0.w, c3, r0 */
3045 0x0000ffff, /* end */
3048 static const uint32_t vs_2_0[] =
3050 0xfffe0200, /* vs_2_0 */
3051 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */
3052 0x0200001f, 0x80000003, 0x900f0001, /* dcl_normal v1 */
3053 0x0200001f, 0x8001000a, 0x900f0002, /* dcl_color1 v2 */
3054 0x0200001f, 0x80000005, 0x900f0003, /* dcl_texcoord0 v3 */
3055 0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */
3056 0x02000001, 0xd00f0001, 0x90e40002, /* mov oD1, v2 */
3057 0x02000001, 0xe0070000, 0x90e40003, /* mov oT0.xyz, v3 */
3058 0x02000001, 0xc00f0001, 0x90ff0002, /* mov oFog, v2.w */
3059 0x02000001, 0xc00f0002, 0x90ff0001, /* mov oPts, v1.w */
3060 0x0000ffff, /* end */
3063 /* A shader model 3 vertex shader without dcl_ instructions. */
3064 static const uint32_t vs_3_0[] =
3066 0xfffe0300, /* vs_3_0 */
3067 0x02000001, 0xe00f0000, 0x90e40000, /* mov o0, v0 */
3068 0x0000ffff, /* end */
3071 /* A "shader model 4" d3dbc vertex shader. */
3072 static const uint32_t vs_4_0[] =
3074 0xfffe0400, /* vs_4_0 */
3075 0x02000001, 0xe00f0000, 0x90e40000, /* mov o0, v0 */
3076 0x0000ffff, /* end */
3079 /* An actual shader model 4 dxbc-tpf vertex shader. */
3080 static const uint32_t vs_4_0_dxbc[] =
3082 #if 0
3083 float4 main(float4 position : POSITION) : SV_POSITION
3085 return position;
3087 #endif
3088 0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
3089 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
3090 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
3091 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
3092 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
3093 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
3094 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
3097 hr = D3DDisassemble(vs_1_1, 0, 0, NULL, &blob);
3098 ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
3100 hr = D3DDisassemble(vs_1_1, sizeof(vs_1_1), 0, NULL, &blob);
3101 ok(hr == S_OK, "Got hr %#x.\n", hr);
3102 ID3D10Blob_Release(blob);
3104 hr = D3DDisassemble(vs_2_0, sizeof(vs_2_0), 0, NULL, &blob);
3105 ok(hr == S_OK, "Got hr %#x.\n", hr);
3106 ID3D10Blob_Release(blob);
3108 hr = D3DDisassemble(vs_3_0, sizeof(vs_3_0), 0, NULL, &blob);
3109 ok(hr == S_OK, "Got hr %#x.\n", hr);
3110 ID3D10Blob_Release(blob);
3112 hr = D3DDisassemble(vs_4_0, sizeof(vs_4_0), 0, NULL, &blob);
3113 todo ok(hr == S_OK, "Got hr %#x.\n", hr);
3114 if (SUCCEEDED(hr))
3115 ID3D10Blob_Release(blob);
3117 hr = D3DDisassemble(vs_4_0_dxbc, sizeof(vs_4_0_dxbc), 0, NULL, &blob);
3118 ok(hr == S_OK, "Got hr %#x.\n", hr);
3119 ID3D10Blob_Release(blob);
3122 START_TEST(hlsl_d3d12)
3124 parse_args(argc, argv);
3125 enable_d3d12_debug_layer();
3126 init_adapter_info();
3128 run_test(test_preprocess);
3129 run_test(test_thread_id);
3130 run_test(test_create_blob);
3131 run_test(test_get_blob_part);
3132 run_test(test_reflection);
3133 run_test(test_default_values_reflection);
3134 run_test(test_signature_reflection);
3135 run_test(test_disassemble_shader);