summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/i915simple
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2007-09-18 13:24:44 -0400
committerZack Rusin <[email protected]>2007-09-18 13:24:44 -0400
commitccd63b54cfbb6bb241d55f7ac95afcd14819f469 (patch)
tree3ea07838de79877e6d441506cdd6f805fcb9d308 /src/mesa/pipe/i915simple
parent498a1b5dc4ca431bb1de45d04140bfb2ac319ab2 (diff)
Convert shader to an immutable state object.
Diffstat (limited to 'src/mesa/pipe/i915simple')
-rw-r--r--src/mesa/pipe/i915simple/i915_context.h2
-rw-r--r--src/mesa/pipe/i915simple/i915_fpc.h2
-rw-r--r--src/mesa/pipe/i915simple/i915_fpc_translate.c8
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c27
-rw-r--r--src/mesa/pipe/i915simple/i915_state_derived.c2
5 files changed, 29 insertions, 12 deletions
diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h
index 3fab821fde6..9052c92d72c 100644
--- a/src/mesa/pipe/i915simple/i915_context.h
+++ b/src/mesa/pipe/i915simple/i915_context.h
@@ -127,6 +127,7 @@ struct i915_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;
struct pipe_alpha_test_state alpha_test;
struct pipe_blend_color blend_color;
@@ -134,7 +135,6 @@ struct i915_context
struct pipe_clip_state clip;
struct pipe_constant_buffer constants[PIPE_SHADER_TYPES];
struct pipe_framebuffer_state framebuffer;
- struct pipe_shader_state fs;
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/i915simple/i915_fpc.h b/src/mesa/pipe/i915simple/i915_fpc.h
index 59fcbf40d9f..84e4c5a6f36 100644
--- a/src/mesa/pipe/i915simple/i915_fpc.h
+++ b/src/mesa/pipe/i915simple/i915_fpc.h
@@ -44,7 +44,7 @@
* Program translation state
*/
struct i915_fp_compile {
- struct pipe_shader_state *shader;
+ const struct pipe_shader_state *shader;
struct vertex_info *vertex_info;
diff --git a/src/mesa/pipe/i915simple/i915_fpc_translate.c b/src/mesa/pipe/i915simple/i915_fpc_translate.c
index c2ad80c5d03..32c5600496a 100644
--- a/src/mesa/pipe/i915simple/i915_fpc_translate.c
+++ b/src/mesa/pipe/i915simple/i915_fpc_translate.c
@@ -872,11 +872,11 @@ i915_translate_instructions(struct i915_fp_compile *p,
static struct i915_fp_compile *
i915_init_compile(struct i915_context *i915,
- struct pipe_shader_state *fs)
+ const struct pipe_shader_state *fs)
{
struct i915_fp_compile *p = CALLOC_STRUCT(i915_fp_compile);
- p->shader = &i915->fs;
+ p->shader = i915->fs;
p->vertex_info = &i915->current.vertex_info;
@@ -1032,8 +1032,8 @@ i915_fixup_depth_write(struct i915_fp_compile *p)
void
i915_translate_fragment_program( struct i915_context *i915 )
{
- struct i915_fp_compile *p = i915_init_compile(i915, &i915->fs);
- const struct tgsi_token *tokens = i915->fs.tokens;
+ struct i915_fp_compile *p = i915_init_compile(i915, i915->fs);
+ const struct tgsi_token *tokens = i915->fs->tokens;
i915_find_wpos_space(p);
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index 1dfa10ab28e..fe835643e06 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -161,19 +161,29 @@ static void i915_set_polygon_stipple( struct pipe_context *pipe,
}
+static const struct pipe_shader_state *
+i915_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;
+}
-static void i915_set_fs_state( struct pipe_context *pipe,
+static void i915_bind_fs_state( struct pipe_context *pipe,
const struct pipe_shader_state *fs )
{
struct i915_context *i915 = i915_context(pipe);
- memcpy(&i915->fs, fs, sizeof(*fs));
+ i915->fs = fs;
i915->dirty |= I915_NEW_FS;
}
-static void i915_set_vs_state( struct pipe_context *pipe,
+static void i915_bind_vs_state( struct pipe_context *pipe,
const struct pipe_shader_state *vs )
{
struct i915_context *i915 = i915_context(pipe);
@@ -182,6 +192,11 @@ static void i915_set_vs_state( struct pipe_context *pipe,
draw_set_vertex_shader(i915->draw, vs);
}
+static void i915_delete_shader_state( struct pipe_context *pipe,
+ const struct pipe_shader_state *shader )
+{
+ free((struct pipe_shader_state*)shader);
+}
static void i915_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
@@ -358,6 +373,10 @@ i915_init_state_functions( struct i915_context *i915 )
i915->pipe.create_rasterizer_state = i915_create_rasterizer_state;
i915->pipe.bind_rasterizer_state = i915_bind_rasterizer_state;
i915->pipe.delete_rasterizer_state = i915_delete_rasterizer_state;
+ i915->pipe.create_shader_state = i915_create_shader_state;
+ i915->pipe.bind_fs_state = i915_bind_fs_state;
+ i915->pipe.bind_vs_state = i915_bind_vs_state;
+ i915->pipe.delete_shader_state = i915_delete_shader_state;
i915->pipe.set_alpha_test_state = i915_set_alpha_test_state;
i915->pipe.set_blend_color = i915_set_blend_color;
@@ -365,8 +384,6 @@ i915_init_state_functions( struct i915_context *i915 )
i915->pipe.set_clear_color_state = i915_set_clear_color_state;
i915->pipe.set_constant_buffer = i915_set_constant_buffer;
i915->pipe.set_framebuffer_state = i915_set_framebuffer_state;
- i915->pipe.set_fs_state = i915_set_fs_state;
- i915->pipe.set_vs_state = i915_set_vs_state;
i915->pipe.set_polygon_stipple = i915_set_polygon_stipple;
i915->pipe.set_scissor_state = i915_set_scissor_state;
i915->pipe.set_texture_state = i915_set_texture_state;
diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c
index 504bc10a9e4..8d404c55ab2 100644
--- a/src/mesa/pipe/i915simple/i915_state_derived.c
+++ b/src/mesa/pipe/i915simple/i915_state_derived.c
@@ -42,7 +42,7 @@
*/
static void calculate_vertex_layout( struct i915_context *i915 )
{
- const uint inputsRead = i915->fs.inputs_read;
+ const uint inputsRead = i915->fs->inputs_read;
const interp_mode colorInterp
= i915->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
struct vertex_info *vinfo = &i915->current.vertex_info;