From: Connor McAdams conmanx360@gmail.com
Signed-off-by: Connor McAdams conmanx360@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dcompiler_43/reflection.c | 107 +++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+)
diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index a79439a3fe5..93819534e69 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -1312,6 +1312,7 @@ static struct d3dcompiler_shader_reflection_type *get_reflection_type(struct d3d return NULL;
type->ID3D11ShaderReflectionType_iface.lpVtbl = &d3dcompiler_shader_reflection_type_vtbl; + type->ID3D10ShaderReflectionType_iface.lpVtbl = &d3d10_shader_reflection_type_vtbl; type->id = offset; type->reflection = reflection;
@@ -2143,6 +2144,112 @@ static const struct ID3D10ShaderReflectionVariableVtbl d3d10_shader_reflection_v d3d10_shader_reflection_variable_GetType, };
+static inline struct d3dcompiler_shader_reflection_type *impl_from_ID3D10ShaderReflectionType( + ID3D10ShaderReflectionType *iface) +{ + return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection_type, ID3D10ShaderReflectionType_iface); +} + +static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_type_GetDesc(ID3D10ShaderReflectionType *iface, + D3D10_SHADER_TYPE_DESC *desc) +{ + struct d3dcompiler_shader_reflection_type *type = impl_from_ID3D10ShaderReflectionType(iface); + + TRACE("iface %p, desc %p.\n", iface, desc); + + if (type == &null_type) + { + WARN("Null type specified.\n"); + return E_FAIL; + } + + if (!desc) + { + WARN("Invalid argument specified.\n"); + return E_FAIL; + } + + memcpy(desc, &type->desc, sizeof(*desc)); + + return S_OK; +} + +static ID3D10ShaderReflectionType * STDMETHODCALLTYPE d3d10_shader_reflection_type_GetMemberTypeByIndex( + ID3D10ShaderReflectionType *iface, UINT index) +{ + struct d3dcompiler_shader_reflection_type *type = impl_from_ID3D10ShaderReflectionType(iface); + + TRACE("iface %p, index %u.\n", iface, index); + + if (index >= type->desc.Members) + { + WARN("Invalid index specified.\n"); + return &null_type.ID3D10ShaderReflectionType_iface; + } + + return &type->members[index].type->ID3D10ShaderReflectionType_iface; +} + +static ID3D10ShaderReflectionType * STDMETHODCALLTYPE d3d10_shader_reflection_type_GetMemberTypeByName( + ID3D10ShaderReflectionType *iface, const char *name) +{ + struct d3dcompiler_shader_reflection_type *type = impl_from_ID3D10ShaderReflectionType(iface); + unsigned int i; + + TRACE("iface %p, name %s.\n", iface, debugstr_a(name)); + + if (!name) + { + WARN("Invalid argument specified.\n"); + return &null_type.ID3D10ShaderReflectionType_iface; + } + + for (i = 0; i < type->desc.Members; ++i) + { + struct d3dcompiler_shader_reflection_type_member *member = &type->members[i]; + + if (!strcmp(member->name, name)) + { + TRACE("Returning ID3D10ShaderReflectionType %p.\n", member->type); + return &member->type->ID3D10ShaderReflectionType_iface; + } + } + + WARN("Invalid name specified.\n"); + + return &null_type.ID3D10ShaderReflectionType_iface; +} + +static const char * STDMETHODCALLTYPE d3d10_shader_reflection_type_GetMemberTypeName( + ID3D10ShaderReflectionType *iface, UINT index) +{ + struct d3dcompiler_shader_reflection_type *type = impl_from_ID3D10ShaderReflectionType(iface); + + TRACE("iface %p, index %u.\n", iface, index); + + if (type == &null_type) + { + WARN("Null type specified.\n"); + return "$Invalid"; + } + + if (index >= type->desc.Members) + { + WARN("Invalid index specified.\n"); + return NULL; + } + + return type->members[index].name; +} + +static const struct ID3D10ShaderReflectionTypeVtbl d3d10_shader_reflection_type_vtbl = +{ + d3d10_shader_reflection_type_GetDesc, + d3d10_shader_reflection_type_GetMemberTypeByIndex, + d3d10_shader_reflection_type_GetMemberTypeByName, + d3d10_shader_reflection_type_GetMemberTypeName, +}; + HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10ShaderReflection **reflector) { struct d3dcompiler_shader_reflection *object;
From: Connor McAdams conmanx360@gmail.com
Signed-off-by: Connor McAdams conmanx360@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dcompiler_43/reflection.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index 93819534e69..34a9984768d 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -2133,9 +2133,11 @@ static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_variable_GetDesc(ID3D10 static ID3D10ShaderReflectionType * STDMETHODCALLTYPE d3d10_shader_reflection_variable_GetType( ID3D10ShaderReflectionVariable *iface) { - FIXME("iface %p stub!\n", iface); + struct d3dcompiler_shader_reflection_variable *var = impl_from_ID3D10ShaderReflectionVariable(iface);
- return &null_type.ID3D10ShaderReflectionType_iface; + TRACE("iface %p.\n", iface); + + return &var->type->ID3D10ShaderReflectionType_iface; }
static const struct ID3D10ShaderReflectionVariableVtbl d3d10_shader_reflection_variable_vtbl =
From: Connor McAdams conmanx360@gmail.com
Signed-off-by: Connor McAdams conmanx360@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dcompiler_43/reflection.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index 34a9984768d..5c08cdf5e45 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -2077,9 +2077,17 @@ static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_constant_buffer_GetDesc static ID3D10ShaderReflectionVariable * STDMETHODCALLTYPE d3d10_shader_reflection_constant_buffer_GetVariableByIndex( ID3D10ShaderReflectionConstantBuffer *iface, UINT index) { - FIXME("iface %p, index %d stub!\n", iface, index); + struct d3dcompiler_shader_reflection_constant_buffer *cb = impl_from_ID3D10ShaderReflectionConstantBuffer(iface);
- return &null_variable.ID3D10ShaderReflectionVariable_iface; + TRACE("iface %p, index %u.\n", iface, index); + + if (index >= cb->variable_count) + { + WARN("Invalid index specified.\n"); + return &null_variable.ID3D10ShaderReflectionVariable_iface; + } + + return &cb->variables[index].ID3D10ShaderReflectionVariable_iface; }
static ID3D10ShaderReflectionVariable * STDMETHODCALLTYPE d3d10_shader_reflection_constant_buffer_GetVariableByName(
From: Connor McAdams conmanx360@gmail.com
Signed-off-by: Connor McAdams conmanx360@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dcompiler_43/reflection.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index 5c08cdf5e45..820e5c239f2 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -2093,7 +2093,29 @@ static ID3D10ShaderReflectionVariable * STDMETHODCALLTYPE d3d10_shader_reflectio static ID3D10ShaderReflectionVariable * STDMETHODCALLTYPE d3d10_shader_reflection_constant_buffer_GetVariableByName( ID3D10ShaderReflectionConstantBuffer *iface, const char *name) { - FIXME("iface %p, name %s stub!\n", iface, name); + struct d3dcompiler_shader_reflection_constant_buffer *cb = impl_from_ID3D10ShaderReflectionConstantBuffer(iface); + unsigned int i; + + TRACE("iface %p, name %s.\n", iface, debugstr_a(name)); + + if (!name) + { + WARN("Invalid argument specified.\n"); + return &null_variable.ID3D10ShaderReflectionVariable_iface; + } + + for (i = 0; i < cb->variable_count; ++i) + { + struct d3dcompiler_shader_reflection_variable *v = &cb->variables[i]; + + if (!strcmp(v->name, name)) + { + TRACE("Returning ID3D10ShaderReflectionVariable %p.\n", v); + return &v->ID3D10ShaderReflectionVariable_iface; + } + } + + WARN("Invalid name specified.\n");
return &null_variable.ID3D10ShaderReflectionVariable_iface; }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dcompiler_43/tests/reflection.c | 50 +++++++++++++------------- 1 file changed, 26 insertions(+), 24 deletions(-)
diff --git a/dlls/d3dcompiler_43/tests/reflection.c b/dlls/d3dcompiler_43/tests/reflection.c index fb117fd6a9c..c5726198af6 100644 --- a/dlls/d3dcompiler_43/tests/reflection.c +++ b/dlls/d3dcompiler_43/tests/reflection.c @@ -908,27 +908,28 @@ static const DWORD test_reflection_desc_ps_output_blob_5[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, };
-static const DWORD *test_reflection_desc_ps_output_blob[] = { - test_reflection_desc_ps_output_blob_0, - test_reflection_desc_ps_output_blob_1, - test_reflection_desc_ps_output_blob_2, - test_reflection_desc_ps_output_blob_3, - test_reflection_desc_ps_output_blob_4, - test_reflection_desc_ps_output_blob_5, -}; - -static const D3D11_SIGNATURE_PARAMETER_DESC test_reflection_desc_ps_output_result[] = -{ - {"SV_Target", 3, 3, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0, 0}, - {"SV_DepthLessEqual", 0, 0xffffffff, D3D_NAME_DEPTH_LESS_EQUAL, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}, - {"SV_DepthGreaterEqual", 0, 0xffffffff, D3D11_NAME_DEPTH_GREATER_EQUAL, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}, - {"sV_DePtH", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}, - {"SV_Depth", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}, - {"SV_COVERAGE", 0, 0xffffffff, D3D_NAME_COVERAGE, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe, 0}, -}; - static void test_reflection_desc_ps_output(void) { + static const struct test_reflection_desc_ps_output_test + { + const DWORD *blob; + D3D11_SIGNATURE_PARAMETER_DESC desc; + } + tests[] = + { + {test_reflection_desc_ps_output_blob_0, + {"SV_Target", 3, 3, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0, 0}}, + {test_reflection_desc_ps_output_blob_1, + {"SV_DepthLessEqual", 0, 0xffffffff, D3D_NAME_DEPTH_LESS_EQUAL, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}}, + {test_reflection_desc_ps_output_blob_2, + {"SV_DepthGreaterEqual", 0, 0xffffffff, D3D11_NAME_DEPTH_GREATER_EQUAL, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}}, + {test_reflection_desc_ps_output_blob_3, + {"sV_DePtH", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}}, + {test_reflection_desc_ps_output_blob_4, + {"SV_Depth", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}}, + {test_reflection_desc_ps_output_blob_5, + {"SV_COVERAGE", 0, 0xffffffff, D3D_NAME_COVERAGE, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe, 0}}, + }; HRESULT hr; ULONG count; ID3D11ShaderReflection *ref11; @@ -936,12 +937,12 @@ static void test_reflection_desc_ps_output(void) const D3D11_SIGNATURE_PARAMETER_DESC *pdesc; unsigned int i;
- for (i = 0; i < ARRAY_SIZE(test_reflection_desc_ps_output_result); ++i) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { - hr = pD3DReflect(test_reflection_desc_ps_output_blob[i], test_reflection_desc_ps_output_blob[i][6], &IID_ID3D11ShaderReflection, (void **)&ref11); - ok(hr == S_OK, "(%u): D3DReflect failed %x\n", i, hr); + hr = pD3DReflect(tests[i].blob, tests[i].blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11); + ok(hr == S_OK, "(%u): got unexpected hr %x.\n", i, hr);
- pdesc = &test_reflection_desc_ps_output_result[i]; + pdesc = &tests[i].desc;
hr = ref11->lpVtbl->GetOutputParameterDesc(ref11, 0, &desc); ok(hr == S_OK, "(%u): GetOutputParameterDesc failed, got %x, expected %x\n", i, hr, S_OK); @@ -1050,7 +1051,8 @@ static void test_reflection_bound_resources(void) const D3D11_SHADER_INPUT_BIND_DESC *pdesc; unsigned int i;
- hr = pD3DReflect(test_reflection_bound_resources_blob, test_reflection_bound_resources_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11); + hr = pD3DReflect(test_reflection_bound_resources_blob, test_reflection_bound_resources_blob[6], + &IID_ID3D11ShaderReflection, (void **)&ref11); ok(hr == S_OK, "D3DReflect failed %x\n", hr);
/* check invalid cases */
Share and reuse most of the d3dcompiler test.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d10/tests/Makefile.in | 5 +- dlls/d3d10/tests/device.c | 1 - dlls/d3dcompiler_43/tests/reflection.c | 103 ++++++++++++++++++++----- 3 files changed, 88 insertions(+), 21 deletions(-)
diff --git a/dlls/d3d10/tests/Makefile.in b/dlls/d3d10/tests/Makefile.in index ceabc1f4546..e3849ec634b 100644 --- a/dlls/d3d10/tests/Makefile.in +++ b/dlls/d3d10/tests/Makefile.in @@ -1,6 +1,9 @@ TESTDLL = d3d10.dll IMPORTS = d3d10 +EXTRADEFS = -DD3D_COMPILER_VERSION=0 +PARENTSRC = ../../d3dcompiler_43/tests
C_SRCS = \ device.c \ - effect.c + effect.c \ + reflection.c diff --git a/dlls/d3d10/tests/device.c b/dlls/d3d10/tests/device.c index c712d400257..bb4bff51bdb 100644 --- a/dlls/d3d10/tests/device.c +++ b/dlls/d3d10/tests/device.c @@ -17,7 +17,6 @@ */
#define COBJMACROS -#include "initguid.h" #include "d3d10.h" #include "wine/test.h"
diff --git a/dlls/d3dcompiler_43/tests/reflection.c b/dlls/d3dcompiler_43/tests/reflection.c index c5726198af6..ca7aa7760fc 100644 --- a/dlls/d3dcompiler_43/tests/reflection.c +++ b/dlls/d3dcompiler_43/tests/reflection.c @@ -38,7 +38,18 @@ */ #define D3DERR_INVALIDCALL 0x8876086c
+#if D3D_COMPILER_VERSION static HRESULT (WINAPI *pD3DReflect)(const void *, SIZE_T, REFIID, void **); +#endif + +static HRESULT call_reflect(const void *data, SIZE_T data_size, REFIID riid, void **reflection) +{ +#if D3D_COMPILER_VERSION + return pD3DReflect(data, data_size, riid, reflection); +#else + return D3D10ReflectShader(data, data_size, (ID3D10ShaderReflection **)reflection); +#endif +}
/* Creator string for comparison - Version 9.29.952.3111 (43) */ static DWORD shader_creator[] = { @@ -46,6 +57,7 @@ static DWORD shader_creator[] = { 0x39207265, 0x2e39322e, 0x2e323539, 0x31313133, 0xababab00, };
+#if D3D_COMPILER_VERSION /* * fxc.exe /E VS /Tvs_4_0 /Fx */ @@ -141,6 +153,7 @@ static void test_reflection_references(void) hr = pD3DReflect(test_reflection_blob, test_reflection_blob[6]-1, &IID_ID3D11ShaderReflection, (void **)&ref11); ok(hr == expected, "Got %x, expected %x.\n", hr, expected); } +#endif
/* * fxc.exe /E VS /Tvs_4_1 /Fx @@ -320,9 +333,11 @@ static void test_reflection_desc_vs(void) unsigned int i; ULONG count; HRESULT hr; +#if D3D_COMPILER_VERSION UINT ret; +#endif
- hr = pD3DReflect(test_reflection_desc_vs_blob, test_reflection_desc_vs_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11); + hr = call_reflect(test_reflection_desc_vs_blob, test_reflection_desc_vs_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11); ok(hr == S_OK, "D3DReflect failed %x\n", hr);
hr = ref11->lpVtbl->GetDesc(ref11, NULL); @@ -370,6 +385,7 @@ static void test_reflection_desc_vs(void) ok(sdesc11.cInterlockedInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cInterlockedInstructions, 0); ok(sdesc11.cTextureStoreInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cTextureStoreInstructions, 0);
+#if D3D_COMPILER_VERSION ret = ref11->lpVtbl->GetBitwiseInstructionCount(ref11); ok(ret == 0, "GetBitwiseInstructionCount failed, got %u, expected %u\n", ret, 0);
@@ -381,6 +397,7 @@ static void test_reflection_desc_vs(void)
ret = ref11->lpVtbl->GetMovcInstructionCount(ref11); ok(ret == 0, "GetMovcInstructionCount failed, got %u, expected %u\n", ret, 0); +#endif
/* GetIn/OutputParameterDesc */ desc_46.MinPrecision = ~0u; @@ -616,10 +633,13 @@ static void test_reflection_desc_ps(void) D3D11_SHADER_DESC sdesc11 = {0}; D3D11_SIGNATURE_PARAMETER_DESC desc = {0}; const D3D11_SIGNATURE_PARAMETER_DESC *pdesc; - UINT ret; + D3D_NAME expected; unsigned int i; +#if D3D_COMPILER_VERSION + UINT ret; +#endif
- hr = pD3DReflect(test_reflection_desc_ps_blob, test_reflection_desc_ps_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11); + hr = call_reflect(test_reflection_desc_ps_blob, test_reflection_desc_ps_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11); ok(hr == S_OK, "D3DReflect failed %x\n", hr);
hr = ref11->lpVtbl->GetDesc(ref11, &sdesc11); @@ -664,6 +684,7 @@ static void test_reflection_desc_ps(void) ok(sdesc11.cInterlockedInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cInterlockedInstructions, 0); ok(sdesc11.cTextureStoreInstructions == 0, "GetDesc failed, got %u, expected %u\n", sdesc11.cTextureStoreInstructions, 0);
+#if D3D_COMPILER_VERSION ret = ref11->lpVtbl->GetBitwiseInstructionCount(ref11); ok(ret == 0, "GetBitwiseInstructionCount failed, got %u, expected %u\n", ret, 0);
@@ -675,6 +696,7 @@ static void test_reflection_desc_ps(void)
ret = ref11->lpVtbl->GetMovcInstructionCount(ref11); ok(ret == 0, "GetMovcInstructionCount failed, got %u, expected %u\n", ret, 0); +#endif
/* check invalid Get*ParameterDesc cases*/ hr = ref11->lpVtbl->GetInputParameterDesc(ref11, 0, NULL); @@ -689,8 +711,10 @@ static void test_reflection_desc_ps(void) hr = ref11->lpVtbl->GetOutputParameterDesc(ref11, 0xffffffff, &desc); ok(hr == E_INVALIDARG, "GetOutputParameterDesc failed, got %x, expected %x\n", hr, E_INVALIDARG);
+#if D3D_COMPILER_VERSION hr = ref11->lpVtbl->GetPatchConstantParameterDesc(ref11, 0, &desc); ok(hr == E_INVALIDARG, "GetPatchConstantParameterDesc failed, got %x, expected %x\n", hr, E_INVALIDARG); +#endif
/* GetIn/OutputParameterDesc */ for (i = 0; i < ARRAY_SIZE(test_reflection_desc_ps_resultin); ++i) @@ -731,8 +755,14 @@ static void test_reflection_desc_ps(void) i, desc.SemanticIndex, pdesc->SemanticIndex); ok(desc.Register == pdesc->Register, "GetOutputParameterDesc(%u) Register failed, got %u, expected %u\n", i, desc.Register, pdesc->Register); - ok(desc.SystemValueType == pdesc->SystemValueType, "GetOutputParameterDesc(%u) SystemValueType failed, got %x, expected %x\n", - i, desc.SystemValueType, pdesc->SystemValueType); +#if D3D_COMPILER_VERSION + expected = pdesc->SystemValueType; +#else + expected = D3D_NAME_UNDEFINED; + todo_wine +#endif + ok(desc.SystemValueType == expected, "(%u): got unexpected SystemValueType %#x, expected %#x.\n", + i, desc.SystemValueType, expected); ok(desc.ComponentType == pdesc->ComponentType, "GetOutputParameterDesc(%u) ComponentType failed, got %x, expected %x\n", i, desc.ComponentType, pdesc->ComponentType); ok(desc.Mask == pdesc->Mask, "GetOutputParameterDesc(%u) Mask failed, got %x, expected %x\n", @@ -914,32 +944,41 @@ static void test_reflection_desc_ps_output(void) { const DWORD *blob; D3D11_SIGNATURE_PARAMETER_DESC desc; + BOOL d3d10; } tests[] = { {test_reflection_desc_ps_output_blob_0, - {"SV_Target", 3, 3, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0, 0}}, + {"SV_Target", 3, 3, D3D_NAME_TARGET, D3D_REGISTER_COMPONENT_FLOAT32, 0xf, 0, 0}, TRUE}, {test_reflection_desc_ps_output_blob_1, - {"SV_DepthLessEqual", 0, 0xffffffff, D3D_NAME_DEPTH_LESS_EQUAL, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}}, + {"SV_DepthLessEqual", 0, 0xffffffff, D3D_NAME_DEPTH_LESS_EQUAL, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}, FALSE}, {test_reflection_desc_ps_output_blob_2, - {"SV_DepthGreaterEqual", 0, 0xffffffff, D3D11_NAME_DEPTH_GREATER_EQUAL, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}}, + {"SV_DepthGreaterEqual", 0, 0xffffffff, D3D11_NAME_DEPTH_GREATER_EQUAL, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}, FALSE}, {test_reflection_desc_ps_output_blob_3, - {"sV_DePtH", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}}, + {"sV_DePtH", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}, FALSE}, {test_reflection_desc_ps_output_blob_4, - {"SV_Depth", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}}, + {"SV_Depth", 0, 0xffffffff, D3D_NAME_DEPTH, D3D_REGISTER_COMPONENT_FLOAT32, 0x1, 0xe, 0}, TRUE}, {test_reflection_desc_ps_output_blob_5, - {"SV_COVERAGE", 0, 0xffffffff, D3D_NAME_COVERAGE, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe, 0}}, + {"SV_COVERAGE", 0, 0xffffffff, D3D_NAME_COVERAGE, D3D_REGISTER_COMPONENT_UINT32, 0x1, 0xe, 0}, FALSE}, }; HRESULT hr; ULONG count; ID3D11ShaderReflection *ref11; D3D11_SIGNATURE_PARAMETER_DESC desc = {0}; const D3D11_SIGNATURE_PARAMETER_DESC *pdesc; + D3D_NAME expected; unsigned int i;
for (i = 0; i < ARRAY_SIZE(tests); ++i) { - hr = pD3DReflect(tests[i].blob, tests[i].blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11); + hr = call_reflect(tests[i].blob, tests[i].blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11); + if (!D3D_COMPILER_VERSION && !tests[i].d3d10) + { + todo_wine ok(hr == E_INVALIDARG, "(%u): got unexpected hr %x.\n", i, hr); + if (SUCCEEDED(hr)) + ref11->lpVtbl->Release(ref11); + continue; + } ok(hr == S_OK, "(%u): got unexpected hr %x.\n", i, hr);
pdesc = &tests[i].desc; @@ -953,8 +992,14 @@ static void test_reflection_desc_ps_output(void) i, desc.SemanticIndex, pdesc->SemanticIndex); ok(desc.Register == pdesc->Register, "(%u): GetOutputParameterDesc Register failed, got %u, expected %u\n", i, desc.Register, pdesc->Register); - ok(desc.SystemValueType == pdesc->SystemValueType, "(%u): GetOutputParameterDesc SystemValueType failed, got %x, expected %x\n", - i, desc.SystemValueType, pdesc->SystemValueType); +#if D3D_COMPILER_VERSION + expected = pdesc->SystemValueType; +#else + expected = D3D_NAME_UNDEFINED; + todo_wine +#endif + ok(desc.SystemValueType == expected, "(%u): Got unexpected SystemValueType %#x, expected %x.\n", + i, desc.SystemValueType, expected); ok(desc.ComponentType == pdesc->ComponentType, "(%u): GetOutputParameterDesc ComponentType failed, got %x, expected %x\n", i, desc.ComponentType, pdesc->ComponentType); ok(desc.Mask == pdesc->Mask, "(%u): GetOutputParameterDesc Mask failed, got %x, expected %x\n", @@ -1050,8 +1095,9 @@ static void test_reflection_bound_resources(void) D3D11_SHADER_INPUT_BIND_DESC desc; const D3D11_SHADER_INPUT_BIND_DESC *pdesc; unsigned int i; + UINT expected;
- hr = pD3DReflect(test_reflection_bound_resources_blob, test_reflection_bound_resources_blob[6], + hr = call_reflect(test_reflection_bound_resources_blob, test_reflection_bound_resources_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11); ok(hr == S_OK, "D3DReflect failed %x\n", hr);
@@ -1062,6 +1108,7 @@ static void test_reflection_bound_resources(void) hr = ref11->lpVtbl->GetResourceBindingDesc(ref11, 0xffffffff, &desc); ok(hr == E_INVALIDARG, "GetResourceBindingDesc failed, got %x, expected %x\n", hr, E_INVALIDARG);
+#if D3D_COMPILER_VERSION hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, NULL, &desc); ok(hr == E_INVALIDARG, "GetResourceBindingDescByName failed, got %x, expected %x\n", hr, E_INVALIDARG);
@@ -1073,6 +1120,7 @@ static void test_reflection_bound_resources(void)
hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, "invalid", &desc); ok(hr == E_INVALIDARG, "GetResourceBindingDescByName failed, got %x, expected %x\n", hr, E_INVALIDARG); +#endif
/* GetResourceBindingDesc */ for (i = 0; i < ARRAY_SIZE(test_reflection_bound_resources_result); ++i) @@ -1090,8 +1138,14 @@ static void test_reflection_bound_resources(void) i, desc.BindPoint, pdesc->BindPoint); ok(desc.BindCount == pdesc->BindCount, "GetResourceBindingDesc(%u) BindCount failed, got %u, expected %u\n", i, desc.BindCount, pdesc->BindCount); - ok(desc.uFlags == pdesc->uFlags, "GetResourceBindingDesc(%u) uFlags failed, got %u, expected %u\n", - i, desc.uFlags, pdesc->uFlags); +#if D3D_COMPILER_VERSION + expected = pdesc->uFlags; +#else + expected = 0; + todo_wine_if(pdesc->uFlags) +#endif + ok(desc.uFlags == expected, "(%u): Got unexpected uFlags %#x, expected %#x.\n", + i, desc.uFlags, expected); ok(desc.ReturnType == pdesc->ReturnType, "GetResourceBindingDesc(%u) ReturnType failed, got %x, expected %x\n", i, desc.ReturnType, pdesc->ReturnType); ok(desc.Dimension == pdesc->Dimension, "GetResourceBindingDesc(%u) Dimension failed, got %x, expected %x\n", @@ -1100,6 +1154,7 @@ static void test_reflection_bound_resources(void) i, desc.NumSamples, pdesc->NumSamples); }
+#if D3D_COMPILER_VERSION /* GetResourceBindingDescByName */ for (i = 0; i < ARRAY_SIZE(test_reflection_bound_resources_result); ++i) { @@ -1125,11 +1180,13 @@ static void test_reflection_bound_resources(void) ok(desc.NumSamples == pdesc->NumSamples, "GetResourceBindingDescByName(%u) NumSamples failed, got %u, expected %u\n", i, desc.NumSamples, pdesc->NumSamples); } +#endif
count = ref11->lpVtbl->Release(ref11); ok(count == 0, "Release failed %u\n", count); }
+#if D3D_COMPILER_VERSION /* * fxc.exe /E PS /Tps_5_0 /Fx */ @@ -1269,7 +1326,8 @@ static void test_reflection_constant_buffer(void) unsigned int i; LPCSTR string;
- hr = pD3DReflect(test_reflection_constant_buffer_blob, test_reflection_constant_buffer_blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11); + hr = call_reflect(test_reflection_constant_buffer_blob, test_reflection_constant_buffer_blob[6], + &IID_ID3D11ShaderReflection, (void **)&ref11); ok(hr == S_OK, "D3DReflect failed %x\n", hr);
hr = ref11->lpVtbl->GetDesc(ref11, &sdesc); @@ -1545,20 +1603,23 @@ static void test_reflection_constant_buffer(void) count = ref11->lpVtbl->Release(ref11); ok(count == 0, "Release failed %u\n", count); } +#endif
static BOOL load_d3dreflect(void) { #if D3D_COMPILER_VERSION == 47 static const char filename[] = "d3dcompiler_47.dll"; -#else +#elif D3D_COMPILER_VERSION static const char filename[] = "d3dcompiler_43.dll"; #endif +#if D3D_COMPILER_VERSION HMODULE module;
if (!(module = LoadLibraryA(filename))) return FALSE;
pD3DReflect = (void*)GetProcAddress(module, "D3DReflect"); +#endif return TRUE; }
@@ -1570,10 +1631,14 @@ START_TEST(reflection) return; }
+#if D3D_COMPILER_VERSION test_reflection_references(); +#endif test_reflection_desc_vs(); test_reflection_desc_ps(); test_reflection_desc_ps_output(); test_reflection_bound_resources(); +#if D3D_COMPILER_VERSION test_reflection_constant_buffer(); +#endif }