[virglrenderer-devel] [PATCH 10/12] arb_gpu_shader5: add support for non-uniform texture offsets

Dave Airlie airlied at gmail.com
Tue May 15 04:38:08 UTC 2018


From: Dave Airlie <airlied at redhat.com>

---
 src/vrend_shader.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 56b1bbb..6e7ca2f 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -1512,13 +1512,16 @@ static int translate_tex(struct dump_ctx *ctx,
             return false;
          }
       } else if (inst->TexOffsets[0].File == TGSI_FILE_TEMPORARY) {
+         struct vrend_temp_range *range = find_temp_range(ctx, inst->TexOffsets[0].Index);
+         int idx = inst->TexOffsets[0].Index - range->first;
          switch (inst->Texture.Texture) {
          case TGSI_TEXTURE_1D:
          case TGSI_TEXTURE_1D_ARRAY:
          case TGSI_TEXTURE_SHADOW1D:
          case TGSI_TEXTURE_SHADOW1D_ARRAY:
-            snprintf(offbuf, 120, ", int(floatBitsToInt(temps[%d].%c))",
-                     inst->TexOffsets[0].Index, get_swiz_char(inst->TexOffsets[0].SwizzleX));
+            snprintf(offbuf, 120, ", int(floatBitsToInt(temp%d[%d].%c))",
+                     range->first, idx,
+                     get_swiz_char(inst->TexOffsets[0].SwizzleX));
             break;
          case TGSI_TEXTURE_RECT:
          case TGSI_TEXTURE_SHADOWRECT:
@@ -1526,15 +1529,20 @@ static int translate_tex(struct dump_ctx *ctx,
          case TGSI_TEXTURE_2D_ARRAY:
          case TGSI_TEXTURE_SHADOW2D:
          case TGSI_TEXTURE_SHADOW2D_ARRAY:
-            snprintf(offbuf, 120, ", ivec2(floatBitsToInt(temps[%d].%c), floatBitsToInt(temps[%d].%c))",
-                     inst->TexOffsets[0].Index, get_swiz_char(inst->TexOffsets[0].SwizzleX),
-                     inst->TexOffsets[0].Index, get_swiz_char(inst->TexOffsets[0].SwizzleY));
+            snprintf(offbuf, 120, ", ivec2(floatBitsToInt(temp%d[%d].%c), floatBitsToInt(temp%d[%d].%c))",
+                     range->first, idx,
+                     get_swiz_char(inst->TexOffsets[0].SwizzleX),
+                     range->first, idx,
+                     get_swiz_char(inst->TexOffsets[0].SwizzleY));
             break;
          case TGSI_TEXTURE_3D:
-            snprintf(offbuf, 120, ", ivec2(floatBitsToInt(temps[%d].%c), floatBitsToInt(temps[%d].%c), floatBitsToInt(temps[%d].%c)",
-                     inst->TexOffsets[0].Index, get_swiz_char(inst->TexOffsets[0].SwizzleX),
-                     inst->TexOffsets[0].Index, get_swiz_char(inst->TexOffsets[0].SwizzleY),
-                     inst->TexOffsets[0].Index, get_swiz_char(inst->TexOffsets[0].SwizzleZ));
+            snprintf(offbuf, 120, ", ivec2(floatBitsToInt(temp%d[%d].%c), floatBitsToInt(temp%d[%d].%c), floatBitsToInt(temp%d[%d].%c)",
+                     range->first, idx,
+                     get_swiz_char(inst->TexOffsets[0].SwizzleX),
+                     range->first, idx,
+                     get_swiz_char(inst->TexOffsets[0].SwizzleY),
+                     range->first, idx,
+                     get_swiz_char(inst->TexOffsets[0].SwizzleZ));
                      break;
          default:
             fprintf(stderr, "unhandled texture: %x\n", inst->Texture.Texture);
-- 
2.14.3



More information about the virglrenderer-devel mailing list