declaration.Local = 0;
declaration.Array = 0;
declaration.Atomic = 0;
- declaration.Shared = 0;
+ declaration.MemType = TGSI_MEMORY_TYPE_GLOBAL;
declaration.Padding = 0;
return declaration;
unsigned local,
unsigned array,
unsigned atomic,
- unsigned shared,
+ unsigned mem_type,
struct tgsi_header *header )
{
struct tgsi_declaration declaration;
declaration.Local = local;
declaration.Array = array;
declaration.Atomic = atomic;
- declaration.Shared = shared;
+ declaration.MemType = mem_type;
header_bodysize_grow( header );
return 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)
}
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) {
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 {
struct ureg_tokens domain[2];
- bool use_shared_memory;
+ bool use_memory[TGSI_MEMORY_TYPE_COUNT];
};
static union tgsi_any_token error_tokens[32];
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;
}
}
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);
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
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++) {
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,
std::vector<Resource> resources;
struct MemoryFile {
- bool shared;
+ uint8_t mem_type; // TGSI_MEMORY_TYPE_*
};
std::vector<MemoryFile> memoryFiles;
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:
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) {
#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 */
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
}
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)) {