st/mesa: use correct TGSI texture target in bitmap fragment shader
authorBrian Paul <brianp@vmware.com>
Fri, 18 Mar 2016 18:16:50 +0000 (12:16 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 21 Mar 2016 17:59:25 +0000 (11:59 -0600)
Depending on the driver's support for NPOT textures, we might use
a RECT texture instead of 2D texture.  We should propogate that info
to the fragment shader's TEX instruction.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/mesa/state_tracker/st_cb_bitmap.h
src/mesa/state_tracker/st_cb_bitmap_shader.c
src/mesa/state_tracker/st_program.c

index 4d1ae222b81199a7e7de08f560ed9dcfae7f1340..323158ea11ddc1eb806203c227d389ddf1ed470c 100644 (file)
@@ -49,7 +49,7 @@ st_flush_bitmap_cache(struct st_context *st);
 
 extern const struct tgsi_token *
 st_get_bitmap_shader(const struct tgsi_token *tokens,
-                     unsigned sampler_index,
+                     unsigned tex_target, unsigned sampler_index,
                      bool use_texcoord, bool swizzle_xxxx);
 
 #endif /* ST_CB_BITMAP_H */
index 42aa0337af94c43fd6beb46ae7a8ac4fea884521..a0b9be33415240e16469ab1d4b21b00ebe83d2c9 100644 (file)
@@ -36,6 +36,7 @@ struct tgsi_bitmap_transform {
    struct tgsi_transform_context base;
    struct tgsi_shader_info info;
    unsigned sampler_index;
+   unsigned tex_target;
    bool use_texcoord;
    bool swizzle_xxxx;
    bool first_instruction_emitted;
@@ -53,6 +54,8 @@ transform_instr(struct tgsi_transform_context *tctx,
 {
    struct tgsi_bitmap_transform *ctx = tgsi_bitmap_transform(tctx);
    struct tgsi_full_instruction inst;
+   unsigned tgsi_tex_target = ctx->tex_target == PIPE_TEXTURE_2D
+      ? TGSI_TEXTURE_2D : TGSI_TEXTURE_RECT;
    unsigned i, semantic;
    int texcoord_index = -1;
 
@@ -92,7 +95,7 @@ transform_instr(struct tgsi_transform_context *tctx,
    tgsi_transform_tex_inst(tctx,
                            TGSI_FILE_TEMPORARY, 0,
                            TGSI_FILE_INPUT, texcoord_index,
-                           TGSI_TEXTURE_2D, ctx->sampler_index);
+                           tgsi_tex_target, ctx->sampler_index);
 
    /* KIL if -tmp0 < 0 # texel=0 -> keep / texel=0 -> discard */
    inst = tgsi_default_full_instruction();
@@ -121,15 +124,19 @@ transform_instr(struct tgsi_transform_context *tctx,
 
 const struct tgsi_token *
 st_get_bitmap_shader(const struct tgsi_token *tokens,
-                     unsigned sampler_index,
+                     unsigned tex_target, unsigned sampler_index,
                      bool use_texcoord, bool swizzle_xxxx)
 {
    struct tgsi_bitmap_transform ctx;
    struct tgsi_token *newtoks;
    int newlen;
 
+   assert(tex_target == PIPE_TEXTURE_2D ||
+          tex_target == PIPE_TEXTURE_RECT);
+
    memset(&ctx, 0, sizeof(ctx));
    ctx.base.transform_instruction = transform_instr;
+   ctx.tex_target = tex_target;
    ctx.sampler_index = sampler_index;
    ctx.use_texcoord = use_texcoord;
    ctx.swizzle_xxxx = swizzle_xxxx;
index c9f390aa9a25e7ceec45a825251f0caefcbdab8e..d4ff845a023fd59277233237e00bf969809dd440 100644 (file)
@@ -871,6 +871,7 @@ st_create_fp_variant(struct st_context *st,
       variant->bitmap_sampler = ffs(~stfp->Base.Base.SamplersUsed) - 1;
 
       tokens = st_get_bitmap_shader(tgsi.tokens,
+                                    st->internal_target,
                                     variant->bitmap_sampler,
                                     st->needs_texcoord_semantic,
                                     st->bitmap.tex_format ==