d3d10core/tests: Add test for sample_c_lz instruction.
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:
parent
ac36e446c3
commit
e4069767e7
|
@ -8016,6 +8016,229 @@ static void test_depth_stencil_sampling(void)
|
|||
release_test_context(&test_context);
|
||||
}
|
||||
|
||||
static void test_sample_c_lz(void)
|
||||
{
|
||||
struct d3d10core_test_context test_context;
|
||||
D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc;
|
||||
D3D10_DEPTH_STENCIL_VIEW_DESC dsv_desc;
|
||||
ID3D10Texture2D *texture, *rt_texture;
|
||||
D3D10_TEXTURE2D_DESC texture_desc;
|
||||
D3D10_SAMPLER_DESC sampler_desc;
|
||||
ID3D10ShaderResourceView *srv;
|
||||
ID3D10DepthStencilView *dsv;
|
||||
ID3D10RenderTargetView *rtv;
|
||||
ID3D10SamplerState *sampler;
|
||||
struct vec4 ps_constant;
|
||||
ID3D10PixelShader *ps;
|
||||
ID3D10Device *device;
|
||||
ID3D10Buffer *cb;
|
||||
unsigned int i;
|
||||
HRESULT hr;
|
||||
RECT rect;
|
||||
|
||||
static const float clear_color[] = {0.5f, 0.5f, 0.5f, 0.5f};
|
||||
static const DWORD ps_cube_code[] =
|
||||
{
|
||||
#if 0
|
||||
TextureCube t;
|
||||
SamplerComparisonState s;
|
||||
|
||||
float ref;
|
||||
float face;
|
||||
|
||||
float4 main(float4 position : SV_Position) : SV_Target
|
||||
{
|
||||
float2 p;
|
||||
p.x = position.x / 640.0f;
|
||||
p.y = position.y / 480.0f;
|
||||
|
||||
float3 coord;
|
||||
switch ((uint)face)
|
||||
{
|
||||
case 0:
|
||||
coord = float3(1.0f, p.x, p.y);
|
||||
break;
|
||||
case 1:
|
||||
coord = float3(-1.0f, p.x, p.y);
|
||||
break;
|
||||
case 2:
|
||||
coord = float3(p.x, 1.0f, p.y);
|
||||
break;
|
||||
case 3:
|
||||
coord = float3(p.x, -1.0f, p.y);
|
||||
break;
|
||||
case 4:
|
||||
coord = float3(p.x, p.y, 1.0f);
|
||||
break;
|
||||
case 5:
|
||||
default:
|
||||
coord = float3(p.x, p.y, -1.0f);
|
||||
break;
|
||||
}
|
||||
|
||||
return t.SampleCmpLevelZero(s, coord, ref);
|
||||
}
|
||||
#endif
|
||||
0x43425844, 0x6a84fc2d, 0x0a599d2f, 0xf7e42c22, 0x1c880369, 0x00000001, 0x00000324, 0x00000003,
|
||||
0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
|
||||
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
|
||||
0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
|
||||
0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000288, 0x00000040,
|
||||
0x000000a2, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300085a, 0x00106000, 0x00000000,
|
||||
0x04003058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, 0x00000001,
|
||||
0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0600001c, 0x00100012, 0x00000000,
|
||||
0x0020801a, 0x00000000, 0x00000000, 0x0300004c, 0x0010000a, 0x00000000, 0x03000006, 0x00004001,
|
||||
0x00000000, 0x05000036, 0x00100012, 0x00000000, 0x00004001, 0x3f800000, 0x0a000038, 0x00100062,
|
||||
0x00000000, 0x00101106, 0x00000000, 0x00004002, 0x00000000, 0x3acccccd, 0x3b088889, 0x00000000,
|
||||
0x01000002, 0x03000006, 0x00004001, 0x00000001, 0x05000036, 0x00100012, 0x00000000, 0x00004001,
|
||||
0xbf800000, 0x0a000038, 0x00100062, 0x00000000, 0x00101106, 0x00000000, 0x00004002, 0x00000000,
|
||||
0x3acccccd, 0x3b088889, 0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000002, 0x0a000038,
|
||||
0x00100052, 0x00000000, 0x00101106, 0x00000000, 0x00004002, 0x3acccccd, 0x00000000, 0x3b088889,
|
||||
0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x00004001, 0x3f800000, 0x01000002, 0x03000006,
|
||||
0x00004001, 0x00000003, 0x0a000038, 0x00100052, 0x00000000, 0x00101106, 0x00000000, 0x00004002,
|
||||
0x3acccccd, 0x00000000, 0x3b088889, 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x00004001,
|
||||
0xbf800000, 0x01000002, 0x03000006, 0x00004001, 0x00000004, 0x0a000038, 0x00100032, 0x00000000,
|
||||
0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000, 0x05000036,
|
||||
0x00100042, 0x00000000, 0x00004001, 0x3f800000, 0x01000002, 0x0100000a, 0x0a000038, 0x00100032,
|
||||
0x00000000, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, 0x00000000,
|
||||
0x05000036, 0x00100042, 0x00000000, 0x00004001, 0xbf800000, 0x01000002, 0x01000017, 0x0c000047,
|
||||
0x00100012, 0x00000000, 0x00100246, 0x00000000, 0x00107006, 0x00000000, 0x00106000, 0x00000000,
|
||||
0x0020800a, 0x00000000, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000,
|
||||
0x0100003e,
|
||||
};
|
||||
static const float depth_values[] = {1.0f, 0.0f, 0.5f, 0.6f, 0.4f, 0.1f};
|
||||
static const struct
|
||||
{
|
||||
unsigned int layer;
|
||||
float d_ref;
|
||||
float expected;
|
||||
}
|
||||
tests[] =
|
||||
{
|
||||
{0, 0.5f, 0.0f},
|
||||
{1, 0.5f, 1.0f},
|
||||
{2, 0.5f, 0.0f},
|
||||
{3, 0.5f, 0.0f},
|
||||
{4, 0.5f, 1.0f},
|
||||
{5, 0.5f, 1.0f},
|
||||
|
||||
{0, 0.0f, 0.0f},
|
||||
{1, 0.0f, 0.0f},
|
||||
{2, 0.0f, 0.0f},
|
||||
{3, 0.0f, 0.0f},
|
||||
{4, 0.0f, 0.0f},
|
||||
{5, 0.0f, 0.0f},
|
||||
|
||||
{0, 1.0f, 0.0f},
|
||||
{1, 1.0f, 1.0f},
|
||||
{2, 1.0f, 1.0f},
|
||||
{3, 1.0f, 1.0f},
|
||||
{4, 1.0f, 1.0f},
|
||||
{5, 1.0f, 1.0f},
|
||||
};
|
||||
|
||||
if (!init_test_context(&test_context))
|
||||
return;
|
||||
|
||||
device = test_context.device;
|
||||
|
||||
sampler_desc.Filter = D3D10_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR;
|
||||
sampler_desc.AddressU = D3D10_TEXTURE_ADDRESS_CLAMP;
|
||||
sampler_desc.AddressV = D3D10_TEXTURE_ADDRESS_CLAMP;
|
||||
sampler_desc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP;
|
||||
sampler_desc.MipLODBias = 0.0f;
|
||||
sampler_desc.MaxAnisotropy = 0;
|
||||
sampler_desc.ComparisonFunc = D3D10_COMPARISON_GREATER;
|
||||
sampler_desc.BorderColor[0] = 0.0f;
|
||||
sampler_desc.BorderColor[1] = 0.0f;
|
||||
sampler_desc.BorderColor[2] = 0.0f;
|
||||
sampler_desc.BorderColor[3] = 0.0f;
|
||||
sampler_desc.MinLOD = 0.0f;
|
||||
sampler_desc.MaxLOD = 10.0f;
|
||||
hr = ID3D10Device_CreateSamplerState(device, &sampler_desc, &sampler);
|
||||
ok(hr == S_OK, "Failed to create sampler state, hr %#x.\n", hr);
|
||||
|
||||
ID3D10Texture2D_GetDesc(test_context.backbuffer, &texture_desc);
|
||||
texture_desc.Format = DXGI_FORMAT_R32_FLOAT;
|
||||
hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &rt_texture);
|
||||
ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr);
|
||||
hr = ID3D10Device_CreateRenderTargetView(device, (ID3D10Resource *)rt_texture, NULL, &rtv);
|
||||
ok(hr == S_OK, "Failed to create rendertarget view, hr %#x.\n", hr);
|
||||
ID3D10Device_OMSetRenderTargets(device, 1, &rtv, NULL);
|
||||
|
||||
memset(&ps_constant, 0, sizeof(ps_constant));
|
||||
cb = create_buffer(device, D3D10_BIND_CONSTANT_BUFFER, sizeof(ps_constant), &ps_constant);
|
||||
|
||||
/* 2D array texture */
|
||||
texture_desc.Width = 32;
|
||||
texture_desc.Height = 32;
|
||||
texture_desc.MipLevels = 2;
|
||||
texture_desc.ArraySize = ARRAY_SIZE(depth_values);
|
||||
texture_desc.Format = DXGI_FORMAT_R32_TYPELESS;
|
||||
texture_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE | D3D10_BIND_DEPTH_STENCIL;
|
||||
texture_desc.MiscFlags = D3D10_RESOURCE_MISC_TEXTURECUBE;
|
||||
hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
|
||||
ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(depth_values); ++i)
|
||||
{
|
||||
dsv_desc.Format = DXGI_FORMAT_D32_FLOAT;
|
||||
dsv_desc.ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2DARRAY;
|
||||
U(dsv_desc).Texture2DArray.MipSlice = 0;
|
||||
U(dsv_desc).Texture2DArray.FirstArraySlice = i;
|
||||
U(dsv_desc).Texture2DArray.ArraySize = 1;
|
||||
|
||||
hr = ID3D10Device_CreateDepthStencilView(device, (ID3D10Resource *)texture, &dsv_desc, &dsv);
|
||||
ok(hr == S_OK, "Failed to create depth stencil view, hr %#x.\n", hr);
|
||||
ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH, depth_values[i], 0);
|
||||
ID3D10DepthStencilView_Release(dsv);
|
||||
|
||||
U(dsv_desc).Texture2DArray.MipSlice = 1;
|
||||
hr = ID3D10Device_CreateDepthStencilView(device, (ID3D10Resource *)texture, &dsv_desc, &dsv);
|
||||
ok(hr == S_OK, "Failed to create depth stencil view, hr %#x.\n", hr);
|
||||
ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH, 1.0f, 0);
|
||||
ID3D10DepthStencilView_Release(dsv);
|
||||
}
|
||||
|
||||
srv_desc.Format = DXGI_FORMAT_R32_FLOAT;
|
||||
srv_desc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURECUBE;
|
||||
U(srv_desc).TextureCube.MostDetailedMip = 0;
|
||||
U(srv_desc).TextureCube.MipLevels = ~0u;
|
||||
hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)texture, &srv_desc, &srv);
|
||||
ok(hr == S_OK, "Failed to create shader resource view, hr %#x.\n", hr);
|
||||
|
||||
hr = ID3D10Device_CreatePixelShader(device, ps_cube_code, sizeof(ps_cube_code), &ps);
|
||||
ok(hr == S_OK, "Failed to create pixel shader, hr %#x.\n", hr);
|
||||
|
||||
ID3D10Device_PSSetShader(device, ps);
|
||||
ID3D10Device_PSSetConstantBuffers(device, 0, 1, &cb);
|
||||
ID3D10Device_PSSetSamplers(device, 0, 1, &sampler);
|
||||
ID3D10Device_PSSetShaderResources(device, 0, 1, &srv);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(tests); ++i)
|
||||
{
|
||||
ps_constant.x = tests[i].d_ref;
|
||||
ps_constant.y = tests[i].layer;
|
||||
ID3D10Device_UpdateSubresource(device, (ID3D10Resource *)cb, 0,
|
||||
NULL, &ps_constant, 0, 0);
|
||||
ID3D10Device_ClearRenderTargetView(device, rtv, clear_color);
|
||||
draw_quad(&test_context);
|
||||
/* Avoid testing values affected by seamless cube map filtering. */
|
||||
SetRect(&rect, 100, 100, 540, 380);
|
||||
check_texture_sub_resource_float(rt_texture, 0, &rect, tests[i].expected, 2);
|
||||
}
|
||||
|
||||
ID3D10Texture2D_Release(texture);
|
||||
ID3D10ShaderResourceView_Release(srv);
|
||||
|
||||
ID3D10Buffer_Release(cb);
|
||||
ID3D10PixelShader_Release(ps);
|
||||
ID3D10RenderTargetView_Release(rtv);
|
||||
ID3D10SamplerState_Release(sampler);
|
||||
ID3D10Texture2D_Release(rt_texture);
|
||||
release_test_context(&test_context);
|
||||
}
|
||||
|
||||
static void test_multiple_render_targets(void)
|
||||
{
|
||||
ID3D10RenderTargetView *rtv[4], *tmp_rtv[4];
|
||||
|
@ -17697,6 +17920,7 @@ START_TEST(d3d10core)
|
|||
queue_test(test_texture);
|
||||
queue_test(test_cube_maps);
|
||||
queue_test(test_depth_stencil_sampling);
|
||||
queue_test(test_sample_c_lz);
|
||||
queue_test(test_multiple_render_targets);
|
||||
queue_test(test_private_data);
|
||||
queue_test(test_state_refcounting);
|
||||
|
|
Loading…
Reference in New Issue