summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2008-03-02 02:35:17 +1100
committerBen Skeggs <skeggsb@gmail.com>2008-03-02 02:35:17 +1100
commit132def0c4182b8d2251e9d6e2b5b470cb806713c (patch)
tree8609fed67628e3ebf0d0af4a05982ff7cc211be1
parent17f6db9d0197657cd753249ef60355c6fd983032 (diff)
parent07d6347e8a51fc7bbd5c586a5739f17c68c5eafd (diff)
Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
-rw-r--r--src/gallium/auxiliary/draw/draw_aaline.c32
-rw-r--r--src/gallium/auxiliary/draw/draw_aapoint.c32
-rw-r--r--src/gallium/auxiliary/draw/draw_pstipple.c32
-rw-r--r--src/gallium/auxiliary/draw/draw_unfilled.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_validate.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_wide_line.c21
-rw-r--r--src/gallium/auxiliary/draw/draw_wide_point.c18
-rw-r--r--src/gallium/auxiliary/util/p_tile.c124
-rw-r--r--src/gallium/auxiliary/util/p_tile.h14
-rw-r--r--src/gallium/drivers/softpipe/SConscript1
-rw-r--r--src/gallium/include/pipe/p_context.h1
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c12
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c12
-rw-r--r--src/mesa/state_tracker/st_context.h2
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c3
15 files changed, 194 insertions, 113 deletions
diff --git a/src/gallium/auxiliary/draw/draw_aaline.c b/src/gallium/auxiliary/draw/draw_aaline.c
index 51140388f0..7660e56fe6 100644
--- a/src/gallium/auxiliary/draw/draw_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_aaline.c
@@ -691,35 +691,11 @@ draw_aaline_stage(struct draw_context *draw)
}
-/*
- * XXX temporary? solution to mapping a pipe_context to a aaline_stage.
- */
-
-#define MAX_CONTEXTS 10
-
-static struct pipe_context *Pipe[MAX_CONTEXTS];
-static struct aaline_stage *Stage[MAX_CONTEXTS];
-static uint NumContexts;
-
-static void
-add_aa_pipe_context(struct pipe_context *pipe, struct aaline_stage *aa)
-{
- assert(NumContexts < MAX_CONTEXTS);
- Pipe[NumContexts] = pipe;
- Stage[NumContexts] = aa;
- NumContexts++;
-}
-
static struct aaline_stage *
aaline_stage_from_pipe(struct pipe_context *pipe)
{
- uint i;
- for (i = 0; i < NumContexts; i++) {
- if (Pipe[i] == pipe)
- return Stage[i];
- }
- assert(0);
- return NULL;
+ struct draw_context *draw = (struct draw_context *) pipe->draw;
+ return aaline_stage(draw->pipeline.aaline);
}
@@ -802,6 +778,8 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
{
struct aaline_stage *aaline;
+ pipe->draw = (void *) draw;
+
/*
* Create / install AA line drawing / prim stage
*/
@@ -830,6 +808,4 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
pipe->bind_sampler_state = aaline_bind_sampler_state;
pipe->set_sampler_texture = aaline_set_sampler_texture;
-
- add_aa_pipe_context(pipe, aaline);
}
diff --git a/src/gallium/auxiliary/draw/draw_aapoint.c b/src/gallium/auxiliary/draw/draw_aapoint.c
index d48a416899..70f696475f 100644
--- a/src/gallium/auxiliary/draw/draw_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_aapoint.c
@@ -762,35 +762,11 @@ draw_aapoint_stage(struct draw_context *draw)
}
-/*
- * XXX temporary? solution to mapping a pipe_context to a aapoint_stage.
- */
-
-#define MAX_CONTEXTS 10
-
-static struct pipe_context *Pipe[MAX_CONTEXTS];
-static struct aapoint_stage *Stage[MAX_CONTEXTS];
-static uint NumContexts;
-
-static void
-add_aa_pipe_context(struct pipe_context *pipe, struct aapoint_stage *aa)
-{
- assert(NumContexts < MAX_CONTEXTS);
- Pipe[NumContexts] = pipe;
- Stage[NumContexts] = aa;
- NumContexts++;
-}
-
static struct aapoint_stage *
aapoint_stage_from_pipe(struct pipe_context *pipe)
{
- uint i;
- for (i = 0; i < NumContexts; i++) {
- if (Pipe[i] == pipe)
- return Stage[i];
- }
- assert(0);
- return NULL;
+ struct draw_context *draw = (struct draw_context *) pipe->draw;
+ return aapoint_stage(draw->pipeline.aapoint);
}
@@ -850,6 +826,8 @@ draw_install_aapoint_stage(struct draw_context *draw,
{
struct aapoint_stage *aapoint;
+ pipe->draw = (void *) draw;
+
/*
* Create / install AA point drawing / prim stage
*/
@@ -868,6 +846,4 @@ draw_install_aapoint_stage(struct draw_context *draw,
pipe->create_fs_state = aapoint_create_fs_state;
pipe->bind_fs_state = aapoint_bind_fs_state;
pipe->delete_fs_state = aapoint_delete_fs_state;
-
- add_aa_pipe_context(pipe, aapoint);
}
diff --git a/src/gallium/auxiliary/draw/draw_pstipple.c b/src/gallium/auxiliary/draw/draw_pstipple.c
index f6200aa820..2cfeb813b3 100644
--- a/src/gallium/auxiliary/draw/draw_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pstipple.c
@@ -559,35 +559,11 @@ draw_pstip_stage(struct draw_context *draw)
}
-/*
- * XXX temporary? solution to mapping a pipe_context to a pstip_stage.
- */
-
-#define MAX_CONTEXTS 10
-
-static struct pipe_context *Pipe[MAX_CONTEXTS];
-static struct pstip_stage *Stage[MAX_CONTEXTS];
-static uint NumContexts;
-
-static void
-add_pstip_pipe_context(struct pipe_context *pipe, struct pstip_stage *pstip)
-{
- assert(NumContexts < MAX_CONTEXTS);
- Pipe[NumContexts] = pipe;
- Stage[NumContexts] = pstip;
- NumContexts++;
-}
-
static struct pstip_stage *
pstip_stage_from_pipe(struct pipe_context *pipe)
{
- uint i;
- for (i = 0; i < NumContexts; i++) {
- if (Pipe[i] == pipe)
- return Stage[i];
- }
- assert(0);
- return NULL;
+ struct draw_context *draw = (struct draw_context *) pipe->draw;
+ return pstip_stage(draw->pipeline.pstipple);
}
@@ -686,6 +662,8 @@ draw_install_pstipple_stage(struct draw_context *draw,
{
struct pstip_stage *pstip;
+ pipe->draw = (void *) draw;
+
/*
* Create / install AA line drawing / prim stage
*/
@@ -716,6 +694,4 @@ draw_install_pstipple_stage(struct draw_context *draw,
pipe->bind_sampler_state = pstip_bind_sampler_state;
pipe->set_sampler_texture = pstip_set_sampler_texture;
pipe->set_polygon_stipple = pstip_set_polygon_stipple;
-
- add_pstip_pipe_context(pipe, pstip);
}
diff --git a/src/gallium/auxiliary/draw/draw_unfilled.c b/src/gallium/auxiliary/draw/draw_unfilled.c
index 8777cfdfc8..4d718d514c 100644
--- a/src/gallium/auxiliary/draw/draw_unfilled.c
+++ b/src/gallium/auxiliary/draw/draw_unfilled.c
@@ -101,9 +101,9 @@ static void lines( struct draw_stage *stage,
assert(((header->edgeflags & 0x4) >> 2) == header->v[2]->edgeflag);
#endif
+ if (header->edgeflags & 0x4) line( stage, v2, v0 );
if (header->edgeflags & 0x1) line( stage, v0, v1 );
if (header->edgeflags & 0x2) line( stage, v1, v2 );
- if (header->edgeflags & 0x4) line( stage, v2, v0 );
}
diff --git a/src/gallium/auxiliary/draw/draw_validate.c b/src/gallium/auxiliary/draw/draw_validate.c
index 084eee9b6e..b43295b586 100644
--- a/src/gallium/auxiliary/draw/draw_validate.c
+++ b/src/gallium/auxiliary/draw/draw_validate.c
@@ -84,6 +84,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
if (wide_lines) {
draw->pipeline.wide_line->next = next;
next = draw->pipeline.wide_line;
+ precalc_flat = 1;
}
if (wide_points || draw->rasterizer->point_sprite) {
diff --git a/src/gallium/auxiliary/draw/draw_wide_line.c b/src/gallium/auxiliary/draw/draw_wide_line.c
index 946a983f00..9a168ce8bd 100644
--- a/src/gallium/auxiliary/draw/draw_wide_line.c
+++ b/src/gallium/auxiliary/draw/draw_wide_line.c
@@ -86,7 +86,10 @@ static void wideline_line( struct draw_stage *stage,
const float dx = FABSF(pos0[0] - pos2[0]);
const float dy = FABSF(pos0[1] - pos2[1]);
-
+
+ /* small tweak to meet GL specification */
+ const float bias = 0.125f;
+
/*
* Draw wide line as a quad (two tris) by "stretching" the line along
* X or Y.
@@ -95,10 +98,10 @@ static void wideline_line( struct draw_stage *stage,
if (dx > dy) {
/* x-major line */
- pos0[1] = pos0[1] - half_width - 0.25f;
- pos1[1] = pos1[1] + half_width - 0.25f;
- pos2[1] = pos2[1] - half_width - 0.25f;
- pos3[1] = pos3[1] + half_width - 0.25f;
+ pos0[1] = pos0[1] - half_width - bias;
+ pos1[1] = pos1[1] + half_width - bias;
+ pos2[1] = pos2[1] - half_width - bias;
+ pos3[1] = pos3[1] + half_width - bias;
if (pos0[0] < pos2[0]) {
/* left to right line */
pos0[0] -= 0.5f;
@@ -116,10 +119,10 @@ static void wideline_line( struct draw_stage *stage,
}
else {
/* y-major line */
- pos0[0] = pos0[0] - half_width + 0.25f;
- pos1[0] = pos1[0] + half_width + 0.25f;
- pos2[0] = pos2[0] - half_width + 0.25f;
- pos3[0] = pos3[0] + half_width + 0.25f;
+ pos0[0] = pos0[0] - half_width + bias;
+ pos1[0] = pos1[0] + half_width + bias;
+ pos2[0] = pos2[0] - half_width + bias;
+ pos3[0] = pos3[0] + half_width + bias;
if (pos0[1] < pos2[1]) {
/* top to bottom line */
pos0[1] -= 0.5f;
diff --git a/src/gallium/auxiliary/draw/draw_wide_point.c b/src/gallium/auxiliary/draw/draw_wide_point.c
index 8f877a102a..65bd50f2b8 100644
--- a/src/gallium/auxiliary/draw/draw_wide_point.c
+++ b/src/gallium/auxiliary/draw/draw_wide_point.c
@@ -109,7 +109,7 @@ static void widepoint_point( struct draw_stage *stage,
const struct widepoint_stage *wide = widepoint_stage(stage);
const boolean sprite = (boolean) stage->draw->rasterizer->point_sprite;
float half_size;
- float left_adj, right_adj;
+ float left_adj, right_adj, bot_adj, top_adj;
struct prim_header tri;
@@ -124,6 +124,8 @@ static void widepoint_point( struct draw_stage *stage,
float *pos2 = v2->data[0];
float *pos3 = v3->data[0];
+ const float xbias = 0.0, ybias = -0.125;
+
/* point size is either per-vertex or fixed size */
if (wide->psize_slot >= 0) {
half_size = 0.5f * header->v[0]->data[wide->psize_slot][0];
@@ -132,20 +134,22 @@ static void widepoint_point( struct draw_stage *stage,
half_size = wide->half_point_size;
}
- left_adj = -half_size; /* + 0.25f;*/
- right_adj = half_size; /* + 0.25f;*/
+ left_adj = -half_size + xbias;
+ right_adj = half_size + xbias;
+ bot_adj = half_size + ybias;
+ top_adj = -half_size + ybias;
pos0[0] += left_adj;
- pos0[1] -= half_size;
+ pos0[1] += top_adj;
pos1[0] += left_adj;
- pos1[1] += half_size;
+ pos1[1] += bot_adj;
pos2[0] += right_adj;
- pos2[1] -= half_size;
+ pos2[1] += top_adj;
pos3[0] += right_adj;
- pos3[1] += half_size;
+ pos3[1] += bot_adj;
if (sprite) {
static const float tex00[4] = { 0, 0, 0, 1 };
diff --git a/src/gallium/auxiliary/util/p_tile.c b/src/gallium/auxiliary/util/p_tile.c
index 3f795a3898..287d783981 100644
--- a/src/gallium/auxiliary/util/p_tile.c
+++ b/src/gallium/auxiliary/util/p_tile.c
@@ -697,3 +697,127 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
FREE(packed);
}
+
+
+/**
+ * Get a block of Z values, converted to 32-bit range.
+ */
+void
+pipe_get_tile_z(struct pipe_context *pipe,
+ struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h,
+ uint *z)
+{
+ const uint dstStride = w;
+ uint *pDest = z;
+ uint i, j;
+
+ if (pipe_clip_tile(x, y, &w, &h, ps))
+ return;
+
+ switch (ps->format) {
+ case PIPE_FORMAT_Z32_UNORM:
+ {
+ const uint *pSrc
+ = (const uint *) pipe_surface_map(ps) + (y * ps->pitch + x);
+ for (i = 0; i < h; i++) {
+ memcpy(pDest, pSrc, 4 * w);
+ pDest += dstStride;
+ pSrc += ps->pitch;
+ }
+ }
+ break;
+ case PIPE_FORMAT_S8Z24_UNORM:
+ {
+ const uint *pSrc
+ = (const uint *) pipe_surface_map(ps) + (y * ps->pitch + x);
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ /* convert 24-bit Z to 32-bit Z */
+ pDest[j] = (pSrc[j] << 8) | (pSrc[j] & 0xff);
+ }
+ pDest += dstStride;
+ pSrc += ps->pitch;
+ }
+ }
+ break;
+ case PIPE_FORMAT_Z16_UNORM:
+ {
+ const ushort *pSrc
+ = (const ushort *) pipe_surface_map(ps) + (y * ps->pitch + x);
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ /* convert 16-bit Z to 32-bit Z */
+ pDest[j] = (pSrc[j] << 16) | pSrc[j];
+ }
+ pDest += dstStride;
+ pSrc += ps->pitch;
+ }
+ }
+ break;
+ default:
+ assert(0);
+ }
+
+ pipe_surface_unmap(ps);
+}
+
+
+void
+pipe_put_tile_z(struct pipe_context *pipe,
+ struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h,
+ const uint *zSrc)
+{
+ const uint srcStride = w;
+ const uint *pSrc = zSrc;
+ uint i, j;
+
+ if (pipe_clip_tile(x, y, &w, &h, ps))
+ return;
+
+ switch (ps->format) {
+ case PIPE_FORMAT_Z32_UNORM:
+ {
+ uint *pDest = (uint *) pipe_surface_map(ps) + (y * ps->pitch + x);
+ for (i = 0; i < h; i++) {
+ memcpy(pDest, pSrc, 4 * w);
+ pDest += ps->pitch;
+ pSrc += srcStride;
+ }
+ }
+ break;
+ case PIPE_FORMAT_S8Z24_UNORM:
+ {
+ uint *pDest = (uint *) pipe_surface_map(ps) + (y * ps->pitch + x);
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ /* convert 32-bit Z to 24-bit Z (0 stencil) */
+ pDest[j] = pSrc[j] >> 8;
+ }
+ pDest += ps->pitch;
+ pSrc += srcStride;
+ }
+ }
+ break;
+ case PIPE_FORMAT_Z16_UNORM:
+ {
+ ushort *pDest = (ushort *) pipe_surface_map(ps) + (y * ps->pitch + x);
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ /* convert 32-bit Z to 16-bit Z */
+ pDest[j] = pSrc[j] >> 16;
+ }
+ pDest += ps->pitch;
+ pSrc += srcStride;
+ }
+ }
+ break;
+ default:
+ assert(0);
+ }
+
+ pipe_surface_unmap(ps);
+}
+
+
diff --git a/src/gallium/auxiliary/util/p_tile.h b/src/gallium/auxiliary/util/p_tile.h
index cd8124bf11..318b6d11a6 100644
--- a/src/gallium/auxiliary/util/p_tile.h
+++ b/src/gallium/auxiliary/util/p_tile.h
@@ -78,4 +78,18 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
uint x, uint y, uint w, uint h,
const float *p);
+
+extern void
+pipe_get_tile_z(struct pipe_context *pipe,
+ struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h,
+ uint *z);
+
+extern void
+pipe_put_tile_z(struct pipe_context *pipe,
+ struct pipe_surface *ps,
+ uint x, uint y, uint w, uint h,
+ const uint *z);
+
+
#endif
diff --git a/src/gallium/drivers/softpipe/SConscript b/src/gallium/drivers/softpipe/SConscript
index 4c1a6d5df0..88c21ee3b0 100644
--- a/src/gallium/drivers/softpipe/SConscript
+++ b/src/gallium/drivers/softpipe/SConscript
@@ -28,6 +28,7 @@ softpipe = env.ConvenienceLibrary(
'sp_quad_stencil.c',
'sp_quad_stipple.c',
'sp_query.c',
+ 'sp_screen.c',
'sp_state_blend.c',
'sp_state_clip.c',
'sp_state_derived.c',
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index d0f25d7d46..1501b52f3e 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -56,6 +56,7 @@ struct pipe_context {
struct pipe_screen *screen;
void *priv; /** context private data (for DRI for example) */
+ void *draw; /** private, for draw module (temporary? */
void (*destroy)( struct pipe_context * );
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index a4ac726816..697d2cdfb4 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -55,6 +55,7 @@ update_textures(struct st_context *st)
const GLuint su = fprog->Base.SamplerUnits[unit];
struct gl_texture_object *texObj = st->ctx->Texture.Unit[su]._Current;
struct st_texture_object *stObj = st_texture_object(texObj);
+ struct pipe_texture *pt;
if (texObj) {
GLboolean flush, retval;
@@ -67,16 +68,15 @@ update_textures(struct st_context *st)
* this table before being deleted, otherwise the pointer
* comparison below could fail.
*/
- if (st->state.sampler_texture[unit] != stObj) {
- struct pipe_texture *pt = st_get_stobj_texture(stObj);
- st->state.sampler_texture[unit] = stObj;
+
+ pt = st_get_stobj_texture(stObj);
+
+ if (st->state.sampler_texture[unit] != pt) {
+ st->state.sampler_texture[unit] = pt;
st->pipe->set_sampler_texture(st->pipe, unit, pt);
}
- stObj = st->state.sampler_texture[unit];
-
if (stObj && stObj->dirtyData) {
- struct pipe_texture *pt = st_get_stobj_texture(stObj);
st->pipe->texture_update(st->pipe, pt);
stObj->dirtyData = GL_FALSE;
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 6c0d75cc55..65c9fda9cb 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -727,8 +727,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data);
pipe->bind_fs_state(pipe, ctx->st->state.fs->data);
pipe->bind_vs_state(pipe, ctx->st->state.vs->cso->data);
- pipe->set_sampler_texture(pipe, unit,
- st_get_stobj_texture(ctx->st->state.sampler_texture[unit]));
+ pipe->set_sampler_texture(pipe, unit, ctx->st->state.sampler_texture[unit]);
pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data);
pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
}
@@ -1299,7 +1298,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
psRead,
srcx, srcy, width, height);
}
- else {
+ else if (type == GL_COLOR) {
/* alternate path using get/put_tile() */
GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
@@ -1308,6 +1307,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
free(buf);
}
+ else {
+ /* GL_DEPTH */
+ GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint));
+ pipe_get_tile_z(pipe, psRead, srcx, srcy, width, height, buf);
+ pipe_put_tile_z(pipe, psTex, 0, 0, width, height, buf);
+ free(buf);
+ }
/* draw textured quad */
draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2],
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 5be4769be4..1fbf9721e7 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -86,7 +86,7 @@ struct st_context
struct pipe_clip_state clip;
struct pipe_constant_buffer constants[2];
struct pipe_framebuffer_state framebuffer;
- struct st_texture_object *sampler_texture[PIPE_MAX_SAMPLERS];
+ struct pipe_texture *sampler_texture[PIPE_MAX_SAMPLERS];
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
struct pipe_viewport_state viewport;
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 243dc0b1d0..841d77abbc 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -312,8 +312,7 @@ st_render_mipmap(struct st_context *st,
pipe->bind_vs_state(pipe, st->state.vs->cso->data);
if (st->state.sampler[0])
pipe->bind_sampler_state(pipe, 0, st->state.sampler[0]->data);
- pipe->set_sampler_texture(pipe, 0,
- st_get_stobj_texture(st->state.sampler_texture[0]));
+ pipe->set_sampler_texture(pipe, 0, st->state.sampler_texture[0]);
pipe->set_viewport_state(pipe, &st->state.viewport);
return TRUE;