mfplat: Read queue subscriber within the critical section.
[wine/zf.git] / dlls / d3dcompiler_43 / tests / reflection.c
blobbc802f016a5f5ff64ce2c779327ed11020080c19
1 /*
2 * Copyright 2010 Rico Schüller
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
20 * Nearly all compiler functions need the shader blob and the size. The size
21 * is always located at DWORD #6 in the shader blob (blob[6]).
22 * The functions are e.g.: D3DGet*SignatureBlob, D3DReflect
25 #define COBJMACROS
26 #include "initguid.h"
27 #include "d3dcompiler.h"
28 #include "wine/test.h"
30 /* includes for older reflection interfaces */
31 #include "d3d10.h"
32 #include "d3d10_1shader.h"
35 * This doesn't belong here, but for some functions it is possible to return that value,
36 * see http://msdn.microsoft.com/en-us/library/bb205278%28v=VS.85%29.aspx
37 * The original definition is in D3DX10core.h.
39 #define D3DERR_INVALIDCALL 0x8876086c
41 #if D3D_COMPILER_VERSION
42 static HRESULT (WINAPI *pD3DReflect)(const void *, SIZE_T, REFIID, void **);
43 #endif
45 static HRESULT call_reflect(const void *data, SIZE_T data_size, REFIID riid, void **reflection)
47 #if D3D_COMPILER_VERSION
48 return pD3DReflect(data, data_size, riid, reflection);
49 #else
50 return D3D10ReflectShader(data, data_size, (ID3D10ShaderReflection **)reflection);
51 #endif
54 /* Creator string for comparison - Version 9.29.952.3111 (43) */
55 static DWORD shader_creator[] = {
56 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d,
57 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00,
60 #if D3D_COMPILER_VERSION
62 * fxc.exe /E VS /Tvs_4_0 /Fx
64 #if 0
65 float4 VS(float4 position : POSITION, float4 pos : SV_POSITION) : SV_POSITION
67 return position;
69 #endif
70 static DWORD test_reflection_blob[] = {
71 0x43425844, 0x77c6324f, 0xfd27948a, 0xe6958d31, 0x53361cba, 0x00000001, 0x000001d8, 0x00000005,
72 0x00000034, 0x0000008c, 0x000000e4, 0x00000118, 0x0000015c, 0x46454452, 0x00000050, 0x00000000,
73 0x00000000, 0x00000000, 0x0000001c, 0xfffe0400, 0x00000100, 0x0000001c, 0x7263694d, 0x666f736f,
74 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e,
75 0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000050, 0x00000002, 0x00000008, 0x00000038,
76 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
77 0x00000003, 0x00000001, 0x0000000f, 0x49534f50, 0x4e4f4954, 0x5f565300, 0x49534f50, 0x4e4f4954,
78 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001,
79 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c,
80 0x00010040, 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000,
81 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x54415453,
82 0x00000074, 0x00000002, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000,
83 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
84 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
85 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
88 static void test_reflection_references(void)
90 ID3D11ShaderReflection *ref11, *ref11_test;
91 ID3D10ShaderReflection1 *ref10_1;
92 ID3D10ShaderReflection *ref10;
93 HRESULT hr, expected;
94 ULONG count;
96 hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
97 ok(hr == S_OK, "D3DReflect failed, got %x, expected %x\n", hr, S_OK);
99 hr = ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D11ShaderReflection, (void **)&ref11_test);
100 ok(hr == S_OK, "QueryInterface failed, got %x, expected %x\n", hr, S_OK);
102 count = ref11_test->lpVtbl->Release(ref11_test);
103 ok(count == 1, "Release failed %u\n", count);
105 hr = ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D10ShaderReflection, (void **)&ref10);
106 ok(hr == E_NOINTERFACE, "QueryInterface failed, got %x, expected %x\n", hr, E_NOINTERFACE);
108 hr = ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
109 ok(hr == E_NOINTERFACE, "QueryInterface failed, got %x, expected %x\n", hr, E_NOINTERFACE);
111 count = ref11->lpVtbl->Release(ref11);
112 ok(count == 0, "Release failed %u\n", count);
114 /* check invalid cases */
115 #if D3D_COMPILER_VERSION >= 46
116 expected = E_INVALIDARG;
117 #else
118 expected = E_NOINTERFACE;
119 #endif
120 hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D10ShaderReflection, (void **)&ref10);
121 ok(hr == expected || broken(hr == E_NOINTERFACE) /* Windows 8 */,
122 "D3DReflect failed, got %x, expected %x\n", hr, expected);
124 hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
125 ok(hr == expected || broken(hr == E_NOINTERFACE) /* Windows 8 */,
126 "D3DReflect failed, got %x, expected %x\n", hr, expected);
128 hr = pD3DReflect(NULL, test_reflection_blob[6], &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
129 ok(hr == D3DERR_INVALIDCALL, "D3DReflect failed, got %x, expected %x\n", hr, D3DERR_INVALIDCALL);
131 hr = pD3DReflect(NULL, test_reflection_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
132 ok(hr == D3DERR_INVALIDCALL, "D3DReflect failed, got %x, expected %x\n", hr, D3DERR_INVALIDCALL);
134 /* returns different errors with different sizes */
135 hr = pD3DReflect(test_reflection_blob, 31, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
136 ok(hr == D3DERR_INVALIDCALL, "D3DReflect failed, got %x, expected %x\n", hr, D3DERR_INVALIDCALL);
138 #if D3D_COMPILER_VERSION >= 46
139 expected = D3DERR_INVALIDCALL;
140 #else
141 expected = E_FAIL;
142 #endif
143 hr = pD3DReflect(test_reflection_blob, 32, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
144 ok(hr == expected, "Got %x, expected %x.\n", hr, expected);
146 hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
147 ok(hr == expected, "Got %x, expected %x.\n", hr, expected);
149 hr = pD3DReflect(test_reflection_blob, 31, &IID_ID3D11ShaderReflection, (void **)&ref11);
150 ok(hr == D3DERR_INVALIDCALL, "Got %x, expected %x.\n", hr, D3DERR_INVALIDCALL);
152 hr = pD3DReflect(test_reflection_blob, 32, &IID_ID3D11ShaderReflection, (void **)&ref11);
153 ok(hr == expected, "Got %x, expected %x.\n", hr, expected);
155 hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D11ShaderReflection, (void **)&ref11);
156 ok(hr == expected, "Got %x, expected %x.\n", hr, expected);
158 #endif
160 #if D3D_COMPILER_VERSION
161 static void test_reflection_interfaces(void)
163 ID3D12ShaderReflection *ref12 = NULL;
164 ID3D11ShaderReflection *ref11;
165 HRESULT hr, expected_hr;
166 IUnknown *iface, *iunk;
167 ULONG count;
169 expected_hr = D3D_COMPILER_VERSION < 46 ? E_NOINTERFACE : D3D_COMPILER_VERSION == 46 ? E_INVALIDARG : S_OK;
170 hr = call_reflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D12ShaderReflection, (void **)&ref12);
171 /* Broken with older d3dcompiler_47. */
172 ok(hr == expected_hr || broken(expected_hr == S_OK && hr == E_NOINTERFACE), "Got unexpected hr %#x.\n", hr);
174 if (hr != S_OK)
175 return;
177 hr = call_reflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
178 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
180 hr = ref12->lpVtbl->QueryInterface(ref12, &IID_ID3D11ShaderReflection, (void **)&iface);
181 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
182 ok(iface == (void *)ref12, "Got unexpected interfaces %p, %p.\n", iface, ref12);
183 hr = iface->lpVtbl->QueryInterface(iface, &IID_IUnknown, (void **)&iunk);
184 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
185 ok(iface == iunk, "Got unexpected iface %p.\n", iface);
186 iface->lpVtbl->Release(iunk);
187 iface->lpVtbl->Release(iface);
189 hr = ref12->lpVtbl->QueryInterface(ref12, &IID_IUnknown, (void **)&iface);
190 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
191 ok(iface == (IUnknown *)ref12, "Got unexpected iface %p.\n", iface);
192 iface->lpVtbl->Release(iface);
194 hr = ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D12ShaderReflection, (void **)&iface);
195 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
196 ok(iface == (void *)ref11, "Got unexpected interfaces %p, %p.\n", iface, ref11);
197 hr = iface->lpVtbl->QueryInterface(iface, &IID_IUnknown, (void **)&iunk);
198 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
199 ok(iface == iunk, "Got unexpected iface %p.\n", iface);
200 iface->lpVtbl->Release(iunk);
201 iface->lpVtbl->Release(iface);
203 hr = ref11->lpVtbl->QueryInterface(ref11, &IID_IUnknown, (void **)&iface);
204 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
205 ok(iface == (IUnknown *)ref11, "Got unexpected iface %p.\n", iface);
206 iface->lpVtbl->Release(iface);
208 hr = ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D10ShaderReflection, (void **)&iface);
209 ok(hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
210 hr = ref12->lpVtbl->QueryInterface(ref12, &IID_ID3D10ShaderReflection, (void **)&iface);
211 ok(hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
213 count = ref12->lpVtbl->Release(ref12);
214 ok(!count, "Got unexpected ref count %u.\n", count);
215 count = ref11->lpVtbl->Release(ref11);
216 ok(!count, "Got unexpected ref count %u.\n", count);
218 #endif
221 * fxc.exe /E VS /Tvs_4_1 /Fx
223 #if 0
224 struct vsin
226 float4 x : SV_position;
227 float4 a : BINORMAL;
228 uint b : BLENDINDICES;
229 float c : BLENDWEIGHT;
230 float4 d : COLOR;
231 float4 d1 : COLOR1;
232 float4 e : NORMAL;
233 float4 f : POSITION;
234 float4 g : POSITIONT;
235 float h : PSIZE;
236 float4 i : TANGENT;
237 float4 j : TEXCOORD;
238 uint k : SV_VertexID;
239 uint l : SV_InstanceID;
240 float m : testin;
242 struct vsout
244 float4 x : SV_position;
245 float4 a : COLOR0;
246 float b : FOG;
247 float4 c : POSITION0;
248 float d : PSIZE;
249 float e : TESSFACTOR0;
250 float4 f : TEXCOORD0;
251 float g : SV_ClipDistance0;
252 float h : SV_CullDistance0;
253 uint i : SV_InstanceID;
254 float j : testout;
256 vsout VS(vsin x)
258 vsout s;
259 s.x = float4(1.6f, 0.3f, 0.1f, 0.0f);
260 int y = 1;
261 int p[5] = {1, 2, 3, 5, 4};
262 y = y << (int) x.x.x & 0xf;
263 s.x.x = p[y];
264 s.a = x.d;
265 s.b = x.c;
266 s.c = x.f;
267 s.d = x.h;
268 s.e = x.h;
269 s.f = x.j;
270 s.g = 1.0f;
271 s.h = 1.0f;
272 s.i = 2;
273 s.j = x.m;
274 return s;
276 #endif
277 static DWORD test_reflection_desc_vs_blob[] = {
278 0x43425844, 0xb65955ac, 0xcea1cb75, 0x06c5a1ad, 0x8a555fa1, 0x00000001, 0x0000076c, 0x00000005,
279 0x00000034, 0x0000008c, 0x0000028c, 0x00000414, 0x000006f0, 0x46454452, 0x00000050, 0x00000000,
280 0x00000000, 0x00000000, 0x0000001c, 0xfffe0401, 0x00000100, 0x0000001c, 0x7263694d, 0x666f736f,
281 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e,
282 0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x000001f8, 0x0000000f, 0x00000008, 0x00000170,
283 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000010f, 0x0000017c, 0x00000000, 0x00000000,
284 0x00000003, 0x00000001, 0x0000000f, 0x00000185, 0x00000000, 0x00000000, 0x00000001, 0x00000002,
285 0x00000001, 0x00000192, 0x00000000, 0x00000000, 0x00000003, 0x00000003, 0x00000101, 0x0000019e,
286 0x00000000, 0x00000000, 0x00000003, 0x00000004, 0x00000f0f, 0x0000019e, 0x00000001, 0x00000000,
287 0x00000003, 0x00000005, 0x0000000f, 0x000001a4, 0x00000000, 0x00000000, 0x00000003, 0x00000006,
288 0x0000000f, 0x000001ab, 0x00000000, 0x00000000, 0x00000003, 0x00000007, 0x00000f0f, 0x000001b4,
289 0x00000000, 0x00000000, 0x00000003, 0x00000008, 0x0000000f, 0x000001be, 0x00000000, 0x00000000,
290 0x00000003, 0x00000009, 0x00000101, 0x000001c4, 0x00000000, 0x00000000, 0x00000003, 0x0000000a,
291 0x0000000f, 0x000001cc, 0x00000000, 0x00000000, 0x00000003, 0x0000000b, 0x00000f0f, 0x000001d5,
292 0x00000000, 0x00000006, 0x00000001, 0x0000000c, 0x00000001, 0x000001e1, 0x00000000, 0x00000008,
293 0x00000001, 0x0000000d, 0x00000001, 0x000001ef, 0x00000000, 0x00000000, 0x00000003, 0x0000000e,
294 0x00000101, 0x705f5653, 0x7469736f, 0x006e6f69, 0x4f4e4942, 0x4c414d52, 0x454c4200, 0x4e49444e,
295 0x45434944, 0x4c420053, 0x57444e45, 0x48474945, 0x4f430054, 0x00524f4c, 0x4d524f4e, 0x50004c41,
296 0x5449534f, 0x004e4f49, 0x49534f50, 0x4e4f4954, 0x53500054, 0x00455a49, 0x474e4154, 0x00544e45,
297 0x43584554, 0x44524f4f, 0x5f565300, 0x74726556, 0x44497865, 0x5f565300, 0x74736e49, 0x65636e61,
298 0x74004449, 0x69747365, 0xabab006e, 0x4e47534f, 0x00000180, 0x0000000b, 0x00000008, 0x00000110,
299 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000011c, 0x00000000, 0x00000000,
300 0x00000003, 0x00000001, 0x0000000f, 0x00000122, 0x00000000, 0x00000000, 0x00000003, 0x00000002,
301 0x00000e01, 0x00000126, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000d02, 0x0000012c,
302 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000b04, 0x00000137, 0x00000000, 0x00000000,
303 0x00000003, 0x00000002, 0x00000708, 0x0000013f, 0x00000000, 0x00000000, 0x00000003, 0x00000003,
304 0x0000000f, 0x00000148, 0x00000000, 0x00000000, 0x00000003, 0x00000004, 0x0000000f, 0x00000151,
305 0x00000000, 0x00000002, 0x00000003, 0x00000005, 0x00000e01, 0x00000161, 0x00000000, 0x00000003,
306 0x00000003, 0x00000005, 0x00000d02, 0x00000171, 0x00000000, 0x00000000, 0x00000001, 0x00000006,
307 0x00000e01, 0x705f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0x4f460052, 0x53500047, 0x00455a49,
308 0x53534554, 0x54434146, 0x7400524f, 0x6f747365, 0x50007475, 0x5449534f, 0x004e4f49, 0x43584554,
309 0x44524f4f, 0x5f565300, 0x70696c43, 0x74736944, 0x65636e61, 0x5f565300, 0x6c6c7543, 0x74736944,
310 0x65636e61, 0x5f565300, 0x74736e49, 0x65636e61, 0xab004449, 0x52444853, 0x000002d4, 0x00010041,
311 0x000000b5, 0x0100086a, 0x0300005f, 0x00101012, 0x00000000, 0x0300005f, 0x00101012, 0x00000003,
312 0x0300005f, 0x001010f2, 0x00000004, 0x0300005f, 0x001010f2, 0x00000007, 0x0300005f, 0x00101012,
313 0x00000009, 0x0300005f, 0x001010f2, 0x0000000b, 0x0300005f, 0x00101012, 0x0000000e, 0x04000067,
314 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102012,
315 0x00000002, 0x03000065, 0x00102022, 0x00000002, 0x03000065, 0x00102042, 0x00000002, 0x03000065,
316 0x00102082, 0x00000002, 0x03000065, 0x001020f2, 0x00000003, 0x03000065, 0x001020f2, 0x00000004,
317 0x04000067, 0x00102012, 0x00000005, 0x00000002, 0x04000067, 0x00102022, 0x00000005, 0x00000003,
318 0x03000065, 0x00102012, 0x00000006, 0x02000068, 0x00000001, 0x04000069, 0x00000000, 0x00000005,
319 0x00000004, 0x06000036, 0x00203012, 0x00000000, 0x00000000, 0x00004001, 0x00000001, 0x06000036,
320 0x00203012, 0x00000000, 0x00000001, 0x00004001, 0x00000002, 0x06000036, 0x00203012, 0x00000000,
321 0x00000002, 0x00004001, 0x00000003, 0x06000036, 0x00203012, 0x00000000, 0x00000003, 0x00004001,
322 0x00000005, 0x06000036, 0x00203012, 0x00000000, 0x00000004, 0x00004001, 0x00000004, 0x0500001b,
323 0x00100012, 0x00000000, 0x0010100a, 0x00000000, 0x07000029, 0x00100012, 0x00000000, 0x00004001,
324 0x00000001, 0x0010000a, 0x00000000, 0x07000001, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
325 0x00004001, 0x0000000f, 0x07000036, 0x00100012, 0x00000000, 0x0420300a, 0x00000000, 0x0010000a,
326 0x00000000, 0x0500002b, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x08000036, 0x001020e2,
327 0x00000000, 0x00004002, 0x00000000, 0x3e99999a, 0x3dcccccd, 0x00000000, 0x05000036, 0x001020f2,
328 0x00000001, 0x00101e46, 0x00000004, 0x05000036, 0x00102012, 0x00000002, 0x0010100a, 0x00000003,
329 0x05000036, 0x00102062, 0x00000002, 0x00101006, 0x00000009, 0x05000036, 0x00102082, 0x00000002,
330 0x0010100a, 0x0000000e, 0x05000036, 0x001020f2, 0x00000003, 0x00101e46, 0x00000007, 0x05000036,
331 0x001020f2, 0x00000004, 0x00101e46, 0x0000000b, 0x05000036, 0x00102012, 0x00000005, 0x00004001,
332 0x3f800000, 0x05000036, 0x00102022, 0x00000005, 0x00004001, 0x3f800000, 0x05000036, 0x00102012,
333 0x00000006, 0x00004001, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000015, 0x00000001,
334 0x00000000, 0x00000012, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000,
335 0x00000005, 0x00000006, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
336 0x00000000, 0x0000000a, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
337 0x00000000, 0x00000000, 0x00000000,
340 static const D3D11_SIGNATURE_PARAMETER_DESC test_reflection_desc_vs_resultin[] =
342 {"SV_position", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x1, 0},
343 {"BINORMAL", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
344 {"BLENDINDICES", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x0, 0},
345 {"BLENDWEIGHT", 0, 3, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0x1, 0},
346 {"COLOR", 0, 4, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf, 0},
347 {"COLOR", 1, 5, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
348 {"NORMAL", 0, 6, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
349 {"POSITION", 0, 7, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf, 0},
350 {"POSITIONT", 0, 8, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
351 {"PSIZE", 0, 9, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0x1, 0},
352 {"TANGENT", 0, 10, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
353 {"TEXCOORD", 0, 11, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf, 0},
354 {"SV_VertexID", 0, 12, D3D_NAME_VERTEX_ID, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x0, 0},
355 {"SV_InstanceID", 0, 13, D3D_NAME_INSTANCE_ID, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x0, 0},
356 {"testin", 0, 14, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0x1, 0},
359 static const D3D11_SIGNATURE_PARAMETER_DESC test_reflection_desc_vs_resultout[] =
361 {"SV_position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
362 {"COLOR", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
363 {"FOG", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0},
364 {"PSIZE", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x2, 0xd, 0},
365 {"TESSFACTOR", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x4, 0xb, 0},
366 {"testout", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x8, 0x7, 0},
367 {"POSITION", 0, 3, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
368 {"TEXCOORD", 0, 4, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
369 {"SV_ClipDistance", 0, 5, D3D_NAME_CLIP_DISTANCE, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0},
370 {"SV_CullDistance", 0, 5, D3D_NAME_CULL_DISTANCE, D3D_REGISTER_COMPONENT_FLOAT32, 0x2, 0xd, 0},
371 {"SV_InstanceID", 0, 6, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe, 0},
374 struct D3D11_SIGNATURE_PARAMETER_DESC_46
376 const char *SemanticName;
377 UINT SemanticIndex;
378 UINT Register;
379 D3D_NAME SystemValueType;
380 D3D_REGISTER_COMPONENT_TYPE ComponentType;
381 BYTE Mask;
382 BYTE ReadWriteMask;
383 UINT Stream;
384 D3D_MIN_PRECISION MinPrecision;
387 static void test_reflection_desc_vs(void)
389 struct D3D11_SIGNATURE_PARAMETER_DESC_46 desc_46 = {0};
390 const D3D11_SIGNATURE_PARAMETER_DESC *pdesc;
391 D3D11_SIGNATURE_PARAMETER_DESC desc11 = {0};
392 D3D12_SIGNATURE_PARAMETER_DESC desc12 = {0};
393 D3D_MIN_PRECISION expected_min_prec;
394 D3D11_SHADER_DESC sdesc11 = {0};
395 D3D12_SHADER_DESC sdesc12 = {0};
396 ID3D11ShaderReflection *ref11;
397 ID3D12ShaderReflection *ref12;
398 unsigned int i;
399 ULONG count;
400 HRESULT hr;
401 #if D3D_COMPILER_VERSION
402 UINT ret;
403 #endif
405 hr = call_reflect(test_reflection_desc_vs_blob, test_reflection_desc_vs_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
406 ok(hr == S_OK, "D3DReflect failed %x\n", hr);
408 ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D12ShaderReflection, (void **)&ref12);
410 hr = ref11->lpVtbl->GetDesc(ref11, NULL);
411 ok(hr == E_FAIL, "GetDesc failed %x\n", hr);
413 hr = ref11->lpVtbl->GetDesc(ref11, &sdesc11);
414 ok(hr == S_OK, "GetDesc failed %x\n", hr);
416 ok(sdesc11.Version == 65601, "GetDesc failed, got %u, expected %u\n", sdesc11.Version, 65601);
417 ok(strcmp(sdesc11.Creator, (char*) shader_creator) == 0, "GetDesc failed, got \"%s\", expected \"%s\"\n", sdesc11.Creator, (char*)shader_creator);
418 ok(sdesc11.Flags == 256, "GetDesc failed, got %u, expected %u\n", sdesc11.Flags, 256);
419 ok(sdesc11.ConstantBuffers == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.ConstantBuffers, 0);
420 ok(sdesc11.BoundResources == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.BoundResources, 0);
421 ok(sdesc11.InputParameters == 15, "GetDesc failed, got %u, expected %u\n", sdesc11.InputParameters, 15);
422 ok(sdesc11.OutputParameters == 11, "GetDesc failed, got %u, expected %u\n", sdesc11.OutputParameters, 11);
423 ok(sdesc11.InstructionCount == 21, "GetDesc failed, got %u, expected %u\n", sdesc11.InstructionCount, 21);
424 ok(sdesc11.TempRegisterCount == 1, "GetDesc failed, got %u, expected %u\n", sdesc11.TempRegisterCount, 1);
425 ok(sdesc11.TempArrayCount == 5, "GetDesc failed, got %u, expected %u\n", sdesc11.TempArrayCount, 5);
426 ok(sdesc11.DefCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.DefCount, 0);
427 ok(sdesc11.DclCount == 18, "GetDesc failed, got %u, expected %u\n", sdesc11.DclCount, 18);
428 ok(sdesc11.TextureNormalInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureNormalInstructions, 0);
429 ok(sdesc11.TextureLoadInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureLoadInstructions, 0);
430 ok(sdesc11.TextureCompInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureCompInstructions, 0);
431 ok(sdesc11.TextureBiasInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureBiasInstructions, 0);
432 ok(sdesc11.TextureGradientInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureGradientInstructions, 0);
433 ok(sdesc11.FloatInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.FloatInstructionCount, 0);
434 ok(sdesc11.IntInstructionCount == 1, "GetDesc failed, got %u, expected %u\n", sdesc11.IntInstructionCount, 1);
435 ok(sdesc11.UintInstructionCount == 1, "GetDesc failed, got %u, expected %u\n", sdesc11.UintInstructionCount, 1);
436 ok(sdesc11.StaticFlowControlCount == 1, "GetDesc failed, got %u, expected %u\n", sdesc11.StaticFlowControlCount, 1);
437 ok(sdesc11.DynamicFlowControlCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.DynamicFlowControlCount, 0);
438 ok(sdesc11.MacroInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.MacroInstructionCount, 0);
439 ok(sdesc11.ArrayInstructionCount == 6, "GetDesc failed, got %u, expected %u\n", sdesc11.ArrayInstructionCount, 6);
440 ok(sdesc11.CutInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.CutInstructionCount, 0);
441 ok(sdesc11.EmitInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.EmitInstructionCount, 0);
442 ok(sdesc11.GSOutputTopology == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.GSOutputTopology, 0);
443 ok(sdesc11.GSMaxOutputVertexCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.GSMaxOutputVertexCount, 0);
444 ok(sdesc11.InputPrimitive == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.InputPrimitive, 0);
445 ok(sdesc11.PatchConstantParameters == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.PatchConstantParameters, 0);
446 ok(sdesc11.cGSInstanceCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cGSInstanceCount, 0);
447 ok(sdesc11.cControlPoints == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cControlPoints, 0);
448 ok(sdesc11.HSOutputPrimitive == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.HSOutputPrimitive, 0);
449 ok(sdesc11.HSPartitioning == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.HSPartitioning, 0);
450 ok(sdesc11.TessellatorDomain == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.TessellatorDomain, 0);
451 ok(sdesc11.cBarrierInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cBarrierInstructions, 0);
452 ok(sdesc11.cInterlockedInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cInterlockedInstructions, 0);
453 ok(sdesc11.cTextureStoreInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cTextureStoreInstructions, 0);
455 if (ref12)
457 hr = ref12->lpVtbl->GetDesc(ref12, &sdesc12);
458 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
459 ok(!memcmp(&sdesc11, &sdesc12, sizeof(sdesc12)), "D3D11 and D3D12 descs do not match.\n");
462 #if D3D_COMPILER_VERSION
463 ret = ref11->lpVtbl->GetBitwiseInstructionCount(ref11);
464 ok(ret == 0, "Got unexpected ret %u.\n", ret);
466 ret = ref11->lpVtbl->GetConversionInstructionCount(ref11);
467 ok(ret == 2, "Got unexpected ret %u.\n", ret);
469 ret = ref11->lpVtbl->GetMovInstructionCount(ref11);
470 ok(ret == 10, "Got unexpected ret %u.\n", ret);
472 ret = ref11->lpVtbl->GetMovcInstructionCount(ref11);
473 ok(ret == 0, "Got unexpected ret %u.\n", ret);
475 if (ref12)
477 ret = ref12->lpVtbl->GetBitwiseInstructionCount(ref12);
478 ok(ret == 0, "Got unexpected ret %u.\n", ret);
480 ret = ref12->lpVtbl->GetConversionInstructionCount(ref12);
481 ok(ret == 2, "Got unexpected ret %u.\n", ret);
483 ret = ref12->lpVtbl->GetMovInstructionCount(ref12);
484 ok(ret == 10, "Got unexpected ret %u.\n", ret);
486 ret = ref12->lpVtbl->GetMovcInstructionCount(ref12);
487 ok(ret == 0, "Got unexpected ret %u.\n", ret);
489 #endif
491 /* GetIn/OutputParameterDesc */
492 desc_46.MinPrecision = ~0u;
493 hr = ref11->lpVtbl->GetInputParameterDesc(ref11, 0, (D3D11_SIGNATURE_PARAMETER_DESC *)&desc_46);
494 #if D3D_COMPILER_VERSION >= 46
495 expected_min_prec = 0;
496 #else
497 expected_min_prec = ~0u;
498 #endif
499 ok(desc_46.MinPrecision == expected_min_prec, "Got MinPrecision %#x, expected %#x.\n",
500 desc_46.MinPrecision, expected_min_prec);
502 for (i = 0; i < ARRAY_SIZE(test_reflection_desc_vs_resultin); ++i)
504 pdesc = &test_reflection_desc_vs_resultin[i];
506 hr = ref11->lpVtbl->GetInputParameterDesc(ref11, i, &desc11);
507 ok(hr == S_OK, "Got unexpected hr %#x, i %u.\n", hr, i);
509 ok(!strcmp(desc11.SemanticName, pdesc->SemanticName), "Got unexpected SemanticName \"%s\", i %u.\n",
510 desc11.SemanticName, i);
511 ok(desc11.SemanticIndex == pdesc->SemanticIndex, "Got unexpected SemanticIndex %u, i %u.\n",
512 desc11.SemanticIndex, i);
513 ok(desc11.Register == pdesc->Register, "Got unexpected Register %u, i %u.\n", desc11.Register, i);
514 ok(desc11.SystemValueType == pdesc->SystemValueType, "Got unexpected SystemValueType %u, i %u.\n",
515 desc11.SystemValueType, i);
516 ok(desc11.ComponentType == pdesc->ComponentType, "Got unexpected ComponentType %u, i %u.\n",
517 desc11.ComponentType, i);
518 ok(desc11.Mask == pdesc->Mask, "Got unexpected SystemValueType %#x, i %u.\n", desc11.Mask, i);
519 ok(desc11.ReadWriteMask == pdesc->ReadWriteMask, "Got unexpected ReadWriteMask %#x, i %u.\n",
520 desc11.ReadWriteMask, i);
521 /* The Stream field of D3D11_SIGNATURE_PARAMETER_DESC is in the
522 * trailing padding of the D3D10_SIGNATURE_PARAMETER_DESC struct on
523 * 64-bits and thus undefined. Don't test it. */
524 if (D3D_COMPILER_VERSION)
525 ok(desc11.Stream == pdesc->Stream, "Got unexpected Stream %u, i %u.\n",
526 desc11.Stream, i);
527 else if (sizeof(void *) == 4)
528 ok(!desc11.Stream, "Got unexpected Stream %u, i %u.\n", desc11.Stream, i);
530 if (ref12)
532 hr = ref12->lpVtbl->GetInputParameterDesc(ref12, i, &desc12);
533 ok(hr == S_OK, "Got unexpected hr %#x, i %u.\n", hr, i);
535 ok(!memcmp(&desc12, &desc11, sizeof(desc11)), "D3D11 and D3D12 descs do not match.\n");
539 for (i = 0; i < ARRAY_SIZE(test_reflection_desc_vs_resultout); ++i)
541 pdesc = &test_reflection_desc_vs_resultout[i];
543 hr = ref11->lpVtbl->GetOutputParameterDesc(ref11, i, &desc11);
544 ok(hr == S_OK, "Got unexpected hr %#x, i %u.\n", hr, i);
546 ok(!strcmp(desc11.SemanticName, pdesc->SemanticName), "Got unexpected SemanticName \"%s\", i %u.\n",
547 desc11.SemanticName, i);
548 ok(desc11.SemanticIndex == pdesc->SemanticIndex, "Got unexpected SemanticIndex %u, i %u.\n",
549 desc11.SemanticIndex, i);
550 ok(desc11.Register == pdesc->Register, "Got unexpected Register %u, i %u.\n", desc11.Register, i);
551 ok(desc11.SystemValueType == pdesc->SystemValueType, "Got unexpected SystemValueType %u, i %u.\n",
552 desc11.SystemValueType, i);
553 ok(desc11.ComponentType == pdesc->ComponentType, "Got unexpected ComponentType %u, i %u.\n",
554 desc11.ComponentType, i);
555 ok(desc11.Mask == pdesc->Mask, "Got unexpected SystemValueType %#x, i %u.\n", desc11.Mask, i);
556 ok(desc11.ReadWriteMask == pdesc->ReadWriteMask, "Got unexpected ReadWriteMask %#x, i %u.\n",
557 desc11.ReadWriteMask, i);
558 /* The Stream field of D3D11_SIGNATURE_PARAMETER_DESC is in the
559 * trailing padding of the D3D10_SIGNATURE_PARAMETER_DESC struct on
560 * 64-bits and thus undefined. Don't test it. */
561 if (D3D_COMPILER_VERSION)
562 ok(desc11.Stream == pdesc->Stream, "Got unexpected Stream %u, i %u.\n",
563 desc11.Stream, i);
564 else if (sizeof(void *) == 4)
565 ok(!desc11.Stream, "Got unexpected Stream %u, i %u.\n", desc11.Stream, i);
567 if (ref12)
569 hr = ref12->lpVtbl->GetOutputParameterDesc(ref12, i, &desc12);
570 ok(hr == S_OK, "Got unexpected hr %#x, i %u.\n", hr, i);
572 ok(!memcmp(&desc12, &desc11, sizeof(desc11)), "D3D11 and D3D12 descs do not match.\n");
576 if (ref12)
578 count = ref12->lpVtbl->Release(ref12);
579 ok(count == 1, "Got unexpected ref count %u.\n", count);
582 count = ref11->lpVtbl->Release(ref11);
583 ok(count == 0, "Got unexpected ref count %u.\n", count);
587 * fxc.exe /E PS /Tps_4_1 /Fx
589 #if 0
590 Texture2D tex1;
591 Texture2D tex2;
592 SamplerState sam
594 Filter = MIN_MAG_MIP_LINEAR;
595 AddressU = Wrap;
596 AddressV = Wrap;
598 SamplerComparisonState samc
600 Filter = MIN_MAG_MIP_LINEAR;
601 AddressU = w1;
602 AddressV = Wrap;
603 ComparisonFunc = LESS;
605 struct psin
607 uint f : SV_RenderTargetArrayIndex;
608 uint g : SV_InstanceID;
609 uint h : SV_PrimitiveID;
610 float2 uv : TEXCOORD;
611 float4 a : COLOR3;
612 float b : VFACE;
613 float4 c : SV_position;
614 bool d : SV_Coverage;
615 bool e : SV_IsFrontFace;
617 struct psout
619 float a : SV_Target1;
620 float b : SV_Depth;
621 float x : SV_Target;
622 bool c : SV_Coverage;
624 psout PS(psin p)
626 psout a;
627 float4 x = tex1.Sample(sam, p.uv);
628 x += tex1.SampleCmp(samc, p.uv, 0.3f);
629 if (x.y < 0.1f)
630 x += tex2.SampleCmp(samc, p.uv, 0.4f);
631 else if (x.y < 0.2f)
632 x += tex2.SampleCmp(samc, p.uv, 0.1f);
633 else if (x.y < 0.3f)
634 x += tex2.SampleBias(sam, p.uv, 0.1f);
635 else if (x.y < 0.4f)
636 x += tex2.SampleBias(sam, p.uv, 0.2f);
637 else if (x.y < 0.5f)
638 x += tex2.SampleBias(sam, p.uv, 0.3f);
639 else
640 x += tex2.SampleBias(sam, p.uv, 0.4f);
641 x += tex2.SampleGrad(sam, p.uv, x.xy, x.xy);
642 x += tex2.SampleGrad(sam, p.uv, x.xz, x.xz);
643 x += tex2.SampleGrad(sam, p.uv, x.xz, x.zy);
644 x += tex2.SampleGrad(sam, p.uv, x.xz, x.zw);
645 x += tex2.SampleGrad(sam, p.uv, x.xz, x.wz);
646 a.a = x.y;
647 a.b = x.x;
648 a.x = x.x;
649 a.c = true;
650 return a;
652 #endif
653 static DWORD test_reflection_desc_ps_blob[] = {
654 0x43425844, 0x19e2f325, 0xf1ec39a3, 0x3c5a8b53, 0x5bd5fb65, 0x00000001, 0x000008d0, 0x00000005,
655 0x00000034, 0x0000011c, 0x00000254, 0x000002e4, 0x00000854, 0x46454452, 0x000000e0, 0x00000000,
656 0x00000000, 0x00000004, 0x0000001c, 0xffff0401, 0x00000100, 0x000000af, 0x0000009c, 0x00000003,
657 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x000000a0, 0x00000003,
658 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000002, 0x000000a5, 0x00000002,
659 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000c, 0x000000aa, 0x00000002,
660 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000c, 0x006d6173, 0x636d6173,
661 0x78657400, 0x65740031, 0x4d003278, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
662 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072, 0x392e3932, 0x332e3235, 0x00313131, 0x4e475349,
663 0x00000130, 0x00000008, 0x00000008, 0x000000c8, 0x00000000, 0x00000004, 0x00000001, 0x00000000,
664 0x00000001, 0x000000e2, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000002, 0x000000f0,
665 0x00000000, 0x00000007, 0x00000001, 0x00000000, 0x00000004, 0x000000ff, 0x00000000, 0x00000009,
666 0x00000001, 0x00000000, 0x00000008, 0x0000010e, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
667 0x00000303, 0x00000117, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000004, 0x0000011d,
668 0x00000003, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x00000123, 0x00000000, 0x00000001,
669 0x00000003, 0x00000003, 0x0000000f, 0x525f5653, 0x65646e65, 0x72615472, 0x41746567, 0x79617272,
670 0x65646e49, 0x56530078, 0x736e495f, 0x636e6174, 0x00444965, 0x505f5653, 0x696d6972, 0x65766974,
671 0x53004449, 0x73495f56, 0x6e6f7246, 0x63614674, 0x45540065, 0x4f4f4358, 0x56004452, 0x45434146,
672 0x4c4f4300, 0x5300524f, 0x6f705f56, 0x69746973, 0xab006e6f, 0x4e47534f, 0x00000088, 0x00000004,
673 0x00000008, 0x00000068, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000e01, 0x00000068,
674 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x00000072, 0x00000000, 0x00000000,
675 0x00000001, 0xffffffff, 0x00000e01, 0x0000007e, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
676 0x00000e01, 0x545f5653, 0x65677261, 0x56530074, 0x766f435f, 0x67617265, 0x56530065, 0x7065445f,
677 0xab006874, 0x52444853, 0x00000568, 0x00000041, 0x0000015a, 0x0100086a, 0x0300005a, 0x00106000,
678 0x00000000, 0x0300085a, 0x00106000, 0x00000001, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
679 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03000065,
680 0x00102012, 0x00000000, 0x03000065, 0x00102012, 0x00000001, 0x02000065, 0x0000f000, 0x02000065,
681 0x0000c001, 0x02000068, 0x00000003, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001,
682 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0b000046, 0x00100012, 0x00000001, 0x00101046,
683 0x00000001, 0x00107006, 0x00000000, 0x00106000, 0x00000001, 0x00004001, 0x3e99999a, 0x07000000,
684 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100006, 0x00000001, 0x07000031, 0x00100012,
685 0x00000001, 0x0010001a, 0x00000000, 0x00004001, 0x3dcccccd, 0x0304001f, 0x0010000a, 0x00000001,
686 0x0b000046, 0x00100012, 0x00000001, 0x00101046, 0x00000001, 0x00107006, 0x00000001, 0x00106000,
687 0x00000001, 0x00004001, 0x3ecccccd, 0x07000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000000,
688 0x00100006, 0x00000001, 0x01000012, 0x07000031, 0x00100012, 0x00000002, 0x0010001a, 0x00000000,
689 0x00004001, 0x3e4ccccd, 0x0304001f, 0x0010000a, 0x00000002, 0x0b000046, 0x00100012, 0x00000002,
690 0x00101046, 0x00000001, 0x00107006, 0x00000001, 0x00106000, 0x00000001, 0x00004001, 0x3dcccccd,
691 0x07000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000000, 0x00100006, 0x00000002, 0x01000012,
692 0x07000031, 0x00100012, 0x00000002, 0x0010001a, 0x00000000, 0x00004001, 0x3e99999a, 0x0304001f,
693 0x0010000a, 0x00000002, 0x0b00004a, 0x001000f2, 0x00000002, 0x00101046, 0x00000001, 0x00107e46,
694 0x00000001, 0x00106000, 0x00000000, 0x00004001, 0x3dcccccd, 0x07000000, 0x001000f2, 0x00000001,
695 0x00100e46, 0x00000000, 0x00100e46, 0x00000002, 0x01000012, 0x07000031, 0x00100012, 0x00000002,
696 0x0010001a, 0x00000000, 0x00004001, 0x3ecccccd, 0x0304001f, 0x0010000a, 0x00000002, 0x0b00004a,
697 0x001000f2, 0x00000002, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000,
698 0x00004001, 0x3e4ccccd, 0x07000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000000, 0x00100e46,
699 0x00000002, 0x01000012, 0x07000031, 0x00100012, 0x00000002, 0x0010001a, 0x00000000, 0x00004001,
700 0x3f000000, 0x0304001f, 0x0010000a, 0x00000002, 0x0b00004a, 0x001000f2, 0x00000002, 0x00101046,
701 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x00004001, 0x3e99999a, 0x07000000,
702 0x001000f2, 0x00000001, 0x00100e46, 0x00000000, 0x00100e46, 0x00000002, 0x01000012, 0x0b00004a,
703 0x001000f2, 0x00000002, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000,
704 0x00004001, 0x3ecccccd, 0x07000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000000, 0x00100e46,
705 0x00000002, 0x01000015, 0x01000015, 0x01000015, 0x01000015, 0x01000015, 0x0d000049, 0x001000f2,
706 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x00100046,
707 0x00000001, 0x00100046, 0x00000001, 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
708 0x00100e46, 0x00000001, 0x0d000049, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
709 0x00000001, 0x00106000, 0x00000000, 0x00100086, 0x00000000, 0x00100086, 0x00000000, 0x07000000,
710 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, 0x0d000049, 0x001000f2,
711 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x00100086,
712 0x00000000, 0x00100a66, 0x00000000, 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
713 0x00100e46, 0x00000001, 0x0d000049, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
714 0x00000001, 0x00106000, 0x00000000, 0x00100086, 0x00000000, 0x00100ae6, 0x00000000, 0x07000000,
715 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, 0x0d000049, 0x001000c2,
716 0x00000000, 0x00101046, 0x00000001, 0x001074e6, 0x00000001, 0x00106000, 0x00000000, 0x00100086,
717 0x00000000, 0x00100fb6, 0x00000000, 0x07000000, 0x00100032, 0x00000000, 0x00100ae6, 0x00000000,
718 0x00100046, 0x00000000, 0x05000036, 0x00102012, 0x00000001, 0x0010001a, 0x00000000, 0x04000036,
719 0x0000c001, 0x0010000a, 0x00000000, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000,
720 0x04000036, 0x0000f001, 0x00004001, 0xffffffff, 0x0100003e, 0x54415453, 0x00000074, 0x00000032,
721 0x00000003, 0x00000000, 0x00000005, 0x00000011, 0x00000000, 0x00000000, 0x00000006, 0x00000005,
722 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000003,
723 0x00000004, 0x00000005, 0x00000018, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
724 0x00000000, 0x00000000, 0x00000000, 0x00000000,
727 static const D3D11_SIGNATURE_PARAMETER_DESC test_reflection_desc_ps_resultin[] =
729 {"SV_RenderTargetArrayIndex", 0, 0, D3D_NAME_RENDER_TARGET_ARRAY_INDEX, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x0, 0},
730 {"SV_InstanceID", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x2, 0x0, 0},
731 {"SV_PrimitiveID", 0, 0, D3D_NAME_PRIMITIVE_ID, D3D_REGISTER_COMPONENT_UINT32, 0x4, 0x0, 0},
732 {"SV_IsFrontFace", 0, 0, D3D_NAME_IS_FRONT_FACE, D3D_REGISTER_COMPONENT_UINT32, 0x8, 0x0, 0},
733 {"TEXCOORD", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3, 0x3, 0},
734 {"VFACE", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x4, 0x0, 0},
735 {"COLOR", 3, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
736 {"SV_position", 0, 3, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
739 static const D3D11_SIGNATURE_PARAMETER_DESC test_reflection_desc_ps_resultout[] =
741 {"SV_Target", 0, 0, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0},
742 {"SV_Target", 1, 1, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0},
743 {"SV_Coverage", 0, 0xffffffff, D3D_NAME_COVERAGE, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe, 0},
744 {"SV_Depth", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0},
747 static void test_reflection_desc_ps(void)
749 HRESULT hr;
750 ULONG count;
751 ID3D11ShaderReflection *ref11;
752 D3D11_SHADER_DESC sdesc11 = {0};
753 D3D11_SIGNATURE_PARAMETER_DESC desc = {0};
754 const D3D11_SIGNATURE_PARAMETER_DESC *pdesc;
755 D3D_NAME expected;
756 unsigned int i;
757 #if D3D_COMPILER_VERSION
758 UINT ret;
759 #endif
761 hr = call_reflect(test_reflection_desc_ps_blob, test_reflection_desc_ps_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
762 ok(hr == S_OK, "D3DReflect failed %x\n", hr);
764 hr = ref11->lpVtbl->GetDesc(ref11, &sdesc11);
765 ok(hr == S_OK, "GetDesc failed %x\n", hr);
767 ok(sdesc11.Version == 65, "GetDesc failed, got %u, expected %u\n", sdesc11.Version, 65);
768 ok(strcmp(sdesc11.Creator, (char*) shader_creator) == 0, "GetDesc failed, got \"%s\", expected \"%s\"\n", sdesc11.Creator, (char*)shader_creator);
769 ok(sdesc11.Flags == 256, "GetDesc failed, got %u, expected %u\n", sdesc11.Flags, 256);
770 ok(sdesc11.ConstantBuffers == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.ConstantBuffers, 0);
771 ok(sdesc11.BoundResources == 4, "GetDesc failed, got %u, expected %u\n", sdesc11.BoundResources, 4);
772 ok(sdesc11.InputParameters == 8, "GetDesc failed, got %u, expected %u\n", sdesc11.InputParameters, 8);
773 ok(sdesc11.OutputParameters == 4, "GetDesc failed, got %u, expected %u\n", sdesc11.OutputParameters, 4);
774 ok(sdesc11.InstructionCount == 50, "GetDesc failed, got %u, expected %u\n", sdesc11.InstructionCount, 50);
775 ok(sdesc11.TempRegisterCount == 3, "GetDesc failed, got %u, expected %u\n", sdesc11.TempRegisterCount, 3);
776 ok(sdesc11.TempArrayCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TempArrayCount, 0);
777 ok(sdesc11.DefCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.DefCount, 0);
778 ok(sdesc11.DclCount == 5, "GetDesc failed, got %u, expected %u\n", sdesc11.DclCount, 5);
779 ok(sdesc11.TextureNormalInstructions == 1, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureNormalInstructions, 1);
780 ok(sdesc11.TextureLoadInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureLoadInstructions, 0);
781 ok(sdesc11.TextureCompInstructions == 3, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureCompInstructions, 3);
782 ok(sdesc11.TextureBiasInstructions == 4, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureBiasInstructions, 4);
783 ok(sdesc11.TextureGradientInstructions == 5, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureGradientInstructions, 5);
784 ok(sdesc11.FloatInstructionCount == 17, "GetDesc failed, got %u, expected %u\n", sdesc11.FloatInstructionCount, 17);
785 ok(sdesc11.IntInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.IntInstructionCount, 0);
786 ok(sdesc11.UintInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.UintInstructionCount, 0);
787 ok(sdesc11.StaticFlowControlCount == 6, "GetDesc failed, got %u, expected %u\n", sdesc11.StaticFlowControlCount, 6);
788 ok(sdesc11.DynamicFlowControlCount == 5, "GetDesc failed, got %u, expected %u\n", sdesc11.DynamicFlowControlCount, 5);
789 ok(sdesc11.MacroInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.MacroInstructionCount, 0);
790 ok(sdesc11.ArrayInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.ArrayInstructionCount, 0);
791 ok(sdesc11.CutInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.CutInstructionCount, 0);
792 ok(sdesc11.EmitInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.EmitInstructionCount, 0);
793 ok(sdesc11.GSOutputTopology == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.GSOutputTopology, 0);
794 ok(sdesc11.GSMaxOutputVertexCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.GSMaxOutputVertexCount, 0);
795 ok(sdesc11.InputPrimitive == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.InputPrimitive, 0);
796 ok(sdesc11.PatchConstantParameters == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.PatchConstantParameters, 0);
797 ok(sdesc11.cGSInstanceCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cGSInstanceCount, 0);
798 ok(sdesc11.cControlPoints == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cControlPoints, 0);
799 ok(sdesc11.HSOutputPrimitive == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.HSOutputPrimitive, 0);
800 ok(sdesc11.HSPartitioning == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.HSPartitioning, 0);
801 ok(sdesc11.TessellatorDomain == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.TessellatorDomain, 0);
802 ok(sdesc11.cBarrierInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cBarrierInstructions, 0);
803 ok(sdesc11.cInterlockedInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cInterlockedInstructions, 0);
804 ok(sdesc11.cTextureStoreInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cTextureStoreInstructions, 0);
806 #if D3D_COMPILER_VERSION
807 ret = ref11->lpVtbl->GetBitwiseInstructionCount(ref11);
808 ok(ret == 0, "GetBitwiseInstructionCount failed, got %u, expected %u\n", ret, 0);
810 ret = ref11->lpVtbl->GetConversionInstructionCount(ref11);
811 ok(ret == 0, "GetConversionInstructionCount failed, got %u, expected %u\n", ret, 0);
813 ret = ref11->lpVtbl->GetMovInstructionCount(ref11);
814 ok(ret == 24, "GetMovInstructionCount failed, got %u, expected %u\n", ret, 24);
816 ret = ref11->lpVtbl->GetMovcInstructionCount(ref11);
817 ok(ret == 0, "GetMovcInstructionCount failed, got %u, expected %u\n", ret, 0);
818 #endif
820 /* check invalid Get*ParameterDesc cases*/
821 hr = ref11->lpVtbl->GetInputParameterDesc(ref11, 0, NULL);
822 ok(hr == E_INVALIDARG, "GetInputParameterDesc failed, got %x, expected %x\n", hr, E_INVALIDARG);
824 hr = ref11->lpVtbl->GetInputParameterDesc(ref11, 0xffffffff, &desc);
825 ok(hr == E_INVALIDARG, "GetInputParameterDesc failed, got %x, expected %x\n", hr, E_INVALIDARG);
827 hr = ref11->lpVtbl->GetOutputParameterDesc(ref11, 0, NULL);
828 ok(hr == E_INVALIDARG, "GetOutputParameterDesc failed, got %x, expected %x\n", hr, E_INVALIDARG);
830 hr = ref11->lpVtbl->GetOutputParameterDesc(ref11, 0xffffffff, &desc);
831 ok(hr == E_INVALIDARG, "GetOutputParameterDesc failed, got %x, expected %x\n", hr, E_INVALIDARG);
833 #if D3D_COMPILER_VERSION
834 hr = ref11->lpVtbl->GetPatchConstantParameterDesc(ref11, 0, &desc);
835 ok(hr == E_INVALIDARG, "GetPatchConstantParameterDesc failed, got %x, expected %x\n", hr, E_INVALIDARG);
836 #endif
838 /* GetIn/OutputParameterDesc */
839 for (i = 0; i < ARRAY_SIZE(test_reflection_desc_ps_resultin); ++i)
841 pdesc = &test_reflection_desc_ps_resultin[i];
843 hr = ref11->lpVtbl->GetInputParameterDesc(ref11, i, &desc);
844 ok(hr == S_OK, "GetInputParameterDesc(%u) failed, got %x, expected %x\n", i, hr, S_OK);
846 ok(!strcmp(desc.SemanticName, pdesc->SemanticName), "GetInputParameterDesc(%u) SemanticName failed, got \"%s\", expected \"%s\"\n",
847 i, desc.SemanticName, pdesc->SemanticName);
848 ok(desc.SemanticIndex == pdesc->SemanticIndex, "GetInputParameterDesc(%u) SemanticIndex failed, got %u, expected %u\n",
849 i, desc.SemanticIndex, pdesc->SemanticIndex);
850 ok(desc.Register == pdesc->Register, "GetInputParameterDesc(%u) Register failed, got %u, expected %u\n",
851 i, desc.Register, pdesc->Register);
852 ok(desc.SystemValueType == pdesc->SystemValueType, "GetInputParameterDesc(%u) SystemValueType failed, got %x, expected %x\n",
853 i, desc.SystemValueType, pdesc->SystemValueType);
854 ok(desc.ComponentType == pdesc->ComponentType, "GetInputParameterDesc(%u) ComponentType failed, got %x, expected %x\n",
855 i, desc.ComponentType, pdesc->ComponentType);
856 ok(desc.Mask == pdesc->Mask, "GetInputParameterDesc(%u) Mask failed, got %x, expected %x\n",
857 i, desc.Mask, pdesc->Mask);
858 ok(desc.ReadWriteMask == pdesc->ReadWriteMask, "GetInputParameterDesc(%u) ReadWriteMask failed, got %x, expected %x\n",
859 i, desc.ReadWriteMask, pdesc->ReadWriteMask);
860 if (D3D_COMPILER_VERSION)
861 ok(desc.Stream == pdesc->Stream, "(%u): got unexpected Stream %u, expected %u.\n",
862 i, desc.Stream, pdesc->Stream);
863 else if (sizeof(void *) == 4)
864 ok(!desc.Stream, "(%u): got unexpected Stream %u.\n", i, desc.Stream);
867 for (i = 0; i < ARRAY_SIZE(test_reflection_desc_ps_resultout); ++i)
869 pdesc = &test_reflection_desc_ps_resultout[i];
871 hr = ref11->lpVtbl->GetOutputParameterDesc(ref11, i, &desc);
872 ok(hr == S_OK, "GetOutputParameterDesc(%u) failed, got %x, expected %x\n", i, hr, S_OK);
874 ok(!strcmp(desc.SemanticName, pdesc->SemanticName), "GetOutputParameterDesc(%u) SemanticName failed, got \"%s\", expected \"%s\"\n",
875 i, desc.SemanticName, pdesc->SemanticName);
876 ok(desc.SemanticIndex == pdesc->SemanticIndex, "GetOutputParameterDesc(%u) SemanticIndex failed, got %u, expected %u\n",
877 i, desc.SemanticIndex, pdesc->SemanticIndex);
878 ok(desc.Register == pdesc->Register, "GetOutputParameterDesc(%u) Register failed, got %u, expected %u\n",
879 i, desc.Register, pdesc->Register);
880 #if D3D_COMPILER_VERSION
881 expected = pdesc->SystemValueType;
882 #else
883 expected = D3D_NAME_UNDEFINED;
884 todo_wine
885 #endif
886 ok(desc.SystemValueType == expected, "(%u): got unexpected SystemValueType %#x, expected %#x.\n",
887 i, desc.SystemValueType, expected);
888 ok(desc.ComponentType == pdesc->ComponentType, "GetOutputParameterDesc(%u) ComponentType failed, got %x, expected %x\n",
889 i, desc.ComponentType, pdesc->ComponentType);
890 ok(desc.Mask == pdesc->Mask, "GetOutputParameterDesc(%u) Mask failed, got %x, expected %x\n",
891 i, desc.Mask, pdesc->Mask);
892 ok(desc.ReadWriteMask == pdesc->ReadWriteMask, "GetOutputParameterDesc(%u) ReadWriteMask failed, got %x, expected %x\n",
893 i, desc.ReadWriteMask, pdesc->ReadWriteMask);
894 if (D3D_COMPILER_VERSION)
895 ok(desc.Stream == pdesc->Stream, "(%u): got unexpected Stream %u, expected %u.\n",
896 i, desc.Stream, pdesc->Stream);
897 else if (sizeof(void *) == 4)
898 ok(!desc.Stream, "(%u): got unexpected Stream %u.\n", i, desc.Stream);
901 count = ref11->lpVtbl->Release(ref11);
902 ok(count == 0, "Release failed %u\n", count);
905 /* The following shaders are stripped, in order to show that the correct
906 * reporting of pixel shader output sysvals should not depend on the RDEF chunk
907 * being present. */
908 #if 0
909 float4 PS() : SV_Target3
911 float4 a = float4(1.2f, 1.0f, 0.2f, 0.0f);
912 return a;
914 #endif
915 static const DWORD test_reflection_desc_ps_output_blob_0[] =
917 0x43425844, 0xc3773602, 0x04f86bdc, 0x715f33b2, 0x9c063cae, 0x00000001, 0x000000b4, 0x00000003,
918 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
919 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000003, 0x00000000, 0x00000003, 0x00000003,
920 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000003c, 0x00000050, 0x0000000f,
921 0x0100086a, 0x03000065, 0x001020f2, 0x00000003, 0x08000036, 0x001020f2, 0x00000003, 0x00004002,
922 0x3f99999a, 0x3f800000, 0x3e4ccccd, 0x00000000, 0x0100003e,
925 #if 0
926 float PS() : SV_DepthLessEqual
928 float a = 1.2f;
929 return a;
931 #endif
932 static const DWORD test_reflection_desc_ps_output_blob_1[] =
934 0x43425844, 0xc45db587, 0xdb0601fb, 0x7370900b, 0x219464be, 0x00000001, 0x000000a8, 0x00000003,
935 0x0000002c, 0x0000003c, 0x00000078, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
936 0x00000034, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
937 0x00000e01, 0x445f5653, 0x68747065, 0x7373654c, 0x61757145, 0xabab006c, 0x58454853, 0x00000028,
938 0x00000050, 0x0000000a, 0x0100086a, 0x02000065, 0x00027001, 0x04000036, 0x00027001, 0x00004001,
939 0x3f99999a, 0x0100003e,
942 #if 0
943 float PS() : SV_DepthGreaterEqual
945 float a = 1.2f;
946 return a;
948 #endif
949 static const DWORD test_reflection_desc_ps_output_blob_2[] =
951 0x43425844, 0x13cce144, 0x3628f322, 0xa8ea9b7d, 0xbbf9f8d7, 0x00000001, 0x000000ac, 0x00000003,
952 0x0000002c, 0x0000003c, 0x0000007c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
953 0x00000038, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
954 0x00000e01, 0x445f5653, 0x68747065, 0x61657247, 0x45726574, 0x6c617571, 0xababab00, 0x58454853,
955 0x00000028, 0x00000050, 0x0000000a, 0x0100086a, 0x02000065, 0x00026001, 0x04000036, 0x00026001,
956 0x00004001, 0x3f99999a, 0x0100003e,
959 #if 0
960 float PS() : sV_DePtH
962 float a = 1.2f;
963 return a;
965 #endif
966 static const DWORD test_reflection_desc_ps_output_blob_3[] =
968 0x43425844, 0x31c891d1, 0xcbb9d935, 0xa199e1d5, 0x70205254, 0x00000001, 0x000000a0, 0x00000003,
969 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
970 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
971 0x00000e01, 0x445f5673, 0x48745065, 0xababab00, 0x58454853, 0x00000028, 0x00000050, 0x0000000a,
972 0x0100086a, 0x02000065, 0x0000c001, 0x04000036, 0x0000c001, 0x00004001, 0x3f99999a, 0x0100003e,
975 #if 0
976 float PS() : SV_Depth
978 float a = 1.2f;
979 return a;
981 #endif
982 static const DWORD test_reflection_desc_ps_output_blob_4[] =
984 0x43425844, 0x1d404736, 0x00e4a4aa, 0x5fcdad54, 0x5abd13f8, 0x00000001, 0x0000009c, 0x00000003,
985 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
986 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
987 0x00000e01, 0x445f5653, 0x68747065, 0xababab00, 0x52444853, 0x00000024, 0x00000040, 0x00000009,
988 0x02000065, 0x0000c001, 0x04000036, 0x0000c001, 0x00004001, 0x3f99999a, 0x0100003e,
991 #if 0
992 bool PS() : SV_COVERAGE
994 bool a = true;
995 return a;
997 #endif
998 static const DWORD test_reflection_desc_ps_output_blob_5[] =
1000 0x43425844, 0x6127612d, 0x09e2bb9a, 0xbba3889a, 0x987dafc2, 0x00000001, 0x000000a0, 0x00000003,
1001 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
1002 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0xffffffff,
1003 0x00000e01, 0x435f5653, 0x5245564f, 0x00454741, 0x52444853, 0x00000028, 0x00000041, 0x0000000a,
1004 0x0100086a, 0x02000065, 0x0000f000, 0x04000036, 0x0000f001, 0x00004001, 0xffffffff, 0x0100003e,
1007 static void test_reflection_desc_ps_output(void)
1009 static const struct test_reflection_desc_ps_output_test
1011 const DWORD *blob;
1012 D3D11_SIGNATURE_PARAMETER_DESC desc;
1014 tests[] =
1016 {test_reflection_desc_ps_output_blob_0,
1017 {"SV_Target", 3, 3, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0, 0}},
1018 {test_reflection_desc_ps_output_blob_1,
1019 {"SV_DepthLessEqual", 0, 0xffffffff, D3D_NAME_DEPTH_LESS_EQUAL, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}},
1020 {test_reflection_desc_ps_output_blob_2,
1021 {"SV_DepthGreaterEqual", 0, 0xffffffff, D3D11_NAME_DEPTH_GREATER_EQUAL, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}},
1022 {test_reflection_desc_ps_output_blob_3,
1023 {"sV_DePtH", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}},
1024 {test_reflection_desc_ps_output_blob_4,
1025 {"SV_Depth", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}},
1026 {test_reflection_desc_ps_output_blob_5,
1027 {"SV_COVERAGE", 0, 0xffffffff, D3D_NAME_COVERAGE, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe, 0}},
1029 HRESULT hr;
1030 ULONG count;
1031 ID3D11ShaderReflection *ref11;
1032 D3D11_SIGNATURE_PARAMETER_DESC desc = {0};
1033 const D3D11_SIGNATURE_PARAMETER_DESC *pdesc;
1034 D3D_NAME expected;
1035 unsigned int i;
1037 for (i = 0; i < ARRAY_SIZE(tests); ++i)
1039 hr = call_reflect(tests[i].blob, tests[i].blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
1040 if (!D3D_COMPILER_VERSION)
1042 todo_wine ok(hr == E_INVALIDARG, "(%u): got unexpected hr %x.\n", i, hr);
1043 if (SUCCEEDED(hr))
1044 ref11->lpVtbl->Release(ref11);
1045 continue;
1047 ok(hr == S_OK, "(%u): got unexpected hr %x.\n", i, hr);
1049 pdesc = &tests[i].desc;
1051 hr = ref11->lpVtbl->GetOutputParameterDesc(ref11, 0, &desc);
1052 ok(hr == S_OK, "(%u): GetOutputParameterDesc failed, got %x, expected %x\n", i, hr, S_OK);
1054 ok(!strcmp(desc.SemanticName, pdesc->SemanticName), "(%u): GetOutputParameterDesc SemanticName failed, got \"%s\", expected \"%s\"\n",
1055 i, desc.SemanticName, pdesc->SemanticName);
1056 ok(desc.SemanticIndex == pdesc->SemanticIndex, "(%u): GetOutputParameterDesc SemanticIndex failed, got %u, expected %u\n",
1057 i, desc.SemanticIndex, pdesc->SemanticIndex);
1058 ok(desc.Register == pdesc->Register, "(%u): GetOutputParameterDesc Register failed, got %u, expected %u\n",
1059 i, desc.Register, pdesc->Register);
1060 #if D3D_COMPILER_VERSION
1061 expected = pdesc->SystemValueType;
1062 #else
1063 expected = D3D_NAME_UNDEFINED;
1064 todo_wine
1065 #endif
1066 ok(desc.SystemValueType == expected, "(%u): Got unexpected SystemValueType %#x, expected %x.\n",
1067 i, desc.SystemValueType, expected);
1068 ok(desc.ComponentType == pdesc->ComponentType, "(%u): GetOutputParameterDesc ComponentType failed, got %x, expected %x\n",
1069 i, desc.ComponentType, pdesc->ComponentType);
1070 ok(desc.Mask == pdesc->Mask, "(%u): GetOutputParameterDesc Mask failed, got %x, expected %x\n",
1071 i, desc.Mask, pdesc->Mask);
1072 ok(desc.ReadWriteMask == pdesc->ReadWriteMask, "(%u): GetOutputParameterDesc ReadWriteMask failed, got %x, expected %x\n",
1073 i, desc.ReadWriteMask, pdesc->ReadWriteMask);
1074 if (D3D_COMPILER_VERSION)
1075 ok(desc.Stream == pdesc->Stream, "(%u): got unexpected Stream %u, expected %u.\n",
1076 i, desc.Stream, pdesc->Stream);
1077 else if (sizeof(void *) == 4)
1078 ok(!desc.Stream, "(%u): got unexpected Stream %u.\n", i, desc.Stream);
1080 count = ref11->lpVtbl->Release(ref11);
1081 ok(count == 0, "(%u): Release failed %u\n", i, count);
1086 * fxc.exe /E PS /Tps_4_0 /Fo
1088 #if 0
1089 Texture2D tex1[2];
1090 Texture2D tex2;
1091 SamplerState sam
1093 Filter = MIN_MAG_MIP_LINEAR;
1094 AddressU = Wrap;
1095 AddressV = Wrap;
1097 cbuffer c1
1099 float x;
1100 float y[2];
1101 int z;
1103 cbuffer c2
1105 float t;
1108 float4 PS(float2 uv : TEXCOORD0) : sv_target
1110 float4 q = tex1[0].Sample(sam, uv) + tex1[1].Sample(sam, uv) + tex2.Sample(sam, uv);
1111 q.x = q.x + x;
1112 q.w = q.w + y[0] + y[1] + t;
1113 return q;
1115 #endif
1116 static const DWORD test_reflection_bound_resources_blob[] =
1118 0x43425844, 0x003472ed, 0xe3436185, 0xcc1faad3, 0xfdac0a07, 0x00000001, 0x000004b0, 0x00000005,
1119 0x00000034, 0x00000204, 0x00000238, 0x0000026c, 0x00000434, 0x46454452, 0x000001c8, 0x00000002,
1120 0x000000d0, 0x00000005, 0x0000001c, 0xffff0400, 0x00000100, 0x0000019e, 0x000000bc, 0x00000003,
1121 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x000000c0, 0x00000002,
1122 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000002, 0x0000000c, 0x000000c5, 0x00000002,
1123 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000c, 0x000000ca, 0x00000000,
1124 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x000000cd, 0x00000000,
1125 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x006d6173, 0x31786574,
1126 0x78657400, 0x31630032, 0x00326300, 0x000000ca, 0x00000003, 0x00000100, 0x00000030, 0x00000000,
1127 0x00000000, 0x000000cd, 0x00000001, 0x00000184, 0x00000010, 0x00000000, 0x00000000, 0x00000148,
1128 0x00000000, 0x00000004, 0x00000002, 0x0000014c, 0x00000000, 0x0000015c, 0x00000010, 0x00000014,
1129 0x00000002, 0x00000160, 0x00000000, 0x00000170, 0x00000024, 0x00000004, 0x00000000, 0x00000174,
1130 0x00000000, 0xabab0078, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0xabab0079, 0x00030000,
1131 0x00010001, 0x00000002, 0x00000000, 0xabab007a, 0x00020000, 0x00010001, 0x00000000, 0x00000000,
1132 0x0000019c, 0x00000000, 0x00000004, 0x00000002, 0x0000014c, 0x00000000, 0x694d0074, 0x736f7263,
1133 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43, 0x72656c69, 0x2e303120,
1134 0xabab0031, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
1135 0x00000003, 0x00000000, 0x00000303, 0x43584554, 0x44524f4f, 0xababab00, 0x4e47534f, 0x0000002c,
1136 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
1137 0x745f7673, 0x65677261, 0xabab0074, 0x52444853, 0x000001c0, 0x00000040, 0x00000070, 0x04000059,
1138 0x00208e46, 0x00000000, 0x00000003, 0x04000059, 0x00208e46, 0x00000001, 0x00000001, 0x0300005a,
1139 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000,
1140 0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555, 0x03001062, 0x00101032,
1141 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2,
1142 0x00000000, 0x00101046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045,
1143 0x001000f2, 0x00000001, 0x00101046, 0x00000000, 0x00107e46, 0x00000001, 0x00106000, 0x00000000,
1144 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, 0x09000045,
1145 0x001000f2, 0x00000001, 0x00101046, 0x00000000, 0x00107e46, 0x00000002, 0x00106000, 0x00000000,
1146 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, 0x08000000,
1147 0x00100082, 0x00000000, 0x0010003a, 0x00000000, 0x0020800a, 0x00000000, 0x00000001, 0x08000000,
1148 0x00100082, 0x00000000, 0x0010003a, 0x00000000, 0x0020800a, 0x00000000, 0x00000002, 0x08000000,
1149 0x00102082, 0x00000000, 0x0010003a, 0x00000000, 0x0020800a, 0x00000001, 0x00000000, 0x08000000,
1150 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x05000036,
1151 0x00102062, 0x00000000, 0x00100656, 0x00000000, 0x0100003e, 0x54415453, 0x00000074, 0x0000000b,
1152 0x00000002, 0x00000000, 0x00000002, 0x00000006, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
1153 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000,
1154 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1155 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1158 static const D3D12_SHADER_INPUT_BIND_DESC test_reflection_bound_resources_result[] =
1160 {"sam", D3D_SIT_SAMPLER, 0, 1, 0, 0, D3D_SRV_DIMENSION_UNKNOWN, 0},
1161 {"tex1", D3D_SIT_TEXTURE, 0, 2, 12, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, 0xffffffff},
1162 {"tex2", D3D_SIT_TEXTURE, 2, 1, 12, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, 0xffffffff, 0, 2},
1163 {"c1", D3D_SIT_CBUFFER, 0, 1, 0, 0, D3D_SRV_DIMENSION_UNKNOWN, 0},
1164 {"c2", D3D_SIT_CBUFFER, 1, 1, 0, 0, D3D_SRV_DIMENSION_UNKNOWN, 0, 0, 1},
1167 static void test_reflection_bound_resources(const DWORD *blob, const D3D12_SHADER_INPUT_BIND_DESC *result,
1168 unsigned int result_count, unsigned int target_version)
1170 ID3D12ShaderReflection *ref12 = NULL, *ref12_from_d3d11 = NULL, *ref11_from_d3d12 = NULL;
1171 const D3D12_SHADER_INPUT_BIND_DESC *pdesc;
1172 D3D12_SHADER_INPUT_BIND_DESC desc12;
1173 D3D11_SHADER_INPUT_BIND_DESC desc11;
1174 ID3D11ShaderReflection *ref11;
1175 HRESULT hr, expected_hr;
1176 unsigned int i;
1177 UINT expected;
1178 ULONG count;
1180 hr = call_reflect(blob, blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
1182 expected_hr = D3D_COMPILER_VERSION < 47 && target_version >= 0x501 ? E_INVALIDARG : S_OK;
1184 /* Older d3dcompiler_47 does not support sm5.1. */
1185 ok(hr == expected_hr || broken(hr == E_INVALIDARG && target_version >= 0x501), "Got unexpected hr %x.\n", hr);
1187 if (hr == E_INVALIDARG)
1188 return;
1190 #if D3D_COMPILER_VERSION
1191 call_reflect(blob, blob[6], &IID_ID3D12ShaderReflection, (void **)&ref12);
1192 ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D12ShaderReflection, (void **)&ref12_from_d3d11);
1193 ok((!ref12 && !ref12_from_d3d11) || (ref12 && ref12_from_d3d11), "Got unexpected interfaces %p, %p.\n",
1194 ref12, ref12_from_d3d11);
1196 if (ref12)
1198 ok(ref12 != (void *)ref11, "Got unexpected interfaces %p, %p.\n", ref11, ref12);
1199 ok(ref12_from_d3d11 == (void *)ref11, "Got unexpected interfaces %p, %p.\n",
1200 ref11, ref12_from_d3d11);
1201 ref12->lpVtbl->QueryInterface(ref12, &IID_ID3D11ShaderReflection, (void **)&ref11_from_d3d12);
1202 ok(!!ref11_from_d3d12, "Got zero interface.\n");
1204 #endif
1206 /* check invalid cases */
1207 hr = ref11->lpVtbl->GetResourceBindingDesc(ref11, 0, NULL);
1208 ok(hr == E_INVALIDARG, "Got unexpected hr %x.\n", hr);
1210 hr = ref11->lpVtbl->GetResourceBindingDesc(ref11, 0xffffffff, &desc11);
1211 ok(hr == E_INVALIDARG, "Got unexpected hr %x.\n", hr);
1213 #if D3D_COMPILER_VERSION
1214 hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, NULL, &desc11);
1215 ok(hr == E_INVALIDARG, "Got unexpected hr %x.\n", hr);
1217 hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, "sam", NULL);
1218 ok(hr == E_INVALIDARG, "Got unexpected hr %x.\n", hr);
1220 hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, "invalid", NULL);
1221 ok(hr == E_INVALIDARG, "Got unexpected hr %x.\n", hr);
1223 hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, "invalid", &desc11);
1224 ok(hr == E_INVALIDARG, "Got unexpected hr %x.\n", hr);
1225 #endif
1227 /* GetResourceBindingDesc */
1228 for (i = 0; i < result_count; ++i)
1230 pdesc = &result[i];
1232 hr = ref11->lpVtbl->GetResourceBindingDesc(ref11, i, &desc11);
1233 ok(hr == S_OK, "Got unexpected hr %x, i %u.\n", hr, i);
1235 ok(!strcmp(desc11.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc11.Name, i);
1236 ok(desc11.Type == pdesc->Type, "Got unexpected Type %#x, i %u.\n", desc11.Type, i);
1237 ok(desc11.BindPoint == pdesc->BindPoint, "Got unexpected BindPoint %u, i %u.\n", desc11.BindPoint, i);
1238 ok(desc11.BindCount == pdesc->BindCount, "Got unexpected BindCount %u, i %u.\n", desc11.BindCount, i);
1239 #if D3D_COMPILER_VERSION
1240 expected = pdesc->uFlags;
1241 #else
1242 expected = 0;
1243 todo_wine_if(pdesc->uFlags)
1244 #endif
1245 ok(desc11.uFlags == expected, "Got unexpected uFlags %#x, i %u.\n", desc11.uFlags, i);
1246 ok(desc11.ReturnType == pdesc->ReturnType, "Got unexpected ReturnType %#x, i %u.\n", desc11.ReturnType, i);
1247 ok(desc11.Dimension == pdesc->Dimension, "Got unexpected Dimension %#x, i %u.\n", desc11.Dimension, i);
1248 ok(desc11.NumSamples == pdesc->NumSamples, "Got unexpected NumSamples %u, i %u.\n", desc11.NumSamples, i);
1250 if (ref12)
1252 memset(&desc12, 0, sizeof(desc12));
1253 desc12.Space = 0xdeadbeef;
1254 desc12.uID = 0xdeadbeef;
1256 hr = ref12->lpVtbl->GetResourceBindingDesc(ref12, i, &desc12);
1257 ok(hr == S_OK, "Got unexpected hr %x, i %u.\n", hr, i);
1259 ok(!strcmp(desc12.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc12.Name, i);
1260 ok(!memcmp(&desc12.Type, &desc11.Type, sizeof(desc11) - offsetof(D3D11_SHADER_INPUT_BIND_DESC, Type)),
1261 "D3D11 and D3D12 descs do not match.\n");
1262 ok(desc12.Space == pdesc->Space, "Got unexpected Space %u, i %u.\n", desc12.Space, i);
1263 ok(desc12.uID == pdesc->uID, "Got unexpected uID %#x, i %u.\n", desc12.uID, i);
1265 memset(&desc12, 0, sizeof(desc12));
1266 desc12.Space = 0xdeadbeef;
1267 desc12.uID = 0xdeadbeef;
1268 hr = ref12_from_d3d11->lpVtbl->GetResourceBindingDesc(ref12_from_d3d11, i, &desc12);
1269 ok(hr == S_OK, "Got unexpected hr %x, i %u.\n", hr, i);
1271 ok(!strcmp(desc12.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc12.Name, i);
1272 ok(!memcmp(&desc12.Type, &desc11.Type, sizeof(desc11) - offsetof(D3D11_SHADER_INPUT_BIND_DESC, Type)),
1273 "D3D11 and D3D12 descs do not match.\n");
1274 /* Native d3dcompiler_47 returns the same interface pointer when queried for ID3D12ShaderReflection
1275 * from ID3D11ShaderReflection. Space field still gets the correct value on x64 due to
1276 * D3D11_SHADER_INPUT_BIND_DESC padding. */
1277 expected = offsetof(D3D12_SHADER_INPUT_BIND_DESC, Space) < sizeof(D3D11_SHADER_INPUT_BIND_DESC)
1278 ? pdesc->Space : 0xdeadbeef;
1279 ok(desc12.Space == expected, "Got unexpected Space %u, i %u.\n",
1280 desc12.Space, i);
1281 ok(desc12.uID == 0xdeadbeef, "Got unexpected uID %#x, i %u.\n", desc12.uID, i);
1283 memset(&desc12, 0, sizeof(desc12));
1284 desc12.Space = 0xdeadbeef;
1285 desc12.uID = 0xdeadbeef;
1286 hr = ref11_from_d3d12->lpVtbl->GetResourceBindingDesc(ref11_from_d3d12, i, &desc12);
1287 ok(hr == S_OK, "Got unexpected hr %x, i %u.\n", hr, i);
1288 ok(!strcmp(desc12.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc12.Name, i);
1289 ok(!memcmp(&desc12.Type, &desc11.Type, sizeof(desc11) - offsetof(D3D11_SHADER_INPUT_BIND_DESC, Type)),
1290 "D3D11 and D3D12 descs do not match.\n");
1291 ok(desc12.Space == pdesc->Space, "Got unexpected Space %u, i %u.\n", desc12.Space, i);
1292 ok(desc12.uID == pdesc->uID, "Got unexpected uID %#x, i %u.\n", desc12.uID, i);
1296 #if D3D_COMPILER_VERSION
1297 /* GetResourceBindingDescByName */
1298 for (i = 0; i < result_count; ++i)
1300 pdesc = &result[i];
1302 hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, pdesc->Name, &desc11);
1303 ok(hr == S_OK, "Got unexpected hr %x, i %u.\n", hr, i);
1305 ok(!strcmp(desc11.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc11.Name, i);
1306 ok(desc11.Type == pdesc->Type, "Got unexpected Type %#x, i %u.\n", desc11.Type, i);
1307 ok(desc11.BindPoint == pdesc->BindPoint, "Got unexpected BindPoint %u, i %u.\n", desc11.BindPoint, i);
1308 ok(desc11.BindCount == pdesc->BindCount, "Got unexpected BindCount failed %u, i %u.\n", desc11.BindCount, i);
1309 ok(desc11.uFlags == pdesc->uFlags, "Got unexpected uFlags %#x, i %u.\n", desc11.uFlags, i);
1310 ok(desc11.ReturnType == pdesc->ReturnType, "Got unexpected ReturnType %#x, i %u.\n", desc11.ReturnType, i);
1311 ok(desc11.Dimension == pdesc->Dimension, "Got unexpected Dimension %#x, i %u.\n", desc11.Dimension, i);
1312 ok(desc11.NumSamples == pdesc->NumSamples, "Got unexpected NumSamples %u, i %u.\n", desc11.NumSamples, i);
1314 if (ref12)
1316 memset(&desc12, 0, sizeof(desc12));
1317 desc12.Space = 0xdeadbeef;
1318 desc12.uID = 0xdeadbeef;
1320 hr = ref12->lpVtbl->GetResourceBindingDescByName(ref12, pdesc->Name, &desc12);
1321 ok(hr == S_OK, "Got unexpected hr %x, i %u.\n", hr, i);
1323 ok(!strcmp(desc12.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc12.Name, i);
1324 ok(!memcmp(&desc12.Type, &desc11.Type, sizeof(desc11) - offsetof(D3D11_SHADER_INPUT_BIND_DESC, Type)),
1325 "D3D11 and D3D12 descs do not match.\n");
1326 ok(desc12.Space == pdesc->Space, "Got unexpected Space %u, i %u.\n", desc12.Space, i);
1327 ok(desc12.uID == pdesc->uID, "Got unexpected uID %#x, i %u.\n", desc12.uID, i);
1329 memset(&desc12, 0, sizeof(desc12));
1330 desc12.Space = 0xdeadbeef;
1331 desc12.uID = 0xdeadbeef;
1332 hr = ref12_from_d3d11->lpVtbl->GetResourceBindingDescByName(ref12_from_d3d11, pdesc->Name, &desc12);
1333 ok(hr == S_OK, "Got unexpected hr %x, i %u.\n", hr, i);
1335 ok(!strcmp(desc12.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc12.Name, i);
1336 ok(!memcmp(&desc12.Type, &desc11.Type, sizeof(desc11) - offsetof(D3D11_SHADER_INPUT_BIND_DESC, Type)),
1337 "D3D11 and D3D12 descs do not match.\n");
1338 expected = offsetof(D3D12_SHADER_INPUT_BIND_DESC, Space) < sizeof(D3D11_SHADER_INPUT_BIND_DESC)
1339 ? pdesc->Space : 0xdeadbeef;
1340 ok(desc12.Space == expected, "Got unexpected Space %u, i %u.\n",
1341 desc12.Space, i);
1342 ok(desc12.uID == 0xdeadbeef, "Got unexpected uID %#x, i %u.\n", desc12.uID, i);
1344 memset(&desc12, 0, sizeof(desc12));
1345 desc12.Space = 0xdeadbeef;
1346 desc12.uID = 0xdeadbeef;
1347 hr = ref11_from_d3d12->lpVtbl->GetResourceBindingDescByName(ref11_from_d3d12, pdesc->Name, &desc12);
1348 ok(hr == S_OK, "Got unexpected hr %x, i %u.\n", hr, i);
1349 ok(!strcmp(desc12.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc12.Name, i);
1350 ok(!memcmp(&desc12.Type, &desc11.Type, sizeof(desc11) - offsetof(D3D11_SHADER_INPUT_BIND_DESC, Type)),
1351 "D3D11 and D3D12 descs do not match.\n");
1352 ok(desc12.Space == pdesc->Space, "Got unexpected Space %u, i %u.\n", desc12.Space, i);
1353 ok(desc12.uID == pdesc->uID, "Got unexpected uID %#x, i %u.\n", desc12.uID, i);
1356 #endif
1358 if (ref12)
1360 count = ref11_from_d3d12->lpVtbl->Release(ref11_from_d3d12);
1361 ok(count == 1, "Got unexpected ref count %u.\n", count);
1363 count = ref12->lpVtbl->Release(ref12);
1364 ok(!count, "Got unexpected ref count %u.\n", count);
1366 count = ref12_from_d3d11->lpVtbl->Release(ref12_from_d3d11);
1367 ok(count == 1, "Got unexpected ref count %u.\n", count);
1370 count = ref11->lpVtbl->Release(ref11);
1371 ok(!count, "Got unexpected ref count %u.\n", count);
1374 #if D3D_COMPILER_VERSION
1376 * fxc.exe /E PS /Tps_5_0 /Fx
1378 #if 0
1379 cbuffer c1
1381 float a;
1382 float b[2];
1383 int i;
1384 struct s {
1385 float a;
1386 float b;
1387 } t;
1390 interface iTest
1392 float4 test(float2 vec);
1395 class cTest : iTest
1397 bool m_on;
1398 float4 test(float2 vec);
1401 float4 cTest::test(float2 vec)
1403 float4 res;
1404 if(m_on)
1405 res = float4(vec.x, vec.y, vec.x+vec.y, 0);
1406 else
1407 res = 0;
1408 return res;
1411 iTest g_Test;
1414 float4 PS(float2 uv : TEXCOORD0) : sv_target
1416 float4 q = g_Test.test(uv);
1417 q.x = q.x + t.a;
1418 return q;
1420 #endif
1421 static DWORD test_reflection_constant_buffer_blob[] = {
1422 0x43425844, 0xe6470e0d, 0x0d5698bb, 0x29373c30, 0x64a5d268, 0x00000001, 0x00000590, 0x00000006,
1423 0x00000038, 0x00000318, 0x0000034c, 0x00000380, 0x000003d8, 0x000004f4, 0x46454452, 0x000002d8,
1424 0x00000002, 0x00000060, 0x00000001, 0x0000003c, 0xffff0500, 0x00000100, 0x000002a4, 0x31314452,
1425 0x0000003c, 0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000001, 0x0000005c,
1426 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0xab003163,
1427 0x00000090, 0x00000001, 0x000000a0, 0x00000010, 0x00000000, 0x00000002, 0x0000005c, 0x00000004,
1428 0x00000120, 0x00000040, 0x00000000, 0x00000000, 0x69685424, 0x696f5073, 0x7265746e, 0xababab00,
1429 0x000000c8, 0x00000000, 0x00000001, 0x00000006, 0x000000fc, 0x00000000, 0xffffffff, 0x00000000,
1430 0xffffffff, 0x00000000, 0x65545f67, 0x69007473, 0x74736554, 0xababab00, 0x00000006, 0x00000001,
1431 0x00000000, 0x000000d8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000cf, 0x00250007,
1432 0x00040001, 0x00000000, 0x00000000, 0x000000d8, 0x00000000, 0x00000000, 0x00000000, 0x000000cf,
1433 0x000001c0, 0x00000000, 0x00000004, 0x00000000, 0x000001c8, 0x00000000, 0xffffffff, 0x00000000,
1434 0xffffffff, 0x00000000, 0x000001ec, 0x00000010, 0x00000014, 0x00000000, 0x000001f0, 0x00000000,
1435 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0x00000214, 0x00000024, 0x00000004, 0x00000000,
1436 0x0000021c, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0x00000240, 0x00000030,
1437 0x00000008, 0x00000002, 0x00000280, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000,
1438 0x6c660061, 0x0074616f, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1439 0x00000000, 0x00000000, 0x000001c2, 0xabab0062, 0x00030000, 0x00010001, 0x00000002, 0x00000000,
1440 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000001c2, 0x6e690069, 0xabab0074, 0x00020000,
1441 0x00010001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000216,
1442 0x00730074, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1443 0x00000000, 0x000001c2, 0x000001c0, 0x00000244, 0x00000000, 0x000001ec, 0x00000244, 0x00000004,
1444 0x00000005, 0x00020001, 0x00020000, 0x00000268, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1445 0x00000242, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072,
1446 0x6c69706d, 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x0000002c,
1447 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303,
1448 0x43584554, 0x44524f4f, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
1449 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x745f7673, 0x65677261, 0xabab0074,
1450 0x45434649, 0x00000050, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000040, 0x00000034,
1451 0x00000024, 0x00000000, 0x4e47534f, 0x00000001, 0x00000001, 0x00000040, 0x00000044, 0x00000048,
1452 0x00010000, 0x00000000, 0xabab0000, 0x00000000, 0x73655463, 0xabab0074, 0x58454853, 0x00000114,
1453 0x00000050, 0x00000045, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000004, 0x03000091,
1454 0x00000000, 0x00000000, 0x05000092, 0x00000000, 0x00000000, 0x00010001, 0x00000000, 0x03001062,
1455 0x00101032, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x07000000,
1456 0x00100042, 0x00000000, 0x0010101a, 0x00000000, 0x0010100a, 0x00000000, 0x05000036, 0x00100032,
1457 0x00000000, 0x00101046, 0x00000000, 0x05000036, 0x00100082, 0x00000000, 0x00004001, 0x00000000,
1458 0x05000036, 0x00100032, 0x00000001, 0x0011d516, 0x00000000, 0x0a000001, 0x001000f2, 0x00000000,
1459 0x00100e46, 0x00000000, 0x04a08006, 0x0010001a, 0x00000001, 0x0010000a, 0x00000001, 0x08000000,
1460 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0020800a, 0x00000000, 0x00000003, 0x05000036,
1461 0x001020e2, 0x00000000, 0x00100e56, 0x00000000, 0x0100003e, 0x54415453, 0x00000094, 0x00000008,
1462 0x00000002, 0x00000000, 0x00000002, 0x00000002, 0x00000000, 0x00000001, 0x00000001, 0x00000000,
1463 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1464 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1465 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1466 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1469 static const D3D11_SHADER_BUFFER_DESC test_reflection_constant_buffer_cb_result[] =
1471 {"$ThisPointer", D3D_CT_INTERFACE_POINTERS, 1, 16, 0},
1472 {"c1", D3D_CT_CBUFFER, 4, 64, 0},
1475 static const struct
1477 D3D11_SHADER_VARIABLE_DESC desc;
1478 unsigned int type;
1479 } test_reflection_constant_buffer_variable_result[] =
1481 {{"g_Test", 0, 1, 6, 0}, 0},
1482 {{"a", 0, 4, 0, 0}, 1},
1483 {{"b", 16, 20, 0, 0}, 2},
1484 {{"i", 36, 4, 0, 0}, 3},
1485 {{"t", 48, 8, 2, 0}, 4},
1488 #else
1490 * fxc.exe /E PS /Tps_4_0 /Fx
1492 #if 0
1493 cbuffer c1
1495 float a;
1496 float b[2];
1497 int i;
1498 struct s {
1499 float a;
1500 float b;
1501 } t;
1504 class cTest
1506 bool m_on;
1507 float4 test(float2 vec);
1510 float4 cTest::test(float2 vec)
1512 float4 res;
1513 if(m_on)
1514 res = float4(vec.x, vec.y, vec.x+vec.y, 0);
1515 else
1516 res = 0;
1517 return res;
1520 cTest g_Test;
1523 float4 PS(float2 uv : TEXCOORD0) : sv_target
1525 float4 q = g_Test.test(uv);
1526 q.x = q.x + t.a;
1527 return q;
1529 #endif
1530 static DWORD test_reflection_constant_buffer_blob[] = {
1531 0x43425844, 0x0241ca0a, 0xa3bf8da0, 0xdd5f853e, 0xfe868252, 0x00000001, 0x00000414, 0x00000005,
1532 0x00000034, 0x00000230, 0x00000264, 0x00000298, 0x00000398, 0x46454452, 0x000001f4, 0x00000002,
1533 0x00000068, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100, 0x000001c0, 0x0000005c, 0x00000000,
1534 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000065, 0x00000000,
1535 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x6f6c4724, 0x736c6162,
1536 0x00316300, 0x0000005c, 0x00000001, 0x00000098, 0x00000010, 0x00000000, 0x00000000, 0x00000065,
1537 0x00000004, 0x000000e8, 0x00000040, 0x00000000, 0x00000000, 0x000000b0, 0x00000000, 0x00000004,
1538 0x00000002, 0x000000d8, 0x00000000, 0x65545f67, 0x6d007473, 0x006e6f5f, 0x00010000, 0x00010001,
1539 0x00000000, 0x00000000, 0x000000b7, 0x000000bc, 0x00000000, 0x00000005, 0x00010001, 0x00010000,
1540 0x000000cc, 0x00000148, 0x00000000, 0x00000004, 0x00000000, 0x0000014c, 0x00000000, 0x0000015c,
1541 0x00000010, 0x00000014, 0x00000000, 0x00000160, 0x00000000, 0x00000170, 0x00000024, 0x00000004,
1542 0x00000000, 0x00000174, 0x00000000, 0x00000184, 0x00000030, 0x00000008, 0x00000002, 0x000001b0,
1543 0x00000000, 0xabab0061, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0xabab0062, 0x00030000,
1544 0x00010001, 0x00000002, 0x00000000, 0xabab0069, 0x00020000, 0x00010001, 0x00000000, 0x00000000,
1545 0xabab0074, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0x00000148, 0x00000188, 0x00000000,
1546 0x0000015c, 0x00000188, 0x00000004, 0x00000005, 0x00020001, 0x00020000, 0x00000198, 0x7263694d,
1547 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265,
1548 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
1549 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x43584554, 0x44524f4f,
1550 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
1551 0x00000003, 0x00000000, 0x0000000f, 0x745f7673, 0x65677261, 0xabab0074, 0x52444853, 0x000000f8,
1552 0x00000040, 0x0000003e, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04000059, 0x00208e46,
1553 0x00000001, 0x00000004, 0x03001062, 0x00101032, 0x00000000, 0x03000065, 0x001020f2, 0x00000000,
1554 0x02000068, 0x00000001, 0x07000000, 0x00100042, 0x00000000, 0x0010101a, 0x00000000, 0x0010100a,
1555 0x00000000, 0x05000036, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x05000036, 0x00100082,
1556 0x00000000, 0x00004001, 0x00000000, 0x0d000037, 0x001000f2, 0x00000000, 0x00208006, 0x00000000,
1557 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1558 0x08000000, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0020800a, 0x00000001, 0x00000003,
1559 0x05000036, 0x001020e2, 0x00000000, 0x00100e56, 0x00000000, 0x0100003e, 0x54415453, 0x00000074,
1560 0x00000007, 0x00000001, 0x00000000, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000001,
1561 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1562 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
1563 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1566 static const D3D11_SHADER_BUFFER_DESC test_reflection_constant_buffer_cb_result[] =
1568 {"$Globals", D3D_CT_CBUFFER, 1, 16, 0},
1569 {"c1", D3D_CT_CBUFFER, 4, 64, 0},
1572 static const struct
1574 D3D11_SHADER_VARIABLE_DESC desc;
1575 unsigned int type;
1576 } test_reflection_constant_buffer_variable_result[] =
1578 {{"a", 0, 4, 0, 0}, 1},
1579 {{"b", 16, 20, 0, 0}, 2},
1580 {{"i", 36, 4, 0, 0}, 3},
1581 {{"t", 48, 8, 2, 0}, 4},
1584 #endif
1586 static const D3D11_SHADER_TYPE_DESC test_reflection_constant_buffer_type_result[] =
1588 {D3D11_SVC_INTERFACE_POINTER, D3D11_SVT_INTERFACE_POINTER, 1, 4, 0, 1, 0, "iTest"},
1589 {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 1, 0, "float"},
1590 {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 2, 1, 0, "float"},
1591 {D3D_SVC_SCALAR, D3D_SVT_INT, 1, 1, 0, 1, 0, "int"},
1592 {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 2, 0, 1, 0, "s"},
1595 static void test_reflection_constant_buffer(void)
1597 ID3D12ShaderReflectionType *t12, *mt12, *mt12_2, *t12_dummy = NULL, *t12_valid = NULL;
1598 ID3D12ShaderReflectionConstantBuffer *cb12, *cb12_dummy = NULL, *cb12_valid = NULL;
1599 ID3D11ShaderReflectionConstantBuffer *cb11, *cb11_dummy = NULL, *cb11_valid = NULL;
1600 ID3D11ShaderReflectionType *t11, *t, *t2, *t11_dummy = NULL, *t11_valid = NULL;
1601 ID3D12ShaderReflectionVariable *v12, *v12_dummy = NULL, *v12_valid = NULL;
1602 ID3D11ShaderReflectionVariable *v11, *v11_dummy = NULL, *v11_valid = NULL;
1603 D3D12_SHADER_VARIABLE_DESC vdesc12 = {0};
1604 const D3D11_SHADER_VARIABLE_DESC *pvdesc;
1605 const D3D11_SHADER_BUFFER_DESC *pcbdesc;
1606 D3D12_SHADER_BUFFER_DESC cbdesc12 = {0};
1607 D3D11_SHADER_VARIABLE_DESC vdesc = {0};
1608 D3D11_SHADER_BUFFER_DESC cbdesc = {0};
1609 ID3D12ShaderReflection *ref12 = NULL;
1610 const D3D11_SHADER_TYPE_DESC *ptdesc;
1611 D3D12_SHADER_TYPE_DESC tdesc12 = {0};
1612 D3D11_SHADER_TYPE_DESC tdesc = {0};
1613 ID3D11ShaderReflection *ref11;
1614 D3D11_SHADER_DESC sdesc = {0};
1615 unsigned int i, expected;
1616 LPCSTR string;
1617 ULONG count;
1618 HRESULT hr;
1620 hr = call_reflect(test_reflection_constant_buffer_blob, test_reflection_constant_buffer_blob[6],
1621 &IID_ID3D11ShaderReflection, (void **)&ref11);
1622 ok(hr == S_OK, "D3DReflect failed %x\n", hr);
1624 #if D3D_COMPILER_VERSION
1625 call_reflect(test_reflection_constant_buffer_blob, test_reflection_constant_buffer_blob[6],
1626 &IID_ID3D12ShaderReflection, (void **)&ref12);
1627 #endif
1629 hr = ref11->lpVtbl->GetDesc(ref11, &sdesc);
1630 ok(hr == S_OK, "GetDesc failed %x\n", hr);
1632 expected = D3D_COMPILER_VERSION ? 80 : 64;
1633 ok(sdesc.Version == expected, "Got unexpected version %u.\n", sdesc.Version);
1634 ok(strcmp(sdesc.Creator, (char*) shader_creator) == 0, "GetDesc failed, got \"%s\", expected \"%s\"\n", sdesc.Creator, (char*)shader_creator);
1635 ok(sdesc.Flags == 256, "GetDesc failed, got %u, expected %u\n", sdesc.Flags, 256);
1636 ok(sdesc.ConstantBuffers == 2, "GetDesc failed, got %u, expected %u\n", sdesc.ConstantBuffers, 2);
1637 expected = D3D_COMPILER_VERSION ? 1 : 2;
1638 ok(sdesc.BoundResources == expected, "Got unexpected BoundResources %u.\n", sdesc.BoundResources);
1639 ok(sdesc.InputParameters == 1, "GetDesc failed, got %u, expected %u\n", sdesc.InputParameters, 1);
1640 ok(sdesc.OutputParameters == 1, "GetDesc failed, got %u, expected %u\n", sdesc.OutputParameters, 1);
1641 expected = D3D_COMPILER_VERSION ? 8 : 7;
1642 ok(sdesc.InstructionCount == expected, "Got unexpected InstructionCount %u.\n", sdesc.InstructionCount);
1643 expected = D3D_COMPILER_VERSION ? 2 : 1;
1644 ok(sdesc.TempRegisterCount == expected, "Got unexpected TempRegisterCount %u.\n", sdesc.TempRegisterCount);
1645 ok(sdesc.TempArrayCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TempArrayCount, 0);
1646 ok(sdesc.DefCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.DefCount, 0);
1647 ok(sdesc.DclCount == 2, "GetDesc failed, got %u, expected %u\n", sdesc.DclCount, 2);
1648 ok(sdesc.TextureNormalInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TextureNormalInstructions, 0);
1649 ok(sdesc.TextureLoadInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TextureLoadInstructions, 0);
1650 ok(sdesc.TextureCompInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TextureCompInstructions, 0);
1651 ok(sdesc.TextureBiasInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TextureBiasInstructions, 0);
1652 ok(sdesc.TextureGradientInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TextureGradientInstructions, 0);
1653 ok(sdesc.FloatInstructionCount == 2, "GetDesc failed, got %u, expected %u\n", sdesc.FloatInstructionCount, 2);
1654 ok(sdesc.IntInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.IntInstructionCount, 0);
1655 expected = D3D_COMPILER_VERSION ? 1 : 0;
1656 ok(sdesc.UintInstructionCount == expected, "Got unexpected UintInstructionCount %u.\n",
1657 sdesc.UintInstructionCount);
1658 ok(sdesc.StaticFlowControlCount == 1, "GetDesc failed, got %u, expected %u\n", sdesc.StaticFlowControlCount, 1);
1659 ok(sdesc.DynamicFlowControlCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.DynamicFlowControlCount, 0);
1660 ok(sdesc.MacroInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.MacroInstructionCount, 0);
1661 ok(sdesc.ArrayInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.ArrayInstructionCount, 0);
1662 ok(sdesc.CutInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.CutInstructionCount, 0);
1663 ok(sdesc.EmitInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.EmitInstructionCount, 0);
1664 ok(sdesc.GSOutputTopology == 0, "GetDesc failed, got %x, expected %x\n", sdesc.GSOutputTopology, 0);
1665 ok(sdesc.GSMaxOutputVertexCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.GSMaxOutputVertexCount, 0);
1666 ok(sdesc.InputPrimitive == 0, "GetDesc failed, got %x, expected %x\n", sdesc.InputPrimitive, 0);
1667 ok(sdesc.PatchConstantParameters == 0, "GetDesc failed, got %u, expected %u\n", sdesc.PatchConstantParameters, 0);
1668 ok(sdesc.cGSInstanceCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.cGSInstanceCount, 0);
1669 ok(sdesc.cControlPoints == 0, "GetDesc failed, got %u, expected %u\n", sdesc.cControlPoints, 0);
1670 ok(sdesc.HSOutputPrimitive == 0, "GetDesc failed, got %x, expected %x\n", sdesc.HSOutputPrimitive, 0);
1671 ok(sdesc.HSPartitioning == 0, "GetDesc failed, got %x, expected %x\n", sdesc.HSPartitioning, 0);
1672 ok(sdesc.TessellatorDomain == 0, "GetDesc failed, got %x, expected %x\n", sdesc.TessellatorDomain, 0);
1673 ok(sdesc.cBarrierInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.cBarrierInstructions, 0);
1674 ok(sdesc.cInterlockedInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.cInterlockedInstructions, 0);
1675 ok(sdesc.cTextureStoreInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.cTextureStoreInstructions, 0);
1677 /* get the dummys for comparison */
1678 cb11_dummy = ref11->lpVtbl->GetConstantBufferByIndex(ref11, 0xffffffff);
1679 ok(!!cb11_dummy, "Got unexpected buffer %p.\n", cb11_dummy);
1681 if (ref12)
1683 cb12_dummy = ref12->lpVtbl->GetConstantBufferByIndex(ref12, 0xffffffff);
1684 ok(!!cb12_dummy, "Got unexpected buffer %p.\n", cb12_dummy);
1685 ok(cb12_dummy == (void *)cb11_dummy, "Got unexpected buffer %p.\n", cb12_dummy);
1687 v12_dummy = cb12_dummy->lpVtbl->GetVariableByIndex(cb12_dummy, 0xffffffff);
1688 ok(!!v12_dummy, "Got unexpected NULL variable.\n");
1690 v11_dummy = cb11_dummy->lpVtbl->GetVariableByIndex(cb11_dummy, 0xffffffff);
1691 ok(!!v11_dummy, "Got unexpected NULL variable.\n");
1693 t11_dummy = v11_dummy->lpVtbl->GetType(v11_dummy);
1694 ok(!!t11_dummy, "Got NULL type.\n");
1696 /* get the valid variables */
1697 cb11_valid = ref11->lpVtbl->GetConstantBufferByIndex(ref11, 1);
1698 ok(cb11_valid != cb11_dummy && cb11_valid, "Got unexpected buffer %p.\n", cb11_valid);
1699 if (ref12)
1701 cb12_valid = ref12->lpVtbl->GetConstantBufferByIndex(ref12, 1);
1702 ok(cb12_valid != cb12_dummy && cb12_valid, "Got unexpected buffer %p.\n", cb11_valid);
1703 ok(cb12_valid != (void *)cb11_valid, "Got unexpected buffer %p.\n", cb12_valid);
1705 v12_valid = cb12_valid->lpVtbl->GetVariableByIndex(cb12_valid, 0);
1706 ok(v12_valid != v12_dummy && v12_valid, "Got unexpected variable %p.\n", v12_valid);
1708 t12_dummy = v12_dummy->lpVtbl->GetType(v12_dummy);
1709 ok(!!t12_dummy, "Got NULL type.\n");
1711 t12_valid = v12_valid->lpVtbl->GetType(v12_valid);
1712 ok(t12_valid != t12_dummy && t12_valid, "GetType failed\n");
1715 v11_valid = cb11_valid->lpVtbl->GetVariableByIndex(cb11_valid, 0);
1716 ok(v11_valid != v11_dummy && v11_valid, "Got unexpected variable %p.\n", v11_valid);
1718 t11_valid = v11_valid->lpVtbl->GetType(v11_valid);
1719 ok(t11_valid != t11_dummy && t11_valid, "GetType failed\n");
1721 /* reflection calls */
1722 cb11 = ref11->lpVtbl->GetConstantBufferByName(ref11, "invalid");
1723 ok(cb11_dummy == cb11, "GetConstantBufferByName failed, got %p, expected %p\n", cb11, cb11_dummy);
1725 cb11 = ref11->lpVtbl->GetConstantBufferByName(ref11, NULL);
1726 ok(cb11_dummy == cb11, "GetConstantBufferByName failed, got %p, expected %p\n", cb11, cb11_dummy);
1728 #if D3D_COMPILER_VERSION
1729 v11 = ref11->lpVtbl->GetVariableByName(ref11, NULL);
1730 ok(v11_dummy == v11, "Got unexpected variable %p.\n", v11);
1732 v11 = ref11->lpVtbl->GetVariableByName(ref11, "invalid");
1733 ok(v11_dummy == v11, "Got unexpected variable %p.\n", v11);
1735 v11 = ref11->lpVtbl->GetVariableByName(ref11, "a");
1736 ok(v11_valid == v11, "Got unexpected variable %p.\n", v11);
1737 #endif
1739 /* constant buffer calls */
1740 v11 = cb11_dummy->lpVtbl->GetVariableByName(cb11_dummy, NULL);
1741 ok(v11_dummy == v11, "Got unexpected variable %p.\n", v11);
1743 v11 = cb11_dummy->lpVtbl->GetVariableByName(cb11_dummy, "invalid");
1744 ok(v11_dummy == v11, "Got unexpected variable %p.\n", v11);
1746 v11 = cb11_valid->lpVtbl->GetVariableByName(cb11_valid, NULL);
1747 ok(v11_dummy == v11, "Got unexpected variable %p.\n", v11);
1749 v11 = cb11_valid->lpVtbl->GetVariableByName(cb11_valid, "invalid");
1750 ok(v11_dummy == v11, "Got unexpected variable %p.\n", v11);
1752 v11 = cb11_valid->lpVtbl->GetVariableByName(cb11_valid, "a");
1753 ok(v11_valid == v11, "Got unexpected variable %p.\n", v11);
1755 if (ref12)
1757 v12 = cb12_valid->lpVtbl->GetVariableByName(cb12_valid, "a");
1758 ok(v12_valid == v12, "Got unexpected variable %p.\n", v12);
1761 hr = cb11_dummy->lpVtbl->GetDesc(cb11_dummy, NULL);
1762 ok(hr == E_FAIL, "GetDesc failed, got %x, expected %x\n", hr, E_FAIL);
1764 hr = cb11_dummy->lpVtbl->GetDesc(cb11_dummy, &cbdesc);
1765 ok(hr == E_FAIL, "GetDesc failed, got %x, expected %x\n", hr, E_FAIL);
1767 hr = cb11_valid->lpVtbl->GetDesc(cb11_valid, NULL);
1768 ok(hr == E_FAIL, "GetDesc failed, got %x, expected %x\n", hr, E_FAIL);
1770 /* variable calls */
1771 hr = v11_dummy->lpVtbl->GetDesc(v11_dummy, NULL);
1772 ok(hr == E_FAIL, "GetDesc failed, got %x, expected %x\n", hr, E_FAIL);
1774 hr = v11_dummy->lpVtbl->GetDesc(v11_dummy, &vdesc);
1775 ok(hr == E_FAIL, "GetDesc failed, got %x, expected %x\n", hr, E_FAIL);
1777 hr = v11_valid->lpVtbl->GetDesc(v11_valid, NULL);
1778 ok(hr == E_FAIL, "GetDesc failed, got %x, expected %x\n", hr, E_FAIL);
1780 /* type calls */
1781 hr = t11_dummy->lpVtbl->GetDesc(t11_dummy, NULL);
1782 ok(hr == E_FAIL, "GetDesc failed, got %x, expected %x\n", hr, E_FAIL);
1784 hr = t11_dummy->lpVtbl->GetDesc(t11_dummy, &tdesc);
1785 ok(hr == E_FAIL, "GetDesc failed, got %x, expected %x\n", hr, E_FAIL);
1787 hr = t11_valid->lpVtbl->GetDesc(t11_valid, NULL);
1788 ok(hr == E_FAIL, "GetDesc failed, got %x, expected %x\n", hr, E_FAIL);
1790 string = t11_dummy->lpVtbl->GetMemberTypeName(t11_dummy, 0xffffffff);
1791 ok(!strcmp(string, "$Invalid"), "GetMemberTypeName failed, got \"%s\", expected \"%s\"\n", string, "$Invalid");
1793 string = t11_valid->lpVtbl->GetMemberTypeName(t11_valid, 0xffffffff);
1794 ok(!string, "GetMemberTypeName failed, got \"%s\", expected NULL\n", string);
1796 t11 = t11_dummy->lpVtbl->GetMemberTypeByIndex(t11_dummy, 0xffffffff);
1797 ok(t11_dummy == t11, "GetMemberTypeByIndex failed, got %p, expected %p\n", t11, t11_dummy);
1799 t11 = t11_valid->lpVtbl->GetMemberTypeByIndex(t11_valid, 0xffffffff);
1800 ok(t11_dummy == t11, "GetMemberTypeByIndex failed, got %p, expected %p\n", t11, t11_dummy);
1802 t11 = t11_dummy->lpVtbl->GetMemberTypeByName(t11_dummy, NULL);
1803 ok(t11_dummy == t11, "GetMemberTypeByName failed, got %p, expected %p\n", t11, t11_dummy);
1805 t11 = t11_dummy->lpVtbl->GetMemberTypeByName(t11_dummy, "invalid");
1806 ok(t11_dummy == t11, "GetMemberTypeByName failed, got %p, expected %p\n", t11, t11_dummy);
1808 t11 = t11_valid->lpVtbl->GetMemberTypeByName(t11_valid, NULL);
1809 ok(t11_dummy == t11, "GetMemberTypeByName failed, got %p, expected %p\n", t11, t11_dummy);
1811 t11 = t11_valid->lpVtbl->GetMemberTypeByName(t11_valid, "invalid");
1812 ok(t11_dummy == t11, "GetMemberTypeByName failed, got %p, expected %p\n", t11, t11_dummy);
1814 #if D3D_COMPILER_VERSION
1815 hr = t11_dummy->lpVtbl->IsEqual(t11_dummy, t11_dummy);
1816 ok(hr == E_FAIL, "IsEqual failed, got %x, expected %x\n", hr, E_FAIL);
1818 hr = t11_valid->lpVtbl->IsEqual(t11_valid, t11_dummy);
1819 ok(hr == S_FALSE, "IsEqual failed, got %x, expected %x\n", hr, S_FALSE);
1821 hr = t11_dummy->lpVtbl->IsEqual(t11_dummy, t11_valid);
1822 ok(hr == E_FAIL, "IsEqual failed, got %x, expected %x\n", hr, E_FAIL);
1824 hr = t11_valid->lpVtbl->IsEqual(t11_valid, t11_valid);
1825 ok(hr == S_OK, "IsEqual failed, got %x, expected %x\n", hr, S_OK);
1826 #endif
1828 /* constant buffers */
1829 for (i = 0; i < ARRAY_SIZE(test_reflection_constant_buffer_cb_result); ++i)
1831 pcbdesc = &test_reflection_constant_buffer_cb_result[i];
1833 cb11 = ref11->lpVtbl->GetConstantBufferByIndex(ref11, i);
1834 ok(cb11_dummy != cb11, "Got dummy constant buffer, i %u.\n", i);
1836 hr = cb11->lpVtbl->GetDesc(cb11, &cbdesc);
1837 ok(hr == S_OK, "Got unexpected hr %#x, i %u.\n", hr, i);
1839 ok(!strcmp(cbdesc.Name, pcbdesc->Name), "Got unexpected name \"%s\", i %u.\n", cbdesc.Name, i);
1840 ok(cbdesc.Type == pcbdesc->Type, "Got unexpected Type %#x, i %u.\n", cbdesc.Type, i);
1841 ok(cbdesc.Variables == pcbdesc->Variables, "Got unexpected Variables %u, i %u.\n", cbdesc.Variables, i);
1842 ok(cbdesc.Size == pcbdesc->Size, "Got unexpected Size %u, i %u.\n", cbdesc.Size, i);
1843 ok(cbdesc.uFlags == pcbdesc->uFlags, "Got unexpected uFlags %#x, i %u.\n", cbdesc.uFlags, i);
1845 if (ref12)
1847 cb12 = ref12->lpVtbl->GetConstantBufferByIndex(ref12, i);
1848 ok(cb12_dummy != cb12, "Got dummy constant buffer, i %u.\n", i);
1850 hr = cb12->lpVtbl->GetDesc(cb12, &cbdesc12);
1851 ok(hr == S_OK, "Got unexpected hr %#x, i %u.\n", hr, i);
1853 ok(!strcmp(cbdesc12.Name, pcbdesc->Name), "Got unexpected name \"%s\", i %u.\n", cbdesc.Name, i);
1854 ok(cbdesc.Type == pcbdesc->Type, "Got unexpected Type %#x, i %u.\n", cbdesc.Type, i);
1855 ok(!memcmp(&cbdesc12.Type, &cbdesc.Type, sizeof(cbdesc) - offsetof(D3D11_SHADER_BUFFER_DESC, Type)),
1856 "CB description does not match. i %u.\n", i);
1860 /* variables */
1861 for (i = 0; i < ARRAY_SIZE(test_reflection_constant_buffer_variable_result); ++i)
1863 pvdesc = &test_reflection_constant_buffer_variable_result[i].desc;
1865 if (D3D_COMPILER_VERSION)
1866 v11 = ref11->lpVtbl->GetVariableByName(ref11, pvdesc->Name);
1867 else
1868 v11 = cb11_valid->lpVtbl->GetVariableByName(cb11_valid, pvdesc->Name);
1869 ok(v11_dummy != v11, "Test %u, got unexpected variable %p.\n", i, v11);
1871 if (D3D_COMPILER_VERSION)
1873 vdesc.StartTexture = 0xdeadbeef;
1874 vdesc.TextureSize = 0xdeadbeef;
1875 vdesc.StartSampler = 0xdeadbeef;
1876 vdesc.SamplerSize = 0xdeadbeef;
1878 else
1880 vdesc.StartTexture = 0xffffffff;
1881 vdesc.StartSampler = 0xffffffff;
1884 hr = v11->lpVtbl->GetDesc(v11, &vdesc);
1885 ok(hr == S_OK, "Got unexpected hr %#x, i %u.\n", hr, i);
1887 ok(!strcmp(vdesc.Name, pvdesc->Name), "Got unexpected name \"%s\", i %u", vdesc.Name, i);
1888 ok(vdesc.StartOffset == pvdesc->StartOffset, "Got unexpected StartOffset %u, i %u.\n",
1889 vdesc.StartOffset, i);
1890 ok(vdesc.Size == pvdesc->Size, "Got unexpected Size %u, i %u.\n", vdesc.Size, i);
1891 ok(vdesc.uFlags == pvdesc->uFlags, "Got unexpected uFlags %#x, i %u.\n", vdesc.uFlags, i);
1892 ok(vdesc.DefaultValue == pvdesc->DefaultValue, "Got unexpected DefaultValue %p, i %u.\n",
1893 vdesc.DefaultValue, i);
1894 ok(vdesc.StartTexture == 0xffffffff, "Got unexpected StartTexture %#x, i %u.\n", vdesc.StartTexture, i);
1895 ok(!vdesc.TextureSize, "Got unexpected TextureSize %u, i %u.\n", vdesc.TextureSize, i);
1896 ok(vdesc.StartSampler == 0xffffffff, "Got unexpected StartSampler %u, i %u.\n", vdesc.StartSampler, i);
1897 ok(!vdesc.SamplerSize, "Got unexpected SamplerSize %u, i %u.\n", vdesc.SamplerSize, i);
1899 if (ref12)
1901 v12 = ref12->lpVtbl->GetVariableByName(ref12, pvdesc->Name);
1902 ok(v12_dummy != v12, "Test %u, got unexpected variable %p.\n", i, v12);
1903 hr = v12->lpVtbl->GetDesc(v12, &vdesc12);
1904 ok(hr == S_OK, "Got unexpected hr %#x, i %u.\n", hr, i);
1905 ok(!strcmp(vdesc12.Name, pvdesc->Name), "Got unexpected name \"%s\", i %u", vdesc12.Name, i);
1906 ok(!memcmp(&vdesc12.StartOffset, &vdesc.StartOffset,
1907 sizeof(vdesc) - offsetof(D3D11_SHADER_VARIABLE_DESC, StartOffset)),
1908 "D3D11 and D3D12 descs do not match.\n");
1910 else
1912 /* Silence compiler warning. */
1913 v12 = NULL;
1916 /* types */
1917 ptdesc = &test_reflection_constant_buffer_type_result[test_reflection_constant_buffer_variable_result[i].type];
1919 t11 = v11->lpVtbl->GetType(v11);
1920 ok(t11_dummy != t11, "Got unexpected type %p, i %u.\n", t11, i);
1922 hr = t11->lpVtbl->GetDesc(t11, &tdesc);
1923 ok(hr == S_OK, "Got unexpected hr %#x, i %u.\n", hr, i);
1925 ok(tdesc.Class == ptdesc->Class, "Got unexpected Class %u, i %u.\n", tdesc.Class, i);
1926 ok(tdesc.Type == ptdesc->Type, "Got unexpected Type %u, i %u.\n", tdesc.Type, i);
1927 ok(tdesc.Rows == ptdesc->Rows, "Got unexpected Rows %u, i %u.\n", tdesc.Rows, i);
1928 ok(tdesc.Columns == ptdesc->Columns, "Got unexpected Columns %u, i %u.\n", tdesc.Columns, i);
1929 ok(tdesc.Elements == ptdesc->Elements, "Got unexpected Elements %u, i %u.\n", tdesc.Elements, i);
1930 ok(tdesc.Offset == ptdesc->Offset, "Got unexpected Offset %u, i %u.\n", tdesc.Offset, i);
1931 if (D3D_COMPILER_VERSION)
1932 ok(!strcmp(tdesc.Name, ptdesc->Name), "Got unexpected Name %s, i %u.\n", debugstr_a(tdesc.Name), i);
1934 if (ref12)
1936 t12 = v12->lpVtbl->GetType(v12);
1937 ok(t12_dummy != t12, "Got unexpected type %p, i %u.\n", t12, i);
1939 hr = t12->lpVtbl->GetDesc(t12, &tdesc12);
1940 ok(hr == S_OK, "Got unexpected hr %#x, i %u.\n", hr, i);
1941 ok(!memcmp(&tdesc12, &tdesc, offsetof(D3D11_SHADER_TYPE_DESC, Name)),
1942 "D3D11 and D3D12 descs do not match.\n");
1943 ok(!strcmp(tdesc12.Name, ptdesc->Name), "Got unexpected Name %s, i %u.\n", debugstr_a(tdesc12.Name), i);
1947 /* types */
1948 if (D3D_COMPILER_VERSION)
1949 v11 = ref11->lpVtbl->GetVariableByName(ref11, "t");
1950 else
1951 v11 = cb11_valid->lpVtbl->GetVariableByName(cb11_valid, pvdesc->Name);
1952 ok(v11_dummy != v11, "Got unexpected variable %p.\n", v11);
1954 t11 = v11->lpVtbl->GetType(v11);
1955 ok(t11 != t11_dummy, "Got unexpected type %p.\n", t11);
1957 t = t11->lpVtbl->GetMemberTypeByIndex(t11, 0);
1958 ok(t != t11_dummy, "Got unexpected type %p.\n", t);
1960 t2 = t11->lpVtbl->GetMemberTypeByName(t11, "a");
1961 ok(t == t2, "Got unexpected type %p.\n", t2);
1963 string = t11->lpVtbl->GetMemberTypeName(t11, 0);
1964 ok(!strcmp(string, "a"), "Got unexpected string \"%s\".\n", string);
1966 t = t11->lpVtbl->GetMemberTypeByIndex(t11, 1);
1967 ok(t != t11_dummy, "Got unexpected type %p.\n", t);
1969 t2 = t11->lpVtbl->GetMemberTypeByName(t11, "b");
1970 ok(t == t2, "Got unexpected type %p.\n", t2);
1972 string = t11->lpVtbl->GetMemberTypeName(t11, 1);
1973 ok(!strcmp(string, "b"), "Got unexpected string \"%s\".\n", string);
1975 #if D3D_COMPILER_VERSION
1976 /* float vs float (in struct) */
1977 hr = t11->lpVtbl->IsEqual(t11, t11_valid);
1978 ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
1980 hr = t11_valid->lpVtbl->IsEqual(t11_valid, t11);
1981 ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
1983 /* float vs float */
1984 t = t11->lpVtbl->GetMemberTypeByIndex(t11, 0);
1985 ok(t != t11_dummy, "Got unexpected type %p.\n", t);
1987 t2 = t11->lpVtbl->GetMemberTypeByIndex(t11, 1);
1988 ok(t2 != t11_dummy, "Got unexpected type %p.\n", t2);
1990 hr = t->lpVtbl->IsEqual(t, t2);
1991 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
1992 #endif
1994 if (ref12)
1996 v12 = ref12->lpVtbl->GetVariableByName(ref12, "t");
1997 ok(v12_dummy != v12, "Got unexpected variable %p.\n", v12);
1999 t12 = v12->lpVtbl->GetType(v12);
2000 ok(t12 != t12_dummy, "Got unexpected type %p.\n", t12);
2002 mt12 = t12->lpVtbl->GetMemberTypeByIndex(t12, 0);
2003 ok(mt12 != t12_dummy, "Got unexpected type %p.\n", mt12);
2005 mt12_2 = t12->lpVtbl->GetMemberTypeByName(t12, "a");
2006 ok(mt12 == mt12_2, "Got unexpected type %p.\n", mt12_2);
2008 string = t12->lpVtbl->GetMemberTypeName(t12, 0);
2009 ok(!strcmp(string, "a"), "Got unexpected string \"%s\".\n", string);
2011 mt12 = t12->lpVtbl->GetMemberTypeByIndex(t12, 1);
2012 ok(mt12 != t12_dummy, "Got unexpected type %p.\n", mt12);
2014 mt12_2 = t12->lpVtbl->GetMemberTypeByName(t12, "b");
2015 ok(mt12 == mt12_2, "Got unexpected type %p.\n", mt12_2);
2017 string = t12->lpVtbl->GetMemberTypeName(t12, 1);
2018 ok(!strcmp(string, "b"), "Got unexpected string \"%s\".\n", string);
2020 hr = t12->lpVtbl->IsEqual(t12, t12_valid);
2021 ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
2023 hr = t12_valid->lpVtbl->IsEqual(t12_valid, t12);
2024 ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
2026 mt12 = t12->lpVtbl->GetMemberTypeByIndex(t12, 0);
2027 ok(mt12 != t12_dummy, "Got unexpected type %p.\n", mt12);
2029 mt12_2 = t12->lpVtbl->GetMemberTypeByIndex(t12, 1);
2030 ok(mt12_2 != t12_dummy, "Got unexpected type %p.\n", mt12_2);
2032 hr = mt12->lpVtbl->IsEqual(mt12, mt12_2);
2033 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
2035 count = ref12->lpVtbl->Release(ref12);
2036 ok(!count, "Got unexpected ref count %u.\n", count);
2038 count = ref11->lpVtbl->Release(ref11);
2039 ok(!count, "Got unexpected ref count %u.\n", count);
2043 * fxc.exe /E PS /Tps_5_1 /Fo
2045 #if 0
2046 Texture2D tex1 : register(t1, space1);
2047 SamplerState sam
2049 Filter = MIN_MAG_MIP_LINEAR;
2050 AddressU = Wrap;
2051 AddressV = Wrap;
2053 cbuffer c1 : register(b0, space0)
2055 float x;
2056 float y[2];
2057 int z;
2059 cbuffer c2 : register(b0, space1)
2061 float t;
2064 float4 PS(float2 uv : TEXCOORD0) : sv_target
2066 float4 q = tex1.Sample(sam, uv);
2067 q.x = q.x + x;
2068 q.w = q.w + y[0] + y[1] + t;
2069 return q;
2071 #endif
2072 static const DWORD test_reflection_bound_resources_sm51_blob[] =
2074 0x43425844, 0x01b901c9, 0xaa053e53, 0x0b6ee9ab, 0x66bcfb8c, 0x00000001, 0x0000051c, 0x00000005,
2075 0x00000034, 0x000002a4, 0x000002d8, 0x0000030c, 0x00000480, 0x46454452, 0x00000268, 0x00000002,
2076 0x000000ec, 0x00000004, 0x0000003c, 0xffff0501, 0x00000500, 0x0000023e, 0x25441313, 0x0000003c,
2077 0x00000018, 0x00000028, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x000000dc, 0x00000003,
2078 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
2079 0x000000e0, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000c,
2080 0x00000001, 0x00000000, 0x000000e5, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2081 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x000000e8, 0x00000000, 0x00000000, 0x00000000,
2082 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x006d6173, 0x31786574,
2083 0x00316300, 0xab003263, 0x000000e5, 0x00000003, 0x0000011c, 0x00000030, 0x00000000, 0x00000000,
2084 0x000000e8, 0x00000001, 0x00000214, 0x00000010, 0x00000000, 0x00000000, 0x00000194, 0x00000000,
2085 0x00000004, 0x00000002, 0x0000019c, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000,
2086 0x000001c0, 0x00000010, 0x00000014, 0x00000002, 0x000001c4, 0x00000000, 0xffffffff, 0x00000000,
2087 0xffffffff, 0x00000000, 0x000001e8, 0x00000024, 0x00000004, 0x00000000, 0x000001f0, 0x00000000,
2088 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0x6c660078, 0x0074616f, 0x00030000, 0x00010001,
2089 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000196, 0xabab0079,
2090 0x00030000, 0x00010001, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2091 0x00000196, 0x6e69007a, 0xabab0074, 0x00020000, 0x00010001, 0x00000000, 0x00000000, 0x00000000,
2092 0x00000000, 0x00000000, 0x00000000, 0x000001ea, 0x0000023c, 0x00000000, 0x00000004, 0x00000002,
2093 0x0000019c, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0x694d0074, 0x736f7263,
2094 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43, 0x72656c69, 0x2e303120,
2095 0xabab0031, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
2096 0x00000003, 0x00000000, 0x00000303, 0x43584554, 0x44524f4f, 0xababab00, 0x4e47534f, 0x0000002c,
2097 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
2098 0x745f7673, 0x65677261, 0xabab0074, 0x58454853, 0x0000016c, 0x00000051, 0x0000005b, 0x0100086a,
2099 0x07000059, 0x00308e46, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x07000059,
2100 0x00308e46, 0x00000001, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x0600005a, 0x00306e46,
2101 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07001858, 0x00307e46, 0x00000000, 0x00000001,
2102 0x00000001, 0x00005555, 0x00000001, 0x03001062, 0x00101032, 0x00000000, 0x03000065, 0x001020f2,
2103 0x00000000, 0x02000068, 0x00000001, 0x0b000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000000,
2104 0x00207e46, 0x00000000, 0x00000001, 0x00206000, 0x00000000, 0x00000000, 0x09000000, 0x00102012,
2105 0x00000000, 0x0010000a, 0x00000000, 0x0030800a, 0x00000000, 0x00000000, 0x00000000, 0x09000000,
2106 0x00100012, 0x00000000, 0x0010003a, 0x00000000, 0x0030800a, 0x00000000, 0x00000000, 0x00000001,
2107 0x09000000, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x0030800a, 0x00000000, 0x00000000,
2108 0x00000002, 0x09000000, 0x00102082, 0x00000000, 0x0010000a, 0x00000000, 0x0030800a, 0x00000001,
2109 0x00000000, 0x00000000, 0x05000036, 0x00102062, 0x00000000, 0x00100656, 0x00000000, 0x0100003e,
2110 0x54415453, 0x00000094, 0x00000007, 0x00000001, 0x00000000, 0x00000002, 0x00000004, 0x00000000,
2111 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2112 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
2113 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2114 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2117 static const D3D12_SHADER_INPUT_BIND_DESC test_reflection_bound_resources_sm51_result[] =
2119 {"sam", D3D_SIT_SAMPLER, 0, 1, 0, 0, D3D_SRV_DIMENSION_UNKNOWN, 0},
2120 {"tex1", D3D_SIT_TEXTURE, 1, 1, 12, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, 0xffffffff, 1, 0},
2121 {"c1", D3D_SIT_CBUFFER, 0, 1, D3D_SIF_USERPACKED, 0, D3D_SRV_DIMENSION_UNKNOWN, 0},
2122 {"c2", D3D_SIT_CBUFFER, 0, 1, D3D_SIF_USERPACKED, 0, D3D_SRV_DIMENSION_UNKNOWN, 0, 1, 1},
2125 static BOOL load_d3dreflect(void)
2127 #if D3D_COMPILER_VERSION == 47
2128 static const char filename[] = "d3dcompiler_47.dll";
2129 #elif D3D_COMPILER_VERSION
2130 static const char filename[] = "d3dcompiler_43.dll";
2131 #endif
2132 #if D3D_COMPILER_VERSION
2133 HMODULE module;
2135 if (!(module = LoadLibraryA(filename)))
2136 return FALSE;
2138 pD3DReflect = (void*)GetProcAddress(module, "D3DReflect");
2139 #endif
2140 return TRUE;
2143 START_TEST(reflection)
2145 if (!load_d3dreflect())
2147 win_skip("Could not load DLL.\n");
2148 return;
2151 #if D3D_COMPILER_VERSION
2152 test_reflection_references();
2153 test_reflection_interfaces();
2154 #endif
2155 test_reflection_desc_vs();
2156 test_reflection_desc_ps();
2157 test_reflection_desc_ps_output();
2158 test_reflection_bound_resources(test_reflection_bound_resources_blob, test_reflection_bound_resources_result,
2159 ARRAY_SIZE(test_reflection_bound_resources_result), 0x400);
2160 test_reflection_bound_resources(test_reflection_bound_resources_sm51_blob,
2161 test_reflection_bound_resources_sm51_result,
2162 ARRAY_SIZE(test_reflection_bound_resources_sm51_result), 0x501);
2163 test_reflection_constant_buffer();