d3d10core/tests: Port test_multiple_render_targets() from d3d11.

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 2016-03-01 22:20:02 +01:00 committed by Alexandre Julliard
parent 0ac8dd6976
commit 9e9b51f1b1
1 changed files with 175 additions and 0 deletions

View File

@ -3930,6 +3930,180 @@ static void test_texture(void)
DestroyWindow(window);
}
static void test_multiple_render_targets(void)
{
D3D10_SUBRESOURCE_DATA resource_data;
D3D10_TEXTURE2D_DESC texture_desc;
ID3D10InputLayout *input_layout;
unsigned int stride, offset, i;
ID3D10RenderTargetView *rtv[4];
D3D10_BUFFER_DESC buffer_desc;
ID3D10Texture2D *rt[4];
ID3D10VertexShader *vs;
ID3D10PixelShader *ps;
ID3D10Device *device;
D3D10_VIEWPORT vp;
ID3D10Buffer *vb;
ULONG refcount;
HRESULT hr;
static const D3D10_INPUT_ELEMENT_DESC layout_desc[] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
};
static const DWORD vs_code[] =
{
#if 0
float4 main(float4 position : POSITION) : SV_POSITION
{
return position;
}
#endif
0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
};
static const DWORD ps_code[] =
{
#if 0
struct output
{
float4 t1 : SV_TARGET0;
float4 t2 : SV_Target1;
float4 t3 : SV_TARGET2;
float4 t4 : SV_Target3;
};
output main(float4 position : SV_POSITION)
{
struct output o;
o.t1 = (float4)1.0f;
o.t2 = (float4)0.5f;
o.t3 = (float4)0.2f;
o.t4 = float4(0.0f, 0.2f, 0.5f, 1.0f);
return o;
}
#endif
0x43425844, 0x8701ad18, 0xe3d5291d, 0x7b4288a6, 0x01917515, 0x00000001, 0x000001a8, 0x00000003,
0x0000002c, 0x00000060, 0x000000e4, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
0x4e47534f, 0x0000007c, 0x00000004, 0x00000008, 0x00000068, 0x00000000, 0x00000000, 0x00000003,
0x00000000, 0x0000000f, 0x00000072, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
0x00000068, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x00000072, 0x00000003,
0x00000000, 0x00000003, 0x00000003, 0x0000000f, 0x545f5653, 0x45475241, 0x56530054, 0x7261545f,
0x00746567, 0x52444853, 0x000000bc, 0x00000040, 0x0000002f, 0x03000065, 0x001020f2, 0x00000000,
0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x03000065, 0x001020f2,
0x00000003, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000,
0x3f800000, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000,
0x3f000000, 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x3e4ccccd, 0x3e4ccccd, 0x3e4ccccd,
0x3e4ccccd, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x00000000, 0x3e4ccccd, 0x3f000000,
0x3f800000, 0x0100003e,
};
static const struct
{
struct vec2 position;
}
quad[] =
{
{{-1.0f, -1.0f}},
{{-1.0f, 1.0f}},
{{ 1.0f, -1.0f}},
{{ 1.0f, 1.0f}},
};
static const float red[] = {1.0f, 0.0f, 0.0f, 1.0f};
if (!(device = create_device()))
{
skip("Failed to create device.\n");
return;
}
hr = ID3D10Device_CreateInputLayout(device, layout_desc, sizeof(layout_desc) / sizeof(*layout_desc),
vs_code, sizeof(vs_code), &input_layout);
ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
buffer_desc.ByteWidth = sizeof(quad);
buffer_desc.Usage = D3D10_USAGE_DEFAULT;
buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
buffer_desc.CPUAccessFlags = 0;
buffer_desc.MiscFlags = 0;
resource_data.pSysMem = quad;
resource_data.SysMemPitch = 0;
resource_data.SysMemSlicePitch = 0;
hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &resource_data, &vb);
ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
texture_desc.Width = 640;
texture_desc.Height = 480;
texture_desc.MipLevels = 1;
texture_desc.ArraySize = 1;
texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
texture_desc.SampleDesc.Count = 1;
texture_desc.SampleDesc.Quality = 0;
texture_desc.Usage = D3D10_USAGE_DEFAULT;
texture_desc.BindFlags = D3D10_BIND_RENDER_TARGET;
texture_desc.CPUAccessFlags = 0;
texture_desc.MiscFlags = 0;
for (i = 0; i < sizeof(rt) / sizeof(*rt); ++i)
{
hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &rt[i]);
ok(SUCCEEDED(hr), "Failed to create texture %u, hr %#x.\n", i, hr);
hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)rt[i], NULL, &rtv[i]);
ok(SUCCEEDED(hr), "Failed to create rendertarget view %u, hr %#x.\n", i, hr);
}
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);
ID3D10Device_OMSetRenderTargets(device, 4, rtv, NULL);
ID3D10Device_IASetInputLayout(device, input_layout);
ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
stride = sizeof(*quad);
offset = 0;
ID3D10Device_IASetVertexBuffers(device, 0, 1, &vb, &stride, &offset);
ID3D10Device_VSSetShader(device, vs);
ID3D10Device_PSSetShader(device, ps);
vp.TopLeftX = 0;
vp.TopLeftY = 0;
vp.Width = 640;
vp.Height = 480;
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;
ID3D10Device_RSSetViewports(device, 1, &vp);
for (i = 0; i < sizeof(rtv) / sizeof(*rtv); ++i)
ID3D10Device_ClearRenderTargetView(device, rtv[i], red);
ID3D10Device_Draw(device, 4, 0);
check_texture_color(rt[0], 0xffffffff, 2);
check_texture_color(rt[1], 0x7f7f7f7f, 2);
check_texture_color(rt[2], 0x33333333, 2);
check_texture_color(rt[3], 0xff7f3300, 2);
ID3D10Buffer_Release(vb);
ID3D10PixelShader_Release(ps);
ID3D10VertexShader_Release(vs);
ID3D10InputLayout_Release(input_layout);
for (i = 0; i < sizeof(rtv) / sizeof(*rtv); ++i)
ID3D10RenderTargetView_Release(rtv[i]);
for (i = 0; i < sizeof(rt) / sizeof(*rt); ++i)
ID3D10Texture2D_Release(rt[i]);
refcount = ID3D10Device_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
}
static void test_private_data(void)
{
D3D10_TEXTURE2D_DESC texture_desc;
@ -5872,6 +6046,7 @@ START_TEST(device)
test_clear_state();
test_blend();
test_texture();
test_multiple_render_targets();
test_private_data();
test_il_append_aligned();
test_fragment_coords();