[PATCH 4/5] d3d11/tests: Add test for writing special floating-point values to render target.
Józef Kucia
jkucia at codeweavers.com
Wed Jul 13 03:52:03 CDT 2016
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/d3d11/tests/d3d11.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 90 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 69cf5cd..e00e506 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -18,11 +18,30 @@
*/
#include <assert.h>
+#include <math.h>
+#include <limits.h>
#define COBJMACROS
#include "initguid.h"
#include "d3d11.h"
#include "wine/test.h"
-#include <limits.h>
+
+#ifndef INFINITY
+static inline float __port_infinity(void)
+{
+ static const unsigned __inf_bytes = 0x7f800000;
+ return *(const float *)&__inf_bytes;
+}
+#define INFINITY __port_infinity()
+#endif
+
+#ifndef NAN
+static inline float __port_nan(void)
+{
+ static const unsigned __nan_bytes = 0x7fc00000;
+ return *(const float *)&__nan_bytes;
+}
+#define NAN __port_nan()
+#endif
#define SWAPCHAIN_FLAG_SHADER_INPUT 0x1
@@ -9262,6 +9281,75 @@ static void test_immediate_constant_buffer(void)
release_test_context(&test_context);
}
+static void test_special_float_values(void)
+{
+ struct d3d11_test_context test_context;
+ D3D11_TEXTURE2D_DESC texture_desc;
+ ID3D11DeviceContext *context;
+ ID3D11RenderTargetView *rtv;
+ struct texture_readback rb;
+ ID3D11Texture2D *texture;
+ ID3D11PixelShader *ps;
+ ID3D11Device *device;
+ unsigned int x, y;
+ HRESULT hr;
+
+ static const DWORD ps_code[] =
+ {
+#if 0
+ float4 main() : SV_Target
+ {
+ return float4(0.0f / 0.0f, 1.0f / 0.0f, -1.0f / 0.0f, 1.0f);
+ }
+#endif
+ 0x43425844, 0x86d7f319, 0x14cde598, 0xe7ce83a8, 0x0e06f3f0, 0x00000001, 0x000000b0, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, 0x0000000e,
+ 0x03000065, 0x001020f2, 0x00000000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0xffc00000,
+ 0x7f800000, 0xff800000, 0x3f800000, 0x0100003e,
+ };
+
+ if (!init_test_context(&test_context, NULL))
+ return;
+
+ device = test_context.device;
+ context = test_context.immediate_context;
+
+ hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &ps);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+ ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0);
+
+ ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc);
+ texture_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
+ hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
+ ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+
+ hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)texture, NULL, &rtv);
+ ok(SUCCEEDED(hr), "Failed to create render target view, hr %#x.\n", hr);
+
+ ID3D11DeviceContext_OMSetRenderTargets(context, 1, &rtv, NULL);
+
+ draw_quad(&test_context);
+ get_texture_readback(texture, 0, &rb);
+ for (y = 0; y < texture_desc.Height; ++y)
+ {
+ for (x = 0; x < texture_desc.Width; ++x)
+ {
+ const struct vec4 *value = get_readback_vec4(&rb, x, y);
+ ok(isnan(value->x) && value->y == INFINITY && value->z == -INFINITY && value->w == 1.0f,
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
+ value->x, value->y, value->z, value->w, x, y);
+ }
+ }
+ release_texture_readback(&rb);
+
+ ID3D11PixelShader_Release(ps);
+ ID3D11Texture2D_Release(texture);
+ ID3D11RenderTargetView_Release(rtv);
+ release_test_context(&test_context);
+}
+
START_TEST(d3d11)
{
test_create_device();
@@ -9312,4 +9400,5 @@ START_TEST(d3d11)
test_check_feature_support();
test_create_unordered_access_view();
test_immediate_constant_buffer();
+ test_special_float_values();
}
--
2.7.3
More information about the wine-patches
mailing list