aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker/st_atom_sampler.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/state_tracker/st_atom_sampler.c')
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_sampler.c106
1 files changed, 52 insertions, 54 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
index dc0c789c5..f39fd7551 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
@@ -195,84 +195,82 @@ convert_sampler(struct st_context *st,
}
+/**
+ * Update the gallium driver's sampler state for fragment, vertex or
+ * geometry shader stage.
+ */
static void
-update_vertex_samplers(struct st_context *st)
+update_shader_samplers(struct st_context *st,
+ unsigned shader_stage,
+ const struct gl_program *prog,
+ unsigned max_units,
+ struct pipe_sampler_state *samplers,
+ unsigned *num_samplers)
{
- const struct gl_context *ctx = st->ctx;
- struct gl_vertex_program *vprog = ctx->VertexProgram._Current;
- GLuint su;
-
- if (st->state.num_vertex_samplers == 0 && vprog->Base.SamplersUsed == 0)
- return;
- st->state.num_vertex_samplers = 0;
-
- /* loop over sampler units (aka tex image units) */
- for (su = 0; su < ctx->Const.MaxVertexTextureImageUnits; su++) {
- struct pipe_sampler_state *sampler = st->state.vertex_samplers + su;
-
- if (vprog->Base.SamplersUsed & (1 << su)) {
- GLuint texUnit;
-
- texUnit = vprog->Base.SamplerUnits[su];
+ GLuint unit;
+ GLbitfield samplers_used;
+ const GLuint old_max = *num_samplers;
- convert_sampler(st, sampler, texUnit);
+ samplers_used = prog->SamplersUsed;
- st->state.num_vertex_samplers = su + 1;
-
- cso_single_vertex_sampler(st->cso_context, su, sampler);
- } else {
- cso_single_vertex_sampler(st->cso_context, su, NULL);
- }
- }
- cso_single_vertex_sampler_done(st->cso_context);
-}
-
-
-static void
-update_fragment_samplers(struct st_context *st)
-{
- const struct gl_context *ctx = st->ctx;
- struct gl_fragment_program *fprog = ctx->FragmentProgram._Current;
- GLuint su;
- GLuint samplers_used = fprog->Base.SamplersUsed;
- GLuint old_max = st->state.num_samplers;
+ if (*num_samplers == 0 && samplers_used == 0x0)
+ return;
- st->state.num_samplers = 0;
+ *num_samplers = 0;
/* loop over sampler units (aka tex image units) */
- for (su = 0; su < ctx->Const.MaxTextureImageUnits; su++, samplers_used >>= 1) {
- struct pipe_sampler_state *sampler = st->state.samplers + su;
+ for (unit = 0; unit < max_units; unit++, samplers_used >>= 1) {
+ struct pipe_sampler_state *sampler = samplers + unit;
if (samplers_used & 1) {
- GLuint texUnit;
-
- texUnit = fprog->Base.SamplerUnits[su];
+ const GLuint texUnit = prog->SamplerUnits[unit];
convert_sampler(st, sampler, texUnit);
- st->state.num_samplers = su + 1;
+ *num_samplers = unit + 1;
- /*printf("%s su=%u non-null\n", __FUNCTION__, su);*/
- cso_single_sampler(st->cso_context, su, sampler);
+ cso_single_sampler(st->cso_context, shader_stage, unit, sampler);
+ }
+ else if (samplers_used != 0 || unit < old_max) {
+ cso_single_sampler(st->cso_context, shader_stage, unit, NULL);
}
- else if (samplers_used != 0 || su < old_max) {
- /*printf("%s su=%u null\n", __FUNCTION__, su);*/
- cso_single_sampler(st->cso_context, su, NULL);
- } else {
- /* if we've reset all the old views and we have no more new ones */
+ else {
+ /* if we've reset all the old samplers and we have no more new ones */
break;
}
}
- cso_single_sampler_done(st->cso_context);
+ cso_single_sampler_done(st->cso_context, shader_stage);
}
static void
update_samplers(struct st_context *st)
{
- update_fragment_samplers(st);
- update_vertex_samplers(st);
+ const struct gl_context *ctx = st->ctx;
+
+ update_shader_samplers(st,
+ PIPE_SHADER_FRAGMENT,
+ &ctx->FragmentProgram._Current->Base,
+ ctx->Const.MaxTextureImageUnits,
+ st->state.fragment_samplers,
+ &st->state.num_fragment_samplers);
+
+ update_shader_samplers(st,
+ PIPE_SHADER_VERTEX,
+ &ctx->VertexProgram._Current->Base,
+ ctx->Const.MaxVertexTextureImageUnits,
+ st->state.vertex_samplers,
+ &st->state.num_vertex_samplers);
+
+/*
+ update_shader_samplers(st,
+ PIPE_SHADER_GEOMETRY,
+ &ctx->GeometryProgram._Current->Base,
+ ctx->Const.MaxGeometryTextureImageUnits,
+ st->state.geometry_samplers,
+ &st->state.num_geometry_samplers);
+*/
}