}
/* _NEW_TRANSFORM */
- raster->depth_clip_near = !ctx->Transform.DepthClampNear;
- raster->depth_clip_far = !ctx->Transform.DepthClampFar;
+ raster->depth_clip_near = st->clamp_frag_depth_in_shader ||
+ !ctx->Transform.DepthClampNear;
+ raster->depth_clip_far = st->clamp_frag_depth_in_shader ||
+ !ctx->Transform.DepthClampFar;
raster->clip_plane_enable = ctx->Transform.ClipPlanesEnabled;
raster->clip_halfz = (ctx->Transform.ClipDepthMode == GL_ZERO_TO_ONE);
ctx->Color._ClampFragmentColor;
rasterizer.half_pixel_center = 1;
rasterizer.bottom_edge_rule = 1;
- rasterizer.depth_clip_near = !ctx->Transform.DepthClampNear;
- rasterizer.depth_clip_far = !ctx->Transform.DepthClampFar;
+ rasterizer.depth_clip_near = st->clamp_frag_depth_in_shader ||
+ !ctx->Transform.DepthClampNear;
+ rasterizer.depth_clip_far = st->clamp_frag_depth_in_shader ||
+ !ctx->Transform.DepthClampFar;
rasterizer.scissor = ctx->Scissor.EnableFlags;
cso_set_rasterizer(cso, &rasterizer);
}
}
+/**
+ * Compute the effective raster z position. This performs depth-clamping
+ * if needed.
+ */
+static float
+get_effective_raster_z(struct gl_context *ctx)
+{
+ float z = ctx->Current.RasterPos[2];
+ if (st_context(ctx)->clamp_frag_depth_in_shader) {
+ GLfloat depth_near;
+ GLfloat depth_far;
+ if (ctx->ViewportArray[0].Near < ctx->ViewportArray[0].Far) {
+ depth_near = ctx->ViewportArray[0].Near;
+ depth_far = ctx->ViewportArray[0].Far;
+ } else {
+ depth_near = ctx->ViewportArray[0].Far;
+ depth_far = ctx->ViewportArray[0].Near;
+ }
+
+ if (ctx->Transform.DepthClampNear)
+ z = MAX2(z, depth_near);
+ if (ctx->Transform.DepthClampFar)
+ z = MIN2(z, depth_far);
+ }
+ return z;
+}
+
+
/**
* Called via ctx->Driver.DrawPixels()
*/
num_sampler_view++;
}
- draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2],
+ draw_textured_quad(ctx, x, y, get_effective_raster_z(ctx),
width, height,
ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
sv,
/* OK, the texture 'pt' contains the src image/pixels. Now draw a
* textured quad with that texture.
*/
- draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2],
+
+ draw_textured_quad(ctx, dstx, dsty, get_effective_raster_z(ctx),
width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
sv,
num_sampler_view,