d3d11/tests: Add test for stream output descriptions.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2017-03-30 14:09:19 +02:00 committed by Alexandre Julliard
parent f1896d492a
commit 90bfc6779a
1 changed files with 473 additions and 0 deletions

View File

@ -16011,6 +16011,478 @@ float4 main(struct ps_data ps_input) : SV_Target
release_test_context(&test_context);
}
#define check_so_desc(a, b, c, d, e, f, g, h) check_so_desc_(__LINE__, a, b, c, d, e, f, g, h)
static void check_so_desc_(unsigned int line, ID3D11Device *device,
const DWORD *code, size_t code_size, const D3D11_SO_DECLARATION_ENTRY *entry,
unsigned int entry_count, unsigned int *strides, unsigned int stride_count,
unsigned int rasterizer_stream)
{
ID3D11GeometryShader *gs;
HRESULT hr;
hr = ID3D11Device_CreateGeometryShaderWithStreamOutput(device, code, code_size,
entry, entry_count, strides, stride_count, rasterizer_stream, NULL, &gs);
ok_(__FILE__, line)(hr == S_OK, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
ID3D11GeometryShader_Release(gs);
}
#define check_invalid_so_desc(a, b, c, d, e, f, g, h) check_invalid_so_desc_(__LINE__, a, b, c, d, e, f, g, h)
static void check_invalid_so_desc_(unsigned int line, ID3D11Device *device,
const DWORD *code, size_t code_size, const D3D11_SO_DECLARATION_ENTRY *entry,
unsigned int entry_count, unsigned int *strides, unsigned int stride_count,
unsigned int rasterizer_stream)
{
ID3D11GeometryShader *gs = (ID3D11GeometryShader *)0xdeadbeef;
HRESULT hr;
hr = ID3D11Device_CreateGeometryShaderWithStreamOutput(device, code, code_size,
entry, entry_count, strides, stride_count, rasterizer_stream, NULL, &gs);
ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
ok_(__FILE__, line)(!gs, "Got unexpected geometry shader %p.\n", gs);
}
static void test_stream_output(void)
{
UINT stride[D3D11_SO_BUFFER_SLOT_COUNT];
struct d3d11_test_context test_context;
unsigned int i, count;
ID3D11Device *device;
static const D3D_FEATURE_LEVEL feature_level = D3D_FEATURE_LEVEL_11_0;
static const DWORD vs_code[] =
{
#if 0
struct data
{
float4 position : SV_Position;
float4 attrib1 : ATTRIB1;
float3 attrib2 : attrib2;
float2 attrib3 : ATTriB3;
float attrib4 : ATTRIB4;
};
void main(in data i, out data o)
{
o = i;
}
#endif
0x43425844, 0x3f5b621f, 0x8f390786, 0x7235c8d6, 0xc1181ad3, 0x00000001, 0x00000278, 0x00000003,
0x0000002c, 0x000000d8, 0x00000184, 0x4e475349, 0x000000a4, 0x00000005, 0x00000008, 0x00000080,
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x0000008c, 0x00000001, 0x00000000,
0x00000003, 0x00000001, 0x00000f0f, 0x00000093, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
0x00000707, 0x0000009a, 0x00000003, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x0000008c,
0x00000004, 0x00000000, 0x00000003, 0x00000004, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69,
0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254, 0xababab00, 0x4e47534f, 0x000000a4,
0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000093, 0x00000002,
0x00000000, 0x00000003, 0x00000002, 0x00000807, 0x0000009a, 0x00000003, 0x00000000, 0x00000003,
0x00000003, 0x00000c03, 0x0000008c, 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000b04,
0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254,
0xababab00, 0x52444853, 0x000000ec, 0x00010040, 0x0000003b, 0x0300005f, 0x001010f2, 0x00000000,
0x0300005f, 0x001010f2, 0x00000001, 0x0300005f, 0x00101072, 0x00000002, 0x0300005f, 0x00101032,
0x00000003, 0x0300005f, 0x00101012, 0x00000004, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102072, 0x00000002, 0x03000065, 0x00102032,
0x00000003, 0x03000065, 0x00102042, 0x00000003, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46,
0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x05000036, 0x00102072,
0x00000002, 0x00101246, 0x00000002, 0x05000036, 0x00102032, 0x00000003, 0x00101046, 0x00000003,
0x05000036, 0x00102042, 0x00000003, 0x0010100a, 0x00000004, 0x0100003e,
};
static const DWORD gs_code[] =
{
#if 0
struct data
{
float4 position : SV_Position;
float4 attrib1 : ATTRIB1;
float3 attrib2 : attrib2;
float2 attrib3 : ATTriB3;
float attrib4 : ATTRIB4;
};
[maxvertexcount(1)]
void main(point data i[1], inout PointStream<data> o)
{
o.Append(i[0]);
}
#endif
0x43425844, 0x59c61884, 0x3eef167b, 0x82618c33, 0x243cb630, 0x00000001, 0x000002a0, 0x00000003,
0x0000002c, 0x000000d8, 0x00000184, 0x4e475349, 0x000000a4, 0x00000005, 0x00000008, 0x00000080,
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x0000008c, 0x00000001, 0x00000000,
0x00000003, 0x00000001, 0x00000f0f, 0x00000093, 0x00000002, 0x00000000, 0x00000003, 0x00000002,
0x00000707, 0x0000009a, 0x00000003, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x0000008c,
0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69,
0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254, 0xababab00, 0x4e47534f, 0x000000a4,
0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
0x0000008c, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000093, 0x00000002,
0x00000000, 0x00000003, 0x00000002, 0x00000807, 0x0000009a, 0x00000003, 0x00000000, 0x00000003,
0x00000003, 0x00000c03, 0x0000008c, 0x00000004, 0x00000000, 0x00000003, 0x00000003, 0x00000b04,
0x505f5653, 0x7469736f, 0x006e6f69, 0x52545441, 0x61004249, 0x69727474, 0x54410062, 0x42697254,
0xababab00, 0x52444853, 0x00000114, 0x00020040, 0x00000045, 0x05000061, 0x002010f2, 0x00000001,
0x00000000, 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000001, 0x0400005f, 0x00201072,
0x00000001, 0x00000002, 0x0400005f, 0x00201032, 0x00000001, 0x00000003, 0x0400005f, 0x00201042,
0x00000001, 0x00000003, 0x0100085d, 0x0100085c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102072, 0x00000002, 0x03000065, 0x00102032,
0x00000003, 0x03000065, 0x00102042, 0x00000003, 0x0200005e, 0x00000001, 0x06000036, 0x001020f2,
0x00000000, 0x00201e46, 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46,
0x00000000, 0x00000001, 0x06000036, 0x00102072, 0x00000002, 0x00201246, 0x00000000, 0x00000002,
0x06000036, 0x00102072, 0x00000003, 0x00201246, 0x00000000, 0x00000003, 0x01000013, 0x0100003e,
};
static const D3D11_SO_DECLARATION_ENTRY so_declaration[] =
{
{0, "SV_Position", 0, 0, 4, 0},
};
static const D3D11_SO_DECLARATION_ENTRY invalid_gap_declaration[] =
{
{0, "SV_Position", 0, 0, 4, 0},
{0, NULL, 0, 0, 0, 0},
};
static const D3D11_SO_DECLARATION_ENTRY valid_so_declarations[][12] =
{
/* SemanticName and SemanticIndex */
{
{0, "sv_position", 0, 0, 4, 0},
{0, "attrib", 1, 0, 4, 0},
},
{
{0, "sv_position", 0, 0, 4, 0},
{0, "ATTRIB", 1, 0, 4, 0},
},
/* Gaps */
{
{0, "SV_POSITION", 0, 0, 4, 0},
{0, NULL, 0, 0, 8, 0},
{0, "ATTRIB", 1, 0, 4, 0},
},
{
{0, "SV_POSITION", 0, 0, 4, 0},
{0, NULL, 0, 0, 4, 0},
{0, NULL, 0, 0, 4, 0},
{0, "ATTRIB", 1, 0, 4, 0},
},
/* ComponentCount */
{
{0, "ATTRIB", 1, 0, 4, 0},
},
{
{0, "ATTRIB", 2, 0, 3, 0},
},
{
{0, "ATTRIB", 3, 0, 2, 0},
},
{
{0, "ATTRIB", 4, 0, 1, 0},
},
/* ComponentIndex */
{
{0, "ATTRIB", 1, 1, 3, 0},
},
{
{0, "ATTRIB", 1, 2, 2, 0},
},
{
{0, "ATTRIB", 1, 3, 1, 0},
},
{
{0, "ATTRIB", 3, 1, 1, 0},
},
/* OutputSlot */
{
{0, "attrib", 1, 0, 4, 0},
},
{
{0, "attrib", 1, 0, 4, 1},
},
{
{0, "attrib", 1, 0, 4, 2},
},
{
{0, "attrib", 1, 0, 4, 3},
},
{
{0, "attrib", 1, 0, 4, 0},
{0, "attrib", 2, 0, 3, 1},
{0, NULL, 0, 0, 1, 1},
{0, "attrib", 3, 0, 2, 2},
{0, NULL, 0, 0, 2, 2},
{0, "attrib", 4, 0, 1, 3},
{0, NULL, 0, 0, 7, 3},
},
{
{0, "attrib", 1, 0, 4, 0},
{0, "attrib", 2, 0, 3, 1},
{0, NULL, 0, 0, 1, 1},
{0, "attrib", 3, 0, 2, 2},
{0, NULL, 0, 0, 1, 2},
{0, NULL, 0, 0, 1, 2},
{0, "attrib", 4, 0, 1, 3},
{0, NULL, 0, 0, 3, 3},
{0, NULL, 0, 0, 1, 3},
{0, NULL, 0, 0, 1, 3},
{0, NULL, 0, 0, 1, 3},
{0, NULL, 0, 0, 1, 3},
},
{
{0, "attrib", 1, 0, 4, 0},
{0, "attrib", 2, 0, 3, 0},
{0, "attrib", 3, 0, 2, 0},
{0, NULL, 0, 0, 1, 0},
{0, "attrib", 4, 0, 1, 0},
},
{
{0, "attrib", 1, 0, 4, 0},
{0, "attrib", 2, 0, 3, 0},
{0, "attrib", 3, 0, 2, 3},
{0, NULL, 0, 0, 1, 3},
{0, "attrib", 4, 0, 1, 3},
},
/* Multiple occurrences of the same output */
{
{0, "ATTRIB", 1, 0, 2, 0},
{0, "ATTRIB", 1, 2, 2, 1},
},
{
{0, "ATTRIB", 1, 0, 1, 0},
{0, "ATTRIB", 1, 1, 3, 0},
},
};
static const D3D11_SO_DECLARATION_ENTRY invalid_so_declarations[][12] =
{
/* SemanticName and SemanticIndex */
{
{0, "SV_Position", 0, 0, 4, 0},
{0, "ATTRIB", 0, 0, 4, 0},
},
{
{0, "sv_position", 0, 0, 4, 0},
{0, "ATTRIB_", 1, 0, 4, 0},
},
/* Gaps */
{
{0, "SV_POSITION", 0, 0, 4, 0},
{0, NULL, 0, 1, 8, 0},
{0, "ATTRIB", 1, 0, 4, 0},
},
{
{0, "SV_POSITION", 0, 0, 4, 0},
{0, NULL, 1, 0, 8, 0},
{0, "ATTRIB", 1, 0, 4, 0},
},
/* Buffer stride */
{
{0, "SV_POSITION", 0, 0, 4, 0},
{0, NULL, 0, 0, 8, 0},
{0, NULL, 0, 0, 8, 0},
{0, "ATTRIB", 1, 0, 4, 0},
},
/* ComponentCount */
{
{0, "ATTRIB", 2, 0, 5, 0},
},
{
{0, "ATTRIB", 2, 0, 4, 0},
},
{
{0, "ATTRIB", 3, 0, 3, 0},
},
{
{0, "ATTRIB", 4, 0, 2, 0},
},
/* ComponentIndex */
{
{0, "ATTRIB", 1, 1, 4, 0},
},
{
{0, "ATTRIB", 1, 2, 3, 0},
},
{
{0, "ATTRIB", 1, 3, 2, 0},
},
{
{0, "ATTRIB", 1, 4, 0, 0},
},
{
{0, "ATTRIB", 1, 4, 1, 0},
},
{
{0, "ATTRIB", 3, 2, 1, 0},
},
{
{0, "ATTRIB", 3, 2, 0, 0},
},
/* OutputSlot */
{
{0, "attrib", 1, 0, 4, 4},
},
{
{0, "attrib", 1, 0, 4, 4},
},
{
{0, "attrib", 1, 0, 4, 4},
},
{
{0, "attrib", 1, 0, 4, 4},
},
{
{0, "attrib", 1, 0, 4, 0},
{0, "attrib", 2, 0, 3, 1},
{0, NULL, 0, 0, 1, 1},
{0, "attrib", 3, 0, 2, 2},
{0, NULL, 0, 0, 2, 2},
{0, "attrib", 4, 0, 1, 3},
{0, NULL, 0, 0, 3, 4},
},
{
{0, "attrib", 1, 0, 4, 0},
{0, "attrib", 2, 0, 3, 0},
{0, "attrib", 3, 0, 2, 0},
{0, NULL, 0, 0, 1, 0},
{0, "attrib", 4, 0, 1, 0},
{0, NULL, 0, 0, 3, 3},
{0, NULL, 0, 0, 1, 3},
{0, NULL, 0, 0, 1, 3},
{0, NULL, 0, 0, 1, 3},
{0, NULL, 0, 0, 1, 3},
},
{
{0, "attrib", 1, 0, 4, 0},
{0, NULL, 0, 0, 3, 1},
{0, NULL, 0, 0, 1, 1},
{0, NULL, 0, 0, 1, 2},
{0, "attrib", 2, 0, 3, 3},
{0, NULL, 0, 0, 1, 3},
},
{
{0, "attrib", 2, 0, 3, 3},
{0, NULL, 0, 0, 3, 1},
{0, NULL, 0, 0, 1, 3},
{0, "attrib", 1, 0, 4, 0},
{0, NULL, 0, 0, 1, 2},
{0, NULL, 0, 0, 1, 1},
},
/* Stream */
{
{1, "attrib", 1, 0, 4, 0},
},
{
{4, "attrib", 1, 0, 4, 0},
},
/* Multiple occurrences of the same output */
{
{0, "ATTRIB", 1, 0, 4, 0},
{0, "ATTRIB", 1, 0, 4, 1},
},
{
{0, "ATTRIB", 1, 0, 4, 0},
{0, "ATTRIB", 1, 0, 3, 0},
},
};
if (!init_test_context(&test_context, &feature_level))
return;
device = test_context.device;
for (i = 0; i < ARRAY_SIZE(stride); ++i)
stride[i] = 64;
check_so_desc(device, gs_code, sizeof(gs_code), NULL, 0, NULL, 0, D3D11_SO_NO_RASTERIZED_STREAM);
check_so_desc(device, gs_code, sizeof(gs_code), NULL, 0, stride, 1, D3D11_SO_NO_RASTERIZED_STREAM);
check_so_desc(device, gs_code, sizeof(gs_code), so_declaration, ARRAY_SIZE(so_declaration),
NULL, 0, D3D11_SO_NO_RASTERIZED_STREAM);
check_so_desc(device, gs_code, sizeof(gs_code), so_declaration, ARRAY_SIZE(so_declaration),
stride, 1, D3D11_SO_NO_RASTERIZED_STREAM);
todo_wine
check_so_desc(device, vs_code, sizeof(vs_code), so_declaration, ARRAY_SIZE(so_declaration),
NULL, 0, D3D11_SO_NO_RASTERIZED_STREAM);
todo_wine
check_so_desc(device, vs_code, sizeof(vs_code), so_declaration, ARRAY_SIZE(so_declaration),
stride, 1, D3D11_SO_NO_RASTERIZED_STREAM);
check_invalid_so_desc(device, gs_code, sizeof(gs_code), so_declaration, 0,
stride, 1, D3D11_SO_NO_RASTERIZED_STREAM);
check_invalid_so_desc(device, gs_code, sizeof(gs_code),
invalid_gap_declaration, ARRAY_SIZE(invalid_gap_declaration),
stride, 1, D3D11_SO_NO_RASTERIZED_STREAM);
check_invalid_so_desc(device, vs_code, sizeof(vs_code), so_declaration, 0,
NULL, 0, D3D11_SO_NO_RASTERIZED_STREAM);
check_invalid_so_desc(device, vs_code, sizeof(vs_code), NULL, 0,
NULL, 0, D3D11_SO_NO_RASTERIZED_STREAM);
for (i = 0; i < ARRAY_SIZE(valid_so_declarations); ++i)
{
unsigned int max_output_slot = 0;
for (count = 0; count < ARRAY_SIZE(valid_so_declarations[i]); ++count)
{
const D3D11_SO_DECLARATION_ENTRY *e = &valid_so_declarations[i][count];
max_output_slot = max(max_output_slot, e->OutputSlot);
if (!e->Stream && !e->SemanticName && !e->SemanticIndex && !e->ComponentCount)
break;
}
/* Buffer strides are required for all buffers. */
if (!max_output_slot)
{
check_so_desc(device, gs_code, sizeof(gs_code), valid_so_declarations[i], count,
NULL, 0, D3D11_SO_NO_RASTERIZED_STREAM);
check_so_desc(device, gs_code, sizeof(gs_code), valid_so_declarations[i], count,
stride, 1, D3D11_SO_NO_RASTERIZED_STREAM);
check_so_desc(device, gs_code, sizeof(gs_code), valid_so_declarations[i], count,
stride, 2, D3D11_SO_NO_RASTERIZED_STREAM);
check_so_desc(device, gs_code, sizeof(gs_code), valid_so_declarations[i], count,
stride, 3, D3D11_SO_NO_RASTERIZED_STREAM);
check_so_desc(device, gs_code, sizeof(gs_code), valid_so_declarations[i], count,
stride, 4, D3D11_SO_NO_RASTERIZED_STREAM);
}
else
{
check_so_desc(device, gs_code, sizeof(gs_code), valid_so_declarations[i], count,
NULL, 0, D3D11_SO_NO_RASTERIZED_STREAM);
check_so_desc(device, gs_code, sizeof(gs_code), valid_so_declarations[i], count,
stride, max_output_slot + 1, D3D11_SO_NO_RASTERIZED_STREAM);
}
}
for (i = 0; i < ARRAY_SIZE(invalid_so_declarations); ++i)
{
for (count = 0; count < ARRAY_SIZE(invalid_so_declarations[i]); ++count)
{
const D3D11_SO_DECLARATION_ENTRY *e = &invalid_so_declarations[i][count];
if (!e->Stream && !e->SemanticName && !e->SemanticIndex && !e->ComponentCount)
break;
}
check_invalid_so_desc(device, gs_code, sizeof(gs_code), invalid_so_declarations[i], count,
stride, 1, D3D11_SO_NO_RASTERIZED_STREAM);
check_invalid_so_desc(device, gs_code, sizeof(gs_code), invalid_so_declarations[i], count,
stride, 2, D3D11_SO_NO_RASTERIZED_STREAM);
check_invalid_so_desc(device, gs_code, sizeof(gs_code), invalid_so_declarations[i], count,
stride, 3, D3D11_SO_NO_RASTERIZED_STREAM);
check_invalid_so_desc(device, gs_code, sizeof(gs_code), invalid_so_declarations[i], count,
stride, 4, D3D11_SO_NO_RASTERIZED_STREAM);
}
/* Buffer strides */
stride[1] = 63;
check_invalid_so_desc(device, gs_code, sizeof(gs_code), so_declaration, ARRAY_SIZE(so_declaration),
&stride[1], 1, D3D11_SO_NO_RASTERIZED_STREAM);
check_so_desc(device, gs_code, sizeof(gs_code), so_declaration, ARRAY_SIZE(so_declaration),
stride, 2, D3D11_SO_NO_RASTERIZED_STREAM);
stride[1] = 1;
check_so_desc(device, gs_code, sizeof(gs_code), so_declaration, ARRAY_SIZE(so_declaration),
stride, 2, D3D11_SO_NO_RASTERIZED_STREAM);
/* Rasterizer stream */
for (i = 0; i < D3D11_SO_STREAM_COUNT; ++i)
check_so_desc(device, gs_code, sizeof(gs_code), so_declaration, ARRAY_SIZE(so_declaration), NULL, 0, i);
check_invalid_so_desc(device, gs_code, sizeof(gs_code), so_declaration, ARRAY_SIZE(so_declaration),
NULL, 0, D3D11_SO_STREAM_COUNT);
release_test_context(&test_context);
}
static void test_stream_output_resume(void)
{
struct d3d11_test_context test_context;
@ -16238,5 +16710,6 @@ START_TEST(d3d11)
test_compute_shader_registers();
test_tgsm();
test_geometry_shader();
test_stream_output();
test_stream_output_resume();
}