d3d10core/tests: Add test for shaders interstage interface.

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-10-19 10:07:26 +02:00 committed by Alexandre Julliard
parent 608b6e2018
commit e162ae2333
1 changed files with 160 additions and 0 deletions

View File

@ -9039,6 +9039,165 @@ static void test_shader_stage_input_output_matching(void)
release_test_context(&test_context);
}
static void test_shader_interstage_interface(void)
{
struct d3d10core_test_context test_context;
D3D10_TEXTURE2D_DESC texture_desc;
ID3D10InputLayout *input_layout;
ID3D10Texture2D *render_target;
ID3D10RenderTargetView *rtv;
ID3D10VertexShader *vs;
ID3D10PixelShader *ps;
ID3D10Device *device;
UINT stride, offset;
ID3D10Buffer *vb;
HRESULT hr;
static const DWORD vs_code[] =
{
#if 0
struct vertex
{
float4 position : SV_Position;
float2 t0 : TEXCOORD0;
nointerpolation float t1 : TEXCOORD1;
uint t2 : TEXCOORD2;
uint t3 : TEXCOORD3;
float t4 : TEXCOORD4;
};
void main(in vertex vin, out vertex vout)
{
vout = vin;
}
#endif
0x43425844, 0xd55780bf, 0x76866b06, 0x45d697a2, 0xafac2ecd, 0x00000001, 0x000002bc, 0x00000003,
0x0000002c, 0x000000e4, 0x0000019c, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098,
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x000000a4, 0x00000000, 0x00000000,
0x00000003, 0x00000001, 0x00000303, 0x000000a4, 0x00000001, 0x00000000, 0x00000003, 0x00000002,
0x00000101, 0x000000a4, 0x00000002, 0x00000000, 0x00000001, 0x00000003, 0x00000101, 0x000000a4,
0x00000003, 0x00000000, 0x00000001, 0x00000004, 0x00000101, 0x000000a4, 0x00000004, 0x00000000,
0x00000003, 0x00000005, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
0xababab00, 0x4e47534f, 0x000000b0, 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x00000001,
0x00000003, 0x00000000, 0x0000000f, 0x000000a4, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
0x00000c03, 0x000000a4, 0x00000004, 0x00000000, 0x00000003, 0x00000001, 0x00000b04, 0x000000a4,
0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x00000e01, 0x000000a4, 0x00000002, 0x00000000,
0x00000001, 0x00000002, 0x00000d02, 0x000000a4, 0x00000003, 0x00000000, 0x00000001, 0x00000002,
0x00000b04, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f, 0xababab00, 0x52444853,
0x00000118, 0x00010040, 0x00000046, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101032,
0x00000001, 0x0300005f, 0x00101012, 0x00000002, 0x0300005f, 0x00101012, 0x00000003, 0x0300005f,
0x00101012, 0x00000004, 0x0300005f, 0x00101012, 0x00000005, 0x04000067, 0x001020f2, 0x00000000,
0x00000001, 0x03000065, 0x00102032, 0x00000001, 0x03000065, 0x00102042, 0x00000001, 0x03000065,
0x00102012, 0x00000002, 0x03000065, 0x00102022, 0x00000002, 0x03000065, 0x00102042, 0x00000002,
0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102032, 0x00000001,
0x00101046, 0x00000001, 0x05000036, 0x00102042, 0x00000001, 0x0010100a, 0x00000005, 0x05000036,
0x00102012, 0x00000002, 0x0010100a, 0x00000002, 0x05000036, 0x00102022, 0x00000002, 0x0010100a,
0x00000003, 0x05000036, 0x00102042, 0x00000002, 0x0010100a, 0x00000004, 0x0100003e,
};
static const DWORD ps_code[] =
{
#if 0
void main(float4 position : SV_Position, float2 t0 : TEXCOORD0,
nointerpolation float t1 : TEXCOORD1, uint t2 : TEXCOORD2,
uint t3 : TEXCOORD3, float t4 : TEXCOORD4, out float4 o : SV_Target)
{
o.x = t0.y + t1;
o.y = t2 + t3;
o.z = t4;
o.w = t0.x;
}
#endif
0x43425844, 0x8a7ef706, 0xc8f2cbf1, 0x83a05df1, 0xfab8e613, 0x00000001, 0x000001dc, 0x00000003,
0x0000002c, 0x000000e4, 0x00000118, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098,
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x000000a4, 0x00000000, 0x00000000,
0x00000003, 0x00000001, 0x00000303, 0x000000a4, 0x00000004, 0x00000000, 0x00000003, 0x00000001,
0x00000404, 0x000000a4, 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x00000101, 0x000000a4,
0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x00000202, 0x000000a4, 0x00000003, 0x00000000,
0x00000001, 0x00000002, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f,
0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000bc,
0x00000040, 0x0000002f, 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x00101042, 0x00000001,
0x03000862, 0x00101012, 0x00000002, 0x03000862, 0x00101022, 0x00000002, 0x03000862, 0x00101042,
0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700001e, 0x00100012,
0x00000000, 0x0010101a, 0x00000002, 0x0010102a, 0x00000002, 0x05000056, 0x00102022, 0x00000000,
0x0010000a, 0x00000000, 0x07000000, 0x00102012, 0x00000000, 0x0010101a, 0x00000001, 0x0010100a,
0x00000002, 0x05000036, 0x001020c2, 0x00000000, 0x001012a6, 0x00000001, 0x0100003e,
};
static const D3D10_INPUT_ELEMENT_DESC layout_desc[] =
{
{"SV_POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"TEXCOORD", 1, DXGI_FORMAT_R32_FLOAT, 0, 16, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"TEXCOORD", 2, DXGI_FORMAT_R32_UINT, 0, 20, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"TEXCOORD", 3, DXGI_FORMAT_R32_UINT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"TEXCOORD", 4, DXGI_FORMAT_R32_FLOAT, 0, 28, D3D10_INPUT_PER_VERTEX_DATA, 0},
};
static const struct
{
struct vec2 position;
struct vec2 t0;
float t1;
unsigned int t2;
unsigned int t3;
float t4;
}
quad[] =
{
{{-1.0f, -1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f},
{{-1.0f, 1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f},
{{ 1.0f, -1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f},
{{ 1.0f, 1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f},
};
static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
static const struct vec4 expected_result = {10.0f, 8.0f, 7.0f, 3.0f};
if (!init_test_context(&test_context))
return;
device = test_context.device;
hr = ID3D10Device_CreateVertexShader(device, vs_code, sizeof(vs_code), &vs);
ok(SUCCEEDED(hr), "Failed to create vertex shader, hr %#x.\n", hr);
hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &ps);
ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
ID3D10Texture2D_GetDesc(test_context.backbuffer, &texture_desc);
texture_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &render_target);
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)render_target, NULL, &rtv);
ok(SUCCEEDED(hr), "Failed to create render target view, hr %#x.\n", hr);
hr = ID3D10Device_CreateInputLayout(device, layout_desc, ARRAY_SIZE(layout_desc),
vs_code, sizeof(vs_code), &input_layout);
ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
vb = create_buffer(device, D3D10_BIND_VERTEX_BUFFER, sizeof(quad), quad);
ID3D10Device_ClearRenderTargetView(device, rtv, white);
ID3D10Device_OMSetRenderTargets(device, 1, &rtv, NULL);
ID3D10Device_PSSetShader(device, ps);
ID3D10Device_VSSetShader(device, vs);
ID3D10Device_IASetInputLayout(device, input_layout);
ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
offset = 0;
stride = sizeof(*quad);
ID3D10Device_IASetVertexBuffers(device, 0, 1, &vb, &stride, &offset);
ID3D10Device_Draw(device, 4, 0);
check_texture_vec4(render_target, &expected_result, 0);
ID3D10InputLayout_Release(input_layout);
ID3D10RenderTargetView_Release(rtv);
ID3D10Texture2D_Release(render_target);
ID3D10PixelShader_Release(ps);
ID3D10VertexShader_Release(vs);
ID3D10Buffer_Release(vb);
release_test_context(&test_context);
}
static void test_sm4_if_instruction(void)
{
struct d3d10core_test_context test_context;
@ -12598,6 +12757,7 @@ START_TEST(device)
test_clear_depth_stencil_view();
test_draw_depth_only();
test_shader_stage_input_output_matching();
test_shader_interstage_interface();
test_sm4_if_instruction();
test_sm4_breakc_instruction();
test_sm4_continuec_instruction();