diff options
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_sampler.c | 35 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_texture.c | 56 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_bitmap.c | 8 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 8 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.c | 10 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 6 |
6 files changed, 61 insertions, 62 deletions
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 6d83f963f0a..289856cd72d 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -258,13 +258,18 @@ update_shader_samplers(struct st_context *st, GLbitfield free_slots = ~prog->SamplersUsed; GLbitfield external_samplers_used = prog->ExternalSamplersUsed; unsigned unit, num_samplers; + struct pipe_sampler_state local_samplers[PIPE_MAX_SAMPLERS]; const struct pipe_sampler_state *states[PIPE_MAX_SAMPLERS]; if (samplers_used == 0x0) { - *out_num_samplers = 0; + if (out_num_samplers) + *out_num_samplers = 0; return; } + if (!samplers) + samplers = local_samplers; + num_samplers = util_last_bit(samplers_used); /* loop over sampler units (aka tex image units) */ @@ -320,7 +325,9 @@ update_shader_samplers(struct st_context *st, } cso_set_samplers(st->cso_context, shader_stage, num_samplers, states); - *out_num_samplers = num_samplers; + + if (out_num_samplers) + *out_num_samplers = num_samplers; } @@ -331,9 +338,7 @@ st_update_vertex_samplers(struct st_context *st) update_shader_samplers(st, PIPE_SHADER_VERTEX, - ctx->VertexProgram._Current, - st->state.samplers[PIPE_SHADER_VERTEX], - &st->state.num_samplers[PIPE_SHADER_VERTEX]); + ctx->VertexProgram._Current, NULL, NULL); } @@ -345,9 +350,7 @@ st_update_tessctrl_samplers(struct st_context *st) if (ctx->TessCtrlProgram._Current) { update_shader_samplers(st, PIPE_SHADER_TESS_CTRL, - ctx->TessCtrlProgram._Current, - st->state.samplers[PIPE_SHADER_TESS_CTRL], - &st->state.num_samplers[PIPE_SHADER_TESS_CTRL]); + ctx->TessCtrlProgram._Current, NULL, NULL); } } @@ -360,9 +363,7 @@ st_update_tesseval_samplers(struct st_context *st) if (ctx->TessEvalProgram._Current) { update_shader_samplers(st, PIPE_SHADER_TESS_EVAL, - ctx->TessEvalProgram._Current, - st->state.samplers[PIPE_SHADER_TESS_EVAL], - &st->state.num_samplers[PIPE_SHADER_TESS_EVAL]); + ctx->TessEvalProgram._Current, NULL, NULL); } } @@ -375,9 +376,7 @@ st_update_geometry_samplers(struct st_context *st) if (ctx->GeometryProgram._Current) { update_shader_samplers(st, PIPE_SHADER_GEOMETRY, - ctx->GeometryProgram._Current, - st->state.samplers[PIPE_SHADER_GEOMETRY], - &st->state.num_samplers[PIPE_SHADER_GEOMETRY]); + ctx->GeometryProgram._Current, NULL, NULL); } } @@ -390,8 +389,8 @@ st_update_fragment_samplers(struct st_context *st) update_shader_samplers(st, PIPE_SHADER_FRAGMENT, ctx->FragmentProgram._Current, - st->state.samplers[PIPE_SHADER_FRAGMENT], - &st->state.num_samplers[PIPE_SHADER_FRAGMENT]); + st->state.frag_samplers, + &st->state.num_frag_samplers); } @@ -403,8 +402,6 @@ st_update_compute_samplers(struct st_context *st) if (ctx->ComputeProgram._Current) { update_shader_samplers(st, PIPE_SHADER_COMPUTE, - ctx->ComputeProgram._Current, - st->state.samplers[PIPE_SHADER_COMPUTE], - &st->state.num_samplers[PIPE_SHADER_COMPUTE]); + ctx->ComputeProgram._Current, NULL, NULL); } } diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index 6c26b7751b2..105fa79de02 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -216,7 +216,21 @@ update_textures(struct st_context *st, *out_num_textures = num_textures; } +/* Same as update_textures, but don't store the views in st_context. */ +static void +update_textures_local(struct st_context *st, + enum pipe_shader_type shader_stage, + const struct gl_program *prog, + unsigned *out_num_textures) +{ + struct pipe_sampler_view *local_views[PIPE_MAX_SAMPLERS] = {0}; + update_textures(st, shader_stage, prog, local_views, out_num_textures); + + unsigned num = *out_num_textures; + for (unsigned i = 0; i < num; i++) + pipe_sampler_view_reference(&local_views[i], NULL); +} void st_update_vertex_textures(struct st_context *st) @@ -224,11 +238,9 @@ st_update_vertex_textures(struct st_context *st) const struct gl_context *ctx = st->ctx; if (ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits > 0) { - update_textures(st, - PIPE_SHADER_VERTEX, - ctx->VertexProgram._Current, - st->state.sampler_views[PIPE_SHADER_VERTEX], - &st->state.num_sampler_views[PIPE_SHADER_VERTEX]); + update_textures_local(st, PIPE_SHADER_VERTEX, + ctx->VertexProgram._Current, + &st->state.num_sampler_views[PIPE_SHADER_VERTEX]); } } @@ -241,7 +253,7 @@ st_update_fragment_textures(struct st_context *st) update_textures(st, PIPE_SHADER_FRAGMENT, ctx->FragmentProgram._Current, - st->state.sampler_views[PIPE_SHADER_FRAGMENT], + st->state.frag_sampler_views, &st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]); } @@ -252,11 +264,9 @@ st_update_geometry_textures(struct st_context *st) const struct gl_context *ctx = st->ctx; if (ctx->GeometryProgram._Current) { - update_textures(st, - PIPE_SHADER_GEOMETRY, - ctx->GeometryProgram._Current, - st->state.sampler_views[PIPE_SHADER_GEOMETRY], - &st->state.num_sampler_views[PIPE_SHADER_GEOMETRY]); + update_textures_local(st, PIPE_SHADER_GEOMETRY, + ctx->GeometryProgram._Current, + &st->state.num_sampler_views[PIPE_SHADER_GEOMETRY]); } } @@ -267,11 +277,9 @@ st_update_tessctrl_textures(struct st_context *st) const struct gl_context *ctx = st->ctx; if (ctx->TessCtrlProgram._Current) { - update_textures(st, - PIPE_SHADER_TESS_CTRL, - ctx->TessCtrlProgram._Current, - st->state.sampler_views[PIPE_SHADER_TESS_CTRL], - &st->state.num_sampler_views[PIPE_SHADER_TESS_CTRL]); + update_textures_local(st, PIPE_SHADER_TESS_CTRL, + ctx->TessCtrlProgram._Current, + &st->state.num_sampler_views[PIPE_SHADER_TESS_CTRL]); } } @@ -282,11 +290,9 @@ st_update_tesseval_textures(struct st_context *st) const struct gl_context *ctx = st->ctx; if (ctx->TessEvalProgram._Current) { - update_textures(st, - PIPE_SHADER_TESS_EVAL, - ctx->TessEvalProgram._Current, - st->state.sampler_views[PIPE_SHADER_TESS_EVAL], - &st->state.num_sampler_views[PIPE_SHADER_TESS_EVAL]); + update_textures_local(st, PIPE_SHADER_TESS_EVAL, + ctx->TessEvalProgram._Current, + &st->state.num_sampler_views[PIPE_SHADER_TESS_EVAL]); } } @@ -297,10 +303,8 @@ st_update_compute_textures(struct st_context *st) const struct gl_context *ctx = st->ctx; if (ctx->ComputeProgram._Current) { - update_textures(st, - PIPE_SHADER_COMPUTE, - ctx->ComputeProgram._Current, - st->state.sampler_views[PIPE_SHADER_COMPUTE], - &st->state.num_sampler_views[PIPE_SHADER_COMPUTE]); + update_textures_local(st, PIPE_SHADER_COMPUTE, + ctx->ComputeProgram._Current, + &st->state.num_sampler_views[PIPE_SHADER_COMPUTE]); } } diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index a5c7ed0ee66..0a30ffa0f38 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -224,10 +224,10 @@ setup_render_state(struct gl_context *ctx, { struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; uint num = MAX2(fpv->bitmap_sampler + 1, - st->state.num_samplers[PIPE_SHADER_FRAGMENT]); + st->state.num_frag_samplers); uint i; - for (i = 0; i < st->state.num_samplers[PIPE_SHADER_FRAGMENT]; i++) { - samplers[i] = &st->state.samplers[PIPE_SHADER_FRAGMENT][i]; + for (i = 0; i < st->state.num_frag_samplers; i++) { + samplers[i] = &st->state.frag_samplers[i]; } if (atlas) samplers[fpv->bitmap_sampler] = &st->bitmap.atlas_sampler; @@ -242,7 +242,7 @@ setup_render_state(struct gl_context *ctx, struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; uint num = MAX2(fpv->bitmap_sampler + 1, st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]); - memcpy(sampler_views, st->state.sampler_views[PIPE_SHADER_FRAGMENT], + memcpy(sampler_views, st->state.frag_sampler_views, 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_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index ff3eb9b6143..44f5b235c83 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -736,11 +736,11 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, const struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; uint num = MAX3(fpv->drawpix_sampler + 1, fpv->pixelmap_sampler + 1, - st->state.num_samplers[PIPE_SHADER_FRAGMENT]); + st->state.num_frag_samplers); uint i; - for (i = 0; i < st->state.num_samplers[PIPE_SHADER_FRAGMENT]; i++) - samplers[i] = &st->state.samplers[PIPE_SHADER_FRAGMENT][i]; + for (i = 0; i < st->state.num_frag_samplers; i++) + samplers[i] = &st->state.frag_samplers[i]; samplers[fpv->drawpix_sampler] = &sampler; if (sv[1]) @@ -763,7 +763,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, fpv->pixelmap_sampler + 1, st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]); - memcpy(sampler_views, st->state.sampler_views[PIPE_SHADER_FRAGMENT], + memcpy(sampler_views, st->state.frag_sampler_views, sizeof(sampler_views)); sampler_views[fpv->drawpix_sampler] = sv[0]; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 8274b9e0a8b..7e721572e0a 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -254,7 +254,7 @@ st_invalidate_state(struct gl_context *ctx) static void st_destroy_context_priv(struct st_context *st, bool destroy_pipe) { - uint shader, i; + uint i; st_destroy_atoms(st); st_destroy_draw(st); @@ -267,11 +267,9 @@ st_destroy_context_priv(struct st_context *st, bool destroy_pipe) st_destroy_bound_texture_handles(st); st_destroy_bound_image_handles(st); - for (shader = 0; shader < ARRAY_SIZE(st->state.sampler_views); shader++) { - for (i = 0; i < ARRAY_SIZE(st->state.sampler_views[0]); i++) { - pipe_sampler_view_release(st->pipe, - &st->state.sampler_views[shader][i]); - } + for (i = 0; i < ARRAY_SIZE(st->state.frag_sampler_views); i++) { + pipe_sampler_view_release(st->pipe, + &st->state.frag_sampler_views[i]); } /* free glReadPixels cache data */ diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index ae2bdf596ac..660c993fe22 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -151,9 +151,9 @@ 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 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]; + struct pipe_sampler_state frag_samplers[PIPE_MAX_SAMPLERS]; + GLuint num_frag_samplers; + struct pipe_sampler_view *frag_sampler_views[PIPE_MAX_SAMPLERS]; GLuint num_sampler_views[PIPE_SHADER_TYPES]; struct pipe_clip_state clip; struct { |