summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-08-09 20:59:44 -0600
committerBrian Paul <[email protected]>2012-08-16 09:01:31 -0600
commit6c8a13215813841703e7c2efa233e8d4cf517dfd (patch)
treef4dfc28372595c1fbb7f5680effb523bf59e3834
parentcab2fed135bc1edf7b65ddca3236020638427061 (diff)
st/mesa: combine vertex/fragment sampler state in arrays
As with other recent changes, put the vertex and fragment sampler state into arrays indexed by the shader type. This will let us easily add support for other types of shaders in the future.
-rw-r--r--src/mesa/state_tracker/st_atom_sampler.c12
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c8
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c11
-rw-r--r--src/mesa/state_tracker/st_context.c15
-rw-r--r--src/mesa/state_tracker/st_context.h13
5 files changed, 26 insertions, 33 deletions
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index f39fd7551c2..70ae55fd2eb 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -253,23 +253,23 @@ update_samplers(struct st_context *st)
PIPE_SHADER_FRAGMENT,
&ctx->FragmentProgram._Current->Base,
ctx->Const.MaxTextureImageUnits,
- st->state.fragment_samplers,
- &st->state.num_fragment_samplers);
+ st->state.samplers[PIPE_SHADER_FRAGMENT],
+ &st->state.num_samplers[PIPE_SHADER_FRAGMENT]);
update_shader_samplers(st,
PIPE_SHADER_VERTEX,
&ctx->VertexProgram._Current->Base,
ctx->Const.MaxVertexTextureImageUnits,
- st->state.vertex_samplers,
- &st->state.num_vertex_samplers);
+ st->state.samplers[PIPE_SHADER_VERTEX],
+ &st->state.num_samplers[PIPE_SHADER_VERTEX]);
/*
update_shader_samplers(st,
PIPE_SHADER_GEOMETRY,
&ctx->GeometryProgram._Current->Base,
ctx->Const.MaxGeometryTextureImageUnits,
- st->state.geometry_samplers,
- &st->state.num_geometry_samplers);
+ st->state.samplers[PIPE_SHADER_GEOMETRY],
+ &st->state.num_samplers[PIPE_SHADER_GEOMETRY]);
*/
}
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index e88675d4e6b..5604b8762b2 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -312,8 +312,8 @@ update_vertex_textures(struct st_context *st)
PIPE_SHADER_VERTEX,
&ctx->VertexProgram._Current->Base,
ctx->Const.MaxVertexTextureImageUnits,
- st->state.vertex_sampler_views,
- &st->state.num_vertex_textures);
+ st->state.sampler_views[PIPE_SHADER_VERTEX],
+ &st->state.num_sampler_views[PIPE_SHADER_VERTEX]);
}
}
@@ -327,8 +327,8 @@ update_fragment_textures(struct st_context *st)
PIPE_SHADER_FRAGMENT,
&ctx->FragmentProgram._Current->Base,
ctx->Const.MaxTextureImageUnits,
- st->state.fragment_sampler_views,
- &st->state.num_fragment_textures);
+ st->state.sampler_views[PIPE_SHADER_FRAGMENT],
+ &st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
}
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 7d9ccc1e5a0..dbd778b4fc7 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -481,10 +481,11 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
/* user samplers, plus our bitmap sampler */
{
struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
- uint num = MAX2(fpv->bitmap_sampler + 1, st->state.num_fragment_samplers);
+ uint num = MAX2(fpv->bitmap_sampler + 1,
+ st->state.num_samplers[PIPE_SHADER_FRAGMENT]);
uint i;
- for (i = 0; i < st->state.num_fragment_samplers; i++) {
- samplers[i] = &st->state.fragment_samplers[i];
+ for (i = 0; i < st->state.num_samplers[PIPE_SHADER_FRAGMENT]; i++) {
+ samplers[i] = &st->state.samplers[PIPE_SHADER_FRAGMENT][i];
}
samplers[fpv->bitmap_sampler] =
&st->bitmap.samplers[sv->texture->target != PIPE_TEXTURE_RECT];
@@ -496,8 +497,8 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
{
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
uint num = MAX2(fpv->bitmap_sampler + 1,
- st->state.num_fragment_textures);
- memcpy(sampler_views, st->state.fragment_sampler_views,
+ st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
+ memcpy(sampler_views, st->state.sampler_views[PIPE_SHADER_FRAGMENT],
sizeof(sampler_views));
sampler_views[fpv->bitmap_sampler] = sv;
cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num, sampler_views);
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 2f951617829..7735eee4f3d 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -237,7 +237,7 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
static void st_destroy_context_priv( struct st_context *st )
{
- uint i;
+ uint shader, i;
st_destroy_atoms( st );
st_destroy_draw( st );
@@ -248,14 +248,11 @@ static void st_destroy_context_priv( struct st_context *st )
st_destroy_drawpix(st);
st_destroy_drawtex(st);
- for (i = 0; i < Elements(st->state.fragment_sampler_views); i++) {
- pipe_sampler_view_release(st->pipe,
- &st->state.fragment_sampler_views[i]);
- }
-
- for (i = 0; i < Elements(st->state.vertex_sampler_views); i++) {
- pipe_sampler_view_release(st->pipe,
- &st->state.vertex_sampler_views[i]);
+ for (shader = 0; shader < Elements(st->state.sampler_views); shader++) {
+ for (i = 0; i < Elements(st->state.sampler_views[0]); i++) {
+ pipe_sampler_view_release(st->pipe,
+ &st->state.sampler_views[shader][i]);
+ }
}
if (st->default_texture) {
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 8afd7766362..47d3af52051 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -98,25 +98,20 @@ struct st_context
struct pipe_blend_state blend;
struct pipe_depth_stencil_alpha_state depth_stencil;
struct pipe_rasterizer_state rasterizer;
- struct pipe_sampler_state fragment_samplers[PIPE_MAX_SAMPLERS];
- struct pipe_sampler_state vertex_samplers[PIPE_MAX_SAMPLERS];
+ struct pipe_sampler_state samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
+ GLuint num_samplers[PIPE_SHADER_TYPES];
+ struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
+ GLuint num_sampler_views[PIPE_SHADER_TYPES];
struct pipe_clip_state clip;
struct {
void *ptr;
unsigned size;
} constants[PIPE_SHADER_TYPES];
struct pipe_framebuffer_state framebuffer;
- struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
- struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_SAMPLERS];
struct pipe_scissor_state scissor;
struct pipe_viewport_state viewport;
unsigned sample_mask;
- GLuint num_fragment_samplers;
- GLuint num_vertex_samplers;
- GLuint num_fragment_textures;
- GLuint num_vertex_textures;
-
GLuint poly_stipple[32]; /**< In OpenGL's bottom-to-top order */
GLuint fb_orientation;