st/mesa: emit sampler view declarations for ARB vert/frag programs
authorBrian Paul <brianp@vmware.com>
Wed, 16 Mar 2016 21:58:37 +0000 (15:58 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 21 Mar 2016 17:59:25 +0000 (11:59 -0600)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/mesa/state_tracker/st_mesa_to_tgsi.c

index 8a12ce4c68538b6057f728b04a04dd6907641e01..7a686b199d57f3cd97140369fd248db1dcb2e01b 100644 (file)
@@ -296,6 +296,19 @@ st_translate_texture_target(GLuint textarget, GLboolean shadow)
 }
 
 
+/**
+ * Translate a (1 << TEXTURE_x_INDEX) bit into a TGSI_TEXTURE_x enum.
+ */
+static unsigned
+translate_texture_index(GLbitfield texBit, bool shadow)
+{
+   int index = ffs(texBit);
+   assert(index > 0);
+   assert(index - 1 < NUM_TEXTURE_TARGETS);
+   return st_translate_texture_target(index - 1, shadow);
+}
+
+
 /**
  * Create a TGSI ureg_dst register from a Mesa dest register.
  */
@@ -1147,7 +1160,16 @@ st_translate_mesa_program(
    /* texture samplers */
    for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; i++) {
       if (program->SamplersUsed & (1 << i)) {
+         unsigned target =
+            translate_texture_index(program->TexturesUsed[i],
+                                    !!(program->ShadowSamplers & (1 << i)));
          t->samplers[i] = ureg_DECL_sampler( ureg, i );
+         ureg_DECL_sampler_view(ureg, i, target,
+                                TGSI_RETURN_TYPE_FLOAT,
+                                TGSI_RETURN_TYPE_FLOAT,
+                                TGSI_RETURN_TYPE_FLOAT,
+                                TGSI_RETURN_TYPE_FLOAT);
+
       }
    }