[PATCH 6/8] d3d10core/tests: Add test for ClearDepthStencilView().
Józef Kucia
jkucia at codeweavers.com
Sun Mar 13 18:03:07 CDT 2016
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/d3d10core/tests/device.c | 110 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index eaaec20..145c650 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -22,6 +22,13 @@
#include "wine/test.h"
#include <limits.h>
+static inline float __port_nan(void)
+{
+ static const unsigned __nan_bytes = 0x7fc00000;
+ return *(const float *)&__nan_bytes;
+}
+#define NAN __port_nan()
+
struct vec2
{
float x, y;
@@ -134,6 +141,12 @@ static DWORD get_readback_color(struct texture_readback *rb, unsigned int x, uns
? ((DWORD *)rb->mapped_texture.pData)[rb->mapped_texture.RowPitch * y / sizeof(DWORD) + x] : 0xdeadbeef;
}
+static float get_readback_float(struct texture_readback *rb, unsigned int x, unsigned int y)
+{
+ return rb->texture
+ ? ((float *)rb->mapped_texture.pData)[rb->mapped_texture.RowPitch * y / sizeof(float) + x] : NAN;
+}
+
static void release_texture_readback(struct texture_readback *rb)
{
if (!rb->texture)
@@ -184,6 +197,35 @@ static void check_texture_color_(unsigned int line, ID3D10Texture2D *texture,
"Got unexpected color 0x%08x at (%u, %u).\n", color, x, y);
}
+#define check_texture_float(r, f, d) check_texture_float_(__LINE__, r, f, d)
+static void check_texture_float_(unsigned int line, ID3D10Texture2D *texture,
+ float expected_value, BYTE max_diff)
+{
+ struct texture_readback rb;
+ unsigned int x = 0, y = 0;
+ BOOL all_match = TRUE;
+ float value = 0.0f;
+
+ get_texture_readback(texture, &rb);
+ for (y = 0; y < rb.height; ++y)
+ {
+ for (x = 0; x < rb.width; ++x)
+ {
+ value = get_readback_float(&rb, x, y);
+ if (!compare_float(value, expected_value, max_diff))
+ {
+ all_match = FALSE;
+ break;
+ }
+ }
+ if (!all_match)
+ break;
+ }
+ release_texture_readback(&rb);
+ ok_(__FILE__, line)(all_match,
+ "Got unexpected value %.8e at (%u, %u).\n", value, x, y);
+}
+
static ID3D10Device *create_device(void)
{
ID3D10Device *device;
@@ -5694,6 +5736,73 @@ static void test_create_typeless_resource(void)
ok(!refcount, "Device has %u references left.\n", refcount);
}
+static void test_clear_depth_stencil_view(void)
+{
+ D3D10_TEXTURE2D_DESC texture_desc;
+ ID3D10Texture2D *depth_texture;
+ ID3D10DepthStencilView *dsv;
+ ID3D10Device *device;
+ ULONG refcount;
+ HRESULT hr;
+
+ if (!(device = create_device()))
+ {
+ skip("Failed to create device.\n");
+ return;
+ }
+
+ texture_desc.Width = 640;
+ texture_desc.Height = 480;
+ texture_desc.MipLevels = 1;
+ texture_desc.ArraySize = 1;
+ texture_desc.Format = DXGI_FORMAT_D32_FLOAT;
+ texture_desc.SampleDesc.Count = 1;
+ texture_desc.SampleDesc.Quality = 0;
+ texture_desc.Usage = D3D10_USAGE_DEFAULT;
+ texture_desc.BindFlags = D3D10_BIND_DEPTH_STENCIL;
+ texture_desc.CPUAccessFlags = 0;
+ texture_desc.MiscFlags = 0;
+ hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &depth_texture);
+ ok(SUCCEEDED(hr), "Failed to create depth texture, hr %#x.\n", hr);
+
+ hr = ID3D10Device_CreateDepthStencilView(device, (ID3D10Resource *)depth_texture, NULL, &dsv);
+ ok(SUCCEEDED(hr), "Failed to create depth stencil view, hr %#x.\n", hr);
+
+ ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH, 1.0f, 0);
+ check_texture_float(depth_texture, 1.0f, 0);
+
+ ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH, 0.25f, 0);
+ check_texture_float(depth_texture, 0.25f, 0);
+
+ ID3D10Texture2D_Release(depth_texture);
+ ID3D10DepthStencilView_Release(dsv);
+
+ texture_desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
+ hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &depth_texture);
+ ok(SUCCEEDED(hr), "Failed to create depth texture, hr %#x.\n", hr);
+
+ hr = ID3D10Device_CreateDepthStencilView(device, (ID3D10Resource *)depth_texture, NULL, &dsv);
+ ok(SUCCEEDED(hr), "Failed to create depth stencil view, hr %#x.\n", hr);
+
+ ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, 1.0f, 0);
+ todo_wine check_texture_color(depth_texture, 0x00ffffff, 0);
+
+ ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, 0.0f, 0xff);
+ todo_wine check_texture_color(depth_texture, 0xff000000, 0);
+
+ ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, 1.0f, 0xff);
+ check_texture_color(depth_texture, 0xffffffff, 0);
+
+ ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, 0.0f, 0);
+ check_texture_color(depth_texture, 0x00000000, 0);
+
+ ID3D10Texture2D_Release(depth_texture);
+ ID3D10DepthStencilView_Release(dsv);
+
+ refcount = ID3D10Device_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+}
+
START_TEST(device)
{
test_feature_level();
@@ -5728,4 +5837,5 @@ START_TEST(device)
test_cb_relative_addressing();
test_swapchain_flip();
test_create_typeless_resource();
+ test_clear_depth_stencil_view();
}
--
2.4.10
More information about the wine-patches
mailing list