diff options
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); |