summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_ir.h
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-11-19 14:12:25 -0700
committerBrian Paul <brianp@vmware.com>2009-01-06 08:49:40 -0700
commite779e33261ca42c8acebac216e1b070782e730f2 (patch)
treed081a3ad45716255151dc44b2d3baf5f834666fb /src/mesa/shader/slang/slang_ir.h
parentef4bd18a50ec9989fdcff97c10721e748e897c7b (diff)
mesa: rework GLSL array code generation
We now express arrays in terms of indirect addressing. For example: dst = a[i]; becomes: MOV dst, TEMP[1 + TEMP[2].y]; At instruction-emit time indirect addressing is converted into ARL/ ADDR-relative form: ARL ADDR.x, TEMP[2].y; MOV dst, TEMP[1 + ADDR.x]; This fixes a number of array-related issues. Arrays of arrays and complex array/struct nesting works now. There may be some regressions, but more work is coming. (cherry picked from commit ae0ff8097b85d3537a7be1674d55a44a9bd6018e)
Diffstat (limited to 'src/mesa/shader/slang/slang_ir.h')
-rw-r--r--src/mesa/shader/slang/slang_ir.h57
1 files changed, 51 insertions, 6 deletions
diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h
index 4cd81f0fc7..cc784d431b 100644
--- a/src/mesa/shader/slang/slang_ir.h
+++ b/src/mesa/shader/slang/slang_ir.h
@@ -137,24 +137,53 @@ typedef enum
/**
- * Describes where data storage is allocated.
+ * Describes where data/variables are stored in the various register files.
+ *
+ * In the simple case, the File, Index and Size fields indicate where
+ * a variable is stored. For example, a vec3 variable may be stored
+ * as (File=PROGRAM_TEMPORARY, Index=6, Size=3). Or, File[Index].
+ * Or, a program input like color may be stored as
+ * (File=PROGRAM_INPUT,Index=3,Size=4);
+ *
+ * For single-float values, the Swizzle field indicates which component
+ * of the vector contains the float.
+ *
+ * If IsIndirect is set, the storage is accessed through an indirect
+ * register lookup. The value in question will be located at:
+ * File[Index + IndirectFile[IndirectIndex]]
+ *
+ * This is primary used for indexing arrays. For example, consider this
+ * GLSL code:
+ * uniform int i;
+ * float a[10];
+ * float x = a[i];
+ *
+ * here, storage for a[i] would be described by (File=PROGRAM_TEMPORAY,
+ * Index=aPos, IndirectFile=PROGRAM_UNIFORM, IndirectIndex=iPos), which
+ * would mean TEMP[aPos + UNIFORM[iPos]]
*/
-struct _slang_ir_storage
+struct slang_ir_storage_
{
enum register_file File; /**< PROGRAM_TEMPORARY, PROGRAM_INPUT, etc */
GLint Index; /**< -1 means unallocated */
GLint Size; /**< number of floats */
- GLuint Swizzle;
+ GLuint Swizzle; /**< Swizzle AND writemask info */
GLint RefCount; /**< Used during IR tree delete */
- GLboolean RelAddr;
+
+ GLboolean RelAddr; /* we'll remove this eventually */
+
+ GLboolean IsIndirect;
+ enum register_file IndirectFile;
+ GLint IndirectIndex;
+ GLuint IndirectSwizzle;
/** If Parent is non-null, Index is relative to parent.
* The other fields are ignored.
*/
- struct _slang_ir_storage *Parent;
+ struct slang_ir_storage_ *Parent;
};
-typedef struct _slang_ir_storage slang_ir_storage;
+typedef struct slang_ir_storage_ slang_ir_storage;
/**
@@ -196,6 +225,11 @@ extern const slang_ir_info *
_slang_ir_info(slang_ir_opcode opcode);
+extern void
+_slang_init_ir_storage(slang_ir_storage *st,
+ enum register_file file, GLint index, GLint size,
+ GLuint swizzle);
+
extern slang_ir_storage *
_slang_new_ir_storage(enum register_file file, GLint index, GLint size);
@@ -209,6 +243,17 @@ _slang_new_ir_storage_relative(GLint index, GLint size,
slang_ir_storage *parent);
+extern slang_ir_storage *
+_slang_new_ir_storage_indirect(enum register_file file,
+ GLint index,
+ GLint size,
+ enum register_file indirectFile,
+ GLint indirectIndex,
+ GLuint indirectSwizzle);
+
+extern void
+_slang_copy_ir_storage(slang_ir_storage *dst, const slang_ir_storage *src);
+
extern void
_slang_free_ir_tree(slang_ir_node *n);