d3d10core/tests: Add a test for color masks.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
8ddf4e20a5
commit
3b043c1fdf
|
@ -18064,6 +18064,118 @@ static void test_desktop_window(void)
|
|||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
}
|
||||
|
||||
static void test_color_mask(void)
|
||||
{
|
||||
struct d3d10core_test_context test_context;
|
||||
D3D10_TEXTURE2D_DESC texture_desc;
|
||||
ID3D10RenderTargetView *rtvs[8];
|
||||
ID3D10BlendState *blend_state;
|
||||
struct resource_readback rb;
|
||||
D3D10_BLEND_DESC blend_desc;
|
||||
ID3D10Texture2D *rts[8];
|
||||
ID3D10PixelShader *ps;
|
||||
ID3D10Device *device;
|
||||
unsigned int i;
|
||||
DWORD color;
|
||||
HRESULT hr;
|
||||
|
||||
static const DWORD expected_colors[] =
|
||||
{0xff000080, 0xff0080ff, 0xff8000ff, 0x80808080, 0x800000ff, 0xff008080, 0x800080ff, 0xff0000ff};
|
||||
|
||||
static const DWORD ps_code[] =
|
||||
{
|
||||
#if 0
|
||||
void main(float4 position : SV_Position,
|
||||
out float4 t0 : SV_Target0, out float4 t1 : SV_Target1,
|
||||
out float4 t2 : SV_Target2, out float4 t3 : SV_Target3,
|
||||
out float4 t4 : SV_Target4, out float4 t5 : SV_Target5,
|
||||
out float4 t6 : SV_Target6, out float4 t7 : SV_Target7)
|
||||
{
|
||||
t0 = t1 = t2 = t3 = t4 = t5 = t6 = t7 = float4(0.5f, 0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
#endif
|
||||
0x43425844, 0x7b1ab233, 0xdbe32d3b, 0x77084cc5, 0xe874d2b5, 0x00000001, 0x000002b0, 0x00000003,
|
||||
0x0000002c, 0x00000060, 0x0000013c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
|
||||
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69,
|
||||
0x4e47534f, 0x000000d4, 0x00000008, 0x00000008, 0x000000c8, 0x00000000, 0x00000000, 0x00000003,
|
||||
0x00000000, 0x0000000f, 0x000000c8, 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x0000000f,
|
||||
0x000000c8, 0x00000002, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x000000c8, 0x00000003,
|
||||
0x00000000, 0x00000003, 0x00000003, 0x0000000f, 0x000000c8, 0x00000004, 0x00000000, 0x00000003,
|
||||
0x00000004, 0x0000000f, 0x000000c8, 0x00000005, 0x00000000, 0x00000003, 0x00000005, 0x0000000f,
|
||||
0x000000c8, 0x00000006, 0x00000000, 0x00000003, 0x00000006, 0x0000000f, 0x000000c8, 0x00000007,
|
||||
0x00000000, 0x00000003, 0x00000007, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853,
|
||||
0x0000016c, 0x00000040, 0x0000005b, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2,
|
||||
0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000003, 0x03000065,
|
||||
0x001020f2, 0x00000004, 0x03000065, 0x001020f2, 0x00000005, 0x03000065, 0x001020f2, 0x00000006,
|
||||
0x03000065, 0x001020f2, 0x00000007, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f000000,
|
||||
0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3f000000,
|
||||
0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x3f000000,
|
||||
0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x3f000000,
|
||||
0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000004, 0x00004002, 0x3f000000,
|
||||
0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000005, 0x00004002, 0x3f000000,
|
||||
0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000006, 0x00004002, 0x3f000000,
|
||||
0x3f000000, 0x3f000000, 0x3f000000, 0x08000036, 0x001020f2, 0x00000007, 0x00004002, 0x3f000000,
|
||||
0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e,
|
||||
};
|
||||
|
||||
static const float red[] = {1.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
||||
if (!init_test_context(&test_context))
|
||||
return;
|
||||
|
||||
device = test_context.device;
|
||||
|
||||
hr = ID3D10Device_CreatePixelShader(device, ps_code, sizeof(ps_code), &ps);
|
||||
ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
|
||||
ID3D10Device_PSSetShader(device, ps);
|
||||
|
||||
memset(&blend_desc, 0, sizeof(blend_desc));
|
||||
blend_desc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_RED;
|
||||
blend_desc.RenderTargetWriteMask[1] = D3D10_COLOR_WRITE_ENABLE_GREEN;
|
||||
blend_desc.RenderTargetWriteMask[2] = D3D10_COLOR_WRITE_ENABLE_BLUE;
|
||||
blend_desc.RenderTargetWriteMask[3] = D3D10_COLOR_WRITE_ENABLE_ALL;
|
||||
blend_desc.RenderTargetWriteMask[4] = D3D10_COLOR_WRITE_ENABLE_ALPHA;
|
||||
blend_desc.RenderTargetWriteMask[5] = D3D10_COLOR_WRITE_ENABLE_RED | D3D10_COLOR_WRITE_ENABLE_GREEN;
|
||||
blend_desc.RenderTargetWriteMask[6] = D3D10_COLOR_WRITE_ENABLE_GREEN | D3D10_COLOR_WRITE_ENABLE_ALPHA;
|
||||
blend_desc.RenderTargetWriteMask[7] = 0;
|
||||
|
||||
hr = ID3D10Device_CreateBlendState(device, &blend_desc, &blend_state);
|
||||
ok(hr == S_OK, "Failed to create blend state, hr %#x.\n", hr);
|
||||
ID3D10Device_OMSetBlendState(device, blend_state, NULL, D3D10_DEFAULT_SAMPLE_MASK);
|
||||
|
||||
for (i = 0; i < 8; ++i)
|
||||
{
|
||||
ID3D10Texture2D_GetDesc(test_context.backbuffer, &texture_desc);
|
||||
hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &rts[i]);
|
||||
ok(hr == S_OK, "Failed to create texture %u, hr %#x.\n", i, hr);
|
||||
|
||||
hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)rts[i], NULL, &rtvs[i]);
|
||||
ok(hr == S_OK, "Failed to create rendertarget view %u, hr %#x.\n", i, hr);
|
||||
}
|
||||
|
||||
ID3D10Device_OMSetRenderTargets(device, 8, rtvs, NULL);
|
||||
|
||||
for (i = 0; i < 8; ++i)
|
||||
ID3D10Device_ClearRenderTargetView(device, rtvs[i], red);
|
||||
draw_quad(&test_context);
|
||||
|
||||
for (i = 0; i < 8; ++i)
|
||||
{
|
||||
get_texture_readback(rts[i], 0, &rb);
|
||||
color = get_readback_color(&rb, 320, 240);
|
||||
todo_wine_if (i >= 4)
|
||||
ok(color == expected_colors[i], "%u: Got unexpected color 0x%08x.\n", i, color);
|
||||
release_resource_readback(&rb);
|
||||
|
||||
ID3D10Texture2D_Release(rts[i]);
|
||||
ID3D10RenderTargetView_Release(rtvs[i]);
|
||||
}
|
||||
|
||||
ID3D10BlendState_Release(blend_state);
|
||||
ID3D10PixelShader_Release(ps);
|
||||
release_test_context(&test_context);
|
||||
}
|
||||
|
||||
START_TEST(d3d10core)
|
||||
{
|
||||
unsigned int argc, i;
|
||||
|
@ -18182,6 +18294,7 @@ START_TEST(d3d10core)
|
|||
queue_test(test_staging_buffers);
|
||||
queue_test(test_render_a8);
|
||||
queue_test(test_desktop_window);
|
||||
queue_test(test_color_mask);
|
||||
|
||||
run_queued_tests();
|
||||
|
||||
|
|
Loading…
Reference in New Issue