[PATCH v3] d3d11: Implement depth clip.
Zebediah Figura
z.figura12 at gmail.com
Thu May 17 23:51:09 CDT 2018
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/d3d10core/tests/device.c | 2 --
dlls/d3d11/device.c | 3 ---
dlls/d3d11/state.c | 1 +
dlls/d3d11/tests/d3d11.c | 2 --
dlls/wined3d/directx.c | 2 ++
dlls/wined3d/state.c | 36 ++++++++++++++++++++++++++++++++++++
dlls/wined3d/wined3d_gl.h | 1 +
include/wine/wined3d.h | 1 +
8 files changed, 41 insertions(+), 7 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 4b39c1b..50521bd 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -16894,12 +16894,10 @@ static void test_depth_clip(void)
ID3D10Device_ClearDepthStencilView(device, dsv, D3D10_CLEAR_DEPTH, 1.0f, 0);
set_viewport(device, vp.TopLeftX, vp.TopLeftY, vp.Width, vp.Height, 0.4f, 0.6f);
draw_quad_z(&test_context, 2.0f);
-todo_wine
check_texture_float(texture, 0.6f, 1);
draw_quad_z(&test_context, 0.5f);
check_texture_float(texture, 0.5f, 1);
draw_quad_z(&test_context, -1.0f);
-todo_wine
check_texture_float(texture, 0.4f, 1);
ID3D10DepthStencilView_Release(dsv);
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index c930248..863f71f 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -948,9 +948,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
const_bias.f = desc->DepthBias;
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_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/state.c b/dlls/d3d11/state.c
index f880a23..d4c3bef 100644
--- a/dlls/d3d11/state.c
+++ b/dlls/d3d11/state.c
@@ -1068,6 +1068,7 @@ static HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, str
}
wined3d_desc.front_ccw = desc->FrontCounterClockwise;
+ wined3d_desc.depth_clip = desc->DepthClipEnable;
/* We cannot fail after creating a wined3d_rasterizer_state object. It
* would lead to double free. */
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 2a8ec0a..894c744 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -27396,12 +27396,10 @@ static void test_depth_clip(void)
ID3D11DeviceContext_ClearDepthStencilView(context, dsv, D3D11_CLEAR_DEPTH, 1.0f, 0);
set_viewport(context, vp.TopLeftX, vp.TopLeftY, vp.Width, vp.Height, 0.4f, 0.6f);
draw_quad_z(&test_context, 2.0f);
-todo_wine
check_texture_float(texture, 0.6f, 1);
draw_quad_z(&test_context, 0.5f);
check_texture_float(texture, 0.5f, 1);
draw_quad_z(&test_context, -1.0f);
-todo_wine
check_texture_float(texture, 0.4f, 1);
ID3D11DepthStencilView_Release(dsv);
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 32c2552..a4e4a0c 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 },
@@ -3879,6 +3880,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
{EXT_TEXTURE_SNORM, MAKEDWORD_VERSION(3, 1)},
/* We don't need or want GL_ARB_texture_rectangle (core in 3.1). */
+ {ARB_DEPTH_CLAMP, MAKEDWORD_VERSION(3, 2)},
{ARB_DRAW_ELEMENTS_BASE_VERTEX, MAKEDWORD_VERSION(3, 2)},
/* ARB_geometry_shader4 exposes a somewhat different API compared to 3.2
* core geometry shaders so it's not really correct to expose the
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 34e08e9..be34cb0 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4329,6 +4329,24 @@ static void frontface(struct wined3d_context *context, const struct wined3d_stat
gl_info->gl_ops.gl.p_glFrontFace(mode);
checkGLcall("glFrontFace");
+
+ if (gl_info->supported[ARB_DEPTH_CLAMP])
+ {
+ if (state->rasterizer_state && !state->rasterizer_state->desc.depth_clip)
+ {
+ gl_info->gl_ops.gl.p_glEnable(GL_DEPTH_CLAMP);
+ checkGLcall("glEnable(GL_DEPTH_CLAMP)");
+ }
+ else
+ {
+ gl_info->gl_ops.gl.p_glDisable(GL_DEPTH_CLAMP);
+ checkGLcall("glDisable(GL_DEPTH_CLAMP)");
+ }
+ }
+ else if (state->rasterizer_state && !state->rasterizer_state->desc.depth_clip)
+ {
+ WARN("Depth clip not supported by this GL implementation.\n");
+ }
}
static void frontface_cc(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
@@ -4340,6 +4358,24 @@ static void frontface_cc(struct wined3d_context *context, const struct wined3d_s
gl_info->gl_ops.gl.p_glFrontFace(mode);
checkGLcall("glFrontFace");
+
+ if (gl_info->supported[ARB_DEPTH_CLAMP])
+ {
+ if (state->rasterizer_state && !state->rasterizer_state->desc.depth_clip)
+ {
+ gl_info->gl_ops.gl.p_glEnable(GL_DEPTH_CLAMP);
+ checkGLcall("glEnable(GL_DEPTH_CLAMP)");
+ }
+ else
+ {
+ gl_info->gl_ops.gl.p_glDisable(GL_DEPTH_CLAMP);
+ checkGLcall("glDisable(GL_DEPTH_CLAMP)");
+ }
+ }
+ else if (state->rasterizer_state && !state->rasterizer_state->desc.depth_clip)
+ {
+ WARN("Depth clip not supported by this GL implementation.\n");
+ }
}
static void psorigin_w(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h
index 3140526..525c298 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 15e14e5..7681aa2 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -1986,6 +1986,7 @@ struct wined3d_blend_state_desc
struct wined3d_rasterizer_state_desc
{
BOOL front_ccw;
+ BOOL depth_clip;
};
struct wined3d_sampler_desc
--
2.7.4
More information about the wine-devel
mailing list