[virglrenderer-devel] [PATCH 04/10] shader: decode MEMBAR instruction.

Dave Airlie airlied at gmail.com
Tue Jul 24 23:00:55 UTC 2018


From: Dave Airlie <airlied at redhat.com>

---
 src/vrend_shader.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index bc37935..f6f44dd 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -3667,6 +3667,42 @@ iter_instruction(struct tgsi_iterate_context *iter,
       snprintf(buf, 255, "barrier();\n");
       EMIT_BUF_WITH_RET(ctx, buf);
       break;
+   case TGSI_OPCODE_MEMBAR: {
+      struct immed *imd = &ctx->imm[(inst->Src[0].Register.Index)];
+      uint32_t val = imd->val[inst->Src[0].Register.SwizzleX].ui;
+      uint32_t all_val = (TGSI_MEMBAR_SHADER_BUFFER |
+                          TGSI_MEMBAR_ATOMIC_BUFFER |
+                          TGSI_MEMBAR_SHADER_IMAGE |
+                          TGSI_MEMBAR_SHARED);
+
+      if (val & TGSI_MEMBAR_THREAD_GROUP) {
+         snprintf(buf, 255, "groupMemoryBarrier();\n");
+         EMIT_BUF_WITH_RET(ctx, buf);
+      } else {
+         if ((val & all_val) == all_val) {
+            snprintf(buf, 255, "memoryBarrier();\n");
+            EMIT_BUF_WITH_RET(ctx, buf);
+         } else {
+            if (val & TGSI_MEMBAR_SHADER_BUFFER) {
+               snprintf(buf, 255, "memoryBarrierBuffer();\n");
+               EMIT_BUF_WITH_RET(ctx, buf);
+            }
+            if (val & TGSI_MEMBAR_ATOMIC_BUFFER) {
+               snprintf(buf, 255, "memoryBarrierAtomic();\n");
+               EMIT_BUF_WITH_RET(ctx, buf);
+            }
+            if (val & TGSI_MEMBAR_SHADER_IMAGE) {
+               snprintf(buf, 255, "memoryBarrierImage();\n");
+               EMIT_BUF_WITH_RET(ctx, buf);
+            }
+            if (val & TGSI_MEMBAR_SHARED) {
+               snprintf(buf, 255, "memoryBarrierShared();\n");
+               EMIT_BUF_WITH_RET(ctx, buf);
+            }
+         }
+      }
+      break;
+   }
    case TGSI_OPCODE_STORE:
       ret = translate_store(ctx, inst, srcs, dsts);
       if (ret)
-- 
2.14.3



More information about the virglrenderer-devel mailing list