diff options
author | Zack Rusin <[email protected]> | 2007-09-17 09:47:41 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2007-09-18 06:31:22 -0400 |
commit | f117327a3f246713abfd4dc4320d4a1a7f1b811a (patch) | |
tree | 81c5c58c0ae0685c917996ad04f10003aa95cfa3 /src/mesa/pipe/i915simple | |
parent | e16c045b83f5c5b4f4064df67623bb76b46b6619 (diff) |
Make sampler an immutable state object.
Switch the sample to be an immutable state object.
Diffstat (limited to 'src/mesa/pipe/i915simple')
-rw-r--r-- | src/mesa/pipe/i915simple/i915_context.h | 4 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_state.c | 54 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_state_sampler.c | 2 |
3 files changed, 37 insertions, 23 deletions
diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index 215c5294fa6..51baa281ec5 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -123,7 +123,8 @@ struct i915_context /* The most recent drawing state as set by the driver: */ - const struct pipe_blend_state *blend; + const struct pipe_blend_state *blend; + const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; struct pipe_alpha_test_state alpha_test; struct pipe_blend_color blend_color; @@ -135,7 +136,6 @@ struct i915_context struct pipe_shader_state fs; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_sampler_state sampler[PIPE_MAX_SAMPLERS]; struct pipe_setup_state setup; struct pipe_stencil_state stencil; struct pipe_mipmap_tree *texture[PIPE_MAX_SAMPLERS]; diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c index 478988fd4a9..10060b45a4f 100644 --- a/src/mesa/pipe/i915simple/i915_state.c +++ b/src/mesa/pipe/i915simple/i915_state.c @@ -42,8 +42,6 @@ static const struct pipe_blend_state * i915_create_blend_state(struct pipe_context *pipe, const struct pipe_blend_state *blend) { - /*struct i915_context *i915 = i915_context(pipe);*/ - struct pipe_blend_state *new_blend = malloc(sizeof(struct pipe_blend_state)); memcpy(new_blend, blend, sizeof(struct pipe_blend_state)); @@ -62,10 +60,9 @@ static void i915_bind_blend_state( struct pipe_context *pipe, static void i915_delete_blend_state( struct pipe_context *pipe, - const struct pipe_blend_state *blend ) + const struct pipe_blend_state *blend ) { - /*struct i915_context *i915 = i915_context(pipe);*/ - free(blend); + free((void*)blend); } static void i915_set_blend_color( struct pipe_context *pipe, @@ -78,6 +75,34 @@ static void i915_set_blend_color( struct pipe_context *pipe, i915->dirty |= I915_NEW_BLEND; } +static const struct pipe_sampler_state * +i915_create_sampler_state(struct pipe_context *pipe, + const struct pipe_sampler_state *sampler) +{ + struct pipe_sampler_state *new_sampler = malloc(sizeof(struct pipe_sampler_state)); + memcpy(new_sampler, sampler, sizeof(struct pipe_sampler_state)); + + return new_sampler; +} + +static void i915_bind_sampler_state(struct pipe_context *pipe, + unsigned unit, + const struct pipe_sampler_state *sampler) +{ + struct i915_context *i915 = i915_context(pipe); + + assert(unit < PIPE_MAX_SAMPLERS); + i915->sampler[unit] = sampler; + + i915->dirty |= I915_NEW_SAMPLER; +} + +static void i915_delete_sampler_state(struct pipe_context *pipe, + const struct pipe_sampler_state *sampler) +{ + free((struct pipe_sampler_state*)sampler); +} + /** XXX move someday? Or consolidate all these simple state setters * into one file. @@ -189,19 +214,6 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, } -static void i915_set_sampler_state(struct pipe_context *pipe, - unsigned unit, - const struct pipe_sampler_state *sampler) -{ - struct i915_context *i915 = i915_context(pipe); - - assert(unit < PIPE_MAX_SAMPLERS); - i915->sampler[unit] = *sampler; - - i915->dirty |= I915_NEW_SAMPLER; -} - - static void i915_set_texture_state(struct pipe_context *pipe, unsigned unit, struct pipe_mipmap_tree *texture) @@ -293,7 +305,6 @@ static void i915_set_vertex_buffer( struct pipe_context *pipe, /* pass-through to draw module */ draw_set_vertex_buffer(i915->draw, index, buffer); } - static void i915_set_vertex_element( struct pipe_context *pipe, unsigned index, @@ -313,6 +324,10 @@ i915_init_state_functions( struct i915_context *i915 ) i915->pipe.bind_blend_state = i915_bind_blend_state; i915->pipe.delete_blend_state = i915_delete_blend_state; + i915->pipe.create_sampler_state = i915_create_sampler_state; + i915->pipe.bind_sampler_state = i915_bind_sampler_state; + i915->pipe.delete_sampler_state = i915_delete_sampler_state; + i915->pipe.set_alpha_test_state = i915_set_alpha_test_state; i915->pipe.set_blend_color = i915_set_blend_color; i915->pipe.set_clip_state = i915_set_clip_state; @@ -323,7 +338,6 @@ i915_init_state_functions( struct i915_context *i915 ) 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_sampler_state = i915_set_sampler_state; i915->pipe.set_scissor_state = i915_set_scissor_state; i915->pipe.set_setup_state = i915_set_setup_state; i915->pipe.set_stencil_state = i915_set_stencil_state; diff --git a/src/mesa/pipe/i915simple/i915_state_sampler.c b/src/mesa/pipe/i915simple/i915_state_sampler.c index 7a595d10229..419a156136c 100644 --- a/src/mesa/pipe/i915simple/i915_state_sampler.c +++ b/src/mesa/pipe/i915simple/i915_state_sampler.c @@ -269,7 +269,7 @@ void i915_update_samplers( struct i915_context *i915 ) if (i915->texture[unit]) { update_sampler( i915, unit, - i915->sampler + unit, /* sampler state */ + i915->sampler[unit], /* sampler state */ i915->texture[unit], /* mipmap tree */ i915->current.sampler[unit] /* the result */ ); |