d3d11: Implement depth clip control.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2018-05-19 20:50:19 +04:30 committed by Alexandre Julliard
parent e202a9ea25
commit 19f2c4473b
12 changed files with 35 additions and 19 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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. */

View File

@ -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);

View File

@ -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));
}

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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))

View File

@ -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,

View File

@ -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)

View File

@ -1986,6 +1986,7 @@ struct wined3d_blend_state_desc
struct wined3d_rasterizer_state_desc
{
BOOL front_ccw;
BOOL depth_clip;
};
struct wined3d_sampler_desc