Now that we have the number of samplers available, we don't need to
iterate over all 16. This should be particularly helpful for vertex
shaders.
v2: Use the correct shader program (caught by Paul Berry).
This needs to initialize the exact same set of sampler swizzles as
the actual key setup, or else we end up doing recompiles due to some
being XYZW and others being 0.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
key.clamp_fragment_color = ctx->API == API_OPENGL_COMPAT;
- for (int i = 0; i < MAX_SAMPLERS; i++) {
+ unsigned sampler_count = _mesa_fls(fp->Base.SamplersUsed);
+ for (unsigned i = 0; i < sampler_count; i++) {
if (fp->Base.ShadowSamplers & (1 << i)) {
/* Assume DEPTH_TEXTURE_MODE is the default: X, X, X, 1 */
key.tex.swizzles[i] =
key.base.program_string_id = bvp->id;
key.base.clamp_vertex_color = ctx->API == API_OPENGL_COMPAT;
- for (int i = 0; i < MAX_SAMPLERS; i++) {
+ unsigned sampler_count = _mesa_fls(vp->Base.SamplersUsed);
+ for (unsigned i = 0; i < sampler_count; i++) {
if (vp->Base.ShadowSamplers & (1 << i)) {
/* Assume DEPTH_TEXTURE_MODE is the default: X, X, X, 1 */
key.base.tex.swizzles[i] =