d3dcompiler/tests: Test bound resources' reflection for sm5.1.

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2020-08-08 02:19:50 +03:00 committed by Alexandre Julliard
parent d95920e8d6
commit 2acdde92e8

View file

@ -1064,7 +1064,8 @@ float4 PS(float2 uv : TEXCOORD0) : sv_target
return q;
}
#endif
static DWORD test_reflection_bound_resources_blob[] = {
static const DWORD test_reflection_bound_resources_blob[] =
{
0x43425844, 0xe4af0279, 0x690268fc, 0x76bf6a72, 0xe5aff43b, 0x00000001, 0x000003f4, 0x00000005,
0x00000034, 0x000001e8, 0x0000021c, 0x00000250, 0x00000378, 0x46454452, 0x000001ac, 0x00000002,
0x000000ac, 0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x0000017a, 0x0000009c, 0x00000003,
@ -1107,19 +1108,26 @@ static const D3D11_SHADER_INPUT_BIND_DESC test_reflection_bound_resources_result
{"c2", D3D_SIT_CBUFFER, 1, 1, 0, 0, D3D_SRV_DIMENSION_UNKNOWN, 0},
};
static void test_reflection_bound_resources(void)
static void test_reflection_bound_resources(const DWORD *blob, const D3D11_SHADER_INPUT_BIND_DESC *result,
unsigned int result_count, unsigned int target_version)
{
HRESULT hr;
ULONG count;
ID3D11ShaderReflection *ref11;
D3D11_SHADER_INPUT_BIND_DESC desc;
const D3D11_SHADER_INPUT_BIND_DESC *pdesc;
D3D11_SHADER_INPUT_BIND_DESC desc;
ID3D11ShaderReflection *ref11;
HRESULT hr, expected_hr;
unsigned int i;
UINT expected;
ULONG count;
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);
hr = call_reflect(blob, blob[6], &IID_ID3D11ShaderReflection, (void **)&ref11);
expected_hr = D3D_COMPILER_VERSION < 47 && target_version >= 0x501 ? E_INVALIDARG : S_OK;
/* Older d3dcompiler_47 does not support sm5.1. */
ok(hr == expected_hr || broken(hr == E_INVALIDARG && target_version >= 0x501), "Got unexpected hr %x.\n", hr);
if (hr == E_INVALIDARG)
return;
/* check invalid cases */
hr = ref11->lpVtbl->GetResourceBindingDesc(ref11, 0, NULL);
@ -1143,9 +1151,9 @@ static void test_reflection_bound_resources(void)
#endif
/* GetResourceBindingDesc */
for (i = 0; i < ARRAY_SIZE(test_reflection_bound_resources_result); ++i)
for (i = 0; i < result_count; ++i)
{
pdesc = &test_reflection_bound_resources_result[i];
pdesc = &result[i];
hr = ref11->lpVtbl->GetResourceBindingDesc(ref11, i, &desc);
ok(hr == S_OK, "GetResourceBindingDesc(%u) failed, got %x, expected %x\n", i, hr, S_OK);
@ -1176,9 +1184,9 @@ static void test_reflection_bound_resources(void)
#if D3D_COMPILER_VERSION
/* GetResourceBindingDescByName */
for (i = 0; i < ARRAY_SIZE(test_reflection_bound_resources_result); ++i)
for (i = 0; i < result_count; ++i)
{
pdesc = &test_reflection_bound_resources_result[i];
pdesc = &result[i];
hr = ref11->lpVtbl->GetResourceBindingDescByName(ref11, pdesc->Name, &desc);
ok(hr == S_OK, "GetResourceBindingDescByName(%u) failed, got %x, expected %x\n", i, hr, S_OK);
@ -1742,6 +1750,89 @@ static void test_reflection_constant_buffer(void)
ok(count == 0, "Release failed %u\n", count);
}
/*
* fxc.exe /E PS /Tps_5_1 /Fo
*/
#if 0
Texture2D tex1 : register(t1, space1);
SamplerState sam
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};
cbuffer c1 : register(b0, space0)
{
float x;
float y[2];
int z;
};
cbuffer c2 : register(b0, space1)
{
float t;
};
float4 PS(float2 uv : TEXCOORD0) : sv_target
{
float4 q = tex1.Sample(sam, uv);
q.x = q.x + x;
q.w = q.w + y[0] + y[1] + t;
return q;
}
#endif
static const DWORD test_reflection_bound_resources_sm51_blob[] =
{
0x43425844, 0x01b901c9, 0xaa053e53, 0x0b6ee9ab, 0x66bcfb8c, 0x00000001, 0x0000051c, 0x00000005,
0x00000034, 0x000002a4, 0x000002d8, 0x0000030c, 0x00000480, 0x46454452, 0x00000268, 0x00000002,
0x000000ec, 0x00000004, 0x0000003c, 0xffff0501, 0x00000500, 0x0000023e, 0x25441313, 0x0000003c,
0x00000018, 0x00000028, 0x00000028, 0x00000024, 0x0000000c, 0x00000000, 0x000000dc, 0x00000003,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
0x000000e0, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000c,
0x00000001, 0x00000000, 0x000000e5, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x000000e8, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x006d6173, 0x31786574,
0x00316300, 0xab003263, 0x000000e5, 0x00000003, 0x0000011c, 0x00000030, 0x00000000, 0x00000000,
0x000000e8, 0x00000001, 0x00000214, 0x00000010, 0x00000000, 0x00000000, 0x00000194, 0x00000000,
0x00000004, 0x00000002, 0x0000019c, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000,
0x000001c0, 0x00000010, 0x00000014, 0x00000002, 0x000001c4, 0x00000000, 0xffffffff, 0x00000000,
0xffffffff, 0x00000000, 0x000001e8, 0x00000024, 0x00000004, 0x00000000, 0x000001f0, 0x00000000,
0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0x6c660078, 0x0074616f, 0x00030000, 0x00010001,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000196, 0xabab0079,
0x00030000, 0x00010001, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000196, 0x6e69007a, 0xabab0074, 0x00020000, 0x00010001, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x000001ea, 0x0000023c, 0x00000000, 0x00000004, 0x00000002,
0x0000019c, 0x00000000, 0xffffffff, 0x00000000, 0xffffffff, 0x00000000, 0x694d0074, 0x736f7263,
0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43, 0x72656c69, 0x2e303120,
0xabab0031, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
0x00000003, 0x00000000, 0x00000303, 0x43584554, 0x44524f4f, 0xababab00, 0x4e47534f, 0x0000002c,
0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f,
0x745f7673, 0x65677261, 0xabab0074, 0x58454853, 0x0000016c, 0x00000051, 0x0000005b, 0x0100086a,
0x07000059, 0x00308e46, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x07000059,
0x00308e46, 0x00000001, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x0600005a, 0x00306e46,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x07001858, 0x00307e46, 0x00000000, 0x00000001,
0x00000001, 0x00005555, 0x00000001, 0x03001062, 0x00101032, 0x00000000, 0x03000065, 0x001020f2,
0x00000000, 0x02000068, 0x00000001, 0x0b000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000000,
0x00207e46, 0x00000000, 0x00000001, 0x00206000, 0x00000000, 0x00000000, 0x09000000, 0x00102012,
0x00000000, 0x0010000a, 0x00000000, 0x0030800a, 0x00000000, 0x00000000, 0x00000000, 0x09000000,
0x00100012, 0x00000000, 0x0010003a, 0x00000000, 0x0030800a, 0x00000000, 0x00000000, 0x00000001,
0x09000000, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x0030800a, 0x00000000, 0x00000000,
0x00000002, 0x09000000, 0x00102082, 0x00000000, 0x0010000a, 0x00000000, 0x0030800a, 0x00000001,
0x00000000, 0x00000000, 0x05000036, 0x00102062, 0x00000000, 0x00100656, 0x00000000, 0x0100003e,
0x54415453, 0x00000094, 0x00000007, 0x00000001, 0x00000000, 0x00000002, 0x00000004, 0x00000000,
0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
};
static const D3D11_SHADER_INPUT_BIND_DESC test_reflection_bound_resources_sm51_result[] =
{
{"sam", D3D_SIT_SAMPLER, 0, 1, 0, 0, D3D_SRV_DIMENSION_UNKNOWN, 0},
{"tex1", D3D_SIT_TEXTURE, 1, 1, 12, D3D_RETURN_TYPE_FLOAT, D3D_SRV_DIMENSION_TEXTURE2D, 0xffffffff},
{"c1", D3D_SIT_CBUFFER, 0, 1, D3D_SIF_USERPACKED, 0, D3D_SRV_DIMENSION_UNKNOWN, 0},
{"c2", D3D_SIT_CBUFFER, 0, 1, D3D_SIF_USERPACKED, 0, D3D_SRV_DIMENSION_UNKNOWN, 0},
};
static BOOL load_d3dreflect(void)
{
#if D3D_COMPILER_VERSION == 47
@ -1774,6 +1865,10 @@ START_TEST(reflection)
test_reflection_desc_vs();
test_reflection_desc_ps();
test_reflection_desc_ps_output();
test_reflection_bound_resources();
test_reflection_bound_resources(test_reflection_bound_resources_blob, test_reflection_bound_resources_result,
ARRAY_SIZE(test_reflection_bound_resources_result), 0x400);
test_reflection_bound_resources(test_reflection_bound_resources_sm51_blob,
test_reflection_bound_resources_sm51_result,
ARRAY_SIZE(test_reflection_bound_resources_sm51_result), 0x501);
test_reflection_constant_buffer();
}