mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
d3d11-Depth_Bias: Add tests for depth bias clamp.
This commit is contained in:
parent
deac22809d
commit
1121536608
@ -0,0 +1,175 @@
|
||||
From de26db5e899f92d2477c49fcfc57e673a3048205 Mon Sep 17 00:00:00 2001
|
||||
From: Zebediah Figura <z.figura12@gmail.com>
|
||||
Date: Thu, 17 May 2018 09:29:08 -0500
|
||||
Subject: d3d10core/tests: Add test for depth bias clamp.
|
||||
|
||||
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
|
||||
---
|
||||
dlls/d3d10core/tests/device.c | 120 +++++++++++++++++++++++++-----------------
|
||||
1 file changed, 71 insertions(+), 49 deletions(-)
|
||||
|
||||
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
|
||||
index 50521bd..6e92c77 100644
|
||||
--- a/dlls/d3d10core/tests/device.c
|
||||
+++ b/dlls/d3d10core/tests/device.c
|
||||
@@ -14697,10 +14697,10 @@ static void test_depth_bias(void)
|
||||
struct resource_readback rb;
|
||||
ID3D10DepthStencilView *dsv;
|
||||
unsigned int expected_value;
|
||||
+ unsigned int x, y, i, j, k;
|
||||
ID3D10RasterizerState *rs;
|
||||
ID3D10Texture2D *texture;
|
||||
unsigned int format_idx;
|
||||
- unsigned int x, y, i, j;
|
||||
unsigned int shift = 0;
|
||||
ID3D10Device *device;
|
||||
float *depth_values;
|
||||
@@ -14727,6 +14727,10 @@ static void test_depth_bias(void)
|
||||
-10000, -1000, -100, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 50, 100, 200, 500, 1000, 10000,
|
||||
};
|
||||
+ static const float bias_clamp_tests[] =
|
||||
+ {
|
||||
+ 0.0f, -0.00001f, 0.00001f
|
||||
+ };
|
||||
static const float quad_slopes[] =
|
||||
{
|
||||
0.0f, 0.5f, 1.0f
|
||||
@@ -14819,68 +14823,86 @@ static void test_depth_bias(void)
|
||||
for (j = 0; j < ARRAY_SIZE(bias_tests); ++j)
|
||||
{
|
||||
rasterizer_desc.DepthBias = bias_tests[j];
|
||||
- ID3D10Device_CreateRasterizerState(device, &rasterizer_desc, &rs);
|
||||
- ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
|
||||
- ID3D10Device_RSSetState(device, rs);
|
||||
- ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH, 1.0f, 0);
|
||||
- draw_quad(&test_context);
|
||||
- switch (format)
|
||||
+
|
||||
+ for (k = 0; k < ARRAY_SIZE(bias_clamp_tests); ++k)
|
||||
{
|
||||
- case DXGI_FORMAT_D32_FLOAT:
|
||||
- bias = rasterizer_desc.DepthBias * pow(2.0f, quads[i].exponent - 23.0f);
|
||||
- depth = min(max(0.0f, quads[i].z + bias), 1.0f);
|
||||
+ rasterizer_desc.DepthBiasClamp = bias_clamp_tests[k];
|
||||
+ ID3D10Device_CreateRasterizerState(device, &rasterizer_desc, &rs);
|
||||
+ ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
|
||||
+ ID3D10Device_RSSetState(device, rs);
|
||||
+ ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH, 1.0f, 0);
|
||||
+ draw_quad(&test_context);
|
||||
+ switch (format)
|
||||
+ {
|
||||
+ case DXGI_FORMAT_D32_FLOAT:
|
||||
+ bias = rasterizer_desc.DepthBias * pow(2.0f, quads[i].exponent - 23.0f);
|
||||
+ if (rasterizer_desc.DepthBiasClamp > 0)
|
||||
+ bias = min(bias, rasterizer_desc.DepthBiasClamp);
|
||||
+ if (rasterizer_desc.DepthBiasClamp < 0)
|
||||
+ bias = max(bias, rasterizer_desc.DepthBiasClamp);
|
||||
+ depth = min(max(0.0f, quads[i].z + bias), 1.0f);
|
||||
|
||||
- check_texture_float(texture, depth, 2);
|
||||
- break;
|
||||
- case DXGI_FORMAT_D24_UNORM_S8_UINT:
|
||||
- r = 1.0f / 16777215.0f;
|
||||
- bias = rasterizer_desc.DepthBias * r;
|
||||
- depth = min(max(0.0f, quads[i].z + bias), 1.0f);
|
||||
+ check_texture_float(texture, depth, 2);
|
||||
+ break;
|
||||
+ case DXGI_FORMAT_D24_UNORM_S8_UINT:
|
||||
+ r = 1.0f / 16777215.0f;
|
||||
+ bias = rasterizer_desc.DepthBias * r;
|
||||
+ if (rasterizer_desc.DepthBiasClamp > 0)
|
||||
+ bias = min(bias, rasterizer_desc.DepthBiasClamp);
|
||||
+ if (rasterizer_desc.DepthBiasClamp < 0)
|
||||
+ bias = max(bias, rasterizer_desc.DepthBiasClamp);
|
||||
+ depth = min(max(0.0f, quads[i].z + bias), 1.0f);
|
||||
|
||||
- get_texture_readback(texture, 0, &rb);
|
||||
- for (y = 0; y < texture_desc.Height; ++y)
|
||||
- {
|
||||
- expected_value = depth * 16777215.0f + 0.5f;
|
||||
- for (x = 0; x < texture_desc.Width; ++x)
|
||||
+ get_texture_readback(texture, 0, &rb);
|
||||
+ for (y = 0; y < texture_desc.Height; ++y)
|
||||
{
|
||||
- u32 = get_readback_data(&rb, x, y, sizeof(*u32));
|
||||
- u32_value = *u32 >> shift;
|
||||
- ok(abs(u32_value - expected_value) <= 1,
|
||||
- "Got value %#x (%.8e), expected %#x (%.8e).\n",
|
||||
- u32_value, u32_value / 16777215.0f,
|
||||
- expected_value, expected_value / 16777215.0f);
|
||||
+ expected_value = depth * 16777215.0f + 0.5f;
|
||||
+ for (x = 0; x < texture_desc.Width; ++x)
|
||||
+ {
|
||||
+ u32 = get_readback_data(&rb, x, y, sizeof(*u32));
|
||||
+ u32_value = *u32 >> shift;
|
||||
+ ok(abs(u32_value - expected_value) <= 1,
|
||||
+ "Got value %#x (%.8e), expected %#x (%.8e).\n",
|
||||
+ u32_value, u32_value / 16777215.0f,
|
||||
+ expected_value, expected_value / 16777215.0f);
|
||||
+ }
|
||||
}
|
||||
- }
|
||||
- release_resource_readback(&rb);
|
||||
- break;
|
||||
- case DXGI_FORMAT_D16_UNORM:
|
||||
- r = 1.0f / 65535.0f;
|
||||
- bias = rasterizer_desc.DepthBias * r;
|
||||
- depth = min(max(0.0f, quads[i].z + bias), 1.0f);
|
||||
+ release_resource_readback(&rb);
|
||||
+ break;
|
||||
+ case DXGI_FORMAT_D16_UNORM:
|
||||
+ r = 1.0f / 65535.0f;
|
||||
+ bias = rasterizer_desc.DepthBias * r;
|
||||
+ if (rasterizer_desc.DepthBiasClamp > 0)
|
||||
+ bias = min(bias, rasterizer_desc.DepthBiasClamp);
|
||||
+ if (rasterizer_desc.DepthBiasClamp < 0)
|
||||
+ bias = max(bias, rasterizer_desc.DepthBiasClamp);
|
||||
+ depth = min(max(0.0f, quads[i].z + bias), 1.0f);
|
||||
|
||||
- get_texture_readback(texture, 0, &rb);
|
||||
- for (y = 0; y < texture_desc.Height; ++y)
|
||||
- {
|
||||
- expected_value = depth * 65535.0f + 0.5f;
|
||||
- for (x = 0; x < texture_desc.Width; ++x)
|
||||
+ get_texture_readback(texture, 0, &rb);
|
||||
+ for (y = 0; y < texture_desc.Height; ++y)
|
||||
{
|
||||
- u16 = get_readback_data(&rb, x, y, sizeof(*u16));
|
||||
- ok(abs(*u16 - expected_value) <= 1,
|
||||
- "Got value %#x (%.8e), expected %#x (%.8e).\n",
|
||||
- *u16, *u16 / 65535.0f, expected_value, expected_value / 65535.0f);
|
||||
+ expected_value = depth * 65535.0f + 0.5f;
|
||||
+ for (x = 0; x < texture_desc.Width; ++x)
|
||||
+ {
|
||||
+ u16 = get_readback_data(&rb, x, y, sizeof(*u16));
|
||||
+ ok(abs(*u16 - expected_value) <= 1,
|
||||
+ "Got value %#x (%.8e), expected %#x (%.8e).\n",
|
||||
+ *u16, *u16 / 65535.0f, expected_value, expected_value / 65535.0f);
|
||||
+ }
|
||||
}
|
||||
- }
|
||||
- release_resource_readback(&rb);
|
||||
- break;
|
||||
- default:
|
||||
- break;
|
||||
+ release_resource_readback(&rb);
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+ ID3D10RasterizerState_Release(rs);
|
||||
}
|
||||
- ID3D10RasterizerState_Release(rs);
|
||||
}
|
||||
}
|
||||
|
||||
/* SlopeScaledDepthBias */
|
||||
rasterizer_desc.DepthBias = 0;
|
||||
+ rasterizer_desc.DepthBiasClamp = 0.0f;
|
||||
for (i = 0; i < ARRAY_SIZE(quad_slopes); ++i)
|
||||
{
|
||||
for (j = 0; j < ARRAY_SIZE(vertices); ++j)
|
||||
--
|
||||
2.7.4
|
||||
|
@ -3105,13 +3105,15 @@ fi
|
||||
# | * [#43848] Implement support for depth bias clamping
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/d3d11/device.c, dlls/wined3d/cs.c, dlls/wined3d/directx.c, dlls/wined3d/state.c, dlls/wined3d/stateblock.c,
|
||||
# | dlls/wined3d/utils.c, dlls/wined3d/wined3d_gl.h, include/wine/wined3d.h
|
||||
# | * dlls/d3d10core/tests/device.c, dlls/d3d11/device.c, dlls/wined3d/cs.c, dlls/wined3d/directx.c, dlls/wined3d/state.c,
|
||||
# | dlls/wined3d/stateblock.c, dlls/wined3d/utils.c, dlls/wined3d/wined3d_gl.h, include/wine/wined3d.h
|
||||
# |
|
||||
if test "$enable_d3d11_Depth_Bias" -eq 1; then
|
||||
patch_apply d3d11-Depth_Bias/0006-wined3d-Add-support-for-depth-bias-clamping.patch
|
||||
patch_apply d3d11-Depth_Bias/0007-d3d10core-tests-Add-test-for-depth-bias-clamp.patch
|
||||
(
|
||||
printf '%s\n' '+ { "Michael Müller", "wined3d: Add support for depth bias clamping.", 1 },';
|
||||
printf '%s\n' '+ { "Zebediah Figura", "d3d10core/tests: Add test for depth bias clamp.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user