[Mesa-dev] [PATCH 07/24] st/mesa: when binding sampler states, don't check the max sampler limit
Marek Olšák
maraeo at gmail.com
Mon Jun 12 18:18:38 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
The GLSL linker takes care of it.
---
src/mesa/state_tracker/st_atom_sampler.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 11db6e1..52ff9b6 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -252,38 +252,37 @@ convert_sampler_from_unit(const struct st_context *st,
/**
* Update the gallium driver's sampler state for fragment, vertex or
* geometry shader stage.
*/
static void
update_shader_samplers(struct st_context *st,
enum pipe_shader_type shader_stage,
const struct gl_program *prog,
- unsigned max_units,
struct pipe_sampler_state *samplers,
unsigned *num_samplers)
{
GLbitfield samplers_used = prog->SamplersUsed;
GLbitfield free_slots = ~prog->SamplersUsed;
GLbitfield external_samplers_used = prog->ExternalSamplersUsed;
GLuint unit;
const GLuint old_max = *num_samplers;
const struct pipe_sampler_state *states[PIPE_MAX_SAMPLERS];
if (samplers_used == 0x0)
return;
*num_samplers = 0;
/* loop over sampler units (aka tex image units) */
- for (unit = 0; unit < max_units; unit++, samplers_used >>= 1) {
+ for (unit = 0; samplers_used; unit++, samplers_used >>= 1) {
struct pipe_sampler_state *sampler = samplers + unit;
if (samplers_used & 1) {
const GLuint texUnit = prog->SamplerUnits[unit];
convert_sampler_from_unit(st, sampler, texUnit);
states[unit] = sampler;
*num_samplers = unit + 1;
}
else if (samplers_used != 0 || unit < old_max) {
@@ -335,92 +334,86 @@ update_shader_samplers(struct st_context *st,
void
st_update_vertex_samplers(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
update_shader_samplers(st,
PIPE_SHADER_VERTEX,
ctx->VertexProgram._Current,
- ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_VERTEX],
&st->state.num_samplers[PIPE_SHADER_VERTEX]);
}
void
st_update_tessctrl_samplers(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
if (ctx->TessCtrlProgram._Current) {
update_shader_samplers(st,
PIPE_SHADER_TESS_CTRL,
ctx->TessCtrlProgram._Current,
- ctx->Const.Program[MESA_SHADER_TESS_CTRL].MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_TESS_CTRL],
&st->state.num_samplers[PIPE_SHADER_TESS_CTRL]);
}
}
void
st_update_tesseval_samplers(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
if (ctx->TessEvalProgram._Current) {
update_shader_samplers(st,
PIPE_SHADER_TESS_EVAL,
ctx->TessEvalProgram._Current,
- ctx->Const.Program[MESA_SHADER_TESS_EVAL].MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_TESS_EVAL],
&st->state.num_samplers[PIPE_SHADER_TESS_EVAL]);
}
}
void
st_update_geometry_samplers(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
if (ctx->GeometryProgram._Current) {
update_shader_samplers(st,
PIPE_SHADER_GEOMETRY,
ctx->GeometryProgram._Current,
- ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_GEOMETRY],
&st->state.num_samplers[PIPE_SHADER_GEOMETRY]);
}
}
void
st_update_fragment_samplers(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
update_shader_samplers(st,
PIPE_SHADER_FRAGMENT,
ctx->FragmentProgram._Current,
- ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_FRAGMENT],
&st->state.num_samplers[PIPE_SHADER_FRAGMENT]);
}
void
st_update_compute_samplers(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
if (ctx->ComputeProgram._Current) {
update_shader_samplers(st,
PIPE_SHADER_COMPUTE,
ctx->ComputeProgram._Current,
- ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits,
st->state.samplers[PIPE_SHADER_COMPUTE],
&st->state.num_samplers[PIPE_SHADER_COMPUTE]);
}
}
--
2.7.4
More information about the mesa-dev
mailing list