From: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.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/context.c | 2 +-
dlls/wined3d/cs.c | 2 +-
dlls/wined3d/directx.c | 2 ++
dlls/wined3d/state.c | 28 +++++++++++++++++++++++-----
dlls/wined3d/utils.c | 4 ++--
dlls/wined3d/wined3d_gl.h | 1 +
dlls/wined3d/wined3d_private.h | 6 +++---
include/wine/wined3d.h | 1 +
12 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 4b39c1be256..50521bda443 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 c930248e54a..863f71f80b9 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 f880a2374d7..d4c3befd269 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 2a8ec0a8d88..894c744b977 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/context.c b/dlls/wined3d/context.c
index 300b79b6992..21ad11d9586 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2663,7 +2663,7 @@ static void context_set_render_offscreen(struct wined3d_context *context, BOOL o
context_invalidate_state(context, STATE_SCISSORRECT);
if (!context->gl_info->supported[ARB_CLIP_CONTROL])
{
- context_invalidate_state(context, STATE_FRONTFACE);
+ context_invalidate_state(context, STATE_RASTERIZER);
context_invalidate_state(context, STATE_POINTSPRITECOORDORIGIN);
context_invalidate_state(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION));
}
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index e4a29406a4f..3f1ca8ce658 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -1490,7 +1490,7 @@ static void wined3d_cs_exec_set_rasterizer_state(struct wined3d_cs *cs, const vo
const struct wined3d_cs_set_rasterizer_state *op = data;
cs->state.rasterizer_state = op->state;
- device_invalidate_state(cs->device, STATE_FRONTFACE);
+ device_invalidate_state(cs->device, STATE_RASTERIZER);
}
void wined3d_cs_emit_set_rasterizer_state(struct wined3d_cs *cs,
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 32c255240f7..a4e4a0c0044 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 34e08e9ba51..3b2f84538db 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4318,7 +4318,23 @@ static void indexbuffer(struct wined3d_context *context, const struct wined3d_st
}
}
-static void frontface(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
+static void depth_clip(const struct wined3d_rasterizer_state *r, const struct wined3d_gl_info *gl_info)
+{
+ if (!gl_info->supported[ARB_DEPTH_CLAMP])
+ {
+ if (r && !r->desc.depth_clip)
+ FIXME("Depth clamp not supported by this GL implementation.\n");
+ return;
+ }
+
+ if (r && !r->desc.depth_clip)
+ gl_info->gl_ops.gl.p_glEnable(GL_DEPTH_CLAMP);
+ else
+ gl_info->gl_ops.gl.p_glDisable(GL_DEPTH_CLAMP);
+ checkGLcall("depth clip");
+}
+
+static void rasterizer(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
GLenum mode;
@@ -4329,9 +4345,10 @@ static void frontface(struct wined3d_context *context, const struct wined3d_stat
gl_info->gl_ops.gl.p_glFrontFace(mode);
checkGLcall("glFrontFace");
+ depth_clip(state->rasterizer_state, gl_info);
}
-static void frontface_cc(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
+static void rasterizer_cc(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
GLenum mode;
@@ -4340,6 +4357,7 @@ static void frontface_cc(struct wined3d_context *context, const struct wined3d_s
gl_info->gl_ops.gl.p_glFrontFace(mode);
checkGLcall("glFrontFace");
+ depth_clip(state->rasterizer_state, gl_info);
}
static void psorigin_w(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
@@ -4509,8 +4527,8 @@ const struct StateEntryTemplate misc_state_template[] =
{ STATE_BLEND, { STATE_BLEND, state_blend_object }, WINED3D_GL_EXT_NONE },
{ STATE_STREAMSRC, { STATE_STREAMSRC, streamsrc }, WINED3D_GL_EXT_NONE },
{ STATE_VDECL, { STATE_VDECL, vdecl_miscpart }, WINED3D_GL_EXT_NONE },
- { STATE_FRONTFACE, { STATE_FRONTFACE, frontface_cc }, ARB_CLIP_CONTROL },
- { STATE_FRONTFACE, { STATE_FRONTFACE, frontface }, WINED3D_GL_EXT_NONE },
+ { STATE_RASTERIZER, { STATE_RASTERIZER, rasterizer_cc }, ARB_CLIP_CONTROL },
+ { STATE_RASTERIZER, { STATE_RASTERIZER, rasterizer }, WINED3D_GL_EXT_NONE },
{ STATE_SCISSORRECT, { STATE_SCISSORRECT, scissorrect }, WINED3D_GL_EXT_NONE },
{ STATE_POINTSPRITECOORDORIGIN, { STATE_POINTSPRITECOORDORIGIN, state_nop }, ARB_CLIP_CONTROL },
{ STATE_POINTSPRITECOORDORIGIN, { STATE_POINTSPRITECOORDORIGIN, psorigin }, WINED3D_GL_VERSION_2_0 },
@@ -5449,7 +5467,7 @@ static void validate_state_table(struct StateEntry *state_table)
STATE_VIEWPORT,
STATE_LIGHT_TYPE,
STATE_SCISSORRECT,
- STATE_FRONTFACE,
+ STATE_RASTERIZER,
STATE_POINTSPRITECOORDORIGIN,
STATE_BASEVERTEXINDEX,
STATE_FRAMEBUFFER,
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 655fdb1d8d3..ade1227581c 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -4654,8 +4654,8 @@ const char *debug_d3dstate(DWORD state)
return wine_dbg_sprintf("STATE_CLIPPLANE(%#x)", state - STATE_CLIPPLANE(0));
if (STATE_IS_MATERIAL(state))
return "STATE_MATERIAL";
- if (STATE_IS_FRONTFACE(state))
- return "STATE_FRONTFACE";
+ if (STATE_IS_RASTERIZER(state))
+ return "STATE_RASTERIZER";
if (STATE_IS_POINTSPRITECOORDORIGIN(state))
return "STATE_POINTSPRITECOORDORIGIN";
if (STATE_IS_BASEVERTEXINDEX(state))
diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h
index 3140526ca11..525c29803a5 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/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 3e344a5f0f3..26979b3226e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1639,10 +1639,10 @@ enum wined3d_pipeline
#define STATE_MATERIAL (STATE_CLIPPLANE(MAX_CLIP_DISTANCES))
#define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
-#define STATE_FRONTFACE (STATE_MATERIAL + 1)
-#define STATE_IS_FRONTFACE(a) ((a) == STATE_FRONTFACE)
+#define STATE_RASTERIZER (STATE_MATERIAL + 1)
+#define STATE_IS_RASTERIZER(a) ((a) == STATE_RASTERIZER)
-#define STATE_POINTSPRITECOORDORIGIN (STATE_FRONTFACE + 1)
+#define STATE_POINTSPRITECOORDORIGIN (STATE_RASTERIZER + 1)
#define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
#define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 15e14e5c5f3..7681aa2a0bf 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.11.0