boolean use_shader_stencil_refs;
ubyte shader_stencil_refs[TGSI_QUAD_SIZE];
struct softpipe_cached_tile *tile;
+ float minval, maxval;
+ bool clamp;
};
const struct quad_header *quad )
{
unsigned j;
+ float dvals[TGSI_QUAD_SIZE];
/* Convert quad's float depth values to int depth values (qzzzz).
* If the Z buffer stores integer values, we _have_ to do the depth
* conversion of Z values (which isn't an identity function) will cause
* Z-fighting errors.
*/
+ if (data->clamp) {
+ for (j = 0; j < TGSI_QUAD_SIZE; j++) {
+ dvals[j] = CLAMP(quad->output.depth[j], data->minval, data->maxval);
+ }
+ } else {
+ for (j = 0; j < TGSI_QUAD_SIZE; j++) {
+ dvals[j] = quad->output.depth[j];
+ }
+ }
+
switch (data->format) {
case PIPE_FORMAT_Z16_UNORM:
{
float scale = 65535.0;
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
- data->qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
+ data->qzzzz[j] = (unsigned) (dvals[j] * scale);
}
}
break;
double scale = (double) (uint) ~0UL;
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
- data->qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
+ data->qzzzz[j] = (unsigned) (dvals[j] * scale);
}
}
break;
float scale = (float) ((1 << 24) - 1);
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
- data->qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
+ data->qzzzz[j] = (unsigned) (dvals[j] * scale);
}
}
break;
float scale = (float) ((1 << 24) - 1);
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
- data->qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
+ data->qzzzz[j] = (unsigned) (dvals[j] * scale);
}
}
break;
union fi fui;
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
- fui.f = quad->output.depth[j];
+ fui.f = dvals[j];
data->qzzzz[j] = fui.ui;
}
}
if (qs->softpipe->framebuffer.zsbuf &&
(qs->softpipe->depth_stencil->depth.enabled ||
qs->softpipe->depth_stencil->stencil[0].enabled)) {
+ float near_val, far_val;
data.ps = qs->softpipe->framebuffer.zsbuf;
data.format = data.ps->format;
data.tile = sp_get_cached_tile(qs->softpipe->zsbuf_cache,
quads[0]->input.x0,
quads[0]->input.y0);
+ data.clamp = !qs->softpipe->rasterizer->depth_clip;
+
+ near_val = qs->softpipe->viewport.translate[2] - qs->softpipe->viewport.scale[2];
+ far_val = near_val + (qs->softpipe->viewport.scale[2] * 2.0);
+ data.minval = MIN2(near_val, far_val);
+ data.maxval = MAX2(near_val, far_val);
for (i = 0; i < nr; i++) {
get_depth_stencil_values(&data, quads[i]);
boolean occlusion = qs->softpipe->active_query_count;
+ boolean clipped = !qs->softpipe->rasterizer->depth_clip;
+
if(!qs->softpipe->framebuffer.zsbuf)
depth = depthwrite = stencil = FALSE;
if (!alpha &&
!depth &&
!occlusion &&
+ !clipped &&
!stencil) {
qs->run = depth_noop;
}
depth &&
depthwrite &&
!occlusion &&
+ !clipped &&
!stencil)
{
if (qs->softpipe->framebuffer.zsbuf->format == PIPE_FORMAT_Z16_UNORM) {