summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/draw/draw_validate.c1
-rw-r--r--src/mesa/pipe/draw/draw_vertex_fetch.c12
-rw-r--r--src/mesa/pipe/i915simple/i915_batch.h10
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_context.h3
-rw-r--r--src/mesa/pipe/i915simple/i915_flush.c3
-rw-r--r--src/mesa/pipe/i915simple/i915_winsys.h25
-rw-r--r--src/mesa/pipe/p_state.h1
-rw-r--r--src/mesa/pipe/softpipe/Makefile1
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c2
-rw-r--r--src/mesa/pipe/softpipe/sp_context.h1
-rw-r--r--src/mesa/pipe/softpipe/sp_quad.c70
-rw-r--r--src/mesa/pipe/softpipe/sp_quad.h1
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_depth_test.c24
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_earlyz.c92
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_fs.c4
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_stencil.c16
-rw-r--r--src/mesa/pipe/softpipe/sp_surface.c40
-rw-r--r--src/mesa/pipe/softpipe/sp_tile_cache.c13
-rw-r--r--src/mesa/pipe/tgsi/exec/tgsi_exec.c43
20 files changed, 304 insertions, 60 deletions
diff --git a/src/mesa/pipe/draw/draw_validate.c b/src/mesa/pipe/draw/draw_validate.c
index fdeb1be8ca..4e8f986b27 100644
--- a/src/mesa/pipe/draw/draw_validate.c
+++ b/src/mesa/pipe/draw/draw_validate.c
@@ -85,6 +85,7 @@ static void validate_begin( struct draw_stage *stage )
/* Clip stage
*/
+ if (!draw->rasterizer->bypass_clipping)
{
draw->pipeline.clip->next = next;
next = draw->pipeline.clip;
diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c
index eca10e89fb..b510a4dbba 100644
--- a/src/mesa/pipe/draw/draw_vertex_fetch.c
+++ b/src/mesa/pipe/draw/draw_vertex_fetch.c
@@ -37,6 +37,10 @@
#include "pipe/tgsi/exec/tgsi_core.h"
+
+#define DBG 0
+
+
/**
* Fetch a float[4] vertex attribute from memory, doing format/type
* conversion as needed.
@@ -96,7 +100,9 @@ void draw_vertex_fetch( struct draw_context *draw,
for (j = 0; j < count; j++) {
uint attr;
- /*printf("fetch vertex %u: \n", j);*/
+#if DBG
+ printf("fetch vertex %u: \n", j);
+#endif
/* loop over vertex attributes (vertex shader inputs) */
for (attr = 0; attr < draw->vertex_shader->state->num_inputs; attr++) {
@@ -111,7 +117,9 @@ void draw_vertex_fetch( struct draw_context *draw,
fetch_attrib4(src, draw->vertex_element[attr].src_format, p);
- /*printf(" %u: %f %f %f %f\n", attr, p[0], p[1], p[2], p[3]);*/
+#if DBG
+ printf(" %u: %f %f %f %f\n", attr, p[0], p[1], p[2], p[3]);
+#endif
/* Transform to AoS xxxx/yyyy/zzzz/wwww representation:
*/
diff --git a/src/mesa/pipe/i915simple/i915_batch.h b/src/mesa/pipe/i915simple/i915_batch.h
index fb88cd6db0..603d193f62 100644
--- a/src/mesa/pipe/i915simple/i915_batch.h
+++ b/src/mesa/pipe/i915simple/i915_batch.h
@@ -44,11 +44,11 @@
#define ADVANCE_BATCH()
-#define FLUSH_BATCH() do { \
- if (0) i915_dump_batchbuffer( i915 ); \
- i915->winsys->batch_flush( i915->winsys ); \
- i915->batch_start = NULL; \
- i915->hardware_dirty = ~0; \
+#define FLUSH_BATCH() do { \
+ if (0) i915_dump_batchbuffer( i915 ); \
+ i915->winsys->batch_flush( i915->winsys, &i915->last_fence ); \
+ i915->batch_start = NULL; \
+ i915->hardware_dirty = ~0; \
} while (0)
#endif
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index e43274dc66..f5d770ce0d 100644
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ b/src/mesa/pipe/i915simple/i915_context.c
@@ -175,6 +175,8 @@ static void i915_destroy( struct pipe_context *pipe )
draw_destroy( i915->draw );
+ i915->winsys->fence_reference( i915->winsys, &i915->last_fence, NULL );
+
free( i915 );
}
diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h
index ee430ebc90..488682f852 100644
--- a/src/mesa/pipe/i915simple/i915_context.h
+++ b/src/mesa/pipe/i915simple/i915_context.h
@@ -80,6 +80,7 @@
+struct pipe_fence;
struct i915_cache_context;
/* Use to calculate differences between state emitted to hardware and
@@ -184,6 +185,8 @@ struct i915_context
unsigned dirty;
unsigned *batch_start;
+
+ struct pipe_fence *last_fence;
/** Vertex buffer */
struct pipe_buffer_handle *vbo;
diff --git a/src/mesa/pipe/i915simple/i915_flush.c b/src/mesa/pipe/i915simple/i915_flush.c
index 3c2069b827..1044cb1bdb 100644
--- a/src/mesa/pipe/i915simple/i915_flush.c
+++ b/src/mesa/pipe/i915simple/i915_flush.c
@@ -69,7 +69,8 @@ static void i915_flush( struct pipe_context *pipe,
FLUSH_BATCH();
if (flags & PIPE_FLUSH_WAIT) {
- i915->winsys->batch_finish(i915->winsys);
+ if( i915->last_fence )
+ i915->winsys->fence_wait(i915->winsys, i915->last_fence);
}
}
diff --git a/src/mesa/pipe/i915simple/i915_winsys.h b/src/mesa/pipe/i915simple/i915_winsys.h
index 2c0f335d34..386ed745d3 100644
--- a/src/mesa/pipe/i915simple/i915_winsys.h
+++ b/src/mesa/pipe/i915simple/i915_winsys.h
@@ -52,6 +52,7 @@
struct pipe_buffer_handle;
struct pipe_winsys;
+struct pipe_fence;
/**
@@ -97,8 +98,28 @@ struct i915_winsys {
unsigned access_flags,
unsigned delta );
- void (*batch_flush)( struct i915_winsys *sws );
- void (*batch_finish)( struct i915_winsys *sws );
+ /**
+ * Flush the batch buffer.
+ *
+ * Fence argument must point to NULL or to a previous fence, and the caller
+ * must call fence_reference when done with the fence.
+ */
+ void (*batch_flush)( struct i915_winsys *sws,
+ struct pipe_fence **fence );
+
+
+ /* Fence
+ */
+ void (*fence_reference)( struct i915_winsys *sws,
+ struct pipe_fence **dst_fence,
+ struct pipe_fence *src_fence );
+
+ int (*fence_is_signalled)( struct i915_winsys *sws,
+ struct pipe_fence *fence );
+
+ int (*fence_wait)( struct i915_winsys *sws,
+ struct pipe_fence *fence );
+
};
#define I915_BUFFER_ACCESS_WRITE 0x1
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index 848c32701f..570f44e24e 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -92,6 +92,7 @@ struct pipe_rasterizer_state
unsigned line_stipple_enable:1;
unsigned line_stipple_factor:8; /**< [1..256] actually */
unsigned line_stipple_pattern:16;
+ unsigned bypass_clipping:1;
float line_width;
float point_size; /**< used when no per-vertex size */
diff --git a/src/mesa/pipe/softpipe/Makefile b/src/mesa/pipe/softpipe/Makefile
index 2cbd9e5b51..59628531cc 100644
--- a/src/mesa/pipe/softpipe/Makefile
+++ b/src/mesa/pipe/softpipe/Makefile
@@ -18,6 +18,7 @@ DRIVER_SOURCES = \
sp_quad_colormask.c \
sp_quad_coverage.c \
sp_quad_depth_test.c \
+ sp_quad_earlyz.c \
sp_quad_fs.c \
sp_quad_occlusion.c \
sp_quad_output.c \
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index be4da0ec64..d5e68c189d 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -161,6 +161,7 @@ static void softpipe_destroy( struct pipe_context *pipe )
draw_destroy( softpipe->draw );
softpipe->quad.polygon_stipple->destroy( softpipe->quad.polygon_stipple );
+ softpipe->quad.earlyz->destroy( softpipe->quad.earlyz );
softpipe->quad.shade->destroy( softpipe->quad.shade );
softpipe->quad.alpha_test->destroy( softpipe->quad.alpha_test );
softpipe->quad.depth_test->destroy( softpipe->quad.depth_test );
@@ -369,6 +370,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
/* setup quad rendering stages */
softpipe->quad.polygon_stipple = sp_quad_polygon_stipple_stage(softpipe);
+ softpipe->quad.earlyz = sp_quad_earlyz_stage(softpipe);
softpipe->quad.shade = sp_quad_shade_stage(softpipe);
softpipe->quad.alpha_test = sp_quad_alpha_test_stage(softpipe);
softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe);
diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h
index a411969bc0..872766101d 100644
--- a/src/mesa/pipe/softpipe/sp_context.h
+++ b/src/mesa/pipe/softpipe/sp_context.h
@@ -134,6 +134,7 @@ struct softpipe_context {
/** Software quad rendering pipeline */
struct {
struct quad_stage *polygon_stipple;
+ struct quad_stage *earlyz;
struct quad_stage *shade;
struct quad_stage *alpha_test;
struct quad_stage *stencil_test;
diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c
index 429497e9b2..5a0df6de9d 100644
--- a/src/mesa/pipe/softpipe/sp_quad.c
+++ b/src/mesa/pipe/softpipe/sp_quad.c
@@ -28,24 +28,52 @@
#include "sp_context.h"
+#include "sp_state.h"
+#include "pipe/tgsi/exec/tgsi_token.h"
+static void
+sp_push_quad_first(
+ struct softpipe_context *sp,
+ struct quad_stage *quad )
+{
+ quad->next = sp->quad.first;
+ sp->quad.first = quad;
+}
+
+static void
+sp_build_depth_stencil(
+ struct softpipe_context *sp )
+{
+ if (sp->depth_stencil->stencil.front_enabled ||
+ sp->depth_stencil->stencil.back_enabled) {
+ sp_push_quad_first( sp, sp->quad.stencil_test );
+ }
+ else if (sp->depth_stencil->depth.enabled &&
+ sp->framebuffer.zbuf) {
+ sp_push_quad_first( sp, sp->quad.depth_test );
+ }
+}
void
sp_build_quad_pipeline(struct softpipe_context *sp)
{
+ boolean early_depth_test =
+ sp->depth_stencil->depth.enabled &&
+ sp->framebuffer.zbuf &&
+ !sp->alpha_test->enabled &&
+ sp->fs->shader.output_semantic_name[0] != TGSI_SEMANTIC_POSITION;
+
/* build up the pipeline in reverse order... */
sp->quad.first = sp->quad.output;
if (sp->blend->colormask != 0xf) {
- sp->quad.colormask->next = sp->quad.first;
- sp->quad.first = sp->quad.colormask;
+ sp_push_quad_first( sp, sp->quad.colormask );
}
if (sp->blend->blend_enable ||
sp->blend->logicop_enable) {
- sp->quad.blend->next = sp->quad.first;
- sp->quad.first = sp->quad.blend;
+ sp_push_quad_first( sp, sp->quad.blend );
}
if (sp->framebuffer.num_cbufs == 1) {
@@ -54,46 +82,38 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
}
else {
/* insert bufloop stage */
- sp->quad.bufloop->next = sp->quad.first;
- sp->quad.first = sp->quad.bufloop;
+ sp_push_quad_first( sp, sp->quad.bufloop );
}
if (sp->depth_stencil->depth.occlusion_count) {
- sp->quad.occlusion->next = sp->quad.first;
- sp->quad.first = sp->quad.occlusion;
+ sp_push_quad_first( sp, sp->quad.occlusion );
}
if (sp->rasterizer->poly_smooth ||
sp->rasterizer->line_smooth ||
sp->rasterizer->point_smooth) {
- sp->quad.coverage->next = sp->quad.first;
- sp->quad.first = sp->quad.coverage;
+ sp_push_quad_first( sp, sp->quad.coverage );
}
- if ( sp->depth_stencil->stencil.front_enabled
- || sp->depth_stencil->stencil.back_enabled) {
- sp->quad.stencil_test->next = sp->quad.first;
- sp->quad.first = sp->quad.stencil_test;
- }
- else if (sp->depth_stencil->depth.enabled &&
- sp->framebuffer.zbuf) {
- sp->quad.depth_test->next = sp->quad.first;
- sp->quad.first = sp->quad.depth_test;
+ if (!early_depth_test) {
+ sp_build_depth_stencil( sp );
}
if (sp->alpha_test->enabled) {
- sp->quad.alpha_test->next = sp->quad.first;
- sp->quad.first = sp->quad.alpha_test;
+ sp_push_quad_first( sp, sp->quad.alpha_test );
}
/* XXX always enable shader? */
if (1) {
- sp->quad.shade->next = sp->quad.first;
- sp->quad.first = sp->quad.shade;
+ sp_push_quad_first( sp, sp->quad.shade );
+ }
+
+ if (early_depth_test) {
+ sp_build_depth_stencil( sp );
+ sp_push_quad_first( sp, sp->quad.earlyz );
}
if (sp->rasterizer->poly_stipple_enable) {
- sp->quad.polygon_stipple->next = sp->quad.first;
- sp->quad.first = sp->quad.polygon_stipple;
+ sp_push_quad_first( sp, sp->quad.polygon_stipple );
}
}
diff --git a/src/mesa/pipe/softpipe/sp_quad.h b/src/mesa/pipe/softpipe/sp_quad.h
index 534541122b..f1e0281764 100644
--- a/src/mesa/pipe/softpipe/sp_quad.h
+++ b/src/mesa/pipe/softpipe/sp_quad.h
@@ -51,6 +51,7 @@ struct quad_stage {
struct quad_stage *sp_quad_polygon_stipple_stage( struct softpipe_context *softpipe );
+struct quad_stage *sp_quad_earlyz_stage( struct softpipe_context *softpipe );
struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe );
struct quad_stage *sp_quad_alpha_test_stage( struct softpipe_context *softpipe );
struct quad_stage *sp_quad_stencil_test_stage( struct softpipe_context *softpipe );
diff --git a/src/mesa/pipe/softpipe/sp_quad_depth_test.c b/src/mesa/pipe/softpipe/sp_quad_depth_test.c
index f7e93af784..3318189621 100644
--- a/src/mesa/pipe/softpipe/sp_quad_depth_test.c
+++ b/src/mesa/pipe/softpipe/sp_quad_depth_test.c
@@ -119,6 +119,21 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
}
}
break;
+ case PIPE_FORMAT_Z24_S8:
+ {
+ float scale = (float) ((1 << 24) - 1);
+
+ for (j = 0; j < QUAD_SIZE; j++) {
+ qzzzz[j] = (unsigned) (quad->outputs.depth[j] * scale);
+ }
+
+ for (j = 0; j < QUAD_SIZE; j++) {
+ int x = quad->x0 % TILE_SIZE + (j & 1);
+ int y = quad->y0 % TILE_SIZE + (j >> 1);
+ bzzzz[j] = tile->data.depth32[y][x] >> 8;
+ }
+ }
+ break;
default:
assert(0);
}
@@ -210,6 +225,15 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
tile->data.depth32[y][x] = s8z24;
}
break;
+ case PIPE_FORMAT_Z24_S8:
+ for (j = 0; j < QUAD_SIZE; j++) {
+ int x = quad->x0 % TILE_SIZE + (j & 1);
+ int y = quad->y0 % TILE_SIZE + (j >> 1);
+ uint z24s8 = tile->data.depth32[y][x];
+ z24s8 = (z24s8 & 0xff) | (bzzzz[j] << 24);
+ tile->data.depth32[y][x] = z24s8;
+ }
+ break;
default:
assert(0);
}
diff --git a/src/mesa/pipe/softpipe/sp_quad_earlyz.c b/src/mesa/pipe/softpipe/sp_quad_earlyz.c
new file mode 100644
index 0000000000..89fab2dd35
--- /dev/null
+++ b/src/mesa/pipe/softpipe/sp_quad_earlyz.c
@@ -0,0 +1,92 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * \brief Quad early-z testing
+ */
+
+#include "pipe/p_defines.h"
+#include "pipe/p_util.h"
+#include "sp_headers.h"
+#include "sp_quad.h"
+
+
+/**
+ * All this stage does is compute the quad's Z values (which is normally
+ * done by the shading stage).
+ * The next stage will do the actual depth test.
+ */
+static void
+earlyz_quad(
+ struct quad_stage *qs,
+ struct quad_header *quad )
+{
+ const float fx = (float) quad->x0;
+ const float fy = (float) quad->y0;
+ const float dzdx = quad->coef[0].dadx[2];
+ const float dzdy = quad->coef[0].dady[2];
+ const float z0 = quad->coef[0].a0[2] + dzdx * fx + dzdy * fy;
+
+ quad->outputs.depth[0] = z0;
+ quad->outputs.depth[1] = z0 + dzdx;
+ quad->outputs.depth[2] = z0 + dzdy;
+ quad->outputs.depth[3] = z0 + dzdx + dzdy;
+
+ if (qs->next) {
+ qs->next->run( qs->next, quad );
+ }
+}
+
+static void
+earlyz_begin(
+ struct quad_stage *qs )
+{
+ if (qs->next) {
+ qs->next->begin( qs->next );
+ }
+}
+
+static void
+earlyz_destroy(
+ struct quad_stage *qs )
+{
+ FREE( qs );
+}
+
+struct quad_stage *
+sp_quad_earlyz_stage(
+ struct softpipe_context *softpipe )
+{
+ struct quad_stage *stage = CALLOC_STRUCT( quad_stage );
+
+ stage->softpipe = softpipe;
+ stage->begin = earlyz_begin;
+ stage->run = earlyz_quad;
+ stage->destroy = earlyz_destroy;
+
+ return stage;
+}
diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c
index 17fb10ea72..ed14dac18e 100644
--- a/src/mesa/pipe/softpipe/sp_quad_fs.c
+++ b/src/mesa/pipe/softpipe/sp_quad_fs.c
@@ -104,6 +104,10 @@ shade_quad(
machine->Inputs[0].xyzw[0].f[2] = fx;
machine->Inputs[0].xyzw[0].f[3] = fx + 1.0f;
+ /* XXX for OpenGL we need to invert the Y pos here (y=0=top).
+ * but that'll mess up linear/perspective interpolation of other
+ * attributes...
+ */
machine->Inputs[0].xyzw[1].f[0] = fy;
machine->Inputs[0].xyzw[1].f[1] = fy;
machine->Inputs[0].xyzw[1].f[2] = fy + 1.0f;
diff --git a/src/mesa/pipe/softpipe/sp_quad_stencil.c b/src/mesa/pipe/softpipe/sp_quad_stencil.c
index 831ad8bad0..0149b20f48 100644
--- a/src/mesa/pipe/softpipe/sp_quad_stencil.c
+++ b/src/mesa/pipe/softpipe/sp_quad_stencil.c
@@ -241,6 +241,13 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
stencilVals[j] = tile->data.depth32[y][x] >> 24;
}
break;
+ case PIPE_FORMAT_Z24_S8:
+ for (j = 0; j < QUAD_SIZE; j++) {
+ int x = quad->x0 % TILE_SIZE + (j & 1);
+ int y = quad->y0 % TILE_SIZE + (j >> 1);
+ stencilVals[j] = tile->data.depth32[y][x] & 0xff;
+ }
+ break;
case PIPE_FORMAT_U_S8:
for (j = 0; j < QUAD_SIZE; j++) {
int x = quad->x0 % TILE_SIZE + (j & 1);
@@ -300,6 +307,15 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
tile->data.depth32[y][x] = s8z24;
}
break;
+ case PIPE_FORMAT_Z24_S8:
+ for (j = 0; j < QUAD_SIZE; j++) {
+ int x = quad->x0 % TILE_SIZE + (j & 1);
+ int y = quad->y0 % TILE_SIZE + (j >> 1);
+ uint z24s8 = tile->data.depth32[y][x];
+ z24s8 = (z24s8 & 0xffffff00) | stencilVals[j];
+ tile->data.depth32[y][x] = z24s8;
+ }
+ break;
case PIPE_FORMAT_U_S8:
for (j = 0; j < QUAD_SIZE; j++) {
int x = quad->x0 % TILE_SIZE + (j & 1);
diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c
index ccaf38de3e..b7c9d4f004 100644
--- a/src/mesa/pipe/softpipe/sp_surface.c
+++ b/src/mesa/pipe/softpipe/sp_surface.c
@@ -461,6 +461,40 @@ s8z24_get_tile(struct pipe_surface *ps,
}
+/*** PIPE_FORMAT_Z24_S8 ***/
+
+/**
+ * Return Z component as four float in [0,1]. Stencil part ignored.
+ */
+static void
+z24s8_get_tile(struct pipe_surface *ps,
+ unsigned x, unsigned y, unsigned w, unsigned h, float *p)
+{
+ const uint *src
+ = ((const uint *) (ps->region->map + ps->offset))
+ + y * ps->region->pitch + x;
+ const double scale = 1.0 / ((1 << 24) - 1);
+ unsigned i, j;
+ unsigned w0 = w;
+
+ assert(ps->format == PIPE_FORMAT_Z24_S8);
+
+ CLIP_TILE;
+
+ for (i = 0; i < h; i++) {
+ float *pRow = p;
+ for (j = 0; j < w; j++) {
+ pRow[j * 4 + 0] =
+ pRow[j * 4 + 1] =
+ pRow[j * 4 + 2] =
+ pRow[j * 4 + 3] = (float) (scale * (src[j] >> 8));
+ }
+ src += ps->region->pitch;
+ p += 4 * w0;
+ }
+}
+
+
/**
* Called via pipe->get_tex_surface()
* XXX is this in the right place?
@@ -601,6 +635,9 @@ softpipe_get_tile_rgba(struct pipe_context *pipe,
case PIPE_FORMAT_S8_Z24:
s8z24_get_tile(ps, x, y, w, h, p);
break;
+ case PIPE_FORMAT_Z24_S8:
+ z24s8_get_tile(ps, x, y, w, h, p);
+ break;
default:
assert(0);
}
@@ -645,6 +682,9 @@ softpipe_put_tile_rgba(struct pipe_context *pipe,
case PIPE_FORMAT_S8_Z24:
/*s8z24_put_tile(ps, x, y, w, h, p);*/
break;
+ case PIPE_FORMAT_Z24_S8:
+ /*z24s8_put_tile(ps, x, y, w, h, p);*/
+ break;
default:
assert(0);
}
diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.c b/src/mesa/pipe/softpipe/sp_tile_cache.c
index 19c06323e1..ea0c8b8f91 100644
--- a/src/mesa/pipe/softpipe/sp_tile_cache.c
+++ b/src/mesa/pipe/softpipe/sp_tile_cache.c
@@ -166,6 +166,7 @@ sp_flush_tile_cache(struct softpipe_context *softpipe,
return;
is_depth_stencil = (ps->format == PIPE_FORMAT_S8_Z24 ||
+ ps->format == PIPE_FORMAT_Z24_S8 ||
ps->format == PIPE_FORMAT_U_Z16 ||
ps->format == PIPE_FORMAT_U_Z32 ||
ps->format == PIPE_FORMAT_U_S8);
@@ -203,6 +204,7 @@ sp_get_cached_tile(struct softpipe_context *softpipe,
struct pipe_surface *ps = tc->surface;
boolean is_depth_stencil
= (ps->format == PIPE_FORMAT_S8_Z24 ||
+ ps->format == PIPE_FORMAT_Z24_S8 ||
ps->format == PIPE_FORMAT_U_Z16 ||
ps->format == PIPE_FORMAT_U_Z32 ||
ps->format == PIPE_FORMAT_U_S8);
@@ -268,6 +270,17 @@ sp_get_cached_tile(struct softpipe_context *softpipe,
}
}
break;
+ case PIPE_FORMAT_Z24_S8:
+ {
+ uint clear_val = ((uint) (tc->clear_value[0] * 0xffffff)) << 8;
+ clear_val |= ((uint) tc->clear_value[1]) & 0xff;
+ for (i = 0; i < TILE_SIZE; i++) {
+ for (j = 0; j < TILE_SIZE; j++) {
+ tile->data.depth32[i][j] = clear_val;
+ }
+ }
+ }
+ break;
case PIPE_FORMAT_U_S8:
{
ubyte clear_val = (uint) tc->clear_value[0];
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.c b/src/mesa/pipe/tgsi/exec/tgsi_exec.c
index 5c2fecb3e3..ea6c5021b3 100644
--- a/src/mesa/pipe/tgsi/exec/tgsi_exec.c
+++ b/src/mesa/pipe/tgsi/exec/tgsi_exec.c
@@ -1346,17 +1346,15 @@ linear_interpolation(
unsigned attrib,
unsigned chan )
{
- unsigned i;
-
- for( i = 0; i < QUAD_SIZE; i++ ) {
- const float x = mach->Inputs[0].xyzw[0].f[i];
- const float y = mach->Inputs[0].xyzw[1].f[i];
-
- mach->Inputs[attrib].xyzw[chan].f[i] =
- mach->InterpCoefs[attrib].a0[chan] +
- mach->InterpCoefs[attrib].dadx[chan] * x +
- mach->InterpCoefs[attrib].dady[chan] * y;
- }
+ const float x = mach->Inputs[0].xyzw[0].f[0];
+ const float y = mach->Inputs[0].xyzw[1].f[0];
+ const float dadx = mach->InterpCoefs[attrib].dadx[chan];
+ const float dady = mach->InterpCoefs[attrib].dady[chan];
+ const float a0 = mach->InterpCoefs[attrib].a0[chan] + dadx * x + dady * y;
+ mach->Inputs[attrib].xyzw[chan].f[0] = a0;
+ mach->Inputs[attrib].xyzw[chan].f[1] = a0 + dadx;
+ mach->Inputs[attrib].xyzw[chan].f[2] = a0 + dady;
+ mach->Inputs[attrib].xyzw[chan].f[3] = a0 + dadx + dady;
}
static void
@@ -1365,20 +1363,15 @@ perspective_interpolation(
unsigned attrib,
unsigned chan )
{
- unsigned i;
-
- for( i = 0; i < QUAD_SIZE; i++ ) {
- const float x = mach->Inputs[0].xyzw[0].f[i];
- const float y = mach->Inputs[0].xyzw[1].f[i];
- /* WPOS.w here is really 1/w */
- const float w = 1.0f / mach->Inputs[0].xyzw[3].f[i];
- assert(mach->Inputs[0].xyzw[3].f[i] != 0.0);
-
- mach->Inputs[attrib].xyzw[chan].f[i] =
- (mach->InterpCoefs[attrib].a0[chan] +
- mach->InterpCoefs[attrib].dadx[chan] * x +
- mach->InterpCoefs[attrib].dady[chan] * y) * w;
- }
+ const float x = mach->Inputs[0].xyzw[0].f[0];
+ const float y = mach->Inputs[0].xyzw[1].f[0];
+ const float dadx = mach->InterpCoefs[attrib].dadx[chan];
+ const float dady = mach->InterpCoefs[attrib].dady[chan];
+ const float a0 = mach->InterpCoefs[attrib].a0[chan] + dadx * x + dady * y;
+ mach->Inputs[attrib].xyzw[chan].f[0] = a0 / mach->Inputs[0].xyzw[3].f[0];
+ mach->Inputs[attrib].xyzw[chan].f[1] = (a0 + dadx) / mach->Inputs[0].xyzw[3].f[1];
+ mach->Inputs[attrib].xyzw[chan].f[2] = (a0 + dady) / mach->Inputs[0].xyzw[3].f[2];
+ mach->Inputs[attrib].xyzw[chan].f[3] = (a0 + dadx + dady) / mach->Inputs[0].xyzw[3].f[3];
}