diff options
author | Marek Olšák <[email protected]> | 2015-10-05 01:22:20 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2015-10-09 22:02:18 +0200 |
commit | de6a004035f3de5879648f8afb4670ae82f4ad02 (patch) | |
tree | bec0b650805bea2c763006040fa4c44969a1728d /src/mesa/state_tracker/st_program.c | |
parent | f15bb3e633d577fe6d8d7bc2c64497c6ac4c2021 (diff) |
st/mesa: fix glDrawPixels with a texture
The samplers for DrawPixels data and the pixel map are assigned to slots
which don't overlap with the existing sampler slots.
The texture coordinates for the user texture are uploaded as a constant.
Reviewed-by: Dave Airlie <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Tested-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_program.c')
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 01e33d04f74..95ad2f46827 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -886,7 +886,17 @@ st_translate_fragment_program(struct st_context *st, /* glDrawPixels (color only) */ if (key->drawpixels) { const struct tgsi_token *tokens; - unsigned scale_const = 0, bias_const = 0; + unsigned scale_const = 0, bias_const = 0, texcoord_const = 0; + + /* Find the first unused slot. */ + variant->drawpix_sampler = ffs(~stfp->Base.Base.SamplersUsed) - 1; + + if (key->pixelMaps) { + unsigned samplers_used = stfp->Base.Base.SamplersUsed | + (1 << variant->drawpix_sampler); + + variant->pixelmap_sampler = ffs(~samplers_used) - 1; + } variant->parameters = _mesa_clone_parameter_list(stfp->Base.Base.Parameters); @@ -903,10 +913,21 @@ st_translate_fragment_program(struct st_context *st, bias_state); } + { + static const gl_state_index state[STATE_LENGTH] = + { STATE_INTERNAL, STATE_CURRENT_ATTRIB, VERT_ATTRIB_TEX0 }; + + texcoord_const = _mesa_add_state_reference(variant->parameters, + state); + } + tokens = st_get_drawpix_shader(variant->tgsi.tokens, st->needs_texcoord_semantic, key->scaleAndBias, scale_const, - bias_const, key->pixelMaps); + bias_const, key->pixelMaps, + variant->drawpix_sampler, + variant->pixelmap_sampler, + texcoord_const); if (tokens) { tgsi_free_tokens(variant->tgsi.tokens); |