mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 02:10:12 +01:00
mesa: Mostly fix swrast's ARB_depth_clamp support.
I'd written a testcase for the hard part of the extension enablement, so naturally the easy stuff was completely broken. There are still issues, as I'm seeing FLOAT_TO_UINT(max_f) == 0x0 when max_f == 1.0, but it gets piglit depth-clamp-range closer to success.
This commit is contained in:
parent
6eb6a0e9cb
commit
32ec3f2673
2 changed files with 26 additions and 12 deletions
|
|
@ -506,22 +506,32 @@ _swrast_depth_clamp_span( GLcontext *ctx, SWspan *span )
|
|||
struct gl_renderbuffer *rb = fb->_DepthBuffer;
|
||||
const GLuint count = span->end;
|
||||
GLuint *zValues = span->array->z;
|
||||
GLuint near, far;
|
||||
GLuint min, max;
|
||||
GLfloat min_f, max_f;
|
||||
int i;
|
||||
|
||||
if (ctx->Viewport.Near < ctx->Viewport.Far) {
|
||||
min_f = ctx->Viewport.Near;
|
||||
max_f = ctx->Viewport.Far;
|
||||
} else {
|
||||
min_f = ctx->Viewport.Far;
|
||||
max_f = ctx->Viewport.Near;
|
||||
}
|
||||
|
||||
if (rb->DataType == GL_UNSIGNED_SHORT) {
|
||||
near = FLOAT_TO_UINT(ctx->Viewport.Near);
|
||||
far = FLOAT_TO_UINT(ctx->Viewport.Far);
|
||||
CLAMPED_FLOAT_TO_USHORT(min, min_f);
|
||||
CLAMPED_FLOAT_TO_USHORT(max, max_f);
|
||||
} else {
|
||||
assert(rb->DataType == GL_UNSIGNED_INT);
|
||||
CLAMPED_FLOAT_TO_USHORT(near, ctx->Viewport.Near);
|
||||
CLAMPED_FLOAT_TO_USHORT(far, ctx->Viewport.Far);
|
||||
min = FLOAT_TO_UINT(min_f);
|
||||
max = FLOAT_TO_UINT(max_f);
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (zValues[i] < near)
|
||||
zValues[i] = near;
|
||||
if (zValues[i] > far)
|
||||
zValues[i] = far;
|
||||
if (zValues[i] < min)
|
||||
zValues[i] = min;
|
||||
if (zValues[i] > max)
|
||||
zValues[i] = max;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -880,14 +880,14 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span)
|
|||
stipple_polygon_span(ctx, span);
|
||||
}
|
||||
|
||||
if (ctx->Transform.DepthClamp)
|
||||
_swrast_depth_clamp_span(ctx, span);
|
||||
|
||||
/* Stencil and Z testing */
|
||||
if (ctx->Stencil._Enabled || ctx->Depth.Test) {
|
||||
if (!(span->arrayMask & SPAN_Z))
|
||||
_swrast_span_interpolate_z(ctx, span);
|
||||
|
||||
if (ctx->Transform.DepthClamp)
|
||||
_swrast_depth_clamp_span(ctx, span);
|
||||
|
||||
if (ctx->Stencil._Enabled) {
|
||||
if (!_swrast_stencil_and_ztest_span(ctx, span)) {
|
||||
span->arrayMask = origArrayMask;
|
||||
|
|
@ -1356,6 +1356,10 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
|
|||
if (ctx->Stencil._Enabled || ctx->Depth.Test) {
|
||||
if (!(span->arrayMask & SPAN_Z))
|
||||
_swrast_span_interpolate_z(ctx, span);
|
||||
|
||||
if (ctx->Transform.DepthClamp)
|
||||
_swrast_depth_clamp_span(ctx, span);
|
||||
|
||||
if (ctx->Stencil._Enabled) {
|
||||
/* Combined Z/stencil tests */
|
||||
if (!_swrast_stencil_and_ztest_span(ctx, span)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue