Commit 9b3ab8a6 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Set z = 0.0 via the projection matrix instead of depth clamping.

This works on cards that don't implement ARB_depth_clamp like r500 cards. Note that texturing is influenced by position.w, not position.z.
parent f460db7c
......@@ -112,7 +112,6 @@ static const struct wined3d_extension_map gl_extension_map[] =
{"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT },
{"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_draw_buffers", ARB_DRAW_BUFFERS },
{"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX },
......@@ -204,7 +203,6 @@ static const struct wined3d_extension_map gl_extension_map[] =
{"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA },
/* NV */
{"GL_NV_depth_clamp", NV_DEPTH_CLAMP },
{"GL_NV_fence", NV_FENCE },
{"GL_NV_fog_distance", NV_FOG_DISTANCE },
{"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM },
......@@ -3446,11 +3444,6 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
TRACE(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
gl_info->supported[NV_TEXGEN_REFLECTION] = TRUE;
}
if (!gl_info->supported[ARB_DEPTH_CLAMP] && gl_info->supported[NV_DEPTH_CLAMP])
{
TRACE(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
gl_info->supported[ARB_DEPTH_CLAMP] = TRUE;
}
if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
{
TRACE(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
......
......@@ -103,7 +103,6 @@ static void state_zenable(struct wined3d_context *context, const struct wined3d_
{
enum wined3d_depth_buffer_type zenable = state->render_states[WINED3D_RS_ZENABLE];
const struct wined3d_gl_info *gl_info = context->gl_info;
static UINT once;
/* No z test without depth stencil buffers */
if (!state->fb->depth_stencil)
......@@ -132,21 +131,8 @@ static void state_zenable(struct wined3d_context *context, const struct wined3d_
break;
}
if (context->gl_info->supported[ARB_DEPTH_CLAMP])
{
if (!zenable && context->stream_info.position_transformed)
{
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 (!zenable && !once++)
FIXME("Z buffer disabled, but ARB_depth_clamp isn't supported.\n");
if (context->last_was_rhw && !isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION)))
transform_projection(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION));
}
static void state_cullmode(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
......@@ -4105,12 +4091,16 @@ void transform_projection(struct wined3d_context *context, const struct wined3d_
double y_offset = context->render_offscreen
? ((63.0 / 64.0) - (2.0 * y) - h) / h
: ((63.0 / 64.0) - (2.0 * y) - h) / -h;
enum wined3d_depth_buffer_type zenable = state->fb->depth_stencil ?
state->render_states[WINED3D_RS_ZENABLE] : WINED3D_ZB_FALSE;
double z_scale = zenable ? 2.0f : 0.0f;
double z_offset = zenable ? -1.0f : 0.0f;
const GLdouble projection[] =
{
x_scale, 0.0, 0.0, 0.0,
0.0, y_scale, 0.0, 0.0,
0.0, 0.0, 2.0, 0.0,
x_offset, y_offset, -1.0, 1.0,
x_scale, 0.0, 0.0, 0.0,
0.0, y_scale, 0.0, 0.0,
0.0, 0.0, z_scale, 0.0,
x_offset, y_offset, z_offset, 1.0,
};
gl_info->gl_ops.gl.p_glLoadMatrixd(projection);
......@@ -4775,9 +4765,6 @@ void vertexdeclaration(struct wined3d_context *context, const struct wined3d_sta
&& state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.shader_version.minor <= 3)
context->shader_update_mask |= 1 << WINED3D_SHADER_TYPE_PIXEL;
}
if (transformed != wasrhw && !isStateDirty(context, STATE_RENDER(WINED3D_RS_ZENABLE)))
state_zenable(context, state, STATE_RENDER(WINED3D_RS_ZENABLE));
}
static void viewport_miscpart(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
......
......@@ -48,7 +48,6 @@ enum wined3d_gl_extension
ARB_COLOR_BUFFER_FLOAT,
ARB_DEBUG_OUTPUT,
ARB_DEPTH_BUFFER_FLOAT,
ARB_DEPTH_CLAMP,
ARB_DEPTH_TEXTURE,
ARB_DRAW_BUFFERS,
ARB_DRAW_ELEMENTS_BASE_VERTEX,
......@@ -137,7 +136,6 @@ enum wined3d_gl_extension
EXT_TEXTURE_SRGB_DECODE,
EXT_VERTEX_ARRAY_BGRA,
/* NVIDIA */
NV_DEPTH_CLAMP,
NV_FENCE,
NV_FOG_DISTANCE,
NV_FRAGMENT_PROGRAM,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment