those are unused.
st_context: 10120 -> 3704 bytes
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
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) */
}
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;
}
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);
}
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);
}
}
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);
}
}
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);
}
}
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);
}
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);
}
}
*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)
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]);
}
}
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]);
}
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]);
}
}
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]);
}
}
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]);
}
}
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]);
}
}
{
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;
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);
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])
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];
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);
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 */
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 {