summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_setup.c3
-rw-r--r--src/mesa/pipe/softpipe/sp_quad.h2
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_fs.c56
3 files changed, 48 insertions, 13 deletions
diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c
index 4e66f40e47..c8046befa7 100644
--- a/src/mesa/pipe/softpipe/sp_prim_setup.c
+++ b/src/mesa/pipe/softpipe/sp_prim_setup.c
@@ -1008,8 +1008,11 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
static void setup_begin( struct draw_stage *stage )
{
struct setup_stage *setup = setup_stage(stage);
+ struct softpipe_context *sp = setup->softpipe;
setup->quad.nr_attrs = setup->softpipe->nr_frag_attrs;
+
+ sp->quad.first->begin(sp->quad.first);
}
diff --git a/src/mesa/pipe/softpipe/sp_quad.h b/src/mesa/pipe/softpipe/sp_quad.h
index 72a9981977..cca7dbdcbe 100644
--- a/src/mesa/pipe/softpipe/sp_quad.h
+++ b/src/mesa/pipe/softpipe/sp_quad.h
@@ -41,6 +41,8 @@ struct quad_stage {
struct quad_stage *next;
+ void (*begin)(struct quad_stage *qs);
+
/** the stage action */
void (*run)(struct quad_stage *qs, struct quad_header *quad);
};
diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c
index e55bfd9725..f5240b67f8 100644
--- a/src/mesa/pipe/softpipe/sp_quad_fs.c
+++ b/src/mesa/pipe/softpipe/sp_quad_fs.c
@@ -50,6 +50,23 @@
#define ALIGNED_ATTRIBS 0
#endif
+
+struct quad_shade_stage
+{
+ struct quad_stage stage;
+ struct tgsi_sampler samplers[PIPE_MAX_SAMPLERS];
+};
+
+
+/** cast wrapper */
+static INLINE struct quad_shade_stage *
+quad_shade_stage(struct quad_stage *qs)
+{
+ return (struct quad_shade_stage *) qs;
+}
+
+
+
struct exec_machine {
const struct setup_coefficient *coef; /**< will point to quad->coef */
@@ -136,6 +153,7 @@ static INLINE void pinterp( struct exec_machine *exec,
static void
shade_quad( struct quad_stage *qs, struct quad_header *quad )
{
+ struct quad_shade_stage *qss = quad_shade_stage(qs);
struct softpipe_context *softpipe = qs->softpipe;
struct exec_machine exec;
const GLfloat fx = quad->x0;
@@ -196,7 +214,6 @@ shade_quad( struct quad_stage *qs, struct quad_header *quad )
struct tgsi_exec_machine machine;
struct tgsi_exec_vector outputs[FRAG_ATTRIB_MAX + 1];
struct tgsi_exec_vector *aoutputs;
- struct tgsi_sampler samplers[8];
GLuint i;
#if !ALIGNED_ATTRIBS
@@ -208,18 +225,11 @@ shade_quad( struct quad_stage *qs, struct quad_header *quad )
memset(&machine, 0, sizeof(machine));
#endif
-#if 11 /* temp sampler setup */
- samplers[0].state = &softpipe->sampler[0];
- samplers[0].texture = softpipe->texture[0];
- samplers[0].get_sample = sp_get_sample;
- samplers[0].pipe = &softpipe->pipe;
-#endif
-
/* init machine state */
tgsi_exec_machine_init(
&machine,
softpipe->fs.tokens,
- 8, samplers);
+ PIPE_MAX_SAMPLERS, qss->samplers);
/* Consts does not require 16 byte alignment. */
machine.Consts = softpipe->fs.constants->constant;
@@ -299,13 +309,33 @@ shade_quad( struct quad_stage *qs, struct quad_header *quad )
}
+/**
+ * Per-primitive (or per-begin?) setup
+ */
+static void shade_begin(struct quad_stage *qs)
+{
+ struct quad_shade_stage *qss = quad_shade_stage(qs);
+ struct softpipe_context *softpipe = qs->softpipe;
+ GLuint i;
+ for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
+ qss->samplers[i].state = &softpipe->sampler[i];
+ qss->samplers[i].texture = softpipe->texture[i];
+ qss->samplers[i].get_sample = sp_get_sample;
+ qss->samplers[i].pipe = &softpipe->pipe;
+ }
+
+ if (qs->next->begin)
+ qs->next->begin(qs->next);
+}
+
struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe )
{
- struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
+ struct quad_shade_stage *stage = CALLOC_STRUCT(quad_shade_stage);
- stage->softpipe = softpipe;
- stage->run = shade_quad;
+ stage->stage.softpipe = softpipe;
+ stage->stage.begin = shade_begin;
+ stage->stage.run = shade_quad;
- return stage;
+ return &stage->stage;
}