diff options
author | Miklós Máté <[email protected]> | 2017-12-02 23:35:17 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-12-25 14:32:22 +0100 |
commit | 178a3dfb0ebc517bef3fec37afaaa75af2fdc48d (patch) | |
tree | c7e874b661af78646311994a7eae67cbb6bc5994 /src/mesa/main/texstate.c | |
parent | f9cd6c502e1eea27f4a7904dfd75a6a0a23cb41b (diff) |
mesa: add fallback texture for SampleMapATI if there is nothing
This fixes crash in the state tracker.
Piglit: spec/ati_fragment_shader/render-notexture
v2: fixed formatting, moved stuff inside the loop,
moved the fallback later to fix more cases
Signed-off-by: Miklós Máté <[email protected]>
Diffstat (limited to 'src/mesa/main/texstate.c')
-rw-r--r-- | src/mesa/main/texstate.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 2146723d086..8f87cac0ce4 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -819,6 +819,29 @@ 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 = 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 @@ -875,6 +898,13 @@ _mesa_update_texture_state(struct gl_context *ctx) _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); } |