[Mesa-dev] [PATCH 16/24] st/mesa: don't check MaxTextureImageUnits in update_textures
Marek Olšák
maraeo at gmail.com
Mon Jun 12 18:18:47 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
The linker takes care of it.
---
src/mesa/state_tracker/st_atom_texture.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 890e6f5..6262307 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -96,56 +96,52 @@ update_single_texture(struct st_context *st,
st_get_texture_sampler_view_from_stobj(st, stObj, samp, glsl_version);
return GL_TRUE;
}
static void
update_textures(struct st_context *st,
enum pipe_shader_type shader_stage,
const struct gl_program *prog,
- unsigned max_units,
struct pipe_sampler_view **sampler_views,
unsigned *num_textures)
{
const GLuint old_max = *num_textures;
GLbitfield samplers_used = prog->SamplersUsed;
GLbitfield free_slots = ~prog->SamplersUsed;
GLbitfield external_samplers_used = prog->ExternalSamplersUsed;
GLuint unit;
if (samplers_used == 0x0 && old_max == 0)
return;
*num_textures = 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 < old_max;
+ unit++, samplers_used >>= 1) {
struct pipe_sampler_view *sampler_view = NULL;
if (samplers_used & 1) {
/* prog->sh.data is NULL if it's ARB_fragment_program */
unsigned glsl_version = prog->sh.data ? prog->sh.data->Version : 0;
const GLuint texUnit = prog->SamplerUnits[unit];
GLboolean retval;
retval = update_single_texture(st, &sampler_view, texUnit,
glsl_version);
if (retval == GL_FALSE)
continue;
*num_textures = unit + 1;
}
- else if (samplers_used == 0 && unit >= old_max) {
- /* if we've reset all the old views and we have no more new ones */
- break;
- }
pipe_sampler_view_reference(&(sampler_views[unit]), sampler_view);
}
/* For any external samplers with multiplaner YUV, stuff the additional
* sampler views we need at the end.
*
* Trying to cache the sampler view in the stObj looks painful, so just
* re-create the sampler view for the extra planes each time. Main use
* case is video playback (ie. fps games wouldn't be using this) so I
@@ -200,93 +196,87 @@ update_textures(struct st_context *st,
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,
- ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits,
st->state.sampler_views[PIPE_SHADER_VERTEX],
&st->state.num_sampler_views[PIPE_SHADER_VERTEX]);
}
}
void
st_update_fragment_textures(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
update_textures(st,
PIPE_SHADER_FRAGMENT,
ctx->FragmentProgram._Current,
- ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits,
st->state.sampler_views[PIPE_SHADER_FRAGMENT],
&st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
}
void
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,
- ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits,
st->state.sampler_views[PIPE_SHADER_GEOMETRY],
&st->state.num_sampler_views[PIPE_SHADER_GEOMETRY]);
}
}
void
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,
- ctx->Const.Program[MESA_SHADER_TESS_CTRL].MaxTextureImageUnits,
st->state.sampler_views[PIPE_SHADER_TESS_CTRL],
&st->state.num_sampler_views[PIPE_SHADER_TESS_CTRL]);
}
}
void
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,
- ctx->Const.Program[MESA_SHADER_TESS_EVAL].MaxTextureImageUnits,
st->state.sampler_views[PIPE_SHADER_TESS_EVAL],
&st->state.num_sampler_views[PIPE_SHADER_TESS_EVAL]);
}
}
void
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,
- ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits,
st->state.sampler_views[PIPE_SHADER_COMPUTE],
&st->state.num_sampler_views[PIPE_SHADER_COMPUTE]);
}
}
--
2.7.4
More information about the mesa-dev
mailing list