summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/softpipe
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2007-09-14 04:08:58 -0400
committerZack Rusin <zack@tungstengraphics.com>2007-09-18 06:31:22 -0400
commit9780327c5d95586a88fce94d7b47342355ead118 (patch)
tree9007ea135504d8fd90b49a391a43fa579b9374b5 /src/mesa/pipe/softpipe
parentffacb1c12a77d71613e8171e31ffc348959881e4 (diff)
First stab at immutable state objects (create/bind/delete)
We want our state objects to be immutable, handled via the create/bind/delete calls instead of struct propagation. Only implementing the blend state to see how it would look like and work.
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c5
-rw-r--r--src/mesa/pipe/softpipe/sp_context.h3
-rw-r--r--src/mesa/pipe/softpipe/sp_quad.c4
-rwxr-xr-xsrc/mesa/pipe/softpipe/sp_quad_blend.c12
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_colormask.c8
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h10
-rw-r--r--src/mesa/pipe/softpipe/sp_state_blend.c19
7 files changed, 42 insertions, 19 deletions
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 92357808e2..b9c7013e9e 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -250,9 +250,12 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->pipe.max_texture_size = softpipe_max_texture_size;
/* state setters */
+ softpipe->pipe.create_blend_state = softpipe_create_blend_state;
+ softpipe->pipe.bind_blend_state = softpipe_bind_blend_state;
+ softpipe->pipe.delete_blend_state = softpipe_delete_blend_state;
+
softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state;
softpipe->pipe.set_blend_color = softpipe_set_blend_color;
- softpipe->pipe.set_blend_state = softpipe_set_blend_state;
softpipe->pipe.set_clip_state = softpipe_set_clip_state;
softpipe->pipe.set_clear_color_state = softpipe_set_clear_color_state;
softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h
index 13d1143c89..7fecf2974a 100644
--- a/src/mesa/pipe/softpipe/sp_context.h
+++ b/src/mesa/pipe/softpipe/sp_context.h
@@ -71,8 +71,9 @@ struct softpipe_context {
/* The most recent drawing state as set by the driver:
*/
+ const struct pipe_blend_state *blend;
+
struct pipe_alpha_test_state alpha_test;
- struct pipe_blend_state blend;
struct pipe_blend_color blend_color;
struct pipe_clear_color_state clear_color;
struct pipe_clip_state clip;
diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c
index 0f0736479f..2fcbea1f22 100644
--- a/src/mesa/pipe/softpipe/sp_quad.c
+++ b/src/mesa/pipe/softpipe/sp_quad.c
@@ -11,12 +11,12 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
sp->quad.first = sp->quad.output;
- if (sp->blend.colormask != 0xf) {
+ if (sp->blend->colormask != 0xf) {
sp->quad.colormask->next = sp->quad.first;
sp->quad.first = sp->quad.colormask;
}
- if (sp->blend.blend_enable) {
+ if (sp->blend->blend_enable) {
sp->quad.blend->next = sp->quad.first;
sp->quad.first = sp->quad.blend;
}
diff --git a/src/mesa/pipe/softpipe/sp_quad_blend.c b/src/mesa/pipe/softpipe/sp_quad_blend.c
index e5335f3b19..6c7135e53c 100755
--- a/src/mesa/pipe/softpipe/sp_quad_blend.c
+++ b/src/mesa/pipe/softpipe/sp_quad_blend.c
@@ -111,7 +111,7 @@ blend_quad(struct quad_stage *qs, struct quad_header *quad)
/*
* Compute src/first term RGB
*/
- switch (softpipe->blend.rgb_src_factor) {
+ switch (softpipe->blend->rgb_src_factor) {
case PIPE_BLENDFACTOR_ONE:
VEC4_COPY(source[0], quad->outputs.color[0]); /* R */
VEC4_COPY(source[1], quad->outputs.color[1]); /* G */
@@ -253,7 +253,7 @@ blend_quad(struct quad_stage *qs, struct quad_header *quad)
/*
* Compute src/first term A
*/
- switch (softpipe->blend.alpha_src_factor) {
+ switch (softpipe->blend->alpha_src_factor) {
case PIPE_BLENDFACTOR_ONE:
VEC4_COPY(source[3], quad->outputs.color[3]); /* A */
break;
@@ -275,7 +275,7 @@ blend_quad(struct quad_stage *qs, struct quad_header *quad)
/*
* Compute dest/second term RGB
*/
- switch (softpipe->blend.rgb_dst_factor) {
+ switch (softpipe->blend->rgb_dst_factor) {
case PIPE_BLENDFACTOR_ONE:
/* dest = dest * 1 NO-OP, leave dest as-is */
break;
@@ -301,7 +301,7 @@ blend_quad(struct quad_stage *qs, struct quad_header *quad)
/*
* Compute dest/second term A
*/
- switch (softpipe->blend.alpha_dst_factor) {
+ switch (softpipe->blend->alpha_dst_factor) {
case PIPE_BLENDFACTOR_ONE:
/* dest = dest * 1 NO-OP, leave dest as-is */
break;
@@ -323,7 +323,7 @@ blend_quad(struct quad_stage *qs, struct quad_header *quad)
/*
* Combine RGB terms
*/
- switch (softpipe->blend.rgb_func) {
+ switch (softpipe->blend->rgb_func) {
case PIPE_BLEND_ADD:
VEC4_ADD(quad->outputs.color[0], source[0], dest[0]); /* R */
VEC4_ADD(quad->outputs.color[1], source[1], dest[1]); /* G */
@@ -356,7 +356,7 @@ blend_quad(struct quad_stage *qs, struct quad_header *quad)
/*
* Combine A terms
*/
- switch (softpipe->blend.alpha_func) {
+ switch (softpipe->blend->alpha_func) {
case PIPE_BLEND_ADD:
VEC4_ADD(quad->outputs.color[3], source[3], dest[3]); /* A */
break;
diff --git a/src/mesa/pipe/softpipe/sp_quad_colormask.c b/src/mesa/pipe/softpipe/sp_quad_colormask.c
index 7bb65bf8c8..c3e110532a 100644
--- a/src/mesa/pipe/softpipe/sp_quad_colormask.c
+++ b/src/mesa/pipe/softpipe/sp_quad_colormask.c
@@ -49,19 +49,19 @@ colormask_quad(struct quad_stage *qs, struct quad_header *quad)
sps->read_quad_f_swz(sps, quad->x0, quad->y0, dest);
/* R */
- if (!(softpipe->blend.colormask & PIPE_MASK_R))
+ if (!(softpipe->blend->colormask & PIPE_MASK_R))
COPY_4V(quad->outputs.color[0], dest[0]);
/* G */
- if (!(softpipe->blend.colormask & PIPE_MASK_G))
+ if (!(softpipe->blend->colormask & PIPE_MASK_G))
COPY_4V(quad->outputs.color[1], dest[1]);
/* B */
- if (!(softpipe->blend.colormask & PIPE_MASK_B))
+ if (!(softpipe->blend->colormask & PIPE_MASK_B))
COPY_4V(quad->outputs.color[2], dest[2]);
/* A */
- if (!(softpipe->blend.colormask & PIPE_MASK_A))
+ if (!(softpipe->blend->colormask & PIPE_MASK_A))
COPY_4V(quad->outputs.color[3], dest[3]);
/* pass quad to next stage */
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index f40ebe3e2b..e2b1a2a164 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -33,6 +33,13 @@
#include "pipe/p_state.h"
+const struct pipe_blend_state *
+softpipe_create_blend_state(struct pipe_context *,
+ const struct pipe_blend_state *);
+void softpipe_bind_blend_state(struct pipe_context *,
+ const struct pipe_blend_state *);
+void softpipe_delete_blend_state(struct pipe_context *,
+ const struct pipe_blend_state *);
void softpipe_set_framebuffer_state( struct pipe_context *,
const struct pipe_framebuffer_state * );
@@ -40,9 +47,6 @@ void softpipe_set_framebuffer_state( struct pipe_context *,
void softpipe_set_alpha_test_state( struct pipe_context *,
const struct pipe_alpha_test_state * );
-void softpipe_set_blend_state( struct pipe_context *,
- const struct pipe_blend_state * );
-
void softpipe_set_blend_color( struct pipe_context *pipe,
const struct pipe_blend_color *blend_color );
diff --git a/src/mesa/pipe/softpipe/sp_state_blend.c b/src/mesa/pipe/softpipe/sp_state_blend.c
index b2e85d86cc..57f2df7923 100644
--- a/src/mesa/pipe/softpipe/sp_state_blend.c
+++ b/src/mesa/pipe/softpipe/sp_state_blend.c
@@ -30,17 +30,32 @@
#include "sp_context.h"
#include "sp_state.h"
+const struct pipe_blend_state *
+softpipe_create_blend_state(struct pipe_context *pipe,
+ const struct pipe_blend_state *blend)
+{
+ struct pipe_blend_state *new_blend = malloc(sizeof(struct pipe_blend_state));
+ memcpy(new_blend, blend, sizeof(struct pipe_blend_state));
+
+ return new_blend;
+}
-void softpipe_set_blend_state( struct pipe_context *pipe,
+void softpipe_bind_blend_state( struct pipe_context *pipe,
const struct pipe_blend_state *blend )
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- softpipe->blend = *blend;
+ softpipe->blend = blend;
softpipe->dirty |= SP_NEW_BLEND;
}
+void softpipe_delete_blend_state(struct pipe_context *pipe,
+ const struct pipe_blend_state *blend )
+{
+ free(blend);
+}
+
void softpipe_set_blend_color( struct pipe_context *pipe,
const struct pipe_blend_color *blend_color )