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

2016-03-16 Thread Samuel Pitoiset

Reviewed-by: Samuel Pitoiset 

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


Reviewed-by: XXX (v1)

On 03/16/2016 09:55 AM, Hans de Goede wrote:

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.

Signed-off-by: Hans de Goede 
Reviewed-by: Ilia Mirkin 
---
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 
---
  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(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c 
b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 1cb95b9..a3e659b 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -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)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c 
b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index c8b91bb..6d39ef2 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -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) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c 
b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 77598d2..028633c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -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(, "SHARED")) {
-decl.Declaration.Shared = 1;
+ if (str_match_nocase_whole(, "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(, "SHARED")) {
+decl.Declaration.MemType = TGSI_MEMORY_TYPE_SHARED;
+ctx->cur = cur;
+ } else if (str_match_nocase_whole(, "PRIVATE")) {
+decl.Declaration.MemType = TGSI_MEMORY_TYPE_PRIVATE;
+ctx->cur = cur;
+ } else if (str_match_nocase_whole(, "INPUT")) {
+decl.Declaration.MemType = TGSI_MEMORY_TYPE_INPUT;
  ctx->cur = cur;
   }
} else {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index ab1d034..495db9f 100644
--- 

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

2016-03-16 Thread 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.

Signed-off-by: Hans de Goede 
Reviewed-by: Ilia Mirkin 
---
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 
---
 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(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c 
b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 1cb95b9..a3e659b 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -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)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c 
b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index c8b91bb..6d39ef2 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -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) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c 
b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 77598d2..028633c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -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(, "SHARED")) {
-decl.Declaration.Shared = 1;
+ if (str_match_nocase_whole(, "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(, "SHARED")) {
+decl.Declaration.MemType = TGSI_MEMORY_TYPE_SHARED;
+ctx->cur = cur;
+ } else if (str_match_nocase_whole(, "PRIVATE")) {
+decl.Declaration.MemType = TGSI_MEMORY_TYPE_PRIVATE;
+ctx->cur = cur;
+ } else if (str_match_nocase_whole(, "INPUT")) {
+decl.Declaration.MemType = TGSI_MEMORY_TYPE_INPUT;
 ctx->cur = cur;
  }
   } else {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c 
b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index ab1d034..495db9f 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -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