wined3d: Implement depth bias clamp.
Based on a patch by Michael Müller. 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:
parent
55d4f63164
commit
42b5d88f2e
|
@ -1081,6 +1081,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;
|
||||
wined3d_desc.depth_bias_clamp = desc->DepthBiasClamp;
|
||||
|
||||
/* We cannot fail after creating a wined3d_rasterizer_state object. It
|
||||
* would lead to double free. */
|
||||
|
|
|
@ -103,6 +103,7 @@ static const struct wined3d_extension_map gl_extension_map[] =
|
|||
{"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT },
|
||||
{"GL_ARB_point_parameters", ARB_POINT_PARAMETERS },
|
||||
{"GL_ARB_point_sprite", ARB_POINT_SPRITE },
|
||||
{"GL_ARB_polygon_offset_clamp", ARB_POLYGON_OFFSET_CLAMP },
|
||||
{"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX },
|
||||
{"GL_ARB_query_buffer_object", ARB_QUERY_BUFFER_OBJECT },
|
||||
{"GL_ARB_sample_shading", ARB_SAMPLE_SHADING },
|
||||
|
@ -1254,7 +1255,9 @@ static enum wined3d_feature_level feature_level_from_caps(const struct wined3d_g
|
|||
shader_model = min(shader_model, max(shader_caps->hs_version, 4));
|
||||
shader_model = min(shader_model, max(shader_caps->ds_version, 4));
|
||||
|
||||
if (gl_info->supported[WINED3D_GL_VERSION_3_2] && gl_info->supported[ARB_SAMPLER_OBJECTS])
|
||||
if (gl_info->supported[WINED3D_GL_VERSION_3_2]
|
||||
&& gl_info->supported[ARB_POLYGON_OFFSET_CLAMP]
|
||||
&& gl_info->supported[ARB_SAMPLER_OBJECTS])
|
||||
{
|
||||
if (shader_model >= 5
|
||||
&& gl_info->supported[ARB_DRAW_INDIRECT]
|
||||
|
@ -2172,6 +2175,8 @@ static void load_gl_funcs(struct wined3d_gl_info *gl_info)
|
|||
/* GL_ARB_point_parameters */
|
||||
USE_GL_FUNC(glPointParameterfARB)
|
||||
USE_GL_FUNC(glPointParameterfvARB)
|
||||
/* GL_ARB_polgyon_offset_clamp */
|
||||
USE_GL_FUNC(glPolygonOffsetClamp)
|
||||
/* GL_ARB_provoking_vertex */
|
||||
USE_GL_FUNC(glProvokingVertex)
|
||||
/* GL_ARB_sample_shading */
|
||||
|
@ -3316,6 +3321,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
|
|||
{ARB_SHADER_TEXTURE_IMAGE_SAMPLES, MAKEDWORD_VERSION(4, 5)},
|
||||
|
||||
{ARB_PIPELINE_STATISTICS_QUERY, MAKEDWORD_VERSION(4, 6)},
|
||||
{ARB_POLYGON_OFFSET_CLAMP, MAKEDWORD_VERSION(4, 6)},
|
||||
{ARB_TEXTURE_FILTER_ANISOTROPIC, MAKEDWORD_VERSION(4, 6)},
|
||||
};
|
||||
struct wined3d_driver_info *driver_info = &adapter->driver_info;
|
||||
|
|
|
@ -1775,7 +1775,7 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
|
|||
|| state->render_states[WINED3D_RS_DEPTHBIAS])
|
||||
{
|
||||
const struct wined3d_rendertarget_view *depth = state->fb->depth_stencil;
|
||||
float factor, units, scale;
|
||||
float factor, units, scale, clamp;
|
||||
|
||||
union
|
||||
{
|
||||
|
@ -1783,6 +1783,7 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
|
|||
float f;
|
||||
} scale_bias, const_bias;
|
||||
|
||||
clamp = state->rasterizer_state ? state->rasterizer_state->desc.depth_bias_clamp : 0.0f;
|
||||
scale_bias.d = state->render_states[WINED3D_RS_SLOPESCALEDEPTHBIAS];
|
||||
const_bias.d = state->render_states[WINED3D_RS_DEPTHBIAS];
|
||||
|
||||
|
@ -1811,7 +1812,16 @@ static void state_depthbias(struct wined3d_context *context, const struct wined3
|
|||
}
|
||||
|
||||
gl_info->gl_ops.gl.p_glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
gl_info->gl_ops.gl.p_glPolygonOffset(factor, units);
|
||||
if (gl_info->supported[ARB_POLYGON_OFFSET_CLAMP])
|
||||
{
|
||||
gl_info->gl_ops.ext.p_glPolygonOffsetClamp(factor, units, clamp);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (clamp != 0.0f)
|
||||
WARN("Ignoring depth bias clamp %.8e.\n", clamp);
|
||||
gl_info->gl_ops.gl.p_glPolygonOffset(factor, units);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4345,6 +4355,8 @@ static void rasterizer(struct wined3d_context *context, const struct wined3d_sta
|
|||
|
||||
gl_info->gl_ops.gl.p_glFrontFace(mode);
|
||||
checkGLcall("glFrontFace");
|
||||
if (!isStateDirty(context, STATE_RENDER(WINED3D_RS_DEPTHBIAS)))
|
||||
state_depthbias(context, state, STATE_RENDER(WINED3D_RS_DEPTHBIAS));
|
||||
depth_clip(state->rasterizer_state, gl_info);
|
||||
}
|
||||
|
||||
|
@ -4357,6 +4369,8 @@ static void rasterizer_cc(struct wined3d_context *context, const struct wined3d_
|
|||
|
||||
gl_info->gl_ops.gl.p_glFrontFace(mode);
|
||||
checkGLcall("glFrontFace");
|
||||
if (!isStateDirty(context, STATE_RENDER(WINED3D_RS_DEPTHBIAS)))
|
||||
state_depthbias(context, state, STATE_RENDER(WINED3D_RS_DEPTHBIAS));
|
||||
depth_clip(state->rasterizer_state, gl_info);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ enum wined3d_gl_extension
|
|||
ARB_PIXEL_BUFFER_OBJECT,
|
||||
ARB_POINT_PARAMETERS,
|
||||
ARB_POINT_SPRITE,
|
||||
ARB_POLYGON_OFFSET_CLAMP,
|
||||
ARB_PROVOKING_VERTEX,
|
||||
ARB_QUERY_BUFFER_OBJECT,
|
||||
ARB_SAMPLE_SHADING,
|
||||
|
|
|
@ -2012,6 +2012,7 @@ struct wined3d_blend_state_desc
|
|||
struct wined3d_rasterizer_state_desc
|
||||
{
|
||||
BOOL front_ccw;
|
||||
float depth_bias_clamp;
|
||||
BOOL depth_clip;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue