summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/softpipe
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2007-09-18 13:24:44 -0400
committerZack Rusin <zack@tungstengraphics.com>2007-09-18 13:24:44 -0400
commitccd63b54cfbb6bb241d55f7ac95afcd14819f469 (patch)
tree3ea07838de79877e6d441506cdd6f805fcb9d308 /src/mesa/pipe/softpipe
parent498a1b5dc4ca431bb1de45d04140bfb2ac319ab2 (diff)
Convert shader to an immutable state object.
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c14
-rw-r--r--src/mesa/pipe/softpipe/sp_context.h4
-rwxr-xr-xsrc/mesa/pipe/softpipe/sp_quad_fs.c2
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h14
-rw-r--r--src/mesa/pipe/softpipe/sp_state_derived.c2
-rw-r--r--src/mesa/pipe/softpipe/sp_state_fs.c24
6 files changed, 41 insertions, 19 deletions
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index cf5fc2227e..25cb9d8745 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -251,17 +251,21 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
/* state setters */
softpipe->pipe.create_blend_state = softpipe_create_blend_state;
- softpipe->pipe.bind_blend_state = softpipe_bind_blend_state;
+ softpipe->pipe.bind_blend_state = softpipe_bind_blend_state;
softpipe->pipe.delete_blend_state = softpipe_delete_blend_state;
softpipe->pipe.create_sampler_state = softpipe_create_sampler_state;
- softpipe->pipe.bind_sampler_state = softpipe_bind_sampler_state;
+ softpipe->pipe.bind_sampler_state = softpipe_bind_sampler_state;
softpipe->pipe.delete_sampler_state = softpipe_delete_sampler_state;
softpipe->pipe.create_depth_stencil_state = softpipe_create_depth_stencil_state;
- softpipe->pipe.bind_depth_stencil_state = softpipe_bind_depth_stencil_state;
+ softpipe->pipe.bind_depth_stencil_state = softpipe_bind_depth_stencil_state;
softpipe->pipe.delete_depth_stencil_state = softpipe_delete_depth_stencil_state;
softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state;
- softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state;
+ softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state;
softpipe->pipe.delete_rasterizer_state = softpipe_delete_rasterizer_state;
+ softpipe->pipe.create_shader_state = softpipe_create_shader_state;
+ softpipe->pipe.bind_fs_state = softpipe_bind_fs_state;
+ softpipe->pipe.bind_vs_state = softpipe_bind_vs_state;
+ softpipe->pipe.delete_shader_state = softpipe_delete_shader_state;
softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state;
softpipe->pipe.set_blend_color = softpipe_set_blend_color;
@@ -270,8 +274,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
softpipe->pipe.set_feedback_state = softpipe_set_feedback_state;
softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
- softpipe->pipe.set_fs_state = softpipe_set_fs_state;
- softpipe->pipe.set_vs_state = softpipe_set_vs_state;
softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
softpipe->pipe.set_scissor_state = softpipe_set_scissor_state;
softpipe->pipe.set_texture_state = softpipe_set_texture_state;
diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h
index f1bb3d39a6..5c17c47b12 100644
--- a/src/mesa/pipe/softpipe/sp_context.h
+++ b/src/mesa/pipe/softpipe/sp_context.h
@@ -74,6 +74,8 @@ struct softpipe_context {
const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
const struct pipe_depth_stencil_state *depth_stencil;
const struct pipe_rasterizer_state *rasterizer;
+ const struct pipe_shader_state *fs;
+ const struct pipe_shader_state *vs;
struct pipe_alpha_test_state alpha_test;
struct pipe_blend_color blend_color;
@@ -82,8 +84,6 @@ struct softpipe_context {
struct pipe_constant_buffer constants[2];
struct pipe_feedback_state feedback;
struct pipe_framebuffer_state framebuffer;
- struct pipe_shader_state fs;
- struct pipe_shader_state vs;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS];
diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c
index 46ad08aaa1..25bc170d8c 100755
--- a/src/mesa/pipe/softpipe/sp_quad_fs.c
+++ b/src/mesa/pipe/softpipe/sp_quad_fs.c
@@ -108,7 +108,7 @@ shade_quad(
/* init machine state */
tgsi_exec_machine_init(
&machine,
- softpipe->fs.tokens,
+ softpipe->fs->tokens,
PIPE_MAX_SAMPLERS,
qss->samplers );
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index 62bd26c4df..04cc743bd0 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -88,11 +88,15 @@ void softpipe_set_constant_buffer(struct pipe_context *,
void softpipe_set_feedback_state( struct pipe_context *,
const struct pipe_feedback_state * );
-void softpipe_set_fs_state( struct pipe_context *,
- const struct pipe_shader_state * );
-
-void softpipe_set_vs_state( struct pipe_context *,
- const struct pipe_shader_state * );
+const struct pipe_shader_state *
+softpipe_create_shader_state( struct pipe_context *,
+ const struct pipe_shader_state * );
+void softpipe_bind_fs_state( struct pipe_context *,
+ const struct pipe_shader_state * );
+void softpipe_bind_vs_state( struct pipe_context *,
+ const struct pipe_shader_state * );
+void softpipe_delete_shader_state( struct pipe_context *,
+ const struct pipe_shader_state * );
void softpipe_set_polygon_stipple( struct pipe_context *,
const struct pipe_poly_stipple * );
diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c
index 8c6bacf65c..9611a2ac99 100644
--- a/src/mesa/pipe/softpipe/sp_state_derived.c
+++ b/src/mesa/pipe/softpipe/sp_state_derived.c
@@ -43,7 +43,7 @@
*/
static void calculate_vertex_layout( struct softpipe_context *softpipe )
{
- const uint inputsRead = softpipe->fs.inputs_read;
+ const uint inputsRead = softpipe->fs->inputs_read;
const interp_mode colorInterp
= softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
struct vertex_info *vinfo = &softpipe->vertex_info;
diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c
index 5ab246896b..fbbde2f520 100644
--- a/src/mesa/pipe/softpipe/sp_state_fs.c
+++ b/src/mesa/pipe/softpipe/sp_state_fs.c
@@ -33,23 +33,33 @@
#include "pipe/draw/draw_context.h"
-void softpipe_set_fs_state( struct pipe_context *pipe,
+const struct pipe_shader_state *
+softpipe_create_shader_state( struct pipe_context *pipe,
+ const struct pipe_shader_state *templ )
+{
+ struct pipe_shader_state *shader = malloc(sizeof(struct pipe_shader_state));
+ memcpy(shader, templ, sizeof(struct pipe_shader_state));
+
+ return shader;
+}
+
+void softpipe_bind_fs_state( struct pipe_context *pipe,
const struct pipe_shader_state *fs )
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- memcpy(&softpipe->fs, fs, sizeof(*fs));
+ softpipe->fs = fs;
softpipe->dirty |= SP_NEW_FS;
}
-void softpipe_set_vs_state( struct pipe_context *pipe,
+void softpipe_bind_vs_state( struct pipe_context *pipe,
const struct pipe_shader_state *vs )
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- memcpy(&softpipe->vs, vs, sizeof(*vs));
+ softpipe->vs = vs;
softpipe->dirty |= SP_NEW_VS;
@@ -57,6 +67,12 @@ void softpipe_set_vs_state( struct pipe_context *pipe,
}
+void softpipe_delete_shader_state( struct pipe_context *pipe,
+ const struct pipe_shader_state *shader )
+{
+ free((struct pipe_shader_state*)shader);
+}
+
void softpipe_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
const struct pipe_constant_buffer *buf)