#include "teximage.h"
#include "texstate.h"
#include "mtypes.h"
+#include "state.h"
#include "util/bitscan.h"
#include "util/bitset.h"
}
}
- FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE);
-
ctx->Texture.CurrentUnit = texUnit;
if (ctx->Transform.MatrixMode == GL_TEXTURE) {
/* update current stack pointer */
return;
}
- FLUSH_VERTICES(ctx, _NEW_ARRAY);
+ /* Don't flush vertices. This is a "latched" state. */
ctx->Array.ActiveTexture = texUnit;
}
struct gl_texture_object *texObj;
texObj = update_single_program_texture(ctx, prog, unit);
- if (!texObj)
- return;
_mesa_reference_texobj(&ctx->Texture.Unit[unit]._Current, texObj);
BITSET_SET(enabled_texture_units, unit);
for (i = 0; i < MESA_SHADER_STAGES; i++) {
GLbitfield mask;
+ GLuint s;
if (!prog[i])
continue;
mask = prog[i]->SamplersUsed;
while (mask) {
- const int s = u_bit_scan(&mask);
+ s = u_bit_scan(&mask);
update_single_program_texture_state(ctx, prog[i],
prog[i]->SamplerUnits[s],
enabled_texture_units);
}
+
+ if (unlikely(prog[i]->sh.HasBoundBindlessSampler)) {
+ /* Loop over bindless samplers bound to texture units.
+ */
+ for (s = 0; s < prog[i]->sh.NumBindlessSamplers; s++) {
+ struct gl_bindless_sampler *sampler =
+ &prog[i]->sh.BindlessSamplers[s];
+
+ if (!sampler->bound)
+ continue;
+
+ update_single_program_texture_state(ctx, prog[i], sampler->unit,
+ enabled_texture_units);
+ }
+ }
}
if (prog[MESA_SHADER_FRAGMENT]) {
}
}
+static void
+fix_missing_textures_for_atifs(struct gl_context *ctx,
+ struct gl_program *prog,
+ BITSET_WORD *enabled_texture_units)
+{
+ GLbitfield mask = prog->SamplersUsed;
+
+ while (mask) {
+ const int s = u_bit_scan(&mask);
+ const int unit = prog->SamplerUnits[s];
+ const gl_texture_index target_index = ffs(prog->TexturesUsed[unit]) - 1;
+
+ if (!ctx->Texture.Unit[unit]._Current) {
+ struct gl_texture_object *texObj =
+ _mesa_get_fallback_texture(ctx, target_index);
+ _mesa_reference_texobj(&ctx->Texture.Unit[unit]._Current, texObj);
+ BITSET_SET(enabled_texture_units, unit);
+ ctx->Texture._MaxEnabledTexImageUnit =
+ MAX2(ctx->Texture._MaxEnabledTexImageUnit, (int)unit);
+ }
+ }
+}
+
/**
* \note This routine refers to derived texture matrix values to
* compute the ENABLE_TEXMAT flags, but is only called on
int old_max_unit = ctx->Texture._MaxEnabledTexImageUnit;
BITSET_DECLARE(enabled_texture_units, MAX_COMBINED_TEXTURE_IMAGE_UNITS);
- for (i = 0; i < MESA_SHADER_STAGES; i++) {
- if (ctx->_Shader->CurrentProgram[i]) {
- prog[i] = ctx->_Shader->CurrentProgram[i];
- } else {
- prog[i] = NULL;
- }
- }
+ memcpy(prog, ctx->_Shader->CurrentProgram, sizeof(prog));
- if (prog[MESA_SHADER_FRAGMENT] == NULL && ctx->FragmentProgram._Enabled) {
+ if (prog[MESA_SHADER_FRAGMENT] == NULL &&
+ _mesa_arb_fragment_program_enabled(ctx)) {
prog[MESA_SHADER_FRAGMENT] = ctx->FragmentProgram.Current;
}
_mesa_reference_texobj(&ctx->Texture.Unit[i]._Current, NULL);
}
+ /* add fallback texture for SampleMapATI if there is nothing */
+ if (_mesa_ati_fragment_shader_enabled(ctx) &&
+ ctx->ATIFragmentShader.Current->Program)
+ fix_missing_textures_for_atifs(ctx,
+ ctx->ATIFragmentShader.Current->Program,
+ enabled_texture_units);
+
if (!prog[MESA_SHADER_FRAGMENT] || !prog[MESA_SHADER_VERTEX])
update_texgen(ctx);
}