[Mesa-dev] [PATCH 1/4] mesa: mesa: add fallback texture for SampleMapATI if there is nothing

Miklós Máté mtmkls at gmail.com
Tue Nov 21 00:07:01 UTC 2017


This fixes crash in the state tracker.
Piglit: spec/ati_fragment_shader/render-notexture

Signed-off-by: Miklós Máté <mtmkls at gmail.com>
---
 src/mesa/main/texstate.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 2146723d08..a0717a542f 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -819,6 +819,35 @@ update_ff_texture_state(struct gl_context *ctx,
    }
 }
 
+static void
+fix_missing_textures_for_atifs(struct gl_context *ctx,
+                               struct gl_program *prog,
+                               BITSET_WORD *enabled_texture_units)
+{
+   GLbitfield mask;
+   GLuint s;
+   int unit;
+   gl_texture_index target_index;
+   struct gl_texture_object *texObj;
+
+   mask = prog->SamplersUsed;
+   while (mask) {
+      s = u_bit_scan(&mask);
+      unit = prog->SamplerUnits[s];
+
+      target_index = ffs(prog->TexturesUsed[unit]) - 1;
+
+      if (!ctx->Texture.Unit[unit]._Current) {
+         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
@@ -866,6 +895,12 @@ _mesa_update_texture_state(struct gl_context *ctx)
    if (!prog[MESA_SHADER_FRAGMENT])
       update_ff_texture_state(ctx, enabled_texture_units);
 
+   /* 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);
+
    /* Now, clear out the _Current of any disabled texture units. */
    for (i = 0; i <= ctx->Texture._MaxEnabledTexImageUnit; i++) {
       if (!BITSET_TEST(enabled_texture_units, i))
-- 
2.15.0.rc0



More information about the mesa-dev mailing list