diff options
author | Brian Paul <[email protected]> | 2008-11-19 14:12:25 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-11-19 14:12:25 -0700 |
commit | ae0ff8097b85d3537a7be1674d55a44a9bd6018e (patch) | |
tree | 61c822bc84183fce03a329893daaf19d548eb278 /src/mesa/shader/slang/slang_ir.h | |
parent | e709d68d92ef6f2392b118d0a22452e8f4c53e9a (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.
Diffstat (limited to 'src/mesa/shader/slang/slang_ir.h')
-rw-r--r-- | src/mesa/shader/slang/slang_ir.h | 57 |
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 a4552ae1442..a258e92e06f 100644 --- a/src/mesa/shader/slang/slang_ir.h +++ b/src/mesa/shader/slang/slang_ir.h @@ -140,24 +140,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; /** @@ -199,6 +228,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); @@ -212,6 +246,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); |