d3dcompiler/tests: Build without -DWINE_NO_LONG_TYPES.
[wine.git] / dlls / d3dcompiler_43 / tests / reflection.c
blob9c8247790c570a54f41d235e5ae0e9cf20d48815
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 static HRESULT call_reflect(const void *data, SIZE_T data_size, REFIID riid, void **reflection)
43 #if D3D_COMPILER_VERSION
44 return D3DReflect(data, data_size, riid, reflection);
45 #else
46 return D3D10ReflectShader(data, data_size, (ID3D10ShaderReflection **)reflection);
47 #endif
50 /* Creator string for comparison - Version 9.29.952.3111 (43) */
51 static DWORD shader_creator[] = {
52 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d,
53 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00,
56 #if D3D_COMPILER_VERSION
58 * fxc.exe /E VS /Tvs_4_0 /Fx
60 #if 0
61 float4 VS(float4 position : POSITION, float4 pos : SV_POSITION) : SV_POSITION
63 return position;
65 #endif
66 static DWORD test_reflection_blob[] = {
67 0x43425844, 0x77c6324f, 0xfd27948a, 0xe6958d31, 0x53361cba, 0x00000001, 0x000001d8, 0x00000005,
68 0x00000034, 0x0000008c, 0x000000e4, 0x00000118, 0x0000015c, 0x46454452, 0x00000050, 0x00000000,
69 0x00000000, 0x00000000, 0x0000001c, 0xfffe0400, 0x00000100, 0x0000001c, 0x7263694d, 0x666f736f,
70 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e,
71 0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x00000050, 0x00000002, 0x00000008, 0x00000038,
72 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
73 0x00000003, 0x00000001, 0x0000000f, 0x49534f50, 0x4e4f4954, 0x5f565300, 0x49534f50, 0x4e4f4954,
74 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001,
75 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c,
76 0x00010040, 0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000,
77 0x00000001, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e, 0x54415453,
78 0x00000074, 0x00000002, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000,
79 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
80 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
81 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
84 static void test_reflection_references(void)
86 ID3D11ShaderReflection *ref11, *ref11_test;
87 ID3D10ShaderReflection1 *ref10_1;
88 ID3D10ShaderReflection *ref10;
89 HRESULT hr, expected;
90 ULONG count;
92 hr = D3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
93 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
95 hr = ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D11ShaderReflection, (void **)&ref11_test);
96 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
98 count = ref11_test->lpVtbl->Release(ref11_test);
99 ok(count == 1, "Release failed %lu\n", count);
101 hr = ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D10ShaderReflection, (void **)&ref10);
102 ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
104 hr = ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
105 ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
107 count = ref11->lpVtbl->Release(ref11);
108 ok(!count, "Got unexpected count %lu.\n", count);
110 /* check invalid cases */
111 #if D3D_COMPILER_VERSION >= 46
112 expected = E_INVALIDARG;
113 #else
114 expected = E_NOINTERFACE;
115 #endif
116 hr = D3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D10ShaderReflection, (void **)&ref10);
117 ok(hr == expected || broken(hr == E_NOINTERFACE) /* Windows 8 */,
118 "Got unexpected hr %#lx, expected %#lx.\n", hr, expected);
120 hr = D3DReflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
121 ok(hr == expected || broken(hr == E_NOINTERFACE) /* Windows 8 */,
122 "Got unexpected hr %#lx, expected %#lx.\n", hr, expected);
124 hr = D3DReflect(NULL, test_reflection_blob[6], &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
125 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
127 hr = D3DReflect(NULL, test_reflection_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
128 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
130 /* returns different errors with different sizes */
131 hr = D3DReflect(test_reflection_blob, 31, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
132 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
134 #if D3D_COMPILER_VERSION >= 46
135 expected = D3DERR_INVALIDCALL;
136 #else
137 expected = E_FAIL;
138 #endif
139 hr = D3DReflect(test_reflection_blob, 32, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
140 ok(hr == expected, "Got unexpected hr %#lx, expected %#lx.\n", hr, expected);
142 hr = D3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D10ShaderReflection1, (void **)&ref10_1);
143 ok(hr == expected, "Got unexpected hr %#lx, expected %#lx.\n", hr, expected);
145 hr = D3DReflect(test_reflection_blob, 31, &IID_ID3D11ShaderReflection, (void **)&ref11);
146 ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx.\n", hr);
148 hr = D3DReflect(test_reflection_blob, 32, &IID_ID3D11ShaderReflection, (void **)&ref11);
149 ok(hr == expected, "Got unexpected hr %#lx, expected %#lx.\n", hr, expected);
151 hr = D3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D11ShaderReflection, (void **)&ref11);
152 ok(hr == expected, "Got unexpected hr %#lx, expected %#lx.\n", hr, expected);
154 #endif
156 #if D3D_COMPILER_VERSION
157 static void test_reflection_interfaces(void)
159 ID3D12ShaderReflection *ref12 = NULL;
160 ID3D11ShaderReflection *ref11;
161 HRESULT hr, expected_hr;
162 IUnknown *iface, *iunk;
163 ULONG count;
165 expected_hr = D3D_COMPILER_VERSION < 46 ? E_NOINTERFACE : D3D_COMPILER_VERSION == 46 ? E_INVALIDARG : S_OK;
166 hr = call_reflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D12ShaderReflection, (void **)&ref12);
167 /* Broken with older d3dcompiler_46, d3dcompiler_47. */
168 ok(hr == expected_hr || broken(hr == E_NOINTERFACE),
169 "Got unexpected hr %#lx, expected %#lx.\n", hr, expected_hr);
171 if (hr != S_OK)
172 return;
174 hr = call_reflect(test_reflection_blob, test_reflection_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
175 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
177 hr = ref12->lpVtbl->QueryInterface(ref12, &IID_ID3D11ShaderReflection, (void **)&iface);
178 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
179 ok(iface == (void *)ref12, "Got unexpected interfaces %p, %p.\n", iface, ref12);
180 hr = iface->lpVtbl->QueryInterface(iface, &IID_IUnknown, (void **)&iunk);
181 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
182 ok(iface == iunk, "Got unexpected iface %p.\n", iface);
183 iface->lpVtbl->Release(iunk);
184 iface->lpVtbl->Release(iface);
186 hr = ref12->lpVtbl->QueryInterface(ref12, &IID_IUnknown, (void **)&iface);
187 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
188 ok(iface == (IUnknown *)ref12, "Got unexpected iface %p.\n", iface);
189 iface->lpVtbl->Release(iface);
191 hr = ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D12ShaderReflection, (void **)&iface);
192 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
193 ok(iface == (void *)ref11, "Got unexpected interfaces %p, %p.\n", iface, ref11);
194 hr = iface->lpVtbl->QueryInterface(iface, &IID_IUnknown, (void **)&iunk);
195 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
196 ok(iface == iunk, "Got unexpected iface %p.\n", iface);
197 iface->lpVtbl->Release(iunk);
198 iface->lpVtbl->Release(iface);
200 hr = ref11->lpVtbl->QueryInterface(ref11, &IID_IUnknown, (void **)&iface);
201 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
202 ok(iface == (IUnknown *)ref11, "Got unexpected iface %p.\n", iface);
203 iface->lpVtbl->Release(iface);
205 hr = ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D10ShaderReflection, (void **)&iface);
206 ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
207 hr = ref12->lpVtbl->QueryInterface(ref12, &IID_ID3D10ShaderReflection, (void **)&iface);
208 ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
210 count = ref12->lpVtbl->Release(ref12);
211 ok(!count, "Got unexpected ref count %lu.\n", count);
212 count = ref11->lpVtbl->Release(ref11);
213 ok(!count, "Got unexpected ref count %lu.\n", count);
215 #endif
218 * fxc.exe /E VS /Tvs_4_1 /Fx
220 #if 0
221 struct vsin
223 float4 x : SV_position;
224 float4 a : BINORMAL;
225 uint b : BLENDINDICES;
226 float c : BLENDWEIGHT;
227 float4 d : COLOR;
228 float4 d1 : COLOR1;
229 float4 e : NORMAL;
230 float4 f : POSITION;
231 float4 g : POSITIONT;
232 float h : PSIZE;
233 float4 i : TANGENT;
234 float4 j : TEXCOORD;
235 uint k : SV_VertexID;
236 uint l : SV_InstanceID;
237 float m : testin;
239 struct vsout
241 float4 x : SV_position;
242 float4 a : COLOR0;
243 float b : FOG;
244 float4 c : POSITION0;
245 float d : PSIZE;
246 float e : TESSFACTOR0;
247 float4 f : TEXCOORD0;
248 float g : SV_ClipDistance0;
249 float h : SV_CullDistance0;
250 uint i : SV_InstanceID;
251 float j : testout;
253 vsout VS(vsin x)
255 vsout s;
256 s.x = float4(1.6f, 0.3f, 0.1f, 0.0f);
257 int y = 1;
258 int p[5] = {1, 2, 3, 5, 4};
259 y = y << (int) x.x.x & 0xf;
260 s.x.x = p[y];
261 s.a = x.d;
262 s.b = x.c;
263 s.c = x.f;
264 s.d = x.h;
265 s.e = x.h;
266 s.f = x.j;
267 s.g = 1.0f;
268 s.h = 1.0f;
269 s.i = 2;
270 s.j = x.m;
271 return s;
273 #endif
274 static DWORD test_reflection_desc_vs_blob[] = {
275 0x43425844, 0xb65955ac, 0xcea1cb75, 0x06c5a1ad, 0x8a555fa1, 0x00000001, 0x0000076c, 0x00000005,
276 0x00000034, 0x0000008c, 0x0000028c, 0x00000414, 0x000006f0, 0x46454452, 0x00000050, 0x00000000,
277 0x00000000, 0x00000000, 0x0000001c, 0xfffe0401, 0x00000100, 0x0000001c, 0x7263694d, 0x666f736f,
278 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e39322e,
279 0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x000001f8, 0x0000000f, 0x00000008, 0x00000170,
280 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000010f, 0x0000017c, 0x00000000, 0x00000000,
281 0x00000003, 0x00000001, 0x0000000f, 0x00000185, 0x00000000, 0x00000000, 0x00000001, 0x00000002,
282 0x00000001, 0x00000192, 0x00000000, 0x00000000, 0x00000003, 0x00000003, 0x00000101, 0x0000019e,
283 0x00000000, 0x00000000, 0x00000003, 0x00000004, 0x00000f0f, 0x0000019e, 0x00000001, 0x00000000,
284 0x00000003, 0x00000005, 0x0000000f, 0x000001a4, 0x00000000, 0x00000000, 0x00000003, 0x00000006,
285 0x0000000f, 0x000001ab, 0x00000000, 0x00000000, 0x00000003, 0x00000007, 0x00000f0f, 0x000001b4,
286 0x00000000, 0x00000000, 0x00000003, 0x00000008, 0x0000000f, 0x000001be, 0x00000000, 0x00000000,
287 0x00000003, 0x00000009, 0x00000101, 0x000001c4, 0x00000000, 0x00000000, 0x00000003, 0x0000000a,
288 0x0000000f, 0x000001cc, 0x00000000, 0x00000000, 0x00000003, 0x0000000b, 0x00000f0f, 0x000001d5,
289 0x00000000, 0x00000006, 0x00000001, 0x0000000c, 0x00000001, 0x000001e1, 0x00000000, 0x00000008,
290 0x00000001, 0x0000000d, 0x00000001, 0x000001ef, 0x00000000, 0x00000000, 0x00000003, 0x0000000e,
291 0x00000101, 0x705f5653, 0x7469736f, 0x006e6f69, 0x4f4e4942, 0x4c414d52, 0x454c4200, 0x4e49444e,
292 0x45434944, 0x4c420053, 0x57444e45, 0x48474945, 0x4f430054, 0x00524f4c, 0x4d524f4e, 0x50004c41,
293 0x5449534f, 0x004e4f49, 0x49534f50, 0x4e4f4954, 0x53500054, 0x00455a49, 0x474e4154, 0x00544e45,
294 0x43584554, 0x44524f4f, 0x5f565300, 0x74726556, 0x44497865, 0x5f565300, 0x74736e49, 0x65636e61,
295 0x74004449, 0x69747365, 0xabab006e, 0x4e47534f, 0x00000180, 0x0000000b, 0x00000008, 0x00000110,
296 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000011c, 0x00000000, 0x00000000,
297 0x00000003, 0x00000001, 0x0000000f, 0x00000122, 0x00000000, 0x00000000, 0x00000003, 0x00000002,
298 0x00000e01, 0x00000126, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000d02, 0x0000012c,
299 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000b04, 0x00000137, 0x00000000, 0x00000000,
300 0x00000003, 0x00000002, 0x00000708, 0x0000013f, 0x00000000, 0x00000000, 0x00000003, 0x00000003,
301 0x0000000f, 0x00000148, 0x00000000, 0x00000000, 0x00000003, 0x00000004, 0x0000000f, 0x00000151,
302 0x00000000, 0x00000002, 0x00000003, 0x00000005, 0x00000e01, 0x00000161, 0x00000000, 0x00000003,
303 0x00000003, 0x00000005, 0x00000d02, 0x00000171, 0x00000000, 0x00000000, 0x00000001, 0x00000006,
304 0x00000e01, 0x705f5653, 0x7469736f, 0x006e6f69, 0x4f4c4f43, 0x4f460052, 0x53500047, 0x00455a49,
305 0x53534554, 0x54434146, 0x7400524f, 0x6f747365, 0x50007475, 0x5449534f, 0x004e4f49, 0x43584554,
306 0x44524f4f, 0x5f565300, 0x70696c43, 0x74736944, 0x65636e61, 0x5f565300, 0x6c6c7543, 0x74736944,
307 0x65636e61, 0x5f565300, 0x74736e49, 0x65636e61, 0xab004449, 0x52444853, 0x000002d4, 0x00010041,
308 0x000000b5, 0x0100086a, 0x0300005f, 0x00101012, 0x00000000, 0x0300005f, 0x00101012, 0x00000003,
309 0x0300005f, 0x001010f2, 0x00000004, 0x0300005f, 0x001010f2, 0x00000007, 0x0300005f, 0x00101012,
310 0x00000009, 0x0300005f, 0x001010f2, 0x0000000b, 0x0300005f, 0x00101012, 0x0000000e, 0x04000067,
311 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102012,
312 0x00000002, 0x03000065, 0x00102022, 0x00000002, 0x03000065, 0x00102042, 0x00000002, 0x03000065,
313 0x00102082, 0x00000002, 0x03000065, 0x001020f2, 0x00000003, 0x03000065, 0x001020f2, 0x00000004,
314 0x04000067, 0x00102012, 0x00000005, 0x00000002, 0x04000067, 0x00102022, 0x00000005, 0x00000003,
315 0x03000065, 0x00102012, 0x00000006, 0x02000068, 0x00000001, 0x04000069, 0x00000000, 0x00000005,
316 0x00000004, 0x06000036, 0x00203012, 0x00000000, 0x00000000, 0x00004001, 0x00000001, 0x06000036,
317 0x00203012, 0x00000000, 0x00000001, 0x00004001, 0x00000002, 0x06000036, 0x00203012, 0x00000000,
318 0x00000002, 0x00004001, 0x00000003, 0x06000036, 0x00203012, 0x00000000, 0x00000003, 0x00004001,
319 0x00000005, 0x06000036, 0x00203012, 0x00000000, 0x00000004, 0x00004001, 0x00000004, 0x0500001b,
320 0x00100012, 0x00000000, 0x0010100a, 0x00000000, 0x07000029, 0x00100012, 0x00000000, 0x00004001,
321 0x00000001, 0x0010000a, 0x00000000, 0x07000001, 0x00100012, 0x00000000, 0x0010000a, 0x00000000,
322 0x00004001, 0x0000000f, 0x07000036, 0x00100012, 0x00000000, 0x0420300a, 0x00000000, 0x0010000a,
323 0x00000000, 0x0500002b, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x08000036, 0x001020e2,
324 0x00000000, 0x00004002, 0x00000000, 0x3e99999a, 0x3dcccccd, 0x00000000, 0x05000036, 0x001020f2,
325 0x00000001, 0x00101e46, 0x00000004, 0x05000036, 0x00102012, 0x00000002, 0x0010100a, 0x00000003,
326 0x05000036, 0x00102062, 0x00000002, 0x00101006, 0x00000009, 0x05000036, 0x00102082, 0x00000002,
327 0x0010100a, 0x0000000e, 0x05000036, 0x001020f2, 0x00000003, 0x00101e46, 0x00000007, 0x05000036,
328 0x001020f2, 0x00000004, 0x00101e46, 0x0000000b, 0x05000036, 0x00102012, 0x00000005, 0x00004001,
329 0x3f800000, 0x05000036, 0x00102022, 0x00000005, 0x00004001, 0x3f800000, 0x05000036, 0x00102012,
330 0x00000006, 0x00004001, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000015, 0x00000001,
331 0x00000000, 0x00000012, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000,
332 0x00000005, 0x00000006, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
333 0x00000000, 0x0000000a, 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
334 0x00000000, 0x00000000, 0x00000000,
337 static const D3D11_SIGNATURE_PARAMETER_DESC test_reflection_desc_vs_resultin[] =
339 {"SV_position", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x1, 0},
340 {"BINORMAL", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
341 {"BLENDINDICES", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x0, 0},
342 {"BLENDWEIGHT", 0, 3, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0x1, 0},
343 {"COLOR", 0, 4, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf, 0},
344 {"COLOR", 1, 5, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
345 {"NORMAL", 0, 6, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
346 {"POSITION", 0, 7, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf, 0},
347 {"POSITIONT", 0, 8, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
348 {"PSIZE", 0, 9, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0x1, 0},
349 {"TANGENT", 0, 10, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
350 {"TEXCOORD", 0, 11, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0xf, 0},
351 {"SV_VertexID", 0, 12, D3D_NAME_VERTEX_ID, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x0, 0},
352 {"SV_InstanceID", 0, 13, D3D_NAME_INSTANCE_ID, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x0, 0},
353 {"testin", 0, 14, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0x1, 0},
356 static const D3D11_SIGNATURE_PARAMETER_DESC test_reflection_desc_vs_resultout[] =
358 {"SV_position", 0, 0, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
359 {"COLOR", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
360 {"FOG", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0},
361 {"PSIZE", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x2, 0xd, 0},
362 {"TESSFACTOR", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x4, 0xb, 0},
363 {"testout", 0, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x8, 0x7, 0},
364 {"POSITION", 0, 3, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
365 {"TEXCOORD", 0, 4, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
366 {"SV_ClipDistance", 0, 5, D3D_NAME_CLIP_DISTANCE, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0},
367 {"SV_CullDistance", 0, 5, D3D_NAME_CULL_DISTANCE, D3D_REGISTER_COMPONENT_FLOAT32, 0x2, 0xd, 0},
368 {"SV_InstanceID", 0, 6, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe, 0},
371 struct D3D11_SIGNATURE_PARAMETER_DESC_46
373 const char *SemanticName;
374 UINT SemanticIndex;
375 UINT Register;
376 D3D_NAME SystemValueType;
377 D3D_REGISTER_COMPONENT_TYPE ComponentType;
378 BYTE Mask;
379 BYTE ReadWriteMask;
380 UINT Stream;
381 D3D_MIN_PRECISION MinPrecision;
384 static void test_reflection_desc_vs(void)
386 struct D3D11_SIGNATURE_PARAMETER_DESC_46 desc_46 = {0};
387 const D3D11_SIGNATURE_PARAMETER_DESC *pdesc;
388 D3D11_SIGNATURE_PARAMETER_DESC desc11 = {0};
389 D3D12_SIGNATURE_PARAMETER_DESC desc12 = {0};
390 D3D_MIN_PRECISION expected_min_prec;
391 D3D11_SHADER_DESC sdesc11 = {0};
392 D3D12_SHADER_DESC sdesc12 = {0};
393 ID3D11ShaderReflection *ref11;
394 ID3D12ShaderReflection *ref12;
395 unsigned int i;
396 ULONG count;
397 HRESULT hr;
398 #if D3D_COMPILER_VERSION
399 UINT ret;
400 #endif
402 hr = call_reflect(test_reflection_desc_vs_blob, test_reflection_desc_vs_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
403 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
405 ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D12ShaderReflection, (void **)&ref12);
407 hr = ref11->lpVtbl->GetDesc(ref11, NULL);
408 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
410 hr = ref11->lpVtbl->GetDesc(ref11, &sdesc11);
411 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
413 ok(sdesc11.Version == 65601, "GetDesc failed, got %u, expected %u\n", sdesc11.Version, 65601);
414 ok(strcmp(sdesc11.Creator, (char*) shader_creator) == 0, "GetDesc failed, got \"%s\", expected \"%s\"\n", sdesc11.Creator, (char*)shader_creator);
415 ok(sdesc11.Flags == 256, "GetDesc failed, got %u, expected %u\n", sdesc11.Flags, 256);
416 ok(sdesc11.ConstantBuffers == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.ConstantBuffers, 0);
417 ok(sdesc11.BoundResources == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.BoundResources, 0);
418 ok(sdesc11.InputParameters == 15, "GetDesc failed, got %u, expected %u\n", sdesc11.InputParameters, 15);
419 ok(sdesc11.OutputParameters == 11, "GetDesc failed, got %u, expected %u\n", sdesc11.OutputParameters, 11);
420 ok(sdesc11.InstructionCount == 21, "GetDesc failed, got %u, expected %u\n", sdesc11.InstructionCount, 21);
421 ok(sdesc11.TempRegisterCount == 1, "GetDesc failed, got %u, expected %u\n", sdesc11.TempRegisterCount, 1);
422 ok(sdesc11.TempArrayCount == 5, "GetDesc failed, got %u, expected %u\n", sdesc11.TempArrayCount, 5);
423 ok(sdesc11.DefCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.DefCount, 0);
424 ok(sdesc11.DclCount == 18, "GetDesc failed, got %u, expected %u\n", sdesc11.DclCount, 18);
425 ok(sdesc11.TextureNormalInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureNormalInstructions, 0);
426 ok(sdesc11.TextureLoadInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureLoadInstructions, 0);
427 ok(sdesc11.TextureCompInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureCompInstructions, 0);
428 ok(sdesc11.TextureBiasInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureBiasInstructions, 0);
429 ok(sdesc11.TextureGradientInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureGradientInstructions, 0);
430 ok(sdesc11.FloatInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.FloatInstructionCount, 0);
431 ok(sdesc11.IntInstructionCount == 1, "GetDesc failed, got %u, expected %u\n", sdesc11.IntInstructionCount, 1);
432 ok(sdesc11.UintInstructionCount == 1, "GetDesc failed, got %u, expected %u\n", sdesc11.UintInstructionCount, 1);
433 ok(sdesc11.StaticFlowControlCount == 1, "GetDesc failed, got %u, expected %u\n", sdesc11.StaticFlowControlCount, 1);
434 ok(sdesc11.DynamicFlowControlCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.DynamicFlowControlCount, 0);
435 ok(sdesc11.MacroInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.MacroInstructionCount, 0);
436 ok(sdesc11.ArrayInstructionCount == 6, "GetDesc failed, got %u, expected %u\n", sdesc11.ArrayInstructionCount, 6);
437 ok(sdesc11.CutInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.CutInstructionCount, 0);
438 ok(sdesc11.EmitInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.EmitInstructionCount, 0);
439 ok(sdesc11.GSOutputTopology == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.GSOutputTopology, 0);
440 ok(sdesc11.GSMaxOutputVertexCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.GSMaxOutputVertexCount, 0);
441 ok(sdesc11.InputPrimitive == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.InputPrimitive, 0);
442 ok(sdesc11.PatchConstantParameters == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.PatchConstantParameters, 0);
443 ok(sdesc11.cGSInstanceCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cGSInstanceCount, 0);
444 ok(sdesc11.cControlPoints == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cControlPoints, 0);
445 ok(sdesc11.HSOutputPrimitive == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.HSOutputPrimitive, 0);
446 ok(sdesc11.HSPartitioning == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.HSPartitioning, 0);
447 ok(sdesc11.TessellatorDomain == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.TessellatorDomain, 0);
448 ok(sdesc11.cBarrierInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cBarrierInstructions, 0);
449 ok(sdesc11.cInterlockedInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cInterlockedInstructions, 0);
450 ok(sdesc11.cTextureStoreInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cTextureStoreInstructions, 0);
452 if (ref12)
454 hr = ref12->lpVtbl->GetDesc(ref12, &sdesc12);
455 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
456 ok(!memcmp(&sdesc11, &sdesc12, sizeof(sdesc12)), "D3D11 and D3D12 descs do not match.\n");
459 #if D3D_COMPILER_VERSION
460 ret = ref11->lpVtbl->GetBitwiseInstructionCount(ref11);
461 ok(ret == 0, "Got unexpected ret %u.\n", ret);
463 ret = ref11->lpVtbl->GetConversionInstructionCount(ref11);
464 ok(ret == 2, "Got unexpected ret %u.\n", ret);
466 ret = ref11->lpVtbl->GetMovInstructionCount(ref11);
467 ok(ret == 10, "Got unexpected ret %u.\n", ret);
469 ret = ref11->lpVtbl->GetMovcInstructionCount(ref11);
470 ok(ret == 0, "Got unexpected ret %u.\n", ret);
472 if (ref12)
474 ret = ref12->lpVtbl->GetBitwiseInstructionCount(ref12);
475 ok(ret == 0, "Got unexpected ret %u.\n", ret);
477 ret = ref12->lpVtbl->GetConversionInstructionCount(ref12);
478 ok(ret == 2, "Got unexpected ret %u.\n", ret);
480 ret = ref12->lpVtbl->GetMovInstructionCount(ref12);
481 ok(ret == 10, "Got unexpected ret %u.\n", ret);
483 ret = ref12->lpVtbl->GetMovcInstructionCount(ref12);
484 ok(ret == 0, "Got unexpected ret %u.\n", ret);
486 #endif
488 /* GetIn/OutputParameterDesc */
489 desc_46.MinPrecision = ~0u;
490 hr = ref11->lpVtbl->GetInputParameterDesc(ref11, 0, (D3D11_SIGNATURE_PARAMETER_DESC *)&desc_46);
491 #if D3D_COMPILER_VERSION >= 46
492 expected_min_prec = 0;
493 #else
494 expected_min_prec = ~0u;
495 #endif
496 ok(desc_46.MinPrecision == expected_min_prec, "Got MinPrecision %#x, expected %#x.\n",
497 desc_46.MinPrecision, expected_min_prec);
499 for (i = 0; i < ARRAY_SIZE(test_reflection_desc_vs_resultin); ++i)
501 pdesc = &test_reflection_desc_vs_resultin[i];
503 hr = ref11->lpVtbl->GetInputParameterDesc(ref11, i, &desc11);
504 ok(hr == S_OK, "Got unexpected hr %#lx, i %u.\n", hr, i);
506 ok(!strcmp(desc11.SemanticName, pdesc->SemanticName), "Got unexpected SemanticName \"%s\", i %u.\n",
507 desc11.SemanticName, i);
508 ok(desc11.SemanticIndex == pdesc->SemanticIndex, "Got unexpected SemanticIndex %u, i %u.\n",
509 desc11.SemanticIndex, i);
510 ok(desc11.Register == pdesc->Register, "Got unexpected Register %u, i %u.\n", desc11.Register, i);
511 ok(desc11.SystemValueType == pdesc->SystemValueType, "Got unexpected SystemValueType %u, i %u.\n",
512 desc11.SystemValueType, i);
513 ok(desc11.ComponentType == pdesc->ComponentType, "Got unexpected ComponentType %u, i %u.\n",
514 desc11.ComponentType, i);
515 ok(desc11.Mask == pdesc->Mask, "Got unexpected SystemValueType %#x, i %u.\n", desc11.Mask, i);
516 ok(desc11.ReadWriteMask == pdesc->ReadWriteMask, "Got unexpected ReadWriteMask %#x, i %u.\n",
517 desc11.ReadWriteMask, i);
518 /* The Stream field of D3D11_SIGNATURE_PARAMETER_DESC is in the
519 * trailing padding of the D3D10_SIGNATURE_PARAMETER_DESC struct on
520 * 64-bits and thus undefined. Don't test it. */
521 if (D3D_COMPILER_VERSION)
522 ok(desc11.Stream == pdesc->Stream, "Got unexpected Stream %u, i %u.\n",
523 desc11.Stream, i);
524 else if (sizeof(void *) == 4)
525 ok(!desc11.Stream, "Got unexpected Stream %u, i %u.\n", desc11.Stream, i);
527 if (ref12)
529 hr = ref12->lpVtbl->GetInputParameterDesc(ref12, i, &desc12);
530 ok(hr == S_OK, "Got unexpected hr %#lx, i %u.\n", hr, i);
532 ok(!memcmp(&desc12, &desc11, sizeof(desc11)), "D3D11 and D3D12 descs do not match.\n");
536 for (i = 0; i < ARRAY_SIZE(test_reflection_desc_vs_resultout); ++i)
538 pdesc = &test_reflection_desc_vs_resultout[i];
540 hr = ref11->lpVtbl->GetOutputParameterDesc(ref11, i, &desc11);
541 ok(hr == S_OK, "Got unexpected hr %#lx, i %u.\n", hr, i);
543 ok(!strcmp(desc11.SemanticName, pdesc->SemanticName), "Got unexpected SemanticName \"%s\", i %u.\n",
544 desc11.SemanticName, i);
545 ok(desc11.SemanticIndex == pdesc->SemanticIndex, "Got unexpected SemanticIndex %u, i %u.\n",
546 desc11.SemanticIndex, i);
547 ok(desc11.Register == pdesc->Register, "Got unexpected Register %u, i %u.\n", desc11.Register, i);
548 ok(desc11.SystemValueType == pdesc->SystemValueType, "Got unexpected SystemValueType %u, i %u.\n",
549 desc11.SystemValueType, i);
550 ok(desc11.ComponentType == pdesc->ComponentType, "Got unexpected ComponentType %u, i %u.\n",
551 desc11.ComponentType, i);
552 ok(desc11.Mask == pdesc->Mask, "Got unexpected SystemValueType %#x, i %u.\n", desc11.Mask, i);
553 ok(desc11.ReadWriteMask == pdesc->ReadWriteMask, "Got unexpected ReadWriteMask %#x, i %u.\n",
554 desc11.ReadWriteMask, i);
555 /* The Stream field of D3D11_SIGNATURE_PARAMETER_DESC is in the
556 * trailing padding of the D3D10_SIGNATURE_PARAMETER_DESC struct on
557 * 64-bits and thus undefined. Don't test it. */
558 if (D3D_COMPILER_VERSION)
559 ok(desc11.Stream == pdesc->Stream, "Got unexpected Stream %u, i %u.\n",
560 desc11.Stream, i);
561 else if (sizeof(void *) == 4)
562 ok(!desc11.Stream, "Got unexpected Stream %u, i %u.\n", desc11.Stream, i);
564 if (ref12)
566 hr = ref12->lpVtbl->GetOutputParameterDesc(ref12, i, &desc12);
567 ok(hr == S_OK, "Got unexpected hr %#lx, i %u.\n", hr, i);
569 ok(!memcmp(&desc12, &desc11, sizeof(desc11)), "D3D11 and D3D12 descs do not match.\n");
573 if (ref12)
575 count = ref12->lpVtbl->Release(ref12);
576 ok(count == 1, "Got unexpected ref count %lu.\n", count);
579 count = ref11->lpVtbl->Release(ref11);
580 ok(count == 0, "Got unexpected ref count %lu.\n", count);
584 * fxc.exe /E PS /Tps_4_1 /Fx
586 #if 0
587 Texture2D tex1;
588 Texture2D tex2;
589 SamplerState sam
591 Filter = MIN_MAG_MIP_LINEAR;
592 AddressU = Wrap;
593 AddressV = Wrap;
595 SamplerComparisonState samc
597 Filter = MIN_MAG_MIP_LINEAR;
598 AddressU = w1;
599 AddressV = Wrap;
600 ComparisonFunc = LESS;
602 struct psin
604 uint f : SV_RenderTargetArrayIndex;
605 uint g : SV_InstanceID;
606 uint h : SV_PrimitiveID;
607 float2 uv : TEXCOORD;
608 float4 a : COLOR3;
609 float b : VFACE;
610 float4 c : SV_position;
611 bool d : SV_Coverage;
612 bool e : SV_IsFrontFace;
614 struct psout
616 float a : SV_Target1;
617 float b : SV_Depth;
618 float x : SV_Target;
619 bool c : SV_Coverage;
621 psout PS(psin p)
623 psout a;
624 float4 x = tex1.Sample(sam, p.uv);
625 x += tex1.SampleCmp(samc, p.uv, 0.3f);
626 if (x.y < 0.1f)
627 x += tex2.SampleCmp(samc, p.uv, 0.4f);
628 else if (x.y < 0.2f)
629 x += tex2.SampleCmp(samc, p.uv, 0.1f);
630 else if (x.y < 0.3f)
631 x += tex2.SampleBias(sam, p.uv, 0.1f);
632 else if (x.y < 0.4f)
633 x += tex2.SampleBias(sam, p.uv, 0.2f);
634 else if (x.y < 0.5f)
635 x += tex2.SampleBias(sam, p.uv, 0.3f);
636 else
637 x += tex2.SampleBias(sam, p.uv, 0.4f);
638 x += tex2.SampleGrad(sam, p.uv, x.xy, x.xy);
639 x += tex2.SampleGrad(sam, p.uv, x.xz, x.xz);
640 x += tex2.SampleGrad(sam, p.uv, x.xz, x.zy);
641 x += tex2.SampleGrad(sam, p.uv, x.xz, x.zw);
642 x += tex2.SampleGrad(sam, p.uv, x.xz, x.wz);
643 a.a = x.y;
644 a.b = x.x;
645 a.x = x.x;
646 a.c = true;
647 return a;
649 #endif
650 static DWORD test_reflection_desc_ps_blob[] = {
651 0x43425844, 0x19e2f325, 0xf1ec39a3, 0x3c5a8b53, 0x5bd5fb65, 0x00000001, 0x000008d0, 0x00000005,
652 0x00000034, 0x0000011c, 0x00000254, 0x000002e4, 0x00000854, 0x46454452, 0x000000e0, 0x00000000,
653 0x00000000, 0x00000004, 0x0000001c, 0xffff0401, 0x00000100, 0x000000af, 0x0000009c, 0x00000003,
654 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x000000a0, 0x00000003,
655 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000002, 0x000000a5, 0x00000002,
656 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000c, 0x000000aa, 0x00000002,
657 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000c, 0x006d6173, 0x636d6173,
658 0x78657400, 0x65740031, 0x4d003278, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
659 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e392072, 0x392e3932, 0x332e3235, 0x00313131, 0x4e475349,
660 0x00000130, 0x00000008, 0x00000008, 0x000000c8, 0x00000000, 0x00000004, 0x00000001, 0x00000000,
661 0x00000001, 0x000000e2, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000002, 0x000000f0,
662 0x00000000, 0x00000007, 0x00000001, 0x00000000, 0x00000004, 0x000000ff, 0x00000000, 0x00000009,
663 0x00000001, 0x00000000, 0x00000008, 0x0000010e, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
664 0x00000303, 0x00000117, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000004, 0x0000011d,
665 0x00000003, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x00000123, 0x00000000, 0x00000001,
666 0x00000003, 0x00000003, 0x0000000f, 0x525f5653, 0x65646e65, 0x72615472, 0x41746567, 0x79617272,
667 0x65646e49, 0x56530078, 0x736e495f, 0x636e6174, 0x00444965, 0x505f5653, 0x696d6972, 0x65766974,
668 0x53004449, 0x73495f56, 0x6e6f7246, 0x63614674, 0x45540065, 0x4f4f4358, 0x56004452, 0x45434146,
669 0x4c4f4300, 0x5300524f, 0x6f705f56, 0x69746973, 0xab006e6f, 0x4e47534f, 0x00000088, 0x00000004,
670 0x00000008, 0x00000068, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000e01, 0x00000068,
671 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000e01, 0x00000072, 0x00000000, 0x00000000,
672 0x00000001, 0xffffffff, 0x00000e01, 0x0000007e, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
673 0x00000e01, 0x545f5653, 0x65677261, 0x56530074, 0x766f435f, 0x67617265, 0x56530065, 0x7065445f,
674 0xab006874, 0x52444853, 0x00000568, 0x00000041, 0x0000015a, 0x0100086a, 0x0300005a, 0x00106000,
675 0x00000000, 0x0300085a, 0x00106000, 0x00000001, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
676 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03000065,
677 0x00102012, 0x00000000, 0x03000065, 0x00102012, 0x00000001, 0x02000065, 0x0000f000, 0x02000065,
678 0x0000c001, 0x02000068, 0x00000003, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001,
679 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0b000046, 0x00100012, 0x00000001, 0x00101046,
680 0x00000001, 0x00107006, 0x00000000, 0x00106000, 0x00000001, 0x00004001, 0x3e99999a, 0x07000000,
681 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100006, 0x00000001, 0x07000031, 0x00100012,
682 0x00000001, 0x0010001a, 0x00000000, 0x00004001, 0x3dcccccd, 0x0304001f, 0x0010000a, 0x00000001,
683 0x0b000046, 0x00100012, 0x00000001, 0x00101046, 0x00000001, 0x00107006, 0x00000001, 0x00106000,
684 0x00000001, 0x00004001, 0x3ecccccd, 0x07000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000000,
685 0x00100006, 0x00000001, 0x01000012, 0x07000031, 0x00100012, 0x00000002, 0x0010001a, 0x00000000,
686 0x00004001, 0x3e4ccccd, 0x0304001f, 0x0010000a, 0x00000002, 0x0b000046, 0x00100012, 0x00000002,
687 0x00101046, 0x00000001, 0x00107006, 0x00000001, 0x00106000, 0x00000001, 0x00004001, 0x3dcccccd,
688 0x07000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000000, 0x00100006, 0x00000002, 0x01000012,
689 0x07000031, 0x00100012, 0x00000002, 0x0010001a, 0x00000000, 0x00004001, 0x3e99999a, 0x0304001f,
690 0x0010000a, 0x00000002, 0x0b00004a, 0x001000f2, 0x00000002, 0x00101046, 0x00000001, 0x00107e46,
691 0x00000001, 0x00106000, 0x00000000, 0x00004001, 0x3dcccccd, 0x07000000, 0x001000f2, 0x00000001,
692 0x00100e46, 0x00000000, 0x00100e46, 0x00000002, 0x01000012, 0x07000031, 0x00100012, 0x00000002,
693 0x0010001a, 0x00000000, 0x00004001, 0x3ecccccd, 0x0304001f, 0x0010000a, 0x00000002, 0x0b00004a,
694 0x001000f2, 0x00000002, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000,
695 0x00004001, 0x3e4ccccd, 0x07000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000000, 0x00100e46,
696 0x00000002, 0x01000012, 0x07000031, 0x00100012, 0x00000002, 0x0010001a, 0x00000000, 0x00004001,
697 0x3f000000, 0x0304001f, 0x0010000a, 0x00000002, 0x0b00004a, 0x001000f2, 0x00000002, 0x00101046,
698 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x00004001, 0x3e99999a, 0x07000000,
699 0x001000f2, 0x00000001, 0x00100e46, 0x00000000, 0x00100e46, 0x00000002, 0x01000012, 0x0b00004a,
700 0x001000f2, 0x00000002, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000,
701 0x00004001, 0x3ecccccd, 0x07000000, 0x001000f2, 0x00000001, 0x00100e46, 0x00000000, 0x00100e46,
702 0x00000002, 0x01000015, 0x01000015, 0x01000015, 0x01000015, 0x01000015, 0x0d000049, 0x001000f2,
703 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x00100046,
704 0x00000001, 0x00100046, 0x00000001, 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
705 0x00100e46, 0x00000001, 0x0d000049, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
706 0x00000001, 0x00106000, 0x00000000, 0x00100086, 0x00000000, 0x00100086, 0x00000000, 0x07000000,
707 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, 0x0d000049, 0x001000f2,
708 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x00100086,
709 0x00000000, 0x00100a66, 0x00000000, 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000,
710 0x00100e46, 0x00000001, 0x0d000049, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
711 0x00000001, 0x00106000, 0x00000000, 0x00100086, 0x00000000, 0x00100ae6, 0x00000000, 0x07000000,
712 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, 0x0d000049, 0x001000c2,
713 0x00000000, 0x00101046, 0x00000001, 0x001074e6, 0x00000001, 0x00106000, 0x00000000, 0x00100086,
714 0x00000000, 0x00100fb6, 0x00000000, 0x07000000, 0x00100032, 0x00000000, 0x00100ae6, 0x00000000,
715 0x00100046, 0x00000000, 0x05000036, 0x00102012, 0x00000001, 0x0010001a, 0x00000000, 0x04000036,
716 0x0000c001, 0x0010000a, 0x00000000, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000,
717 0x04000036, 0x0000f001, 0x00004001, 0xffffffff, 0x0100003e, 0x54415453, 0x00000074, 0x00000032,
718 0x00000003, 0x00000000, 0x00000005, 0x00000011, 0x00000000, 0x00000000, 0x00000006, 0x00000005,
719 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000003,
720 0x00000004, 0x00000005, 0x00000018, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
721 0x00000000, 0x00000000, 0x00000000, 0x00000000,
724 static const D3D11_SIGNATURE_PARAMETER_DESC test_reflection_desc_ps_resultin[] =
726 {"SV_RenderTargetArrayIndex", 0, 0, D3D_NAME_RENDER_TARGET_ARRAY_INDEX, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0x0, 0},
727 {"SV_InstanceID", 0, 0, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_UINT32, 0x2, 0x0, 0},
728 {"SV_PrimitiveID", 0, 0, D3D_NAME_PRIMITIVE_ID, D3D_REGISTER_COMPONENT_UINT32, 0x4, 0x0, 0},
729 {"SV_IsFrontFace", 0, 0, D3D_NAME_IS_FRONT_FACE, D3D_REGISTER_COMPONENT_UINT32, 0x8, 0x0, 0},
730 {"TEXCOORD", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x3, 0x3, 0},
731 {"VFACE", 0, 1, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0x4, 0x0, 0},
732 {"COLOR", 3, 2, D3D_NAME_UNDEFINED, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
733 {"SV_position", 0, 3, D3D_NAME_POSITION, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0x0, 0},
736 static const D3D11_SIGNATURE_PARAMETER_DESC test_reflection_desc_ps_resultout[] =
738 {"SV_Target", 0, 0, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0},
739 {"SV_Target", 1, 1, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0},
740 {"SV_Coverage", 0, 0xffffffff, D3D_NAME_COVERAGE, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe, 0},
741 {"SV_Depth", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0},
744 static void test_reflection_desc_ps(void)
746 HRESULT hr;
747 ULONG count;
748 ID3D11ShaderReflection *ref11;
749 D3D11_SHADER_DESC sdesc11 = {0};
750 D3D11_SIGNATURE_PARAMETER_DESC desc = {0};
751 const D3D11_SIGNATURE_PARAMETER_DESC *pdesc;
752 D3D_NAME expected;
753 unsigned int i;
754 #if D3D_COMPILER_VERSION
755 UINT ret;
756 #endif
758 hr = call_reflect(test_reflection_desc_ps_blob, test_reflection_desc_ps_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
759 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
761 hr = ref11->lpVtbl->GetDesc(ref11, &sdesc11);
762 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
764 ok(sdesc11.Version == 65, "GetDesc failed, got %u, expected %u\n", sdesc11.Version, 65);
765 ok(strcmp(sdesc11.Creator, (char*) shader_creator) == 0, "GetDesc failed, got \"%s\", expected \"%s\"\n", sdesc11.Creator, (char*)shader_creator);
766 ok(sdesc11.Flags == 256, "GetDesc failed, got %u, expected %u\n", sdesc11.Flags, 256);
767 ok(sdesc11.ConstantBuffers == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.ConstantBuffers, 0);
768 ok(sdesc11.BoundResources == 4, "GetDesc failed, got %u, expected %u\n", sdesc11.BoundResources, 4);
769 ok(sdesc11.InputParameters == 8, "GetDesc failed, got %u, expected %u\n", sdesc11.InputParameters, 8);
770 ok(sdesc11.OutputParameters == 4, "GetDesc failed, got %u, expected %u\n", sdesc11.OutputParameters, 4);
771 ok(sdesc11.InstructionCount == 50, "GetDesc failed, got %u, expected %u\n", sdesc11.InstructionCount, 50);
772 ok(sdesc11.TempRegisterCount == 3, "GetDesc failed, got %u, expected %u\n", sdesc11.TempRegisterCount, 3);
773 ok(sdesc11.TempArrayCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TempArrayCount, 0);
774 ok(sdesc11.DefCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.DefCount, 0);
775 ok(sdesc11.DclCount == 5, "GetDesc failed, got %u, expected %u\n", sdesc11.DclCount, 5);
776 ok(sdesc11.TextureNormalInstructions == 1, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureNormalInstructions, 1);
777 ok(sdesc11.TextureLoadInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureLoadInstructions, 0);
778 ok(sdesc11.TextureCompInstructions == 3, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureCompInstructions, 3);
779 ok(sdesc11.TextureBiasInstructions == 4, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureBiasInstructions, 4);
780 ok(sdesc11.TextureGradientInstructions == 5, "GetDesc failed, got %u, expected %u\n", sdesc11.TextureGradientInstructions, 5);
781 ok(sdesc11.FloatInstructionCount == 17, "GetDesc failed, got %u, expected %u\n", sdesc11.FloatInstructionCount, 17);
782 ok(sdesc11.IntInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.IntInstructionCount, 0);
783 ok(sdesc11.UintInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.UintInstructionCount, 0);
784 ok(sdesc11.StaticFlowControlCount == 6, "GetDesc failed, got %u, expected %u\n", sdesc11.StaticFlowControlCount, 6);
785 ok(sdesc11.DynamicFlowControlCount == 5, "GetDesc failed, got %u, expected %u\n", sdesc11.DynamicFlowControlCount, 5);
786 ok(sdesc11.MacroInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.MacroInstructionCount, 0);
787 ok(sdesc11.ArrayInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.ArrayInstructionCount, 0);
788 ok(sdesc11.CutInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.CutInstructionCount, 0);
789 ok(sdesc11.EmitInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.EmitInstructionCount, 0);
790 ok(sdesc11.GSOutputTopology == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.GSOutputTopology, 0);
791 ok(sdesc11.GSMaxOutputVertexCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.GSMaxOutputVertexCount, 0);
792 ok(sdesc11.InputPrimitive == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.InputPrimitive, 0);
793 ok(sdesc11.PatchConstantParameters == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.PatchConstantParameters, 0);
794 ok(sdesc11.cGSInstanceCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cGSInstanceCount, 0);
795 ok(sdesc11.cControlPoints == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cControlPoints, 0);
796 ok(sdesc11.HSOutputPrimitive == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.HSOutputPrimitive, 0);
797 ok(sdesc11.HSPartitioning == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.HSPartitioning, 0);
798 ok(sdesc11.TessellatorDomain == 0, "GetDesc failed, got %x, expected %x\n", sdesc11.TessellatorDomain, 0);
799 ok(sdesc11.cBarrierInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cBarrierInstructions, 0);
800 ok(sdesc11.cInterlockedInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cInterlockedInstructions, 0);
801 ok(sdesc11.cTextureStoreInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cTextureStoreInstructions, 0);
803 #if D3D_COMPILER_VERSION
804 ret = ref11->lpVtbl->GetBitwiseInstructionCount(ref11);
805 ok(ret == 0, "GetBitwiseInstructionCount failed, got %u, expected %u\n", ret, 0);
807 ret = ref11->lpVtbl->GetConversionInstructionCount(ref11);
808 ok(ret == 0, "GetConversionInstructionCount failed, got %u, expected %u\n", ret, 0);
810 ret = ref11->lpVtbl->GetMovInstructionCount(ref11);
811 ok(ret == 24, "GetMovInstructionCount failed, got %u, expected %u\n", ret, 24);
813 ret = ref11->lpVtbl->GetMovcInstructionCount(ref11);
814 ok(ret == 0, "GetMovcInstructionCount failed, got %u, expected %u\n", ret, 0);
815 #endif
817 /* check invalid Get*ParameterDesc cases*/
818 hr = ref11->lpVtbl->GetInputParameterDesc(ref11, 0, NULL);
819 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
821 hr = ref11->lpVtbl->GetInputParameterDesc(ref11, 0xffffffff, &desc);
822 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
824 hr = ref11->lpVtbl->GetOutputParameterDesc(ref11, 0, NULL);
825 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
827 hr = ref11->lpVtbl->GetOutputParameterDesc(ref11, 0xffffffff, &desc);
828 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
830 #if D3D_COMPILER_VERSION
831 hr = ref11->lpVtbl->GetPatchConstantParameterDesc(ref11, 0, &desc);
832 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
833 #endif
835 /* GetIn/OutputParameterDesc */
836 for (i = 0; i < ARRAY_SIZE(test_reflection_desc_ps_resultin); ++i)
838 pdesc = &test_reflection_desc_ps_resultin[i];
840 hr = ref11->lpVtbl->GetInputParameterDesc(ref11, i, &desc);
841 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
843 ok(!strcmp(desc.SemanticName, pdesc->SemanticName), "GetInputParameterDesc(%u) SemanticName failed, got \"%s\", expected \"%s\"\n",
844 i, desc.SemanticName, pdesc->SemanticName);
845 ok(desc.SemanticIndex == pdesc->SemanticIndex, "GetInputParameterDesc(%u) SemanticIndex failed, got %u, expected %u\n",
846 i, desc.SemanticIndex, pdesc->SemanticIndex);
847 ok(desc.Register == pdesc->Register, "GetInputParameterDesc(%u) Register failed, got %u, expected %u\n",
848 i, desc.Register, pdesc->Register);
849 ok(desc.SystemValueType == pdesc->SystemValueType, "GetInputParameterDesc(%u) SystemValueType failed, got %x, expected %x\n",
850 i, desc.SystemValueType, pdesc->SystemValueType);
851 ok(desc.ComponentType == pdesc->ComponentType, "GetInputParameterDesc(%u) ComponentType failed, got %x, expected %x\n",
852 i, desc.ComponentType, pdesc->ComponentType);
853 ok(desc.Mask == pdesc->Mask, "GetInputParameterDesc(%u) Mask failed, got %x, expected %x\n",
854 i, desc.Mask, pdesc->Mask);
855 ok(desc.ReadWriteMask == pdesc->ReadWriteMask, "GetInputParameterDesc(%u) ReadWriteMask failed, got %x, expected %x\n",
856 i, desc.ReadWriteMask, pdesc->ReadWriteMask);
857 if (D3D_COMPILER_VERSION)
858 ok(desc.Stream == pdesc->Stream, "(%u): got unexpected Stream %u, expected %u.\n",
859 i, desc.Stream, pdesc->Stream);
860 else if (sizeof(void *) == 4)
861 ok(!desc.Stream, "(%u): got unexpected Stream %u.\n", i, desc.Stream);
864 for (i = 0; i < ARRAY_SIZE(test_reflection_desc_ps_resultout); ++i)
866 pdesc = &test_reflection_desc_ps_resultout[i];
868 hr = ref11->lpVtbl->GetOutputParameterDesc(ref11, i, &desc);
869 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
871 ok(!strcmp(desc.SemanticName, pdesc->SemanticName), "GetOutputParameterDesc(%u) SemanticName failed, got \"%s\", expected \"%s\"\n",
872 i, desc.SemanticName, pdesc->SemanticName);
873 ok(desc.SemanticIndex == pdesc->SemanticIndex, "GetOutputParameterDesc(%u) SemanticIndex failed, got %u, expected %u\n",
874 i, desc.SemanticIndex, pdesc->SemanticIndex);
875 ok(desc.Register == pdesc->Register, "GetOutputParameterDesc(%u) Register failed, got %u, expected %u\n",
876 i, desc.Register, pdesc->Register);
877 #if D3D_COMPILER_VERSION
878 expected = pdesc->SystemValueType;
879 #else
880 expected = D3D_NAME_UNDEFINED;
881 todo_wine
882 #endif
883 ok(desc.SystemValueType == expected, "(%u): got unexpected SystemValueType %#x, expected %#x.\n",
884 i, desc.SystemValueType, expected);
885 ok(desc.ComponentType == pdesc->ComponentType, "GetOutputParameterDesc(%u) ComponentType failed, got %x, expected %x\n",
886 i, desc.ComponentType, pdesc->ComponentType);
887 ok(desc.Mask == pdesc->Mask, "GetOutputParameterDesc(%u) Mask failed, got %x, expected %x\n",
888 i, desc.Mask, pdesc->Mask);
889 ok(desc.ReadWriteMask == pdesc->ReadWriteMask, "GetOutputParameterDesc(%u) ReadWriteMask failed, got %x, expected %x\n",
890 i, desc.ReadWriteMask, pdesc->ReadWriteMask);
891 if (D3D_COMPILER_VERSION)
892 ok(desc.Stream == pdesc->Stream, "(%u): got unexpected Stream %u, expected %u.\n",
893 i, desc.Stream, pdesc->Stream);
894 else if (sizeof(void *) == 4)
895 ok(!desc.Stream, "(%u): got unexpected Stream %u.\n", i, desc.Stream);
898 count = ref11->lpVtbl->Release(ref11);
899 ok(!count, "Got unexpected count %lu.\n", count);
902 /* The following shaders are stripped, in order to show that the correct
903 * reporting of pixel shader output sysvals should not depend on the RDEF chunk
904 * being present. */
905 #if 0
906 float4 PS() : SV_Target3
908 float4 a = float4(1.2f, 1.0f, 0.2f, 0.0f);
909 return a;
911 #endif
912 static const DWORD test_reflection_desc_ps_output_blob_0[] =
914 0x43425844, 0xc3773602, 0x04f86bdc, 0x715f33b2, 0x9c063cae, 0x00000001, 0x000000b4, 0x00000003,
915 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
916 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000003, 0x00000000, 0x00000003, 0x00000003,
917 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000003c, 0x00000050, 0x0000000f,
918 0x0100086a, 0x03000065, 0x001020f2, 0x00000003, 0x08000036, 0x001020f2, 0x00000003, 0x00004002,
919 0x3f99999a, 0x3f800000, 0x3e4ccccd, 0x00000000, 0x0100003e,
922 #if 0
923 float PS() : SV_DepthLessEqual
925 float a = 1.2f;
926 return a;
928 #endif
929 static const DWORD test_reflection_desc_ps_output_blob_1[] =
931 0x43425844, 0xc45db587, 0xdb0601fb, 0x7370900b, 0x219464be, 0x00000001, 0x000000a8, 0x00000003,
932 0x0000002c, 0x0000003c, 0x00000078, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
933 0x00000034, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
934 0x00000e01, 0x445f5653, 0x68747065, 0x7373654c, 0x61757145, 0xabab006c, 0x58454853, 0x00000028,
935 0x00000050, 0x0000000a, 0x0100086a, 0x02000065, 0x00027001, 0x04000036, 0x00027001, 0x00004001,
936 0x3f99999a, 0x0100003e,
939 #if 0
940 float PS() : SV_DepthGreaterEqual
942 float a = 1.2f;
943 return a;
945 #endif
946 static const DWORD test_reflection_desc_ps_output_blob_2[] =
948 0x43425844, 0x13cce144, 0x3628f322, 0xa8ea9b7d, 0xbbf9f8d7, 0x00000001, 0x000000ac, 0x00000003,
949 0x0000002c, 0x0000003c, 0x0000007c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
950 0x00000038, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
951 0x00000e01, 0x445f5653, 0x68747065, 0x61657247, 0x45726574, 0x6c617571, 0xababab00, 0x58454853,
952 0x00000028, 0x00000050, 0x0000000a, 0x0100086a, 0x02000065, 0x00026001, 0x04000036, 0x00026001,
953 0x00004001, 0x3f99999a, 0x0100003e,
956 #if 0
957 float PS() : sV_DePtH
959 float a = 1.2f;
960 return a;
962 #endif
963 static const DWORD test_reflection_desc_ps_output_blob_3[] =
965 0x43425844, 0x31c891d1, 0xcbb9d935, 0xa199e1d5, 0x70205254, 0x00000001, 0x000000a0, 0x00000003,
966 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
967 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
968 0x00000e01, 0x445f5673, 0x48745065, 0xababab00, 0x58454853, 0x00000028, 0x00000050, 0x0000000a,
969 0x0100086a, 0x02000065, 0x0000c001, 0x04000036, 0x0000c001, 0x00004001, 0x3f99999a, 0x0100003e,
972 #if 0
973 float PS() : SV_Depth
975 float a = 1.2f;
976 return a;
978 #endif
979 static const DWORD test_reflection_desc_ps_output_blob_4[] =
981 0x43425844, 0x1d404736, 0x00e4a4aa, 0x5fcdad54, 0x5abd13f8, 0x00000001, 0x0000009c, 0x00000003,
982 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
983 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0xffffffff,
984 0x00000e01, 0x445f5653, 0x68747065, 0xababab00, 0x52444853, 0x00000024, 0x00000040, 0x00000009,
985 0x02000065, 0x0000c001, 0x04000036, 0x0000c001, 0x00004001, 0x3f99999a, 0x0100003e,
988 #if 0
989 bool PS() : SV_COVERAGE
991 bool a = true;
992 return a;
994 #endif
995 static const DWORD test_reflection_desc_ps_output_blob_5[] =
997 0x43425844, 0x6127612d, 0x09e2bb9a, 0xbba3889a, 0x987dafc2, 0x00000001, 0x000000a0, 0x00000003,
998 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
999 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0xffffffff,
1000 0x00000e01, 0x435f5653, 0x5245564f, 0x00454741, 0x52444853, 0x00000028, 0x00000041, 0x0000000a,
1001 0x0100086a, 0x02000065, 0x0000f000, 0x04000036, 0x0000f001, 0x00004001, 0xffffffff, 0x0100003e,
1004 static void test_reflection_desc_ps_output(void)
1006 static const struct test_reflection_desc_ps_output_test
1008 const DWORD *blob;
1009 D3D11_SIGNATURE_PARAMETER_DESC desc;
1011 tests[] =
1013 {test_reflection_desc_ps_output_blob_0,
1014 {"SV_Target", 3, 3, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0, 0}},
1015 {test_reflection_desc_ps_output_blob_1,
1016 {"SV_DepthLessEqual", 0, 0xffffffff, D3D_NAME_DEPTH_LESS_EQUAL, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}},
1017 {test_reflection_desc_ps_output_blob_2,
1018 {"SV_DepthGreaterEqual", 0, 0xffffffff, D3D11_NAME_DEPTH_GREATER_EQUAL, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}},
1019 {test_reflection_desc_ps_output_blob_3,
1020 {"sV_DePtH", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}},
1021 {test_reflection_desc_ps_output_blob_4,
1022 {"SV_Depth", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}},
1023 {test_reflection_desc_ps_output_blob_5,
1024 {"SV_COVERAGE", 0, 0xffffffff, D3D_NAME_COVERAGE, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe, 0}},
1026 HRESULT hr;
1027 ULONG count;
1028 ID3D11ShaderReflection *ref11;
1029 D3D11_SIGNATURE_PARAMETER_DESC desc = {0};
1030 const D3D11_SIGNATURE_PARAMETER_DESC *pdesc;
1031 D3D_NAME expected;
1032 unsigned int i;
1034 for (i = 0; i < ARRAY_SIZE(tests); ++i)
1036 hr = call_reflect(tests[i].blob, tests[i].blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
1037 if (!D3D_COMPILER_VERSION)
1039 todo_wine ok(hr == E_INVALIDARG, "%u: Got unexpected hr %#lx.\n", i, hr);
1040 if (SUCCEEDED(hr))
1041 ref11->lpVtbl->Release(ref11);
1042 continue;
1044 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1046 pdesc = &tests[i].desc;
1048 hr = ref11->lpVtbl->GetOutputParameterDesc(ref11, 0, &desc);
1049 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1051 ok(!strcmp(desc.SemanticName, pdesc->SemanticName), "(%u): GetOutputParameterDesc SemanticName failed, got \"%s\", expected \"%s\"\n",
1052 i, desc.SemanticName, pdesc->SemanticName);
1053 ok(desc.SemanticIndex == pdesc->SemanticIndex, "(%u): GetOutputParameterDesc SemanticIndex failed, got %u, expected %u\n",
1054 i, desc.SemanticIndex, pdesc->SemanticIndex);
1055 ok(desc.Register == pdesc->Register, "(%u): GetOutputParameterDesc Register failed, got %u, expected %u\n",
1056 i, desc.Register, pdesc->Register);
1057 #if D3D_COMPILER_VERSION
1058 expected = pdesc->SystemValueType;
1059 #else
1060 expected = D3D_NAME_UNDEFINED;
1061 todo_wine
1062 #endif
1063 ok(desc.SystemValueType == expected, "(%u): Got unexpected SystemValueType %#x, expected %x.\n",
1064 i, desc.SystemValueType, expected);
1065 ok(desc.ComponentType == pdesc->ComponentType, "(%u): GetOutputParameterDesc ComponentType failed, got %x, expected %x\n",
1066 i, desc.ComponentType, pdesc->ComponentType);
1067 ok(desc.Mask == pdesc->Mask, "(%u): GetOutputParameterDesc Mask failed, got %x, expected %x\n",
1068 i, desc.Mask, pdesc->Mask);
1069 ok(desc.ReadWriteMask == pdesc->ReadWriteMask, "(%u): GetOutputParameterDesc ReadWriteMask failed, got %x, expected %x\n",
1070 i, desc.ReadWriteMask, pdesc->ReadWriteMask);
1071 if (D3D_COMPILER_VERSION)
1072 ok(desc.Stream == pdesc->Stream, "(%u): got unexpected Stream %u, expected %u.\n",
1073 i, desc.Stream, pdesc->Stream);
1074 else if (sizeof(void *) == 4)
1075 ok(!desc.Stream, "(%u): got unexpected Stream %u.\n", i, desc.Stream);
1077 count = ref11->lpVtbl->Release(ref11);
1078 ok(!count, "%u: Got unexpected count %lu.\n", i, count);
1083 * fxc.exe /E PS /Tps_4_0 /Fo
1085 #if 0
1086 Texture2D tex1[2];
1087 Texture2D tex2;
1088 SamplerState sam
1090 Filter = MIN_MAG_MIP_LINEAR;
1091 AddressU = Wrap;
1092 AddressV = Wrap;
1094 cbuffer c1
1096 float x;
1097 float y[2];
1098 int z;
1100 cbuffer c2
1102 float t;
1105 float4 PS(float2 uv : TEXCOORD0) : sv_target
1107 float4 q = tex1[0].Sample(sam, uv) + tex1[1].Sample(sam, uv) + tex2.Sample(sam, uv);
1108 q.x = q.x + x;
1109 q.w = q.w + y[0] + y[1] + t;
1110 return q;
1112 #endif
1113 static const DWORD test_reflection_bound_resources_blob[] =
1115 0x43425844, 0x003472ed, 0xe3436185, 0xcc1faad3, 0xfdac0a07, 0x00000001, 0x000004b0, 0x00000005,
1116 0x00000034, 0x00000204, 0x00000238, 0x0000026c, 0x00000434, 0x46454452, 0x000001c8, 0x00000002,
1117 0x000000d0, 0x00000005, 0x0000001c, 0xffff0400, 0x00000100, 0x0000019e, 0x000000bc, 0x00000003,
1118 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x000000c0, 0x00000002,
1119 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000002, 0x0000000c, 0x000000c5, 0x00000002,
1120 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000c, 0x000000ca, 0x00000000,
1121 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x000000cd, 0x00000000,
1122 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x006d6173, 0x31786574,
1123 0x78657400, 0x31630032, 0x00326300, 0x000000ca, 0x00000003, 0x00000100, 0x00000030, 0x00000000,
1124 0x00000000, 0x000000cd, 0x00000001, 0x00000184, 0x00000010, 0x00000000, 0x00000000, 0x00000148,
1125 0x00000000, 0x00000004, 0x00000002, 0x0000014c, 0x00000000, 0x0000015c, 0x00000010, 0x00000014,
1126 0x00000002, 0x00000160, 0x00000000, 0x00000170, 0x00000024, 0x00000004, 0x00000000, 0x00000174,
1127 0x00000000, 0xabab0078, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0xabab0079, 0x00030000,
1128 0x00010001, 0x00000002, 0x00000000, 0xabab007a, 0x00020000, 0x00010001, 0x00000000, 0x00000000,
1129 0x0000019c, 0x00000000, 0x00000004, 0x00000002, 0x0000014c, 0x00000000, 0x694d0074, 0x736f7263,
1130 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43, 0x72656c69, 0x2e303120,
1131 0xabab0031, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
1132 0x00000003, 0x00000000, 0x00000303, 0x43584554, 0x44524f4f, 0xababab00, 0x4e47534f, 0x0000002c,
1133 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
1134 0x745f7673, 0x65677261, 0xabab0074, 0x52444853, 0x000001c0, 0x00000040, 0x00000070, 0x04000059,
1135 0x00208e46, 0x00000000, 0x00000003, 0x04000059, 0x00208e46, 0x00000001, 0x00000001, 0x0300005a,
1136 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000,
1137 0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555, 0x03001062, 0x00101032,
1138 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2,
1139 0x00000000, 0x00101046, 0x00000000, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045,
1140 0x001000f2, 0x00000001, 0x00101046, 0x00000000, 0x00107e46, 0x00000001, 0x00106000, 0x00000000,
1141 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, 0x09000045,
1142 0x001000f2, 0x00000001, 0x00101046, 0x00000000, 0x00107e46, 0x00000002, 0x00106000, 0x00000000,
1143 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, 0x08000000,
1144 0x00100082, 0x00000000, 0x0010003a, 0x00000000, 0x0020800a, 0x00000000, 0x00000001, 0x08000000,
1145 0x00100082, 0x00000000, 0x0010003a, 0x00000000, 0x0020800a, 0x00000000, 0x00000002, 0x08000000,
1146 0x00102082, 0x00000000, 0x0010003a, 0x00000000, 0x0020800a, 0x00000001, 0x00000000, 0x08000000,
1147 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x05000036,
1148 0x00102062, 0x00000000, 0x00100656, 0x00000000, 0x0100003e, 0x54415453, 0x00000074, 0x0000000b,
1149 0x00000002, 0x00000000, 0x00000002, 0x00000006, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
1150 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000,
1151 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1152 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1155 static const D3D12_SHADER_INPUT_BIND_DESC test_reflection_bound_resources_result[] =
1157 {"sam", D3D_SIT_SAMPLER, 0, 1, 0, 0, D3D_SRV_DIMENSION_UNKNOWN, 0},
1158 {"tex1", D3D_SIT_TEXTURE, 0, 2, 12, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, 0xffffffff},
1159 {"tex2", D3D_SIT_TEXTURE, 2, 1, 12, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, 0xffffffff, 0, 2},
1160 {"c1", D3D_SIT_CBUFFER, 0, 1, 0, 0, D3D_SRV_DIMENSION_UNKNOWN, 0},
1161 {"c2", D3D_SIT_CBUFFER, 1, 1, 0, 0, D3D_SRV_DIMENSION_UNKNOWN, 0, 0, 1},
1164 static void test_reflection_bound_resources(const DWORD *blob, const D3D12_SHADER_INPUT_BIND_DESC *result,
1165 unsigned int result_count, unsigned int target_version)
1167 ID3D12ShaderReflection *ref12 = NULL, *ref12_from_d3d11 = NULL, *ref11_from_d3d12 = NULL;
1168 const D3D12_SHADER_INPUT_BIND_DESC *pdesc;
1169 D3D12_SHADER_INPUT_BIND_DESC desc12;
1170 D3D11_SHADER_INPUT_BIND_DESC desc11;
1171 ID3D11ShaderReflection *ref11;
1172 HRESULT hr, expected_hr;
1173 unsigned int i;
1174 UINT expected;
1175 ULONG count;
1177 hr = call_reflect(blob, blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
1179 expected_hr = D3D_COMPILER_VERSION < 47 && target_version >= 0x501 ? E_INVALIDARG : S_OK;
1181 /* Older d3dcompiler_47 does not support sm5.1. */
1182 ok(hr == expected_hr || broken(hr == E_INVALIDARG && target_version >= 0x501),
1183 "Got unexpected hr %#lx, expected %#lx.\n", hr, expected_hr);
1185 if (hr == E_INVALIDARG)
1186 return;
1188 #if D3D_COMPILER_VERSION
1189 call_reflect(blob, blob[6], &IID_ID3D12ShaderReflection, (void **)&ref12);
1190 ref11->lpVtbl->QueryInterface(ref11, &IID_ID3D12ShaderReflection, (void **)&ref12_from_d3d11);
1191 ok((!ref12 && !ref12_from_d3d11) || (ref12 && ref12_from_d3d11), "Got unexpected interfaces %p, %p.\n",
1192 ref12, ref12_from_d3d11);
1194 if (ref12)
1196 ok(ref12 != (void *)ref11, "Got unexpected interfaces %p, %p.\n", ref11, ref12);
1197 ok(ref12_from_d3d11 == (void *)ref11, "Got unexpected interfaces %p, %p.\n",
1198 ref11, ref12_from_d3d11);
1199 ref12->lpVtbl->QueryInterface(ref12, &IID_ID3D11ShaderReflection, (void **)&ref11_from_d3d12);
1200 ok(!!ref11_from_d3d12, "Got zero interface.\n");
1202 #endif
1204 /* check invalid cases */
1205 hr = ref11->lpVtbl->GetResourceBindingDesc(ref11, 0, NULL);
1206 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
1208 hr = ref11->lpVtbl->GetResourceBindingDesc(ref11, 0xffffffff, &desc11);
1209 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
1211 #if D3D_COMPILER_VERSION
1212 hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, NULL, &desc11);
1213 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
1215 hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, "sam", NULL);
1216 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
1218 hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, "invalid", NULL);
1219 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
1221 hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, "invalid", &desc11);
1222 ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
1223 #endif
1225 /* GetResourceBindingDesc */
1226 for (i = 0; i < result_count; ++i)
1228 pdesc = &result[i];
1230 hr = ref11->lpVtbl->GetResourceBindingDesc(ref11, i, &desc11);
1231 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1233 ok(!strcmp(desc11.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc11.Name, i);
1234 ok(desc11.Type == pdesc->Type, "Got unexpected Type %#x, i %u.\n", desc11.Type, i);
1235 ok(desc11.BindPoint == pdesc->BindPoint, "Got unexpected BindPoint %u, i %u.\n", desc11.BindPoint, i);
1236 ok(desc11.BindCount == pdesc->BindCount, "Got unexpected BindCount %u, i %u.\n", desc11.BindCount, i);
1237 #if D3D_COMPILER_VERSION
1238 expected = pdesc->uFlags;
1239 #else
1240 expected = 0;
1241 todo_wine_if(pdesc->uFlags)
1242 #endif
1243 ok(desc11.uFlags == expected, "Got unexpected uFlags %#x, i %u.\n", desc11.uFlags, i);
1244 ok(desc11.ReturnType == pdesc->ReturnType, "Got unexpected ReturnType %#x, i %u.\n", desc11.ReturnType, i);
1245 ok(desc11.Dimension == pdesc->Dimension, "Got unexpected Dimension %#x, i %u.\n", desc11.Dimension, i);
1246 ok(desc11.NumSamples == pdesc->NumSamples, "Got unexpected NumSamples %u, i %u.\n", desc11.NumSamples, i);
1248 if (ref12)
1250 memset(&desc12, 0, sizeof(desc12));
1251 desc12.Space = 0xdeadbeef;
1252 desc12.uID = 0xdeadbeef;
1254 hr = ref12->lpVtbl->GetResourceBindingDesc(ref12, i, &desc12);
1255 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1257 ok(!strcmp(desc12.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc12.Name, i);
1258 ok(!memcmp(&desc12.Type, &desc11.Type, sizeof(desc11) - offsetof(D3D11_SHADER_INPUT_BIND_DESC, Type)),
1259 "D3D11 and D3D12 descs do not match.\n");
1260 ok(desc12.Space == pdesc->Space, "Got unexpected Space %u, i %u.\n", desc12.Space, i);
1261 ok(desc12.uID == pdesc->uID, "Got unexpected uID %#x, i %u.\n", desc12.uID, i);
1263 memset(&desc12, 0, sizeof(desc12));
1264 desc12.Space = 0xdeadbeef;
1265 desc12.uID = 0xdeadbeef;
1266 hr = ref12_from_d3d11->lpVtbl->GetResourceBindingDesc(ref12_from_d3d11, i, &desc12);
1267 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1269 ok(!strcmp(desc12.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc12.Name, i);
1270 ok(!memcmp(&desc12.Type, &desc11.Type, sizeof(desc11) - offsetof(D3D11_SHADER_INPUT_BIND_DESC, Type)),
1271 "D3D11 and D3D12 descs do not match.\n");
1272 /* Native d3dcompiler_47 returns the same interface pointer when queried for ID3D12ShaderReflection
1273 * from ID3D11ShaderReflection. Space field still gets the correct value on x64 due to
1274 * D3D11_SHADER_INPUT_BIND_DESC padding. */
1275 expected = offsetof(D3D12_SHADER_INPUT_BIND_DESC, Space) < sizeof(D3D11_SHADER_INPUT_BIND_DESC)
1276 ? pdesc->Space : 0xdeadbeef;
1277 ok(desc12.Space == expected, "Got unexpected Space %u, i %u.\n",
1278 desc12.Space, i);
1279 ok(desc12.uID == 0xdeadbeef, "Got unexpected uID %#x, i %u.\n", desc12.uID, i);
1281 memset(&desc12, 0, sizeof(desc12));
1282 desc12.Space = 0xdeadbeef;
1283 desc12.uID = 0xdeadbeef;
1284 hr = ref11_from_d3d12->lpVtbl->GetResourceBindingDesc(ref11_from_d3d12, i, &desc12);
1285 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1286 ok(!strcmp(desc12.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc12.Name, i);
1287 ok(!memcmp(&desc12.Type, &desc11.Type, sizeof(desc11) - offsetof(D3D11_SHADER_INPUT_BIND_DESC, Type)),
1288 "D3D11 and D3D12 descs do not match.\n");
1289 ok(desc12.Space == pdesc->Space, "Got unexpected Space %u, i %u.\n", desc12.Space, i);
1290 ok(desc12.uID == pdesc->uID, "Got unexpected uID %#x, i %u.\n", desc12.uID, i);
1294 #if D3D_COMPILER_VERSION
1295 /* GetResourceBindingDescByName */
1296 for (i = 0; i < result_count; ++i)
1298 pdesc = &result[i];
1300 hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, pdesc->Name, &desc11);
1301 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1303 ok(!strcmp(desc11.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc11.Name, i);
1304 ok(desc11.Type == pdesc->Type, "Got unexpected Type %#x, i %u.\n", desc11.Type, i);
1305 ok(desc11.BindPoint == pdesc->BindPoint, "Got unexpected BindPoint %u, i %u.\n", desc11.BindPoint, i);
1306 ok(desc11.BindCount == pdesc->BindCount, "Got unexpected BindCount failed %u, i %u.\n", desc11.BindCount, i);
1307 ok(desc11.uFlags == pdesc->uFlags, "Got unexpected uFlags %#x, i %u.\n", desc11.uFlags, i);
1308 ok(desc11.ReturnType == pdesc->ReturnType, "Got unexpected ReturnType %#x, i %u.\n", desc11.ReturnType, i);
1309 ok(desc11.Dimension == pdesc->Dimension, "Got unexpected Dimension %#x, i %u.\n", desc11.Dimension, i);
1310 ok(desc11.NumSamples == pdesc->NumSamples, "Got unexpected NumSamples %u, i %u.\n", desc11.NumSamples, i);
1312 if (ref12)
1314 memset(&desc12, 0, sizeof(desc12));
1315 desc12.Space = 0xdeadbeef;
1316 desc12.uID = 0xdeadbeef;
1318 hr = ref12->lpVtbl->GetResourceBindingDescByName(ref12, pdesc->Name, &desc12);
1319 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1321 ok(!strcmp(desc12.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc12.Name, i);
1322 ok(!memcmp(&desc12.Type, &desc11.Type, sizeof(desc11) - offsetof(D3D11_SHADER_INPUT_BIND_DESC, Type)),
1323 "D3D11 and D3D12 descs do not match.\n");
1324 ok(desc12.Space == pdesc->Space, "Got unexpected Space %u, i %u.\n", desc12.Space, i);
1325 ok(desc12.uID == pdesc->uID, "Got unexpected uID %#x, i %u.\n", desc12.uID, i);
1327 memset(&desc12, 0, sizeof(desc12));
1328 desc12.Space = 0xdeadbeef;
1329 desc12.uID = 0xdeadbeef;
1330 hr = ref12_from_d3d11->lpVtbl->GetResourceBindingDescByName(ref12_from_d3d11, pdesc->Name, &desc12);
1331 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1333 ok(!strcmp(desc12.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc12.Name, i);
1334 ok(!memcmp(&desc12.Type, &desc11.Type, sizeof(desc11) - offsetof(D3D11_SHADER_INPUT_BIND_DESC, Type)),
1335 "D3D11 and D3D12 descs do not match.\n");
1336 expected = offsetof(D3D12_SHADER_INPUT_BIND_DESC, Space) < sizeof(D3D11_SHADER_INPUT_BIND_DESC)
1337 ? pdesc->Space : 0xdeadbeef;
1338 ok(desc12.Space == expected, "Got unexpected Space %u, i %u.\n",
1339 desc12.Space, i);
1340 ok(desc12.uID == 0xdeadbeef, "Got unexpected uID %#x, i %u.\n", desc12.uID, i);
1342 memset(&desc12, 0, sizeof(desc12));
1343 desc12.Space = 0xdeadbeef;
1344 desc12.uID = 0xdeadbeef;
1345 hr = ref11_from_d3d12->lpVtbl->GetResourceBindingDescByName(ref11_from_d3d12, pdesc->Name, &desc12);
1346 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1347 ok(!strcmp(desc12.Name, pdesc->Name), "Got unexpected Name \"%s\", i %u.\n", desc12.Name, i);
1348 ok(!memcmp(&desc12.Type, &desc11.Type, sizeof(desc11) - offsetof(D3D11_SHADER_INPUT_BIND_DESC, Type)),
1349 "D3D11 and D3D12 descs do not match.\n");
1350 ok(desc12.Space == pdesc->Space, "Got unexpected Space %u, i %u.\n", desc12.Space, i);
1351 ok(desc12.uID == pdesc->uID, "Got unexpected uID %#x, i %u.\n", desc12.uID, i);
1354 #endif
1356 if (ref12)
1358 count = ref11_from_d3d12->lpVtbl->Release(ref11_from_d3d12);
1359 ok(count == 1, "Got unexpected ref count %lu.\n", count);
1361 count = ref12->lpVtbl->Release(ref12);
1362 ok(!count, "Got unexpected ref count %lu.\n", count);
1364 count = ref12_from_d3d11->lpVtbl->Release(ref12_from_d3d11);
1365 ok(count == 1, "Got unexpected ref count %lu.\n", count);
1368 count = ref11->lpVtbl->Release(ref11);
1369 ok(!count, "Got unexpected ref count %lu.\n", count);
1372 #if D3D_COMPILER_VERSION
1374 * fxc.exe /E PS /Tps_5_0 /Fx
1376 #if 0
1377 cbuffer c1
1379 float a;
1380 float b[2];
1381 int i;
1382 struct s {
1383 float a;
1384 float b;
1385 } t;
1388 interface iTest
1390 float4 test(float2 vec);
1393 class cTest : iTest
1395 bool m_on;
1396 float4 test(float2 vec);
1399 float4 cTest::test(float2 vec)
1401 float4 res;
1402 if(m_on)
1403 res = float4(vec.x, vec.y, vec.x+vec.y, 0);
1404 else
1405 res = 0;
1406 return res;
1409 iTest g_Test;
1412 float4 PS(float2 uv : TEXCOORD0) : sv_target
1414 float4 q = g_Test.test(uv);
1415 q.x = q.x + t.a;
1416 return q;
1418 #endif
1419 static DWORD test_reflection_constant_buffer_blob[] = {
1420 0x43425844, 0xe6470e0d, 0x0d5698bb, 0x29373c30, 0x64a5d268, 0x00000001, 0x00000590, 0x00000006,
1421 0x00000038, 0x00000318, 0x0000034c, 0x00000380, 0x000003d8, 0x000004f4, 0x46454452, 0x000002d8,
1422 0x00000002, 0x00000060, 0x00000001, 0x0000003c, 0xffff0500, 0x00000100, 0x000002a4, 0x31314452,
1423 0x0000003c, 0x00000018, 0x00000020, 0x00000028, 0x00000024, 0x0000000c, 0x00000001, 0x0000005c,
1424 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0xab003163,
1425 0x00000090, 0x00000001, 0x000000a0, 0x00000010, 0x00000000, 0x00000002, 0x0000005c, 0x00000004,
1426 0x00000120, 0x00000040, 0x00000000, 0x00000000, 0x69685424, 0x696f5073, 0x7265746e, 0xababab00,
1427 0x000000c8, 0x00000000, 0x00000001, 0x00000006, 0x000000fc, 0x00000000, 0xffffffff, 0x00000000,
1428 0xffffffff, 0x00000000, 0x65545f67, 0x69007473, 0x74736554, 0xababab00, 0x00000006, 0x00000001,
1429 0x00000000, 0x000000d8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000cf, 0x00250007,
1430 0x00040001, 0x00000000, 0x00000000, 0x000000d8, 0x00000000, 0x00000000, 0x00000000, 0x000000cf,
1431 0x000001c0, 0x00000000, 0x00000004, 0x00000000, 0x000001c8, 0x00000000, 0xffffffff, 0x00000000,
1432 0xffffffff, 0x00000000, 0x000001ec, 0x00000010, 0x00000014, 0x00000000, 0x000001f0, 0x00000000,
1433 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0x00000214, 0x00000024, 0x00000004, 0x00000000,
1434 0x0000021c, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0x00000240, 0x00000030,
1435 0x00000008, 0x00000002, 0x00000280, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000,
1436 0x6c660061, 0x0074616f, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1437 0x00000000, 0x00000000, 0x000001c2, 0xabab0062, 0x00030000, 0x00010001, 0x00000002, 0x00000000,
1438 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000001c2, 0x6e690069, 0xabab0074, 0x00020000,
1439 0x00010001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000216,
1440 0x00730074, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1441 0x00000000, 0x000001c2, 0x000001c0, 0x00000244, 0x00000000, 0x000001ec, 0x00000244, 0x00000004,
1442 0x00000005, 0x00020001, 0x00020000, 0x00000268, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1443 0x00000242, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072,
1444 0x6c69706d, 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x0000002c,
1445 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303,
1446 0x43584554, 0x44524f4f, 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
1447 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x745f7673, 0x65677261, 0xabab0074,
1448 0x45434649, 0x00000050, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000040, 0x00000034,
1449 0x00000024, 0x00000000, 0x4e47534f, 0x00000001, 0x00000001, 0x00000040, 0x00000044, 0x00000048,
1450 0x00010000, 0x00000000, 0xabab0000, 0x00000000, 0x73655463, 0xabab0074, 0x58454853, 0x00000114,
1451 0x00000050, 0x00000045, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000004, 0x03000091,
1452 0x00000000, 0x00000000, 0x05000092, 0x00000000, 0x00000000, 0x00010001, 0x00000000, 0x03001062,
1453 0x00101032, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x07000000,
1454 0x00100042, 0x00000000, 0x0010101a, 0x00000000, 0x0010100a, 0x00000000, 0x05000036, 0x00100032,
1455 0x00000000, 0x00101046, 0x00000000, 0x05000036, 0x00100082, 0x00000000, 0x00004001, 0x00000000,
1456 0x05000036, 0x00100032, 0x00000001, 0x0011d516, 0x00000000, 0x0a000001, 0x001000f2, 0x00000000,
1457 0x00100e46, 0x00000000, 0x04a08006, 0x0010001a, 0x00000001, 0x0010000a, 0x00000001, 0x08000000,
1458 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0020800a, 0x00000000, 0x00000003, 0x05000036,
1459 0x001020e2, 0x00000000, 0x00100e56, 0x00000000, 0x0100003e, 0x54415453, 0x00000094, 0x00000008,
1460 0x00000002, 0x00000000, 0x00000002, 0x00000002, 0x00000000, 0x00000001, 0x00000001, 0x00000000,
1461 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1462 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1463 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1464 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1467 static const D3D11_SHADER_BUFFER_DESC test_reflection_constant_buffer_cb_result[] =
1469 {"$ThisPointer", D3D_CT_INTERFACE_POINTERS, 1, 16, 0},
1470 {"c1", D3D_CT_CBUFFER, 4, 64, 0},
1473 static const struct
1475 D3D11_SHADER_VARIABLE_DESC desc;
1476 unsigned int type;
1477 } test_reflection_constant_buffer_variable_result[] =
1479 {{"g_Test", 0, 1, 6, 0}, 0},
1480 {{"a", 0, 4, 0, 0}, 1},
1481 {{"b", 16, 20, 0, 0}, 2},
1482 {{"i", 36, 4, 0, 0}, 3},
1483 {{"t", 48, 8, 2, 0}, 4},
1486 #else
1488 * fxc.exe /E PS /Tps_4_0 /Fx
1490 #if 0
1491 cbuffer c1
1493 float a;
1494 float b[2];
1495 int i;
1496 struct s {
1497 float a;
1498 float b;
1499 } t;
1502 class cTest
1504 bool m_on;
1505 float4 test(float2 vec);
1508 float4 cTest::test(float2 vec)
1510 float4 res;
1511 if(m_on)
1512 res = float4(vec.x, vec.y, vec.x+vec.y, 0);
1513 else
1514 res = 0;
1515 return res;
1518 cTest g_Test;
1521 float4 PS(float2 uv : TEXCOORD0) : sv_target
1523 float4 q = g_Test.test(uv);
1524 q.x = q.x + t.a;
1525 return q;
1527 #endif
1528 static DWORD test_reflection_constant_buffer_blob[] = {
1529 0x43425844, 0x0241ca0a, 0xa3bf8da0, 0xdd5f853e, 0xfe868252, 0x00000001, 0x00000414, 0x00000005,
1530 0x00000034, 0x00000230, 0x00000264, 0x00000298, 0x00000398, 0x46454452, 0x000001f4, 0x00000002,
1531 0x00000068, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100, 0x000001c0, 0x0000005c, 0x00000000,
1532 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000065, 0x00000000,
1533 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000000, 0x6f6c4724, 0x736c6162,
1534 0x00316300, 0x0000005c, 0x00000001, 0x00000098, 0x00000010, 0x00000000, 0x00000000, 0x00000065,
1535 0x00000004, 0x000000e8, 0x00000040, 0x00000000, 0x00000000, 0x000000b0, 0x00000000, 0x00000004,
1536 0x00000002, 0x000000d8, 0x00000000, 0x65545f67, 0x6d007473, 0x006e6f5f, 0x00010000, 0x00010001,
1537 0x00000000, 0x00000000, 0x000000b7, 0x000000bc, 0x00000000, 0x00000005, 0x00010001, 0x00010000,
1538 0x000000cc, 0x00000148, 0x00000000, 0x00000004, 0x00000000, 0x0000014c, 0x00000000, 0x0000015c,
1539 0x00000010, 0x00000014, 0x00000000, 0x00000160, 0x00000000, 0x00000170, 0x00000024, 0x00000004,
1540 0x00000000, 0x00000174, 0x00000000, 0x00000184, 0x00000030, 0x00000008, 0x00000002, 0x000001b0,
1541 0x00000000, 0xabab0061, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0xabab0062, 0x00030000,
1542 0x00010001, 0x00000002, 0x00000000, 0xabab0069, 0x00020000, 0x00010001, 0x00000000, 0x00000000,
1543 0xabab0074, 0x00030000, 0x00010001, 0x00000000, 0x00000000, 0x00000148, 0x00000188, 0x00000000,
1544 0x0000015c, 0x00000188, 0x00000004, 0x00000005, 0x00020001, 0x00020000, 0x00000198, 0x7263694d,
1545 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265,
1546 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008,
1547 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x43584554, 0x44524f4f,
1548 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
1549 0x00000003, 0x00000000, 0x0000000f, 0x745f7673, 0x65677261, 0xabab0074, 0x52444853, 0x000000f8,
1550 0x00000040, 0x0000003e, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x04000059, 0x00208e46,
1551 0x00000001, 0x00000004, 0x03001062, 0x00101032, 0x00000000, 0x03000065, 0x001020f2, 0x00000000,
1552 0x02000068, 0x00000001, 0x07000000, 0x00100042, 0x00000000, 0x0010101a, 0x00000000, 0x0010100a,
1553 0x00000000, 0x05000036, 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x05000036, 0x00100082,
1554 0x00000000, 0x00004001, 0x00000000, 0x0d000037, 0x001000f2, 0x00000000, 0x00208006, 0x00000000,
1555 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1556 0x08000000, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x0020800a, 0x00000001, 0x00000003,
1557 0x05000036, 0x001020e2, 0x00000000, 0x00100e56, 0x00000000, 0x0100003e, 0x54415453, 0x00000074,
1558 0x00000007, 0x00000001, 0x00000000, 0x00000002, 0x00000002, 0x00000000, 0x00000000, 0x00000001,
1559 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1560 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
1561 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1564 static const D3D11_SHADER_BUFFER_DESC test_reflection_constant_buffer_cb_result[] =
1566 {"$Globals", D3D_CT_CBUFFER, 1, 16, 0},
1567 {"c1", D3D_CT_CBUFFER, 4, 64, 0},
1570 static const struct
1572 D3D11_SHADER_VARIABLE_DESC desc;
1573 unsigned int type;
1574 } test_reflection_constant_buffer_variable_result[] =
1576 {{"a", 0, 4, 0, 0}, 1},
1577 {{"b", 16, 20, 0, 0}, 2},
1578 {{"i", 36, 4, 0, 0}, 3},
1579 {{"t", 48, 8, 2, 0}, 4},
1582 #endif
1584 static const D3D11_SHADER_TYPE_DESC test_reflection_constant_buffer_type_result[] =
1586 {D3D11_SVC_INTERFACE_POINTER, D3D11_SVT_INTERFACE_POINTER, 1, 4, 0, 1, 0, "iTest"},
1587 {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 1, 0, "float"},
1588 {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 2, 1, 0, "float"},
1589 {D3D_SVC_SCALAR, D3D_SVT_INT, 1, 1, 0, 1, 0, "int"},
1590 {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 2, 0, 1, 0, "s"},
1593 static void test_reflection_constant_buffer(void)
1595 ID3D12ShaderReflectionType *t12, *mt12, *mt12_2, *t12_dummy = NULL, *t12_valid = NULL;
1596 ID3D12ShaderReflectionConstantBuffer *cb12, *cb12_dummy = NULL, *cb12_valid = NULL;
1597 ID3D11ShaderReflectionConstantBuffer *cb11, *cb11_dummy = NULL, *cb11_valid = NULL;
1598 ID3D11ShaderReflectionType *t11, *t, *t2, *t11_dummy = NULL, *t11_valid = NULL;
1599 ID3D12ShaderReflectionVariable *v12, *v12_dummy = NULL, *v12_valid = NULL;
1600 ID3D11ShaderReflectionVariable *v11, *v11_dummy = NULL, *v11_valid = NULL;
1601 D3D12_SHADER_VARIABLE_DESC vdesc12 = {0};
1602 const D3D11_SHADER_VARIABLE_DESC *pvdesc;
1603 const D3D11_SHADER_BUFFER_DESC *pcbdesc;
1604 D3D12_SHADER_BUFFER_DESC cbdesc12 = {0};
1605 D3D11_SHADER_VARIABLE_DESC vdesc = {0};
1606 D3D11_SHADER_BUFFER_DESC cbdesc = {0};
1607 ID3D12ShaderReflection *ref12 = NULL;
1608 const D3D11_SHADER_TYPE_DESC *ptdesc;
1609 D3D12_SHADER_TYPE_DESC tdesc12 = {0};
1610 D3D11_SHADER_TYPE_DESC tdesc = {0};
1611 ID3D11ShaderReflection *ref11;
1612 D3D11_SHADER_DESC sdesc = {0};
1613 unsigned int i, expected;
1614 LPCSTR string;
1615 ULONG count;
1616 HRESULT hr;
1618 hr = call_reflect(test_reflection_constant_buffer_blob, test_reflection_constant_buffer_blob[6],
1619 &IID_ID3D11ShaderReflection, (void **)&ref11);
1620 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
1622 #if D3D_COMPILER_VERSION
1623 call_reflect(test_reflection_constant_buffer_blob, test_reflection_constant_buffer_blob[6],
1624 &IID_ID3D12ShaderReflection, (void **)&ref12);
1625 #endif
1627 hr = ref11->lpVtbl->GetDesc(ref11, &sdesc);
1628 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
1630 expected = D3D_COMPILER_VERSION ? 80 : 64;
1631 ok(sdesc.Version == expected, "Got unexpected version %u.\n", sdesc.Version);
1632 ok(strcmp(sdesc.Creator, (char*) shader_creator) == 0, "GetDesc failed, got \"%s\", expected \"%s\"\n", sdesc.Creator, (char*)shader_creator);
1633 ok(sdesc.Flags == 256, "GetDesc failed, got %u, expected %u\n", sdesc.Flags, 256);
1634 ok(sdesc.ConstantBuffers == 2, "GetDesc failed, got %u, expected %u\n", sdesc.ConstantBuffers, 2);
1635 expected = D3D_COMPILER_VERSION ? 1 : 2;
1636 ok(sdesc.BoundResources == expected, "Got unexpected BoundResources %u.\n", sdesc.BoundResources);
1637 ok(sdesc.InputParameters == 1, "GetDesc failed, got %u, expected %u\n", sdesc.InputParameters, 1);
1638 ok(sdesc.OutputParameters == 1, "GetDesc failed, got %u, expected %u\n", sdesc.OutputParameters, 1);
1639 expected = D3D_COMPILER_VERSION ? 8 : 7;
1640 ok(sdesc.InstructionCount == expected, "Got unexpected InstructionCount %u.\n", sdesc.InstructionCount);
1641 expected = D3D_COMPILER_VERSION ? 2 : 1;
1642 ok(sdesc.TempRegisterCount == expected, "Got unexpected TempRegisterCount %u.\n", sdesc.TempRegisterCount);
1643 ok(sdesc.TempArrayCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TempArrayCount, 0);
1644 ok(sdesc.DefCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.DefCount, 0);
1645 ok(sdesc.DclCount == 2, "GetDesc failed, got %u, expected %u\n", sdesc.DclCount, 2);
1646 ok(sdesc.TextureNormalInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TextureNormalInstructions, 0);
1647 ok(sdesc.TextureLoadInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TextureLoadInstructions, 0);
1648 ok(sdesc.TextureCompInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TextureCompInstructions, 0);
1649 ok(sdesc.TextureBiasInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TextureBiasInstructions, 0);
1650 ok(sdesc.TextureGradientInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.TextureGradientInstructions, 0);
1651 ok(sdesc.FloatInstructionCount == 2, "GetDesc failed, got %u, expected %u\n", sdesc.FloatInstructionCount, 2);
1652 ok(sdesc.IntInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.IntInstructionCount, 0);
1653 expected = D3D_COMPILER_VERSION ? 1 : 0;
1654 ok(sdesc.UintInstructionCount == expected, "Got unexpected UintInstructionCount %u.\n",
1655 sdesc.UintInstructionCount);
1656 ok(sdesc.StaticFlowControlCount == 1, "GetDesc failed, got %u, expected %u\n", sdesc.StaticFlowControlCount, 1);
1657 ok(sdesc.DynamicFlowControlCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.DynamicFlowControlCount, 0);
1658 ok(sdesc.MacroInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.MacroInstructionCount, 0);
1659 ok(sdesc.ArrayInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.ArrayInstructionCount, 0);
1660 ok(sdesc.CutInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.CutInstructionCount, 0);
1661 ok(sdesc.EmitInstructionCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.EmitInstructionCount, 0);
1662 ok(sdesc.GSOutputTopology == 0, "GetDesc failed, got %x, expected %x\n", sdesc.GSOutputTopology, 0);
1663 ok(sdesc.GSMaxOutputVertexCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.GSMaxOutputVertexCount, 0);
1664 ok(sdesc.InputPrimitive == 0, "GetDesc failed, got %x, expected %x\n", sdesc.InputPrimitive, 0);
1665 ok(sdesc.PatchConstantParameters == 0, "GetDesc failed, got %u, expected %u\n", sdesc.PatchConstantParameters, 0);
1666 ok(sdesc.cGSInstanceCount == 0, "GetDesc failed, got %u, expected %u\n", sdesc.cGSInstanceCount, 0);
1667 ok(sdesc.cControlPoints == 0, "GetDesc failed, got %u, expected %u\n", sdesc.cControlPoints, 0);
1668 ok(sdesc.HSOutputPrimitive == 0, "GetDesc failed, got %x, expected %x\n", sdesc.HSOutputPrimitive, 0);
1669 ok(sdesc.HSPartitioning == 0, "GetDesc failed, got %x, expected %x\n", sdesc.HSPartitioning, 0);
1670 ok(sdesc.TessellatorDomain == 0, "GetDesc failed, got %x, expected %x\n", sdesc.TessellatorDomain, 0);
1671 ok(sdesc.cBarrierInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.cBarrierInstructions, 0);
1672 ok(sdesc.cInterlockedInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.cInterlockedInstructions, 0);
1673 ok(sdesc.cTextureStoreInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc.cTextureStoreInstructions, 0);
1675 /* get the dummys for comparison */
1676 cb11_dummy = ref11->lpVtbl->GetConstantBufferByIndex(ref11, 0xffffffff);
1677 ok(!!cb11_dummy, "Got unexpected buffer %p.\n", cb11_dummy);
1679 if (ref12)
1681 cb12_dummy = ref12->lpVtbl->GetConstantBufferByIndex(ref12, 0xffffffff);
1682 ok(!!cb12_dummy, "Got unexpected buffer %p.\n", cb12_dummy);
1683 ok(cb12_dummy == (void *)cb11_dummy, "Got unexpected buffer %p.\n", cb12_dummy);
1685 v12_dummy = cb12_dummy->lpVtbl->GetVariableByIndex(cb12_dummy, 0xffffffff);
1686 ok(!!v12_dummy, "Got unexpected NULL variable.\n");
1688 v11_dummy = cb11_dummy->lpVtbl->GetVariableByIndex(cb11_dummy, 0xffffffff);
1689 ok(!!v11_dummy, "Got unexpected NULL variable.\n");
1691 t11_dummy = v11_dummy->lpVtbl->GetType(v11_dummy);
1692 ok(!!t11_dummy, "Got NULL type.\n");
1694 /* get the valid variables */
1695 cb11_valid = ref11->lpVtbl->GetConstantBufferByIndex(ref11, 1);
1696 ok(cb11_valid != cb11_dummy && cb11_valid, "Got unexpected buffer %p.\n", cb11_valid);
1697 if (ref12)
1699 cb12_valid = ref12->lpVtbl->GetConstantBufferByIndex(ref12, 1);
1700 ok(cb12_valid != cb12_dummy && cb12_valid, "Got unexpected buffer %p.\n", cb11_valid);
1701 ok(cb12_valid != (void *)cb11_valid, "Got unexpected buffer %p.\n", cb12_valid);
1703 v12_valid = cb12_valid->lpVtbl->GetVariableByIndex(cb12_valid, 0);
1704 ok(v12_valid != v12_dummy && v12_valid, "Got unexpected variable %p.\n", v12_valid);
1706 t12_dummy = v12_dummy->lpVtbl->GetType(v12_dummy);
1707 ok(!!t12_dummy, "Got NULL type.\n");
1709 t12_valid = v12_valid->lpVtbl->GetType(v12_valid);
1710 ok(t12_valid != t12_dummy && t12_valid, "GetType failed\n");
1713 v11_valid = cb11_valid->lpVtbl->GetVariableByIndex(cb11_valid, 0);
1714 ok(v11_valid != v11_dummy && v11_valid, "Got unexpected variable %p.\n", v11_valid);
1716 t11_valid = v11_valid->lpVtbl->GetType(v11_valid);
1717 ok(t11_valid != t11_dummy && t11_valid, "GetType failed\n");
1719 /* reflection calls */
1720 cb11 = ref11->lpVtbl->GetConstantBufferByName(ref11, "invalid");
1721 ok(cb11_dummy == cb11, "GetConstantBufferByName failed, got %p, expected %p\n", cb11, cb11_dummy);
1723 cb11 = ref11->lpVtbl->GetConstantBufferByName(ref11, NULL);
1724 ok(cb11_dummy == cb11, "GetConstantBufferByName failed, got %p, expected %p\n", cb11, cb11_dummy);
1726 #if D3D_COMPILER_VERSION
1727 v11 = ref11->lpVtbl->GetVariableByName(ref11, NULL);
1728 ok(v11_dummy == v11, "Got unexpected variable %p.\n", v11);
1730 v11 = ref11->lpVtbl->GetVariableByName(ref11, "invalid");
1731 ok(v11_dummy == v11, "Got unexpected variable %p.\n", v11);
1733 v11 = ref11->lpVtbl->GetVariableByName(ref11, "a");
1734 ok(v11_valid == v11, "Got unexpected variable %p.\n", v11);
1735 #endif
1737 /* constant buffer calls */
1738 v11 = cb11_dummy->lpVtbl->GetVariableByName(cb11_dummy, NULL);
1739 ok(v11_dummy == v11, "Got unexpected variable %p.\n", v11);
1741 v11 = cb11_dummy->lpVtbl->GetVariableByName(cb11_dummy, "invalid");
1742 ok(v11_dummy == v11, "Got unexpected variable %p.\n", v11);
1744 v11 = cb11_valid->lpVtbl->GetVariableByName(cb11_valid, NULL);
1745 ok(v11_dummy == v11, "Got unexpected variable %p.\n", v11);
1747 v11 = cb11_valid->lpVtbl->GetVariableByName(cb11_valid, "invalid");
1748 ok(v11_dummy == v11, "Got unexpected variable %p.\n", v11);
1750 v11 = cb11_valid->lpVtbl->GetVariableByName(cb11_valid, "a");
1751 ok(v11_valid == v11, "Got unexpected variable %p.\n", v11);
1753 if (ref12)
1755 v12 = cb12_valid->lpVtbl->GetVariableByName(cb12_valid, "a");
1756 ok(v12_valid == v12, "Got unexpected variable %p.\n", v12);
1759 hr = cb11_dummy->lpVtbl->GetDesc(cb11_dummy, NULL);
1760 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
1762 hr = cb11_dummy->lpVtbl->GetDesc(cb11_dummy, &cbdesc);
1763 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
1765 hr = cb11_valid->lpVtbl->GetDesc(cb11_valid, NULL);
1766 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
1768 /* variable calls */
1769 hr = v11_dummy->lpVtbl->GetDesc(v11_dummy, NULL);
1770 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
1772 hr = v11_dummy->lpVtbl->GetDesc(v11_dummy, &vdesc);
1773 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
1775 hr = v11_valid->lpVtbl->GetDesc(v11_valid, NULL);
1776 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
1778 /* type calls */
1779 hr = t11_dummy->lpVtbl->GetDesc(t11_dummy, NULL);
1780 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
1782 hr = t11_dummy->lpVtbl->GetDesc(t11_dummy, &tdesc);
1783 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
1785 hr = t11_valid->lpVtbl->GetDesc(t11_valid, NULL);
1786 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
1788 string = t11_dummy->lpVtbl->GetMemberTypeName(t11_dummy, 0xffffffff);
1789 ok(!strcmp(string, "$Invalid"), "GetMemberTypeName failed, got \"%s\", expected \"%s\"\n", string, "$Invalid");
1791 string = t11_valid->lpVtbl->GetMemberTypeName(t11_valid, 0xffffffff);
1792 ok(!string, "GetMemberTypeName failed, got \"%s\", expected NULL\n", string);
1794 t11 = t11_dummy->lpVtbl->GetMemberTypeByIndex(t11_dummy, 0xffffffff);
1795 ok(t11_dummy == t11, "GetMemberTypeByIndex failed, got %p, expected %p\n", t11, t11_dummy);
1797 t11 = t11_valid->lpVtbl->GetMemberTypeByIndex(t11_valid, 0xffffffff);
1798 ok(t11_dummy == t11, "GetMemberTypeByIndex failed, got %p, expected %p\n", t11, t11_dummy);
1800 t11 = t11_dummy->lpVtbl->GetMemberTypeByName(t11_dummy, NULL);
1801 ok(t11_dummy == t11, "GetMemberTypeByName failed, got %p, expected %p\n", t11, t11_dummy);
1803 t11 = t11_dummy->lpVtbl->GetMemberTypeByName(t11_dummy, "invalid");
1804 ok(t11_dummy == t11, "GetMemberTypeByName failed, got %p, expected %p\n", t11, t11_dummy);
1806 t11 = t11_valid->lpVtbl->GetMemberTypeByName(t11_valid, NULL);
1807 ok(t11_dummy == t11, "GetMemberTypeByName failed, got %p, expected %p\n", t11, t11_dummy);
1809 t11 = t11_valid->lpVtbl->GetMemberTypeByName(t11_valid, "invalid");
1810 ok(t11_dummy == t11, "GetMemberTypeByName failed, got %p, expected %p\n", t11, t11_dummy);
1812 #if D3D_COMPILER_VERSION
1813 hr = t11_dummy->lpVtbl->IsEqual(t11_dummy, t11_dummy);
1814 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
1816 hr = t11_valid->lpVtbl->IsEqual(t11_valid, t11_dummy);
1817 ok(hr == S_FALSE, "Got unexpected hr %#lx.\n", hr);
1819 hr = t11_dummy->lpVtbl->IsEqual(t11_dummy, t11_valid);
1820 ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
1822 hr = t11_valid->lpVtbl->IsEqual(t11_valid, t11_valid);
1823 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
1824 #endif
1826 /* constant buffers */
1827 for (i = 0; i < ARRAY_SIZE(test_reflection_constant_buffer_cb_result); ++i)
1829 pcbdesc = &test_reflection_constant_buffer_cb_result[i];
1831 cb11 = ref11->lpVtbl->GetConstantBufferByIndex(ref11, i);
1832 ok(cb11_dummy != cb11, "Got dummy constant buffer, i %u.\n", i);
1834 hr = cb11->lpVtbl->GetDesc(cb11, &cbdesc);
1835 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1837 ok(!strcmp(cbdesc.Name, pcbdesc->Name), "Got unexpected name \"%s\", i %u.\n", cbdesc.Name, i);
1838 ok(cbdesc.Type == pcbdesc->Type, "Got unexpected Type %#x, i %u.\n", cbdesc.Type, i);
1839 ok(cbdesc.Variables == pcbdesc->Variables, "Got unexpected Variables %u, i %u.\n", cbdesc.Variables, i);
1840 ok(cbdesc.Size == pcbdesc->Size, "Got unexpected Size %u, i %u.\n", cbdesc.Size, i);
1841 ok(cbdesc.uFlags == pcbdesc->uFlags, "Got unexpected uFlags %#x, i %u.\n", cbdesc.uFlags, i);
1843 if (ref12)
1845 cb12 = ref12->lpVtbl->GetConstantBufferByIndex(ref12, i);
1846 ok(cb12_dummy != cb12, "Got dummy constant buffer, i %u.\n", i);
1848 hr = cb12->lpVtbl->GetDesc(cb12, &cbdesc12);
1849 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1851 ok(!strcmp(cbdesc12.Name, pcbdesc->Name), "Got unexpected name \"%s\", i %u.\n", cbdesc.Name, i);
1852 ok(cbdesc.Type == pcbdesc->Type, "Got unexpected Type %#x, i %u.\n", cbdesc.Type, i);
1853 ok(!memcmp(&cbdesc12.Type, &cbdesc.Type, sizeof(cbdesc) - offsetof(D3D11_SHADER_BUFFER_DESC, Type)),
1854 "CB description does not match. i %u.\n", i);
1858 /* variables */
1859 for (i = 0; i < ARRAY_SIZE(test_reflection_constant_buffer_variable_result); ++i)
1861 pvdesc = &test_reflection_constant_buffer_variable_result[i].desc;
1863 if (D3D_COMPILER_VERSION)
1864 v11 = ref11->lpVtbl->GetVariableByName(ref11, pvdesc->Name);
1865 else
1866 v11 = cb11_valid->lpVtbl->GetVariableByName(cb11_valid, pvdesc->Name);
1867 ok(v11_dummy != v11, "Test %u, got unexpected variable %p.\n", i, v11);
1869 if (D3D_COMPILER_VERSION)
1871 vdesc.StartTexture = 0xdeadbeef;
1872 vdesc.TextureSize = 0xdeadbeef;
1873 vdesc.StartSampler = 0xdeadbeef;
1874 vdesc.SamplerSize = 0xdeadbeef;
1876 else
1878 vdesc.StartTexture = 0xffffffff;
1879 vdesc.StartSampler = 0xffffffff;
1882 hr = v11->lpVtbl->GetDesc(v11, &vdesc);
1883 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1885 ok(!strcmp(vdesc.Name, pvdesc->Name), "Got unexpected name \"%s\", i %u", vdesc.Name, i);
1886 ok(vdesc.StartOffset == pvdesc->StartOffset, "Got unexpected StartOffset %u, i %u.\n",
1887 vdesc.StartOffset, i);
1888 ok(vdesc.Size == pvdesc->Size, "Got unexpected Size %u, i %u.\n", vdesc.Size, i);
1889 ok(vdesc.uFlags == pvdesc->uFlags, "Got unexpected uFlags %#x, i %u.\n", vdesc.uFlags, i);
1890 ok(vdesc.DefaultValue == pvdesc->DefaultValue, "Got unexpected DefaultValue %p, i %u.\n",
1891 vdesc.DefaultValue, i);
1892 ok(vdesc.StartTexture == 0xffffffff, "Got unexpected StartTexture %#x, i %u.\n", vdesc.StartTexture, i);
1893 ok(!vdesc.TextureSize, "Got unexpected TextureSize %u, i %u.\n", vdesc.TextureSize, i);
1894 ok(vdesc.StartSampler == 0xffffffff, "Got unexpected StartSampler %u, i %u.\n", vdesc.StartSampler, i);
1895 ok(!vdesc.SamplerSize, "Got unexpected SamplerSize %u, i %u.\n", vdesc.SamplerSize, i);
1897 if (ref12)
1899 v12 = ref12->lpVtbl->GetVariableByName(ref12, pvdesc->Name);
1900 ok(v12_dummy != v12, "Test %u, got unexpected variable %p.\n", i, v12);
1901 hr = v12->lpVtbl->GetDesc(v12, &vdesc12);
1902 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1903 ok(!strcmp(vdesc12.Name, pvdesc->Name), "Got unexpected name \"%s\", i %u", vdesc12.Name, i);
1904 ok(!memcmp(&vdesc12.StartOffset, &vdesc.StartOffset,
1905 sizeof(vdesc) - offsetof(D3D11_SHADER_VARIABLE_DESC, StartOffset)),
1906 "D3D11 and D3D12 descs do not match.\n");
1908 else
1910 /* Silence compiler warning. */
1911 v12 = NULL;
1914 /* types */
1915 ptdesc = &test_reflection_constant_buffer_type_result[test_reflection_constant_buffer_variable_result[i].type];
1917 t11 = v11->lpVtbl->GetType(v11);
1918 ok(t11_dummy != t11, "Got unexpected type %p, i %u.\n", t11, i);
1920 hr = t11->lpVtbl->GetDesc(t11, &tdesc);
1921 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1923 ok(tdesc.Class == ptdesc->Class, "Got unexpected Class %u, i %u.\n", tdesc.Class, i);
1924 ok(tdesc.Type == ptdesc->Type, "Got unexpected Type %u, i %u.\n", tdesc.Type, i);
1925 ok(tdesc.Rows == ptdesc->Rows, "Got unexpected Rows %u, i %u.\n", tdesc.Rows, i);
1926 ok(tdesc.Columns == ptdesc->Columns, "Got unexpected Columns %u, i %u.\n", tdesc.Columns, i);
1927 ok(tdesc.Elements == ptdesc->Elements, "Got unexpected Elements %u, i %u.\n", tdesc.Elements, i);
1928 ok(tdesc.Offset == ptdesc->Offset, "Got unexpected Offset %u, i %u.\n", tdesc.Offset, i);
1929 if (D3D_COMPILER_VERSION)
1930 ok(!strcmp(tdesc.Name, ptdesc->Name), "Got unexpected Name %s, i %u.\n", debugstr_a(tdesc.Name), i);
1932 if (ref12)
1934 t12 = v12->lpVtbl->GetType(v12);
1935 ok(t12_dummy != t12, "Got unexpected type %p, i %u.\n", t12, i);
1937 hr = t12->lpVtbl->GetDesc(t12, &tdesc12);
1938 ok(hr == S_OK, "%u: Got unexpected hr %#lx.\n", i, hr);
1939 ok(!memcmp(&tdesc12, &tdesc, offsetof(D3D11_SHADER_TYPE_DESC, Name)),
1940 "D3D11 and D3D12 descs do not match.\n");
1941 ok(!strcmp(tdesc12.Name, ptdesc->Name), "Got unexpected Name %s, i %u.\n", debugstr_a(tdesc12.Name), i);
1945 /* types */
1946 if (D3D_COMPILER_VERSION)
1947 v11 = ref11->lpVtbl->GetVariableByName(ref11, "t");
1948 else
1949 v11 = cb11_valid->lpVtbl->GetVariableByName(cb11_valid, pvdesc->Name);
1950 ok(v11_dummy != v11, "Got unexpected variable %p.\n", v11);
1952 t11 = v11->lpVtbl->GetType(v11);
1953 ok(t11 != t11_dummy, "Got unexpected type %p.\n", t11);
1955 t = t11->lpVtbl->GetMemberTypeByIndex(t11, 0);
1956 ok(t != t11_dummy, "Got unexpected type %p.\n", t);
1958 t2 = t11->lpVtbl->GetMemberTypeByName(t11, "a");
1959 ok(t == t2, "Got unexpected type %p.\n", t2);
1961 string = t11->lpVtbl->GetMemberTypeName(t11, 0);
1962 ok(!strcmp(string, "a"), "Got unexpected string \"%s\".\n", string);
1964 t = t11->lpVtbl->GetMemberTypeByIndex(t11, 1);
1965 ok(t != t11_dummy, "Got unexpected type %p.\n", t);
1967 t2 = t11->lpVtbl->GetMemberTypeByName(t11, "b");
1968 ok(t == t2, "Got unexpected type %p.\n", t2);
1970 string = t11->lpVtbl->GetMemberTypeName(t11, 1);
1971 ok(!strcmp(string, "b"), "Got unexpected string \"%s\".\n", string);
1973 #if D3D_COMPILER_VERSION
1974 /* float vs float (in struct) */
1975 hr = t11->lpVtbl->IsEqual(t11, t11_valid);
1976 ok(hr == S_FALSE, "Got unexpected hr %#lx.\n", hr);
1978 hr = t11_valid->lpVtbl->IsEqual(t11_valid, t11);
1979 ok(hr == S_FALSE, "Got unexpected hr %#lx.\n", hr);
1981 /* float vs float */
1982 t = t11->lpVtbl->GetMemberTypeByIndex(t11, 0);
1983 ok(t != t11_dummy, "Got unexpected type %p.\n", t);
1985 t2 = t11->lpVtbl->GetMemberTypeByIndex(t11, 1);
1986 ok(t2 != t11_dummy, "Got unexpected type %p.\n", t2);
1988 hr = t->lpVtbl->IsEqual(t, t2);
1989 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
1990 #endif
1992 if (ref12)
1994 v12 = ref12->lpVtbl->GetVariableByName(ref12, "t");
1995 ok(v12_dummy != v12, "Got unexpected variable %p.\n", v12);
1997 t12 = v12->lpVtbl->GetType(v12);
1998 ok(t12 != t12_dummy, "Got unexpected type %p.\n", t12);
2000 mt12 = t12->lpVtbl->GetMemberTypeByIndex(t12, 0);
2001 ok(mt12 != t12_dummy, "Got unexpected type %p.\n", mt12);
2003 mt12_2 = t12->lpVtbl->GetMemberTypeByName(t12, "a");
2004 ok(mt12 == mt12_2, "Got unexpected type %p.\n", mt12_2);
2006 string = t12->lpVtbl->GetMemberTypeName(t12, 0);
2007 ok(!strcmp(string, "a"), "Got unexpected string \"%s\".\n", string);
2009 mt12 = t12->lpVtbl->GetMemberTypeByIndex(t12, 1);
2010 ok(mt12 != t12_dummy, "Got unexpected type %p.\n", mt12);
2012 mt12_2 = t12->lpVtbl->GetMemberTypeByName(t12, "b");
2013 ok(mt12 == mt12_2, "Got unexpected type %p.\n", mt12_2);
2015 string = t12->lpVtbl->GetMemberTypeName(t12, 1);
2016 ok(!strcmp(string, "b"), "Got unexpected string \"%s\".\n", string);
2018 hr = t12->lpVtbl->IsEqual(t12, t12_valid);
2019 ok(hr == S_FALSE, "Got unexpected hr %#lx.\n", hr);
2021 hr = t12_valid->lpVtbl->IsEqual(t12_valid, t12);
2022 ok(hr == S_FALSE, "Got unexpected hr %#lx.\n", hr);
2024 mt12 = t12->lpVtbl->GetMemberTypeByIndex(t12, 0);
2025 ok(mt12 != t12_dummy, "Got unexpected type %p.\n", mt12);
2027 mt12_2 = t12->lpVtbl->GetMemberTypeByIndex(t12, 1);
2028 ok(mt12_2 != t12_dummy, "Got unexpected type %p.\n", mt12_2);
2030 hr = mt12->lpVtbl->IsEqual(mt12, mt12_2);
2031 ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
2033 count = ref12->lpVtbl->Release(ref12);
2034 ok(!count, "Got unexpected ref count %lu.\n", count);
2036 count = ref11->lpVtbl->Release(ref11);
2037 ok(!count, "Got unexpected ref count %lu.\n", count);
2041 * fxc.exe /E PS /Tps_5_1 /Fo
2043 #if 0
2044 Texture2D tex1 : register(t1, space1);
2045 SamplerState sam
2047 Filter = MIN_MAG_MIP_LINEAR;
2048 AddressU = Wrap;
2049 AddressV = Wrap;
2051 cbuffer c1 : register(b0, space0)
2053 float x;
2054 float y[2];
2055 int z;
2057 cbuffer c2 : register(b0, space1)
2059 float t;
2062 float4 PS(float2 uv : TEXCOORD0) : sv_target
2064 float4 q = tex1.Sample(sam, uv);
2065 q.x = q.x + x;
2066 q.w = q.w + y[0] + y[1] + t;
2067 return q;
2069 #endif
2070 static const DWORD test_reflection_bound_resources_sm51_blob[] =
2072 0x43425844, 0x01b901c9, 0xaa053e53, 0x0b6ee9ab, 0x66bcfb8c, 0x00000001, 0x0000051c, 0x00000005,
2073 0x00000034, 0x000002a4, 0x000002d8, 0x0000030c, 0x00000480, 0x46454452, 0x00000268, 0x00000002,
2074 0x000000ec, 0x00000004, 0x0000003c, 0xffff0501, 0x00000500, 0x0000023e, 0x25441313, 0x0000003c,
2075 0x00000018, 0x00000028, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x000000dc, 0x00000003,
2076 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
2077 0x000000e0, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000c,
2078 0x00000001, 0x00000000, 0x000000e5, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2079 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x000000e8, 0x00000000, 0x00000000, 0x00000000,
2080 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x006d6173, 0x31786574,
2081 0x00316300, 0xab003263, 0x000000e5, 0x00000003, 0x0000011c, 0x00000030, 0x00000000, 0x00000000,
2082 0x000000e8, 0x00000001, 0x00000214, 0x00000010, 0x00000000, 0x00000000, 0x00000194, 0x00000000,
2083 0x00000004, 0x00000002, 0x0000019c, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000,
2084 0x000001c0, 0x00000010, 0x00000014, 0x00000002, 0x000001c4, 0x00000000, 0xffffffff, 0x00000000,
2085 0xffffffff, 0x00000000, 0x000001e8, 0x00000024, 0x00000004, 0x00000000, 0x000001f0, 0x00000000,
2086 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0x6c660078, 0x0074616f, 0x00030000, 0x00010001,
2087 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000196, 0xabab0079,
2088 0x00030000, 0x00010001, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2089 0x00000196, 0x6e69007a, 0xabab0074, 0x00020000, 0x00010001, 0x00000000, 0x00000000, 0x00000000,
2090 0x00000000, 0x00000000, 0x00000000, 0x000001ea, 0x0000023c, 0x00000000, 0x00000004, 0x00000002,
2091 0x0000019c, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0x694d0074, 0x736f7263,
2092 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43, 0x72656c69, 0x2e303120,
2093 0xabab0031, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
2094 0x00000003, 0x00000000, 0x00000303, 0x43584554, 0x44524f4f, 0xababab00, 0x4e47534f, 0x0000002c,
2095 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
2096 0x745f7673, 0x65677261, 0xabab0074, 0x58454853, 0x0000016c, 0x00000051, 0x0000005b, 0x0100086a,
2097 0x07000059, 0x00308e46, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x07000059,
2098 0x00308e46, 0x00000001, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x0600005a, 0x00306e46,
2099 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07001858, 0x00307e46, 0x00000000, 0x00000001,
2100 0x00000001, 0x00005555, 0x00000001, 0x03001062, 0x00101032, 0x00000000, 0x03000065, 0x001020f2,
2101 0x00000000, 0x02000068, 0x00000001, 0x0b000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000000,
2102 0x00207e46, 0x00000000, 0x00000001, 0x00206000, 0x00000000, 0x00000000, 0x09000000, 0x00102012,
2103 0x00000000, 0x0010000a, 0x00000000, 0x0030800a, 0x00000000, 0x00000000, 0x00000000, 0x09000000,
2104 0x00100012, 0x00000000, 0x0010003a, 0x00000000, 0x0030800a, 0x00000000, 0x00000000, 0x00000001,
2105 0x09000000, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x0030800a, 0x00000000, 0x00000000,
2106 0x00000002, 0x09000000, 0x00102082, 0x00000000, 0x0010000a, 0x00000000, 0x0030800a, 0x00000001,
2107 0x00000000, 0x00000000, 0x05000036, 0x00102062, 0x00000000, 0x00100656, 0x00000000, 0x0100003e,
2108 0x54415453, 0x00000094, 0x00000007, 0x00000001, 0x00000000, 0x00000002, 0x00000004, 0x00000000,
2109 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2110 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
2111 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2112 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2115 static const D3D12_SHADER_INPUT_BIND_DESC test_reflection_bound_resources_sm51_result[] =
2117 {"sam", D3D_SIT_SAMPLER, 0, 1, 0, 0, D3D_SRV_DIMENSION_UNKNOWN, 0},
2118 {"tex1", D3D_SIT_TEXTURE, 1, 1, 12, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, 0xffffffff, 1, 0},
2119 {"c1", D3D_SIT_CBUFFER, 0, 1, D3D_SIF_USERPACKED, 0, D3D_SRV_DIMENSION_UNKNOWN, 0},
2120 {"c2", D3D_SIT_CBUFFER, 0, 1, D3D_SIF_USERPACKED, 0, D3D_SRV_DIMENSION_UNKNOWN, 0, 1, 1},
2123 START_TEST(reflection)
2125 #if D3D_COMPILER_VERSION
2126 test_reflection_references();
2127 test_reflection_interfaces();
2128 #endif
2129 test_reflection_desc_vs();
2130 test_reflection_desc_ps();
2131 test_reflection_desc_ps_output();
2132 test_reflection_bound_resources(test_reflection_bound_resources_blob, test_reflection_bound_resources_result,
2133 ARRAY_SIZE(test_reflection_bound_resources_result), 0x400);
2134 test_reflection_bound_resources(test_reflection_bound_resources_sm51_blob,
2135 test_reflection_bound_resources_sm51_result,
2136 ARRAY_SIZE(test_reflection_bound_resources_sm51_result), 0x501);
2137 test_reflection_constant_buffer();