Skip to contentSkip to conversation

tgsi: Fix decl.Atomic and .Shared not propagating when parsing tgsi text

PATCH In review Hans de Goede 3 participants 6 messages Mar 16, 2016 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 tgsi: Fix decl.Atomic and .Shared not propagating when parsing tgsi text

When support for decl.Atomic and .Shared was added, tgsi_build_declaration was not updated to propagate these properly.

---
Changes in v2:
-Add Reviewed-by: Ilia Mirkin <[email protected]>

---
 src/gallium/auxiliary/tgsi/tgsi_build.c | 6 ++++++
 1 file changed, 6 insertions(+)
src/gallium/auxiliary/tgsi/tgsi_build.c +6 -0
index e5355f5..1cb95b9 100644
@@ -127,6 +127,8 @@ tgsi_build_declaration(
    unsigned invariant,
    unsigned local,
    unsigned array,
+   unsigned atomic,
+   unsigned shared,
    struct tgsi_header *header )
 {
    struct tgsi_declaration declaration;
@@ -143,6 +145,8 @@ tgsi_build_declaration(
    declaration.Invariant = invariant;
    declaration.Local = local;
    declaration.Array = array;
+   declaration.Atomic = atomic;
+   declaration.Shared = shared;
    header_bodysize_grow( header );
 
    return declaration;
@@ -401,6 +405,8 @@ tgsi_build_full_declaration(
       full_decl->Declaration.Invariant,
       full_decl->Declaration.Local,
       full_decl->Declaration.Array,
+      full_decl->Declaration.Atomic,
+      full_decl->Declaration.Shared,
       header );
 
    if (maxsize <= size)
Signature · 6 lines
2.7.2

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 1458118502-9016-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH v2 2/3 tgsi: Add support for global / private / input MEMORY

Extend the MEMORY file support to differentiate between global, private and shared memory, as well as "input" memory.

"MEMORY[x], INPUT" is intended to access OpenCL kernel parameters, a special memory type is added for this, since the actual storage of these (e.g. UBO-s) may differ per implementation. The uploading of kernel parameters is handled by launch_grid, "MEMORY[x], INPUT" allows drivers to use an access mechanism for parameter reads which matches with the upload method.

---
Changes in v2:
-Drop mention of GLSL global / GLSL local from comments -Change TGSI_MEMORY_TYPE_LOCAL to TGSI_MEMORY_TYPE_PRIVATE -Add Reviewed-by: Ilia Mirkin <[email protected]>

---
 src/gallium/auxiliary/tgsi/tgsi_build.c            |  8 +++----
 src/gallium/auxiliary/tgsi/tgsi_dump.c             |  9 ++++++--
 src/gallium/auxiliary/tgsi/tgsi_text.c             | 14 ++++++++++--
 src/gallium/auxiliary/tgsi/tgsi_ureg.c             | 25 ++++++++++++----------
 src/gallium/auxiliary/tgsi/tgsi_ureg.h             |  2 +-
 .../drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp  |  7 +++---
 src/gallium/include/pipe/p_shader_tokens.h         | 10 +++++++--
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp         |  2 +-
 8 files changed, 51 insertions(+), 26 deletions(-)
src/gallium/auxiliary/tgsi/tgsi_build.c +4 -4
index 1cb95b9..a3e659b 100644
@@ -111,7 +111,7 @@ tgsi_default_declaration( void )
    declaration.Local = 0;
    declaration.Array = 0;
    declaration.Atomic = 0;
-   declaration.Shared = 0;
+   declaration.MemType = TGSI_MEMORY_TYPE_GLOBAL;
    declaration.Padding = 0;
 
    return declaration;
@@ -128,7 +128,7 @@ tgsi_build_declaration(
    unsigned local,
    unsigned array,
    unsigned atomic,
-   unsigned shared,
+   unsigned mem_type,
    struct tgsi_header *header )
 {
    struct tgsi_declaration declaration;
@@ -146,7 +146,7 @@ tgsi_build_declaration(
    declaration.Local = local;
    declaration.Array = array;
    declaration.Atomic = atomic;
-   declaration.Shared = shared;
+   declaration.MemType = mem_type;
    header_bodysize_grow( header );
 
    return declaration;
@@ -406,7 +406,7 @@ tgsi_build_full_declaration(
       full_decl->Declaration.Local,
       full_decl->Declaration.Array,
       full_decl->Declaration.Atomic,
-      full_decl->Declaration.Shared,
+      full_decl->Declaration.MemType,
       header );
 
    if (maxsize <= size)
src/gallium/auxiliary/tgsi/tgsi_dump.c +7 -2
index c8b91bb..6d39ef2 100644
@@ -365,8 +365,13 @@ iter_declaration(
    }
 
    if (decl->Declaration.File == TGSI_FILE_MEMORY) {
-      if (decl->Declaration.Shared)
-         TXT(", SHARED");
+      switch (decl->Declaration.MemType) {
+      /* Note: ,GLOBAL is optional / the default */
+      case TGSI_MEMORY_TYPE_GLOBAL:  TXT(", GLOBAL");  break;
+      case TGSI_MEMORY_TYPE_SHARED:  TXT(", SHARED");  break;
+      case TGSI_MEMORY_TYPE_PRIVATE: TXT(", PRIVATE"); break;
+      case TGSI_MEMORY_TYPE_INPUT:   TXT(", INPUT");   break;
+      }
    }
 
    if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) {
src/gallium/auxiliary/tgsi/tgsi_text.c +12 -2
index 77598d2..028633c 100644
@@ -1390,8 +1390,18 @@ static boolean parse_declaration( struct translate_ctx *ctx )
             ctx->cur = cur;
          }
       } else if (file == TGSI_FILE_MEMORY) {
-         if (str_match_nocase_whole(&cur, "SHARED")) {
-            decl.Declaration.Shared = 1;
+         if (str_match_nocase_whole(&cur, "GLOBAL")) {
+            /* Note this is a no-op global is the default */
+            decl.Declaration.MemType = TGSI_MEMORY_TYPE_GLOBAL;
+            ctx->cur = cur;
+         } else if (str_match_nocase_whole(&cur, "SHARED")) {
+            decl.Declaration.MemType = TGSI_MEMORY_TYPE_SHARED;
+            ctx->cur = cur;
+         } else if (str_match_nocase_whole(&cur, "PRIVATE")) {
+            decl.Declaration.MemType = TGSI_MEMORY_TYPE_PRIVATE;
+            ctx->cur = cur;
+         } else if (str_match_nocase_whole(&cur, "INPUT")) {
+            decl.Declaration.MemType = TGSI_MEMORY_TYPE_INPUT;
             ctx->cur = cur;
          }
       } else {
src/gallium/auxiliary/tgsi/tgsi_ureg.c +14 -11
index ab1d034..495db9f 100644
@@ -190,7 +190,7 @@ struct ureg_program
 
    struct ureg_tokens domain[2];
 
-   bool use_shared_memory;
+   bool use_memory[TGSI_MEMORY_TYPE_COUNT];
 };
 
 static union tgsi_any_token error_tokens[32];
@@ -729,13 +729,14 @@ struct ureg_src ureg_DECL_buffer(struct ureg_program *ureg, unsigned nr,
    return reg;
 }
 
-/* Allocate a shared memory area.
+/* Allocate a memory area.
  */
-struct ureg_src ureg_DECL_shared_memory(struct ureg_program *ureg)
+struct ureg_src ureg_DECL_memory(struct ureg_program *ureg,
+                                 unsigned memory_type)
 {
-   struct ureg_src reg = ureg_src_register(TGSI_FILE_MEMORY, 0);
+   struct ureg_src reg = ureg_src_register(TGSI_FILE_MEMORY, memory_type);
 
-   ureg->use_shared_memory = true;
+   ureg->use_memory[memory_type] = true;
    return reg;
 }
 
@@ -1672,7 +1673,7 @@ emit_decl_buffer(struct ureg_program *ureg,
 }
 
 static void
-emit_decl_shared_memory(struct ureg_program *ureg)
+emit_decl_memory(struct ureg_program *ureg, unsigned memory_type)
 {
    union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 2);
 
@@ -1681,11 +1682,11 @@ emit_decl_shared_memory(struct ureg_program *ureg)
    out[0].decl.NrTokens = 2;
    out[0].decl.File = TGSI_FILE_MEMORY;
    out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW;
-   out[0].decl.Shared = true;
+   out[0].decl.MemType = memory_type;
 
    out[1].value = 0;
-   out[1].decl_range.First = 0;
-   out[1].decl_range.Last = 0;
+   out[1].decl_range.First = memory_type;
+   out[1].decl_range.Last = memory_type;
 }
 
 static void
@@ -1860,8 +1861,10 @@ static void emit_decls( struct ureg_program *ureg )
       emit_decl_buffer(ureg, ureg->buffer[i].index, ureg->buffer[i].atomic);
    }
 
-   if (ureg->use_shared_memory)
-      emit_decl_shared_memory(ureg);
+   for (i = 0; i < TGSI_MEMORY_TYPE_COUNT; i++) {
+      if (ureg->use_memory[i])
+         emit_decl_memory(ureg, i);
+   }
 
    if (ureg->const_decls.nr_constant_ranges) {
       for (i = 0; i < ureg->const_decls.nr_constant_ranges; i++) {
src/gallium/auxiliary/tgsi/tgsi_ureg.h +1 -1
index 04a62a6..9080b57 100644
@@ -338,7 +338,7 @@ struct ureg_src
 ureg_DECL_buffer(struct ureg_program *ureg, unsigned nr, bool atomic);
 
 struct ureg_src
-ureg_DECL_shared_memory(struct ureg_program *ureg);
+ureg_DECL_memory(struct ureg_program *ureg, unsigned memory_type);
 
 static inline struct ureg_src
 ureg_imm4f( struct ureg_program *ureg,
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +4 -3
index d284446..fb7caca 100644
@@ -864,7 +864,7 @@ public:
    std::vector<Resource> resources;
 
    struct MemoryFile {
-      bool shared;
+      uint8_t mem_type; // TGSI_MEMORY_TYPE_*
    };
    std::vector<MemoryFile> memoryFiles;
 
@@ -1222,7 +1222,7 @@ bool Source::scanDeclaration(const struct tgsi_full_declaration *decl)
       break;
    case TGSI_FILE_MEMORY:
       for (i = first; i <= last; ++i)
-         memoryFiles[i].shared = decl->Declaration.Shared;
+         memoryFiles[i].mem_type = decl->Declaration.MemType;
       break;
    case TGSI_FILE_NULL:
    case TGSI_FILE_TEMPORARY:
@@ -1527,7 +1527,8 @@ Converter::makeSym(uint tgsiFile, int fileIdx, int idx, int c, uint32_t address)
 
    sym->reg.fileIndex = fileIdx;
 
-   if (tgsiFile == TGSI_FILE_MEMORY && code->memoryFiles[fileIdx].shared)
+   if (tgsiFile == TGSI_FILE_MEMORY &&
+       code->memoryFiles[fileIdx].mem_type == TGSI_MEMORY_TYPE_SHARED)
       sym->setFile(FILE_MEMORY_SHARED);
 
    if (idx >= 0) {
src/gallium/include/pipe/p_shader_tokens.h +8 -2
index 7a34841..65d8ad9 100644
@@ -117,6 +117,12 @@ enum tgsi_file_type {
 #define TGSI_CYLINDRICAL_WRAP_Z (1 << 2)
 #define TGSI_CYLINDRICAL_WRAP_W (1 << 3)
 
+#define TGSI_MEMORY_TYPE_GLOBAL        0 /* OpenCL global              */
+#define TGSI_MEMORY_TYPE_SHARED        1 /* OpenCL local / GLSL shared */
+#define TGSI_MEMORY_TYPE_PRIVATE       2 /* OpenCL private             */
+#define TGSI_MEMORY_TYPE_INPUT         3 /* OpenCL kernel input params */
+#define TGSI_MEMORY_TYPE_COUNT         4
+
 struct tgsi_declaration
 {
    unsigned Type        : 4;  /**< TGSI_TOKEN_TYPE_DECLARATION */
@@ -130,8 +136,8 @@ struct tgsi_declaration
    unsigned Local       : 1;  /**< optimize as subroutine local variable? */
    unsigned Array       : 1;  /**< extra array info? */
    unsigned Atomic      : 1;  /**< atomic only? for TGSI_FILE_BUFFER */
-   unsigned Shared      : 1;  /**< shared storage for TGSI_FILE_MEMORY */
-   unsigned Padding     : 4;
+   unsigned MemType     : 2;  /**< TGSI_MEMORY_TYPE_x for TGSI_FILE_MEMORY */
+   unsigned Padding     : 3;
 };
 
 struct tgsi_declaration_range
src/mesa/state_tracker/st_glsl_to_tgsi.cpp +1 -1
index 1841405..ff2e082 100644
@@ -6345,7 +6345,7 @@ st_translate_program(
    }
 
    if (program->use_shared_memory)
-      t->shared_memory = ureg_DECL_shared_memory(ureg);
+      t->shared_memory = ureg_DECL_memory(ureg, TGSI_MEMORY_TYPE_SHARED);
 
    for (i = 0; i < program->shader->NumImages; i++) {
       if (program->images_used & (1 << i)) {
Signature · 6 lines
2.7.2

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 1458118502-9016-2-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Reviewed-by Reviewed-by XXX (v1)
#4 lore raw

Re: [PATCH mesa v2 2/3] tgsi: Add support for global / private / input MEMORY

Btw, usually when someone has reviewed the v1 we add (v1) after the Rb tag, like:

Reviewed-by XXX (v1)
Quoted 261 lines · Hans de Goede

Extend the MEMORY file support to differentiate between global, private and shared memory, as well as "input" memory.

"MEMORY[x], INPUT" is intended to access OpenCL kernel parameters, a special memory type is added for this, since the actual storage of these (e.g. UBO-s) may differ per implementation. The uploading of kernel parameters is handled by launch_grid, "MEMORY[x], INPUT" allows drivers to use an access mechanism for parameter reads which matches with the upload method.

---
Changes in v2:

(quoted diff) +0 -4
-Drop mention of GLSL global / GLSL local from comments
-Change TGSI_MEMORY_TYPE_LOCAL to TGSI_MEMORY_TYPE_PRIVATE
-Add Reviewed-by: Ilia Mirkin <[email protected]>
---
  src/gallium/auxiliary/tgsi/tgsi_build.c            |  8 +++----
  src/gallium/auxiliary/tgsi/tgsi_dump.c             |  9 ++++++--
  src/gallium/auxiliary/tgsi/tgsi_text.c             | 14 ++++++++++--
  src/gallium/auxiliary/tgsi/tgsi_ureg.c             | 25 ++++++++++++----------
  src/gallium/auxiliary/tgsi/tgsi_ureg.h             |  2 +-
  .../drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp  |  7 +++---
  src/gallium/include/pipe/p_shader_tokens.h         | 10 +++++++--
  src/mesa/state_tracker/st_glsl_to_tgsi.cpp         |  2 +-
  8 files changed, 51 insertions(+), 26 deletions(-)
src/gallium/auxiliary/tgsi/tgsi_build.c +4 -4
index 1cb95b9..a3e659b 100644
@@ -111,7 +111,7 @@ tgsi_default_declaration( void )
     declaration.Local = 0;
     declaration.Array = 0;
     declaration.Atomic = 0;
-   declaration.Shared = 0;
+   declaration.MemType = TGSI_MEMORY_TYPE_GLOBAL;
     declaration.Padding = 0;
 
     return declaration;
@@ -128,7 +128,7 @@ tgsi_build_declaration(
     unsigned local,
     unsigned array,
     unsigned atomic,
-   unsigned shared,
+   unsigned mem_type,
     struct tgsi_header *header )
  {
     struct tgsi_declaration declaration;
@@ -146,7 +146,7 @@ tgsi_build_declaration(
     declaration.Local = local;
     declaration.Array = array;
     declaration.Atomic = atomic;
-   declaration.Shared = shared;
+   declaration.MemType = mem_type;
     header_bodysize_grow( header );
 
     return declaration;
@@ -406,7 +406,7 @@ tgsi_build_full_declaration(
        full_decl->Declaration.Local,
        full_decl->Declaration.Array,
        full_decl->Declaration.Atomic,
-      full_decl->Declaration.Shared,
+      full_decl->Declaration.MemType,
        header );
 
     if (maxsize <= size)
src/gallium/auxiliary/tgsi/tgsi_dump.c +7 -2
index c8b91bb..6d39ef2 100644
@@ -365,8 +365,13 @@ iter_declaration(
     }
 
     if (decl->Declaration.File == TGSI_FILE_MEMORY) {
-      if (decl->Declaration.Shared)
-         TXT(", SHARED");
+      switch (decl->Declaration.MemType) {
+      /* Note: ,GLOBAL is optional / the default */
+      case TGSI_MEMORY_TYPE_GLOBAL:  TXT(", GLOBAL");  break;
+      case TGSI_MEMORY_TYPE_SHARED:  TXT(", SHARED");  break;
+      case TGSI_MEMORY_TYPE_PRIVATE: TXT(", PRIVATE"); break;
+      case TGSI_MEMORY_TYPE_INPUT:   TXT(", INPUT");   break;
+      }
     }
 
     if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) {
src/gallium/auxiliary/tgsi/tgsi_text.c +12 -2
index 77598d2..028633c 100644
@@ -1390,8 +1390,18 @@ static boolean parse_declaration( struct translate_ctx *ctx )
              ctx->cur = cur;
           }
        } else if (file == TGSI_FILE_MEMORY) {
-         if (str_match_nocase_whole(&cur, "SHARED")) {
-            decl.Declaration.Shared = 1;
+         if (str_match_nocase_whole(&cur, "GLOBAL")) {
+            /* Note this is a no-op global is the default */
+            decl.Declaration.MemType = TGSI_MEMORY_TYPE_GLOBAL;
+            ctx->cur = cur;
+         } else if (str_match_nocase_whole(&cur, "SHARED")) {
+            decl.Declaration.MemType = TGSI_MEMORY_TYPE_SHARED;
+            ctx->cur = cur;
+         } else if (str_match_nocase_whole(&cur, "PRIVATE")) {
+            decl.Declaration.MemType = TGSI_MEMORY_TYPE_PRIVATE;
+            ctx->cur = cur;
+         } else if (str_match_nocase_whole(&cur, "INPUT")) {
+            decl.Declaration.MemType = TGSI_MEMORY_TYPE_INPUT;
              ctx->cur = cur;
           }
        } else {
src/gallium/auxiliary/tgsi/tgsi_ureg.c +14 -11
index ab1d034..495db9f 100644
@@ -190,7 +190,7 @@ struct ureg_program
 
     struct ureg_tokens domain[2];
 
-   bool use_shared_memory;
+   bool use_memory[TGSI_MEMORY_TYPE_COUNT];
  };
 
  static union tgsi_any_token error_tokens[32];
@@ -729,13 +729,14 @@ struct ureg_src ureg_DECL_buffer(struct ureg_program *ureg, unsigned nr,
     return reg;
  }
 
-/* Allocate a shared memory area.
+/* Allocate a memory area.
   */
-struct ureg_src ureg_DECL_shared_memory(struct ureg_program *ureg)
+struct ureg_src ureg_DECL_memory(struct ureg_program *ureg,
+                                 unsigned memory_type)
  {
-   struct ureg_src reg = ureg_src_register(TGSI_FILE_MEMORY, 0);
+   struct ureg_src reg = ureg_src_register(TGSI_FILE_MEMORY, memory_type);
 
-   ureg->use_shared_memory = true;
+   ureg->use_memory[memory_type] = true;
     return reg;
  }
 
@@ -1672,7 +1673,7 @@ emit_decl_buffer(struct ureg_program *ureg,
  }
 
  static void
-emit_decl_shared_memory(struct ureg_program *ureg)
+emit_decl_memory(struct ureg_program *ureg, unsigned memory_type)
  {
     union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 2);
 
@@ -1681,11 +1682,11 @@ emit_decl_shared_memory(struct ureg_program *ureg)
     out[0].decl.NrTokens = 2;
     out[0].decl.File = TGSI_FILE_MEMORY;
     out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW;
-   out[0].decl.Shared = true;
+   out[0].decl.MemType = memory_type;
 
     out[1].value = 0;
-   out[1].decl_range.First = 0;
-   out[1].decl_range.Last = 0;
+   out[1].decl_range.First = memory_type;
+   out[1].decl_range.Last = memory_type;
  }
 
  static void
@@ -1860,8 +1861,10 @@ static void emit_decls( struct ureg_program *ureg )
        emit_decl_buffer(ureg, ureg->buffer[i].index, ureg->buffer[i].atomic);
     }
 
-   if (ureg->use_shared_memory)
-      emit_decl_shared_memory(ureg);
+   for (i = 0; i < TGSI_MEMORY_TYPE_COUNT; i++) {
+      if (ureg->use_memory[i])
+         emit_decl_memory(ureg, i);
+   }
 
     if (ureg->const_decls.nr_constant_ranges) {
        for (i = 0; i < ureg->const_decls.nr_constant_ranges; i++) {
src/gallium/auxiliary/tgsi/tgsi_ureg.h +1 -1
index 04a62a6..9080b57 100644
@@ -338,7 +338,7 @@ struct ureg_src
  ureg_DECL_buffer(struct ureg_program *ureg, unsigned nr, bool atomic);
 
  struct ureg_src
-ureg_DECL_shared_memory(struct ureg_program *ureg);
+ureg_DECL_memory(struct ureg_program *ureg, unsigned memory_type);
 
  static inline struct ureg_src
  ureg_imm4f( struct ureg_program *ureg,
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +4 -3
index d284446..fb7caca 100644
@@ -864,7 +864,7 @@ public:
     std::vector<Resource> resources;
 
     struct MemoryFile {
-      bool shared;
+      uint8_t mem_type; // TGSI_MEMORY_TYPE_*
     };
     std::vector<MemoryFile> memoryFiles;
 
@@ -1222,7 +1222,7 @@ bool Source::scanDeclaration(const struct tgsi_full_declaration *decl)
        break;
     case TGSI_FILE_MEMORY:
        for (i = first; i <= last; ++i)
-         memoryFiles[i].shared = decl->Declaration.Shared;
+         memoryFiles[i].mem_type = decl->Declaration.MemType;
        break;
     case TGSI_FILE_NULL:
     case TGSI_FILE_TEMPORARY:
@@ -1527,7 +1527,8 @@ Converter::makeSym(uint tgsiFile, int fileIdx, int idx, int c, uint32_t address)
 
     sym->reg.fileIndex = fileIdx;
 
-   if (tgsiFile == TGSI_FILE_MEMORY && code->memoryFiles[fileIdx].shared)
+   if (tgsiFile == TGSI_FILE_MEMORY &&
+       code->memoryFiles[fileIdx].mem_type == TGSI_MEMORY_TYPE_SHARED)
        sym->setFile(FILE_MEMORY_SHARED);
 
     if (idx >= 0) {
src/gallium/include/pipe/p_shader_tokens.h +8 -2
index 7a34841..65d8ad9 100644
@@ -117,6 +117,12 @@ enum tgsi_file_type {
  #define TGSI_CYLINDRICAL_WRAP_Z (1 << 2)
  #define TGSI_CYLINDRICAL_WRAP_W (1 << 3)
 
+#define TGSI_MEMORY_TYPE_GLOBAL        0 /* OpenCL global              */
+#define TGSI_MEMORY_TYPE_SHARED        1 /* OpenCL local / GLSL shared */
+#define TGSI_MEMORY_TYPE_PRIVATE       2 /* OpenCL private             */
+#define TGSI_MEMORY_TYPE_INPUT         3 /* OpenCL kernel input params */
+#define TGSI_MEMORY_TYPE_COUNT         4
+
  struct tgsi_declaration
  {
     unsigned Type        : 4;  /**< TGSI_TOKEN_TYPE_DECLARATION */
@@ -130,8 +136,8 @@ struct tgsi_declaration
     unsigned Local       : 1;  /**< optimize as subroutine local variable? */
     unsigned Array       : 1;  /**< extra array info? */
     unsigned Atomic      : 1;  /**< atomic only? for TGSI_FILE_BUFFER */
-   unsigned Shared      : 1;  /**< shared storage for TGSI_FILE_MEMORY */
-   unsigned Padding     : 4;
+   unsigned MemType     : 2;  /**< TGSI_MEMORY_TYPE_x for TGSI_FILE_MEMORY */
+   unsigned Padding     : 3;
  };
 
  struct tgsi_declaration_range
src/mesa/state_tracker/st_glsl_to_tgsi.cpp +0 -0
index 1841405..ff2e082 100644

src/mesa/state_tracker/st_glsl_to_tgsi.cpp st_translate_program( · line 6351

Quoted 8 lines
src/mesa/state_tracker/st_glsl_to_tgsi.cpp +1 -1
@@ -6345,7 +6345,7 @@ st_translate_program(
     }
 
     if (program->use_shared_memory)
-      t->shared_memory = ureg_DECL_shared_memory(ureg);
+      t->shared_memory = ureg_DECL_memory(ureg, TGSI_MEMORY_TYPE_SHARED);
 
     for (i = 0; i < program->shader->NumImages; i++) {
        if (program->images_used & (1 << i)) {

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#5 lore raw

PATCH v2 3/3 nouveau: codegen: Add support for clover / OpenCL kernel input parameters

In reply to a message not in the archive

Add support for clover / OpenCL kernel input parameters.

---
Changes in v2:
-s/local/private/
-Add: Reviewed-by: Ilia Mirkin <[email protected]>

---
 .../drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp      | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +15 -3
index fb7caca..8a1a426 100644
@@ -1527,9 +1527,21 @@ Converter::makeSym(uint tgsiFile, int fileIdx, int idx, int c, uint32_t address)
 
    sym->reg.fileIndex = fileIdx;
 
-   if (tgsiFile == TGSI_FILE_MEMORY &&
-       code->memoryFiles[fileIdx].mem_type == TGSI_MEMORY_TYPE_SHARED)
-      sym->setFile(FILE_MEMORY_SHARED);
+   if (tgsiFile == TGSI_FILE_MEMORY) {
+      switch (code->memoryFiles[fileIdx].mem_type) {
+      case TGSI_MEMORY_TYPE_SHARED:
+         sym->setFile(FILE_MEMORY_SHARED);
+         break;
+      case TGSI_MEMORY_TYPE_INPUT:
+         assert(prog->getType() == Program::TYPE_COMPUTE);
+         assert(idx == -1);
+         sym->setFile(FILE_SHADER_INPUT);
+         address += info->prop.cp.inputOffset;
+         break;
+      default:
+         assert(0); /* TODO: Add support for global and private memory */
+      }
+   }
 
    if (idx >= 0) {
       if (sym->reg.file == FILE_SHADER_INPUT)
Signature · 6 lines
2.7.2

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 1458118502-9016-3-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Reviewed-by
#7 lore raw

Re: [PATCH mesa v2 3/3] nouveau: codegen: Add support for clover / OpenCL kernel input parameters

Quoted 32 lines · Hans de Goede

Add support for clover / OpenCL kernel input parameters.

---
Changes in v2:

(quoted diff) +0 -3
-s/local/private/
-Add: Reviewed-by: Ilia Mirkin <[email protected]>
---
  .../drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp      | 18 +++++++++++++++---
  1 file changed, 15 insertions(+), 3 deletions(-)
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +8 -3
index fb7caca..8a1a426 100644
@@ -1527,9 +1527,21 @@ Converter::makeSym(uint tgsiFile, int fileIdx, int idx, int c, uint32_t address)
 
     sym->reg.fileIndex = fileIdx;
 
-   if (tgsiFile == TGSI_FILE_MEMORY &&
-       code->memoryFiles[fileIdx].mem_type == TGSI_MEMORY_TYPE_SHARED)
-      sym->setFile(FILE_MEMORY_SHARED);
+   if (tgsiFile == TGSI_FILE_MEMORY) {
+      switch (code->memoryFiles[fileIdx].mem_type) {
+      case TGSI_MEMORY_TYPE_SHARED:
+         sym->setFile(FILE_MEMORY_SHARED);
+         break;
+      case TGSI_MEMORY_TYPE_INPUT:
+         assert(prog->getType() == Program::TYPE_COMPUTE);
+         assert(idx == -1);

src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp Converter::makeSym(uint tgsiFile, int fileIdx, int idx, int c, uint32_t address) · line 1547

Quoted 10 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +7 -0
+         sym->setFile(FILE_SHADER_INPUT);
+         address += info->prop.cp.inputOffset;
+         break;
+      default:
+         assert(0); /* TODO: Add support for global and private memory */
+      }
+   }
 
     if (idx >= 0) {
        if (sym->reg.file == FILE_SHADER_INPUT)

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

Reviewed-by on v2 1/3
#8 lore raw
In reply to Hans de Goede
Quoted 36 lines · Hans de Goede

When support for decl.Atomic and .Shared was added, tgsi_build_declaration was not updated to propagate these properly.

---
Changes in v2:

(quoted diff) +0 -2
-Add Reviewed-by: Ilia Mirkin <[email protected]>
---
  src/gallium/auxiliary/tgsi/tgsi_build.c | 6 ++++++
  1 file changed, 6 insertions(+)
src/gallium/auxiliary/tgsi/tgsi_build.c +4 -0
index e5355f5..1cb95b9 100644
@@ -127,6 +127,8 @@ tgsi_build_declaration(
     unsigned invariant,
     unsigned local,
     unsigned array,
+   unsigned atomic,
+   unsigned shared,
     struct tgsi_header *header )
  {
     struct tgsi_declaration declaration;
@@ -143,6 +145,8 @@ tgsi_build_declaration(
     declaration.Invariant = invariant;
     declaration.Local = local;
     declaration.Array = array;
+   declaration.Atomic = atomic;
+   declaration.Shared = shared;
     header_bodysize_grow( header );
 
     return declaration;

src/gallium/auxiliary/tgsi/tgsi_build.c tgsi_build_full_declaration( · line 412

Quoted 8 lines
src/gallium/auxiliary/tgsi/tgsi_build.c +2 -0
@@ -401,6 +405,8 @@ tgsi_build_full_declaration(
        full_decl->Declaration.Invariant,
        full_decl->Declaration.Local,
        full_decl->Declaration.Array,
+      full_decl->Declaration.Atomic,
+      full_decl->Declaration.Shared,
        header );
 
     if (maxsize <= size)

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev