summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-05-18 16:17:50 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-05-18 16:17:50 -0600
commit54fbd8bbd4e5a484d59907bae852908e3a8b8f3c (patch)
tree2e45fac3c2505fe1131ed38e45110e1319f49806 /src/gallium/drivers
parentb4219e35e2de783ca03e53c311a8a56f8b633aa1 (diff)
parenta0bfeb0c3ca58a1f4d978f2aaa343ed4009de079 (diff)
Merge branch 'gallium-0.1' into gallium-tex-surfaces
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_shader.c84
-rw-r--r--src/gallium/drivers/i915simple/i915_state.c5
-rw-r--r--src/gallium/drivers/i965simple/brw_state.c19
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_exec.c5
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_fs.c15
-rw-r--r--src/gallium/drivers/softpipe/sp_setup.c81
-rw-r--r--src/gallium/drivers/softpipe/sp_state.h7
-rw-r--r--src/gallium/drivers/softpipe/sp_state_fs.c5
8 files changed, 117 insertions, 104 deletions
diff --git a/src/gallium/drivers/cell/ppu/cell_state_shader.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c
index fb2e940348..c3a3fbd066 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_shader.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c
@@ -30,33 +30,50 @@
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "draw/draw_context.h"
-#if 0
-#include "pipe/p_shader_tokens.h"
-#include "gallivm/gallivm.h"
-#include "tgsi/util/tgsi_dump.h"
-#include "tgsi/exec/tgsi_sse2.h"
-#endif
+#include "tgsi/util/tgsi_parse.h"
#include "cell_context.h"
#include "cell_state.h"
+
+/** cast wrapper */
+static INLINE struct cell_fragment_shader_state *
+cell_fragment_shader_state(void *shader)
+{
+ return (struct pipe_shader_state *) shader;
+}
+
+
+/** cast wrapper */
+static INLINE struct cell_vertex_shader_state *
+cell_vertex_shader_state(void *shader)
+{
+ return (struct pipe_shader_state *) shader;
+}
+
+
+
static void *
cell_create_fs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
{
/*struct cell_context *cell = cell_context(pipe);*/
- struct cell_fragment_shader_state *state;
+ struct cell_fragment_shader_state *cfs;
- state = CALLOC_STRUCT(cell_fragment_shader_state);
- if (!state)
+ cfs = CALLOC_STRUCT(cell_fragment_shader_state);
+ if (!cfs)
return NULL;
- state->shader = *templ;
+ cfs->shader.tokens = tgsi_dup_tokens(templ->tokens);
+ if (!cfs->shader.tokens) {
+ FREE(cfs);
+ return NULL;
+ }
- tgsi_scan_shader(templ->tokens, &state->info);
+ tgsi_scan_shader(templ->tokens, &cfs->info);
- return state;
+ return cfs;
}
@@ -65,7 +82,7 @@ cell_bind_fs_state(struct pipe_context *pipe, void *fs)
{
struct cell_context *cell = cell_context(pipe);
- cell->fs = (struct cell_fragment_shader_state *) fs;
+ cell->fs = cell_fragment_shader_state(fs);
cell->dirty |= CELL_NEW_FS;
}
@@ -74,10 +91,10 @@ cell_bind_fs_state(struct pipe_context *pipe, void *fs)
static void
cell_delete_fs_state(struct pipe_context *pipe, void *fs)
{
- struct cell_fragment_shader_state *state =
- (struct cell_fragment_shader_state *) fs;
+ struct cell_fragment_shader_state *cfs = cell_fragment_shader_state(fs);
- FREE( state );
+ FREE((void *) cfs->shader.tokens);
+ FREE(cfs);
}
@@ -86,22 +103,28 @@ cell_create_vs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
{
struct cell_context *cell = cell_context(pipe);
- struct cell_vertex_shader_state *state;
+ struct cell_vertex_shader_state *cvs;
- state = CALLOC_STRUCT(cell_vertex_shader_state);
- if (!state)
+ cvs = CALLOC_STRUCT(cell_vertex_shader_state);
+ if (!cvs)
return NULL;
- state->shader = *templ;
- tgsi_scan_shader(templ->tokens, &state->info);
+ cvs->shader.tokens = tgsi_dup_tokens(templ->tokens);
+ if (!cvs->shader.tokens) {
+ FREE(cvs);
+ return NULL;
+ }
- state->draw_data = draw_create_vertex_shader(cell->draw, &state->shader);
- if (state->draw_data == NULL) {
- FREE( state );
+ tgsi_scan_shader(templ->tokens, &cvs->info);
+
+ cvs->draw_data = draw_create_vertex_shader(cell->draw, &cvs->shader);
+ if (cvs->draw_data == NULL) {
+ FREE( (void *) cvs->shader.tokens );
+ FREE( cvs );
return NULL;
}
- return state;
+ return cvs;
}
@@ -110,7 +133,7 @@ cell_bind_vs_state(struct pipe_context *pipe, void *vs)
{
struct cell_context *cell = cell_context(pipe);
- cell->vs = (const struct cell_vertex_shader_state *) vs;
+ cell->vs = cell_vertex_shader_state(vs);
draw_bind_vertex_shader(cell->draw,
(cell->vs ? cell->vs->draw_data : NULL));
@@ -123,12 +146,11 @@ static void
cell_delete_vs_state(struct pipe_context *pipe, void *vs)
{
struct cell_context *cell = cell_context(pipe);
+ struct cell_vertex_shader_state *cvs = cell_vertex_shader_state(vs);
- struct cell_vertex_shader_state *state =
- (struct cell_vertex_shader_state *) vs;
-
- draw_delete_vertex_shader(cell->draw, state->draw_data);
- FREE( state );
+ draw_delete_vertex_shader(cell->draw, cvs->draw_data);
+ FREE( (void *) cvs->shader.tokens );
+ FREE( cvs );
}
diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c
index 3d94b52366..4adeb37e86 100644
--- a/src/gallium/drivers/i915simple/i915_state.c
+++ b/src/gallium/drivers/i915simple/i915_state.c
@@ -33,6 +33,7 @@
#include "pipe/p_winsys.h"
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "tgsi/util/tgsi_parse.h"
#include "i915_context.h"
#include "i915_reg.h"
@@ -436,7 +437,7 @@ i915_create_fs_state(struct pipe_context *pipe,
if (!ifs)
return NULL;
- ifs->state = *templ;
+ ifs->state.tokens = tgsi_dup_tokens(templ->tokens);
tgsi_scan_shader(templ->tokens, &ifs->info);
@@ -465,6 +466,8 @@ void i915_delete_fs_state(struct pipe_context *pipe, void *shader)
FREE(ifs->program);
ifs->program_len = 0;
+ FREE(ifs->state.tokens);
+
FREE(ifs);
}
diff --git a/src/gallium/drivers/i965simple/brw_state.c b/src/gallium/drivers/i965simple/brw_state.c
index 376f1487b2..ac243b7e4f 100644
--- a/src/gallium/drivers/i965simple/brw_state.c
+++ b/src/gallium/drivers/i965simple/brw_state.c
@@ -35,6 +35,7 @@
#include "pipe/p_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/util/tgsi_dump.h"
+#include "tgsi/util/tgsi_parse.h"
#include "brw_context.h"
#include "brw_defines.h"
@@ -182,9 +183,7 @@ static void * brw_create_fs_state(struct pipe_context *pipe,
{
struct brw_fragment_program *brw_fp = CALLOC_STRUCT(brw_fragment_program);
- /* XXX: Do I have to duplicate the tokens as well??
- */
- brw_fp->program = *shader;
+ brw_fp->program.tokens = tgsi_dup_tokens(shader->tokens);
brw_fp->id = brw_context(pipe)->program_id++;
tgsi_scan_shader(shader->tokens, &brw_fp->info);
@@ -210,7 +209,10 @@ static void brw_bind_fs_state(struct pipe_context *pipe, void *shader)
static void brw_delete_fs_state(struct pipe_context *pipe, void *shader)
{
- FREE(shader);
+ struct brw_fragment_program *brw_fp = (struct brw_fragment_program *) shader;
+
+ FREE((void *) brw_fp->program.tokens);
+ FREE(brw_fp);
}
@@ -223,9 +225,7 @@ static void *brw_create_vs_state(struct pipe_context *pipe,
{
struct brw_vertex_program *brw_vp = CALLOC_STRUCT(brw_vertex_program);
- /* XXX: Do I have to duplicate the tokens as well??
- */
- brw_vp->program = *shader;
+ brw_vp->program.tokens = tgsi_dup_tokens(shader->tokens);
brw_vp->id = brw_context(pipe)->program_id++;
tgsi_scan_shader(shader->tokens, &brw_vp->info);
@@ -251,7 +251,10 @@ static void brw_bind_vs_state(struct pipe_context *pipe, void *vs)
static void brw_delete_vs_state(struct pipe_context *pipe, void *shader)
{
- FREE(shader);
+ struct brw_vertex_program *brw_vp = (struct brw_vertex_program *) shader;
+
+ FREE((void *) brw_vp->program.tokens);
+ FREE(brw_vp);
}
diff --git a/src/gallium/drivers/softpipe/sp_fs_exec.c b/src/gallium/drivers/softpipe/sp_fs_exec.c
index d5bd7a702f..0b199a2193 100644
--- a/src/gallium/drivers/softpipe/sp_fs_exec.c
+++ b/src/gallium/drivers/softpipe/sp_fs_exec.c
@@ -37,6 +37,7 @@
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "tgsi/exec/tgsi_exec.h"
+#include "tgsi/util/tgsi_parse.h"
struct sp_exec_fragment_shader {
struct sp_fragment_shader base;
@@ -116,6 +117,7 @@ exec_run( const struct sp_fragment_shader *base,
static void
exec_delete( struct sp_fragment_shader *base )
{
+ FREE((void *) base->shader.tokens);
FREE(base);
}
@@ -137,7 +139,8 @@ softpipe_create_fs_exec(struct softpipe_context *softpipe,
if (!shader)
return NULL;
- shader->base.shader = *templ;
+ /* we need to keep a local copy of the tokens */
+ shader->base.shader.tokens = tgsi_dup_tokens(templ->tokens);
shader->base.prepare = exec_prepare;
shader->base.run = exec_run;
shader->base.delete = exec_delete;
diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c
index 625d0f9b48..8c88c192f8 100644
--- a/src/gallium/drivers/softpipe/sp_quad_fs.c
+++ b/src/gallium/drivers/softpipe/sp_quad_fs.c
@@ -53,7 +53,6 @@ struct quad_shade_stage
struct tgsi_sampler samplers[PIPE_MAX_SAMPLERS];
struct tgsi_exec_machine machine;
struct tgsi_exec_vector *inputs, *outputs;
- int colorOutSlot, depthOutSlot;
};
@@ -156,20 +155,6 @@ static void shade_begin(struct quad_stage *qs)
qss->samplers[i].texture = softpipe->texture[i];
}
- /* find output slots for depth, color */
- qss->colorOutSlot = -1;
- qss->depthOutSlot = -1;
- for (i = 0; i < qss->stage.softpipe->fs->info.num_outputs; i++) {
- switch (qss->stage.softpipe->fs->info.output_semantic_name[i]) {
- case TGSI_SEMANTIC_POSITION:
- qss->depthOutSlot = i;
- break;
- case TGSI_SEMANTIC_COLOR:
- qss->colorOutSlot = i;
- break;
- }
- }
-
softpipe->fs->prepare( softpipe->fs,
&qss->machine,
qss->samplers );
diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c
index 5370d85275..543d86a5cb 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -209,77 +209,76 @@ static INLINE int block( int x )
/**
- * Compute mask which indicates which pixels in the 2x2 quad are actually inside
- * the triangle's bounds.
- *
- * this is pretty nasty... may need to rework flush_spans again to
- * fix it, if possible.
- */
-static unsigned calculate_mask( struct setup_context *setup, int x )
-{
- unsigned mask = 0x0;
-
- if (x >= setup->span.left[0] && x < setup->span.right[0])
- mask |= MASK_TOP_LEFT;
-
- if (x >= setup->span.left[1] && x < setup->span.right[1])
- mask |= MASK_BOTTOM_LEFT;
-
- if (x+1 >= setup->span.left[0] && x+1 < setup->span.right[0])
- mask |= MASK_TOP_RIGHT;
-
- if (x+1 >= setup->span.left[1] && x+1 < setup->span.right[1])
- mask |= MASK_BOTTOM_RIGHT;
-
- return mask;
-}
-
-
-/**
* Render a horizontal span of quads
*/
static void flush_spans( struct setup_context *setup )
{
+ const int xleft0 = setup->span.left[0];
+ const int xleft1 = setup->span.left[1];
+ const int xright0 = setup->span.right[0];
+ const int xright1 = setup->span.right[1];
int minleft, maxright;
int x;
switch (setup->span.y_flags) {
case 0x3:
/* both odd and even lines written (both quad rows) */
- minleft = MIN2(setup->span.left[0], setup->span.left[1]);
- maxright = MAX2(setup->span.right[0], setup->span.right[1]);
+ minleft = block(MIN2(xleft0, xleft1));
+ maxright = block(MAX2(xright0, xright1));
+ for (x = minleft; x <= maxright; x += 2) {
+ /* determine which of the four pixels is inside the span bounds */
+ uint mask = 0x0;
+ if (x >= xleft0 && x < xright0)
+ mask |= MASK_TOP_LEFT;
+ if (x >= xleft1 && x < xright1)
+ mask |= MASK_BOTTOM_LEFT;
+ if (x+1 >= xleft0 && x+1 < xright0)
+ mask |= MASK_TOP_RIGHT;
+ if (x+1 >= xleft1 && x+1 < xright1)
+ mask |= MASK_BOTTOM_RIGHT;
+ emit_quad( setup, x, setup->span.y, mask );
+ }
break;
case 0x1:
/* only even line written (quad top row) */
- minleft = setup->span.left[0];
- maxright = setup->span.right[0];
+ minleft = block(xleft0);
+ maxright = block(xright0);
+ for (x = minleft; x <= maxright; x += 2) {
+ uint mask = 0x0;
+ if (x >= xleft0 && x < xright0)
+ mask |= MASK_TOP_LEFT;
+ if (x+1 >= xleft0 && x+1 < xright0)
+ mask |= MASK_TOP_RIGHT;
+ emit_quad( setup, x, setup->span.y, mask );
+ }
break;
case 0x2:
/* only odd line written (quad bottom row) */
- minleft = setup->span.left[1];
- maxright = setup->span.right[1];
+ minleft = block(xleft1);
+ maxright = block(xright1);
+ for (x = minleft; x <= maxright; x += 2) {
+ uint mask = 0x0;
+ if (x >= xleft1 && x < xright1)
+ mask |= MASK_BOTTOM_LEFT;
+ if (x+1 >= xleft1 && x+1 < xright1)
+ mask |= MASK_BOTTOM_RIGHT;
+ emit_quad( setup, x, setup->span.y, mask );
+ }
break;
default:
return;
}
- /* XXX this loop could be moved into the above switch cases and
- * calculate_mask() could be simplified a bit...
- */
- for (x = block(minleft); x <= block(maxright); x += 2) {
- emit_quad( setup, x, setup->span.y,
- calculate_mask( setup, x ) );
- }
-
setup->span.y = 0;
setup->span.y_flags = 0;
setup->span.right[0] = 0;
setup->span.right[1] = 0;
}
+
#if DEBUG_VERTS
static void print_vertex(const struct setup_context *setup,
const float (*v)[4])
diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h
index 45056502b8..452e51fa79 100644
--- a/src/gallium/drivers/softpipe/sp_state.h
+++ b/src/gallium/drivers/softpipe/sp_state.h
@@ -54,9 +54,11 @@
struct tgsi_sampler;
struct tgsi_exec_machine;
+struct vertex_info;
-/** Subclass of pipe_shader_state (though it doesn't really need to be).
+/**
+ * Subclass of pipe_shader_state (though it doesn't really need to be).
*
* This is starting to look an awful lot like a quad pipeline stage...
*/
@@ -80,11 +82,10 @@ struct sp_fragment_shader {
void (*delete)( struct sp_fragment_shader * );
};
-struct vertex_info;
/** Subclass of pipe_shader_state */
struct sp_vertex_shader {
- struct pipe_shader_state shader;
+ struct pipe_shader_state shader; /* Note: this field not actually used */
struct draw_vertex_shader *draw_data;
};
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index 9e77b7e91b..24b91fbc79 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -102,10 +102,7 @@ softpipe_create_vs_state(struct pipe_context *pipe,
return NULL;
}
- state->shader = *templ;
-
- state->draw_data = draw_create_vertex_shader(softpipe->draw,
- &state->shader);
+ state->draw_data = draw_create_vertex_shader(softpipe->draw, templ);
if (state->draw_data == NULL) {
FREE( state );
return NULL;