Rebase against 8b9ba16e9ad9ca85b93b05c13d6c5044a1a5ecf3.

This commit is contained in:
Zebediah Figura
2018-05-21 20:30:37 -05:00
parent 53a402bde4
commit da46ed3444
15 changed files with 313 additions and 1338 deletions

View File

@@ -1,255 +0,0 @@
From bdc2d668649d5810b88bcdd842228f7d44d7a012 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 7 Jul 2017 05:44:09 +0200
Subject: [PATCH] d3d11/tests: Add some basic depth tests.
---
dlls/d3d11/tests/d3d11.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 207 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 8279e7b..5831bbc 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -1476,10 +1476,11 @@ static void set_quad_color(struct d3d11_test_context *context, const struct vec4
(ID3D11Resource *)context->ps_cb, 0, NULL, color, 0, 0);
}
-#define draw_color_quad(a, b) draw_color_quad_(__LINE__, a, b, NULL, 0)
-#define draw_color_quad_vs(a, b, c, d) draw_color_quad_(__LINE__, a, b, c, d)
+#define draw_color_quad(a, b) draw_color_quad_(__LINE__, a, b, NULL, 0, 0.0)
+#define draw_color_quad_vs(a, b, c, d) draw_color_quad_(__LINE__, a, b, c, d, 0.0)
+#define draw_color_quad_z(context, color, z) draw_color_quad_(__LINE__, context, color, NULL, 0, z)
static void draw_color_quad_(unsigned int line, struct d3d11_test_context *context,
- const struct vec4 *color, const DWORD *vs_code, size_t vs_code_size)
+ const struct vec4 *color, const DWORD *vs_code, size_t vs_code_size, float z)
{
static const DWORD ps_color_code[] =
{
@@ -1522,6 +1523,7 @@ static void draw_color_quad_(unsigned int line, struct d3d11_test_context *conte
set_quad_color(context, color);
draw_quad_vs_(line, context, vs_code, vs_code_size);
+ draw_quad_z_(line, context, z);
}
static void test_create_device(void)
@@ -17583,6 +17585,207 @@ static void test_stencil_separate(void)
release_test_context(&test_context);
}
+static void test_depth_separate(void)
+{
+ struct d3d11_test_context test_context;
+ D3D11_TEXTURE2D_DESC texture_desc;
+ D3D11_DEPTH_STENCIL_DESC ds_desc;
+ ID3D11DepthStencilState *ds_state;
+ ID3D11DepthStencilView *ds_view;
+ D3D11_RASTERIZER_DESC rs_desc;
+ ID3D11DeviceContext *context;
+ struct resource_readback rb;
+ ID3D11RasterizerState *rs;
+ ID3D11Texture2D *texture;
+ ID3D11Device *device;
+ D3D11_VIEWPORT vp;
+ DWORD color;
+ HRESULT hr;
+
+ static const float red[] = {1.0f, 0.0f, 0.0f, 1.0f};
+ static const struct vec4 green = {0.0f, 1.0f, 0.0f, 1.0f};
+ static const struct vec4 blue = {0.0f, 0.0f, 1.0f, 1.0f};
+ static const struct vec4 white = {1.0f, 1.0f, 1.0f, 1.0f};
+ static const DWORD green_d = 0xff00ff00;
+ static const DWORD blue_d = 0xffff0000;
+ static const DWORD red_d = 0xff0000ff;
+ static const DWORD white_d = 0xffffffff;
+
+ if (!init_test_context(&test_context, NULL))
+ return;
+
+ device = test_context.device;
+ context = test_context.immediate_context;
+
+ texture_desc.Width = 640;
+ texture_desc.Height = 480;
+ texture_desc.MipLevels = 1;
+ texture_desc.ArraySize = 1;
+ texture_desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
+ texture_desc.SampleDesc.Count = 1;
+ texture_desc.SampleDesc.Quality = 0;
+ texture_desc.Usage = D3D11_USAGE_DEFAULT;
+ texture_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
+ texture_desc.CPUAccessFlags = 0;
+ texture_desc.MiscFlags = 0;
+ hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
+ ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
+ hr = ID3D11Device_CreateDepthStencilView(device, (ID3D11Resource *)texture, NULL, &ds_view);
+ ok(SUCCEEDED(hr), "Failed to create depth stencil view, hr %#x.\n", hr);
+
+ ds_desc.DepthEnable = TRUE;
+ ds_desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
+ ds_desc.DepthFunc = D3D11_COMPARISON_LESS;
+ ds_desc.StencilEnable = FALSE;
+ ds_desc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
+ ds_desc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;
+ ds_desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_ZERO;
+ ds_desc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_ZERO;
+ ds_desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_ZERO;
+ ds_desc.FrontFace.StencilFunc = D3D11_COMPARISON_NEVER;
+ ds_desc.BackFace.StencilFailOp = D3D11_STENCIL_OP_ZERO;
+ ds_desc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_ZERO;
+ ds_desc.BackFace.StencilPassOp = D3D11_STENCIL_OP_ZERO;
+ ds_desc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
+ hr = ID3D11Device_CreateDepthStencilState(device, &ds_desc, &ds_state);
+ ok(SUCCEEDED(hr), "Failed to create depth stencil state, hr %#x.\n", hr);
+
+ rs_desc.FillMode = D3D11_FILL_SOLID;
+ rs_desc.CullMode = D3D11_CULL_NONE;
+ rs_desc.FrontCounterClockwise = FALSE;
+ rs_desc.DepthBias = 0;
+ rs_desc.DepthBiasClamp = 0.0f;
+ rs_desc.SlopeScaledDepthBias = 0.0f;
+ rs_desc.DepthClipEnable = TRUE;
+ rs_desc.ScissorEnable = FALSE;
+ rs_desc.MultisampleEnable = FALSE;
+ rs_desc.AntialiasedLineEnable = FALSE;
+ ID3D11Device_CreateRasterizerState(device, &rs_desc, &rs);
+ ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
+
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red);
+ ID3D11DeviceContext_ClearDepthStencilView(context, ds_view, D3D11_CLEAR_DEPTH, 1.1f, 0);
+ ID3D11DeviceContext_OMSetRenderTargets(context, 1, &test_context.backbuffer_rtv, ds_view);
+ ID3D11DeviceContext_OMSetDepthStencilState(context, ds_state, 0);
+ ID3D11DeviceContext_RSSetState(context, rs);
+
+ vp.TopLeftX = 0.0f;
+ vp.TopLeftY = 0.0f;
+ vp.Width = texture_desc.Width;
+ vp.Height = texture_desc.Height;
+ vp.MinDepth = 0.0f;
+ vp.MaxDepth = 0.7f;
+ ID3D11DeviceContext_RSSetViewports(context, 1, &vp);
+
+ /* simple depth tests */
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red);
+ ID3D11DeviceContext_ClearDepthStencilView(context, ds_view, D3D11_CLEAR_DEPTH, 1.0f, 0);
+ draw_color_quad_z(&test_context, &green, 0.0f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ ok(compare_color(color, green_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red);
+ ID3D11DeviceContext_ClearDepthStencilView(context, ds_view, D3D11_CLEAR_DEPTH, 1.0f, 0);
+ draw_color_quad_z(&test_context, &green, 0.7f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ ok(compare_color(color, green_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red);
+ ID3D11DeviceContext_ClearDepthStencilView(context, ds_view, D3D11_CLEAR_DEPTH, 1.0f, 0);
+ draw_color_quad_z(&test_context, &green, 0.0f);
+ draw_color_quad_z(&test_context, &blue, 0.0f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ ok(compare_color(color, green_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+
+ /* clipped */
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red);
+ ID3D11DeviceContext_ClearDepthStencilView(context, ds_view, D3D11_CLEAR_DEPTH, 1.0f, 0);
+ draw_color_quad_z(&test_context, &green, 1.1f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ ok(compare_color(color, red_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red);
+ ID3D11DeviceContext_ClearDepthStencilView(context, ds_view, D3D11_CLEAR_DEPTH, 1.0f, 0);
+ draw_color_quad_z(&test_context, &green, -0.1f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ ok(compare_color(color, red_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+
+ /* clipping disabled */
+ ID3D11RasterizerState_Release(rs);
+ rs_desc.DepthClipEnable = FALSE;
+ ID3D11Device_CreateRasterizerState(device, &rs_desc, &rs);
+ ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
+ ID3D11DeviceContext_RSSetState(context, rs);
+
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red);
+ ID3D11DeviceContext_ClearDepthStencilView(context, ds_view, D3D11_CLEAR_DEPTH, 1.0f, 0);
+ draw_color_quad_z(&test_context, &green, 1.1f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ todo_wine ok(compare_color(color, green_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red);
+ ID3D11DeviceContext_ClearDepthStencilView(context, ds_view, D3D11_CLEAR_DEPTH, 1.0f, 0);
+ draw_color_quad_z(&test_context, &green, -0.1f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ todo_wine ok(compare_color(color, green_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+
+ /* depth bias */
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red);
+ ID3D11DeviceContext_ClearDepthStencilView(context, ds_view, D3D11_CLEAR_DEPTH, 1.0f, 0);
+ draw_color_quad_z(&test_context, &green, 0.5f);
+ ID3D11RasterizerState_Release(rs);
+ rs_desc.DepthClipEnable = TRUE;
+ rs_desc.DepthBias = -100000;
+ ID3D11Device_CreateRasterizerState(device, &rs_desc, &rs);
+ ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
+ ID3D11DeviceContext_RSSetState(context, rs);
+ draw_color_quad_z(&test_context, &blue, 0.5f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ ok(compare_color(color, blue_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+ ID3D11RasterizerState_Release(rs);
+ rs_desc.DepthBias = -100005;
+ ID3D11Device_CreateRasterizerState(device, &rs_desc, &rs);
+ ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
+ ID3D11DeviceContext_RSSetState(context, rs);
+ draw_color_quad_z(&test_context, &white, 0.5f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ ok(compare_color(color, white_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+ ID3D11RasterizerState_Release(rs);
+ rs_desc.DepthBias = -99995;
+ ID3D11Device_CreateRasterizerState(device, &rs_desc, &rs);
+ ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
+ ID3D11DeviceContext_RSSetState(context, rs);
+ draw_color_quad_z(&test_context, &green, 0.5f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ ok(compare_color(color, white_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+
+ ID3D11DepthStencilState_Release(ds_state);
+ ID3D11DepthStencilView_Release(ds_view);
+ ID3D11RasterizerState_Release(rs);
+ ID3D11Texture2D_Release(texture);
+ release_test_context(&test_context);
+}
+
static void test_uav_load(void)
{
struct shader
@@ -26490,6 +26693,7 @@ START_TEST(d3d11)
test_shader_input_registers_limits();
test_unbind_shader_resource_view();
test_stencil_separate();
+ test_depth_separate();
test_uav_load();
test_cs_uav_store();
test_uav_store_immediate_constant();
--
1.9.1

View File

@@ -1,176 +0,0 @@
From 5fdb9b16c65609e00684062ccf426d19acb75b06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 7 Jul 2017 06:10:01 +0200
Subject: [PATCH 2/4] d3d11: Add support for DepthClipEnable in RSSetState.
---
dlls/d3d11/device.c | 4 ++--
dlls/d3d11/tests/d3d11.c | 4 ++--
dlls/wined3d/directx.c | 1 +
dlls/wined3d/state.c | 24 ++++++++++++++++++++++++
dlls/wined3d/stateblock.c | 2 ++
dlls/wined3d/utils.c | 1 +
dlls/wined3d/wined3d_gl.h | 1 +
include/wine/wined3d.h | 3 ++-
8 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 25308c2..555b05b 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -931,6 +931,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, WINED3D_CULL_BACK);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SLOPESCALEDEPTHBIAS, 0);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIAS, 0);
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHCLIP, TRUE);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ANTIALIASEDLINEENABLE, FALSE);
@@ -948,8 +949,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SLOPESCALEDEPTHBIAS, scale_bias.d);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIAS, const_bias.d);
/* GL_DEPTH_CLAMP */
- if (!desc->DepthClipEnable)
- FIXME("Ignoring DepthClipEnable %#x.\n", desc->DepthClipEnable);
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHCLIP, (desc->DepthClipEnable != FALSE));
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
wined3d_device_set_render_state(device->wined3d_device,
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 9d9d74b..813660d 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -16924,7 +16924,7 @@ static void test_depth_separate(void)
draw_color_quad_z(&test_context, &green, 1.1f);
get_texture_readback(test_context.backbuffer, 0, &rb);
color = get_readback_color(&rb, 320, 240);
- todo_wine ok(compare_color(color, green_d, 1), "Got unexpected color 0x%08x.\n", color);
+ ok(compare_color(color, green_d, 1), "Got unexpected color 0x%08x.\n", color);
release_resource_readback(&rb);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red);
@@ -16932,7 +16932,7 @@ static void test_depth_separate(void)
draw_color_quad_z(&test_context, &green, -0.1f);
get_texture_readback(test_context.backbuffer, 0, &rb);
color = get_readback_color(&rb, 320, 240);
- todo_wine ok(compare_color(color, green_d, 1), "Got unexpected color 0x%08x.\n", color);
+ ok(compare_color(color, green_d, 1), "Got unexpected color 0x%08x.\n", color);
release_resource_readback(&rb);
/* depth bias */
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index f7f6452..b7a318a 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -122,6 +122,7 @@ static const struct wined3d_extension_map gl_extension_map[] =
{"GL_ARB_cull_distance", ARB_CULL_DISTANCE },
{"GL_ARB_debug_output", ARB_DEBUG_OUTPUT },
{"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT },
+ {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP },
{"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE },
{"GL_ARB_derivative_control", ARB_DERIVATIVE_CONTROL },
{"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS },
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 407ad62..25cc7d7 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -1822,6 +1822,28 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
checkGLcall("depth bias");
}
+static void state_depthclip(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
+{
+ const struct wined3d_gl_info *gl_info = context->gl_info;
+
+ if (state->render_states[WINED3D_RS_DEPTHCLIP])
+ {
+ gl_info->gl_ops.gl.p_glDisable(GL_DEPTH_CLAMP);
+ checkGLcall("glDisable(GL_DEPTH_CLAMP)");
+ }
+ else
+ {
+ gl_info->gl_ops.gl.p_glEnable(GL_DEPTH_CLAMP);
+ checkGLcall("glEnable(GL_DEPTH_CLAMP)");
+ }
+}
+
+static void state_depthclip_w(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
+{
+ if (!state->render_states[WINED3D_RS_DEPTHCLIP])
+ FIXME("Depth clamping not supported by GL.\n");
+}
+
static void state_zvisible(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
if (state->render_states[WINED3D_RS_ZVISIBLE])
@@ -5263,6 +5285,8 @@ const struct StateEntryTemplate misc_state_template[] =
{ STATE_RENDER(WINED3D_RS_BLENDFACTOR), { STATE_RENDER(WINED3D_RS_BLENDFACTOR), state_blendfactor_w }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_DEPTHBIAS), { STATE_RENDER(WINED3D_RS_DEPTHBIAS), state_depthbias }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_ZVISIBLE), { STATE_RENDER(WINED3D_RS_ZVISIBLE), state_zvisible }, WINED3D_GL_EXT_NONE },
+ { STATE_RENDER(WINED3D_RS_DEPTHCLIP), { STATE_RENDER(WINED3D_RS_DEPTHCLIP), state_depthclip }, ARB_DEPTH_CLAMP },
+ { STATE_RENDER(WINED3D_RS_DEPTHCLIP), { STATE_RENDER(WINED3D_RS_DEPTHCLIP), state_depthclip_w }, WINED3D_GL_EXT_NONE },
/* Samplers */
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler }, WINED3D_GL_EXT_NONE },
{ STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler }, WINED3D_GL_EXT_NONE },
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 4c28eb5..3dae0d9 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -90,6 +90,7 @@ static const DWORD pixel_states_render[] =
WINED3D_RS_ZENABLE,
WINED3D_RS_ZFUNC,
WINED3D_RS_ZWRITEENABLE,
+ WINED3D_RS_DEPTHCLIP,
};
static const DWORD pixel_states_texture[] =
@@ -1243,6 +1244,7 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
state->render_states[WINED3D_RS_BLENDFACTOR] = 0xffffffff;
state->render_states[WINED3D_RS_SRGBWRITEENABLE] = 0;
state->render_states[WINED3D_RS_DEPTHBIAS] = 0;
+ state->render_states[WINED3D_RS_DEPTHCLIP] = TRUE;
state->render_states[WINED3D_RS_WRAP8] = 0;
state->render_states[WINED3D_RS_WRAP9] = 0;
state->render_states[WINED3D_RS_WRAP10] = 0;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 4e1da1c..853feda 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -4446,6 +4446,7 @@ const char *debug_d3drenderstate(enum wined3d_render_state state)
D3DSTATE_TO_STR(WINED3D_RS_SRCBLENDALPHA);
D3DSTATE_TO_STR(WINED3D_RS_DESTBLENDALPHA);
D3DSTATE_TO_STR(WINED3D_RS_BLENDOPALPHA);
+ D3DSTATE_TO_STR(WINED3D_RS_DEPTHCLIP);
#undef D3DSTATE_TO_STR
default:
FIXME("Unrecognized %u render state!\n", state);
diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h
index cc6f888..b982330 100644
--- a/dlls/wined3d/wined3d_gl.h
+++ b/dlls/wined3d/wined3d_gl.h
@@ -55,6 +55,7 @@ enum wined3d_gl_extension
ARB_CULL_DISTANCE,
ARB_DEBUG_OUTPUT,
ARB_DEPTH_BUFFER_FLOAT,
+ ARB_DEPTH_CLAMP,
ARB_DEPTH_TEXTURE,
ARB_DERIVATIVE_CONTROL,
ARB_DRAW_BUFFERS,
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index b6a2ec3..1944a65 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -386,8 +386,9 @@ enum wined3d_render_state
WINED3D_RS_SRCBLENDALPHA = 207,
WINED3D_RS_DESTBLENDALPHA = 208,
WINED3D_RS_BLENDOPALPHA = 209,
+ WINED3D_RS_DEPTHCLIP = 210,
};
-#define WINEHIGHEST_RENDER_STATE WINED3D_RS_BLENDOPALPHA
+#define WINEHIGHEST_RENDER_STATE WINED3D_RS_DEPTHCLIP
enum wined3d_blend
{
--
2.7.4

View File

@@ -1,64 +0,0 @@
From 45291eca9ac098c90471c179a87f882a73ef10b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 7 Oct 2017 00:39:35 +0200
Subject: [PATCH 3/4] d3d11/tests: Add basic test for depth bias clamping.
---
dlls/d3d11/tests/d3d11.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 813660d..2a576e5 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -16971,6 +16971,47 @@ static void test_depth_separate(void)
ok(compare_color(color, white_d, 1), "Got unexpected color 0x%08x.\n", color);
release_resource_readback(&rb);
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, red);
+ ID3D11DeviceContext_ClearDepthStencilView(context, ds_view, D3D11_CLEAR_DEPTH, 1.0f, 0);
+ draw_color_quad_z(&test_context, &green, 0.5f);
+ ID3D11RasterizerState_Release(rs);
+
+ rs_desc.DepthClipEnable = TRUE;
+ rs_desc.DepthBias = -100000;
+ ID3D11Device_CreateRasterizerState(device, &rs_desc, &rs);
+ ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
+ ID3D11DeviceContext_RSSetState(context, rs);
+ draw_color_quad_z(&test_context, &blue, 0.5f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ ok(compare_color(color, blue_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+ ID3D11RasterizerState_Release(rs);
+
+ rs_desc.DepthBias = -100005;
+ rs_desc.DepthBiasClamp = -0.00001f;
+ ID3D11Device_CreateRasterizerState(device, &rs_desc, &rs);
+ ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
+ ID3D11DeviceContext_RSSetState(context, rs);
+ draw_color_quad_z(&test_context, &white, 0.5f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ todo_wine ok(compare_color(color, blue_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+ ID3D11RasterizerState_Release(rs);
+
+ rs_desc.DepthBias = -100010;
+ rs_desc.DepthBiasClamp = -1.0f;
+ ID3D11Device_CreateRasterizerState(device, &rs_desc, &rs);
+ ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
+ ID3D11DeviceContext_RSSetState(context, rs);
+ draw_color_quad_z(&test_context, &green, 0.5f);
+ get_texture_readback(test_context.backbuffer, 0, &rb);
+ color = get_readback_color(&rb, 320, 240);
+ ok(compare_color(color, green_d, 1), "Got unexpected color 0x%08x.\n", color);
+ release_resource_readback(&rb);
+ ID3D11RasterizerState_Release(rs);
+
ID3D11DepthStencilState_Release(ds_state);
ID3D11DepthStencilView_Release(ds_view);
ID3D11RasterizerState_Release(rs);
--
2.7.4

View File

@@ -1,11 +1,10 @@
From 34656e2180491f3946d1a66a02d55b8b110095fe Mon Sep 17 00:00:00 2001
From a93e855c484c622efedfe9696eac72c32007621d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 7 Oct 2017 00:52:34 +0200
Subject: [PATCH 4/4] wined3d: Add support for depth bias clamping.
Subject: wined3d: Add support for depth bias clamping.
---
dlls/d3d11/device.c | 7 +++++--
dlls/d3d11/tests/d3d11.c | 2 +-
dlls/d3d11/device.c | 5 ++++-
dlls/wined3d/cs.c | 1 +
dlls/wined3d/directx.c | 3 +++
dlls/wined3d/state.c | 17 +++++++++++++++--
@@ -13,13 +12,13 @@ Subject: [PATCH 4/4] wined3d: Add support for depth bias clamping.
dlls/wined3d/utils.c | 1 +
dlls/wined3d/wined3d_gl.h | 1 +
include/wine/wined3d.h | 3 ++-
9 files changed, 31 insertions(+), 6 deletions(-)
8 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 555b05b..835ea8b 100644
index 68d6cf0..9854906 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -919,7 +919,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
@@ -920,7 +920,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
{
DWORD d;
float f;
@@ -28,45 +27,30 @@ index 555b05b..835ea8b 100644
TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
@@ -932,6 +932,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
@@ -932,6 +932,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, WINED3D_CULL_BACK);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SLOPESCALEDEPTHBIAS, 0);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIAS, 0);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHCLIP, TRUE);
+ bias_clamp.f = 0.0f;
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIASCLAMP, bias_clamp.d);
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIASCLAMP, 0);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ANTIALIASEDLINEENABLE, FALSE);
@@ -946,9 +948,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
@@ -946,8 +947,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_CULLMODE, desc->CullMode);
scale_bias.f = desc->SlopeScaledDepthBias;
const_bias.f = desc->DepthBias;
+ bias_clamp.f = desc->DepthBiasClamp;
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SLOPESCALEDEPTHBIAS, scale_bias.d);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIAS, const_bias.d);
- /* GL_DEPTH_CLAMP */
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIASCLAMP, bias_clamp.d);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHCLIP, (desc->DepthClipEnable != FALSE));
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 2a576e5..540da93 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -16996,7 +16996,7 @@ static void test_depth_separate(void)
draw_color_quad_z(&test_context, &white, 0.5f);
get_texture_readback(test_context.backbuffer, 0, &rb);
color = get_readback_color(&rb, 320, 240);
- todo_wine ok(compare_color(color, blue_d, 1), "Got unexpected color 0x%08x.\n", color);
+ ok(compare_color(color, blue_d, 1), "Got unexpected color 0x%08x.\n", color);
release_resource_readback(&rb);
ID3D11RasterizerState_Release(rs);
wined3d_device_set_render_state(device->wined3d_device,
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 2f77c7b..68d5759 100644
index 3f1ca8c..aea2cdf 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -1038,6 +1038,7 @@ static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const
@@ -1065,6 +1065,7 @@ static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_STENCILENABLE));
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_STENCILWRITEMASK));
device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS));
@@ -75,10 +59,10 @@ index 2f77c7b..68d5759 100644
else if (prev && prev->format->depth_bias_scale != op->view->format->depth_bias_scale)
{
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index b7a318a..e282c10 100644
index a4e4a0c..e595da5 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -231,6 +231,7 @@ static const struct wined3d_extension_map gl_extension_map[] =
@@ -233,6 +233,7 @@ static const struct wined3d_extension_map gl_extension_map[] =
{"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL },
{"GL_EXT_packed_float", EXT_PACKED_FLOAT },
{"GL_EXT_point_parameters", EXT_POINT_PARAMETERS },
@@ -86,7 +70,7 @@ index b7a318a..e282c10 100644
{"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX },
{"GL_EXT_secondary_color", EXT_SECONDARY_COLOR },
{"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE },
@@ -3114,6 +3115,8 @@ static void load_gl_funcs(struct wined3d_gl_info *gl_info)
@@ -3117,6 +3118,8 @@ static void load_gl_funcs(struct wined3d_gl_info *gl_info)
/* GL_EXT_point_parameters */
USE_GL_FUNC(glPointParameterfEXT)
USE_GL_FUNC(glPointParameterfvEXT)
@@ -96,10 +80,10 @@ index b7a318a..e282c10 100644
USE_GL_FUNC(glProvokingVertexEXT)
/* GL_EXT_secondary_color */
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 25cc7d7..3460d69 100644
index 3b2f845..2dd6ac2 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -1782,10 +1782,11 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
@@ -1781,10 +1781,11 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
{
DWORD d;
float f;
@@ -112,7 +96,7 @@ index 25cc7d7..3460d69 100644
if (context->d3d_info->wined3d_creation_flags & WINED3D_LEGACY_DEPTH_BIAS)
{
@@ -1812,7 +1813,18 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
@@ -1811,7 +1812,18 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
}
gl_info->gl_ops.gl.p_glEnable(GL_POLYGON_OFFSET_FILL);
@@ -132,32 +116,32 @@ index 25cc7d7..3460d69 100644
}
else
{
@@ -5284,6 +5296,7 @@ const struct StateEntryTemplate misc_state_template[] =
@@ -4678,6 +4690,7 @@ const struct StateEntryTemplate misc_state_template[] =
{ STATE_RENDER(WINED3D_RS_BLENDFACTOR), { STATE_RENDER(WINED3D_RS_BLENDFACTOR), state_blendfactor }, EXT_BLEND_COLOR },
{ STATE_RENDER(WINED3D_RS_BLENDFACTOR), { STATE_RENDER(WINED3D_RS_BLENDFACTOR), state_blendfactor_w }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_DEPTHBIAS), { STATE_RENDER(WINED3D_RS_DEPTHBIAS), state_depthbias }, WINED3D_GL_EXT_NONE },
+ { STATE_RENDER(WINED3D_RS_DEPTHBIASCLAMP), { STATE_RENDER(WINED3D_RS_DEPTHBIAS), NULL }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_ZVISIBLE), { STATE_RENDER(WINED3D_RS_ZVISIBLE), state_zvisible }, WINED3D_GL_EXT_NONE },
{ STATE_RENDER(WINED3D_RS_DEPTHCLIP), { STATE_RENDER(WINED3D_RS_DEPTHCLIP), state_depthclip }, ARB_DEPTH_CLAMP },
{ STATE_RENDER(WINED3D_RS_DEPTHCLIP), { STATE_RENDER(WINED3D_RS_DEPTHCLIP), state_depthclip_w }, WINED3D_GL_EXT_NONE },
/* Samplers */
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler }, WINED3D_GL_EXT_NONE },
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 3dae0d9..b9efcec 100644
index b4d1751..093c740 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1244,6 +1244,8 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
@@ -1257,6 +1257,8 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
state->render_states[WINED3D_RS_BLENDFACTOR] = 0xffffffff;
state->render_states[WINED3D_RS_SRGBWRITEENABLE] = 0;
state->render_states[WINED3D_RS_DEPTHBIAS] = 0;
+ tmpfloat.f = 0.0f;
+ state->render_states[WINED3D_RS_DEPTHBIASCLAMP] = tmpfloat.d;
state->render_states[WINED3D_RS_DEPTHCLIP] = TRUE;
state->render_states[WINED3D_RS_WRAP8] = 0;
state->render_states[WINED3D_RS_WRAP9] = 0;
state->render_states[WINED3D_RS_WRAP10] = 0;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 853feda..5de53d0 100644
index 7cecd8c..0152879 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -4434,6 +4434,7 @@ const char *debug_d3drenderstate(enum wined3d_render_state state)
@@ -4425,6 +4425,7 @@ const char *debug_d3drenderstate(enum wined3d_render_state state)
D3DSTATE_TO_STR(WINED3D_RS_BLENDFACTOR);
D3DSTATE_TO_STR(WINED3D_RS_SRGBWRITEENABLE);
D3DSTATE_TO_STR(WINED3D_RS_DEPTHBIAS);
@@ -166,10 +150,10 @@ index 853feda..5de53d0 100644
D3DSTATE_TO_STR(WINED3D_RS_WRAP9);
D3DSTATE_TO_STR(WINED3D_RS_WRAP10);
diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h
index b982330..12e15cc 100644
index 525c298..883faaa 100644
--- a/dlls/wined3d/wined3d_gl.h
+++ b/dlls/wined3d/wined3d_gl.h
@@ -162,6 +162,7 @@ enum wined3d_gl_extension
@@ -164,6 +164,7 @@ enum wined3d_gl_extension
EXT_PACKED_DEPTH_STENCIL,
EXT_PACKED_FLOAT,
EXT_POINT_PARAMETERS,
@@ -178,16 +162,16 @@ index b982330..12e15cc 100644
EXT_SECONDARY_COLOR,
EXT_STENCIL_TWO_SIDE,
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 1944a65..8864965 100644
index bb4ad48..4a5d0dd 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -387,8 +387,9 @@ enum wined3d_render_state
@@ -386,8 +386,9 @@ enum wined3d_render_state
WINED3D_RS_SRCBLENDALPHA = 207,
WINED3D_RS_DESTBLENDALPHA = 208,
WINED3D_RS_BLENDOPALPHA = 209,
WINED3D_RS_DEPTHCLIP = 210,
+ WINED3D_RS_DEPTHBIASCLAMP = 211,
+ WINED3D_RS_DEPTHBIASCLAMP = 210,
};
-#define WINEHIGHEST_RENDER_STATE WINED3D_RS_DEPTHCLIP
-#define WINEHIGHEST_RENDER_STATE WINED3D_RS_BLENDOPALPHA
+#define WINEHIGHEST_RENDER_STATE WINED3D_RS_DEPTHBIASCLAMP
enum wined3d_blend