diff options
Diffstat (limited to 'src/mesa/shader/slang/slang_storage.c')
-rw-r--r-- | src/mesa/shader/slang/slang_storage.c | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/src/mesa/shader/slang/slang_storage.c b/src/mesa/shader/slang/slang_storage.c index 946dc2e..34c6208 100644 --- a/src/mesa/shader/slang/slang_storage.c +++ b/src/mesa/shader/slang/slang_storage.c @@ -37,7 +37,7 @@ GLboolean slang_storage_array_construct (slang_storage_array *arr) { arr->type = slang_stor_aggregate; arr->aggregate = NULL; - arr->length = 0;
+ arr->length = 0; return GL_TRUE; } @@ -55,13 +55,13 @@ GLvoid slang_storage_array_destruct (slang_storage_array *arr) GLboolean slang_storage_aggregate_construct (slang_storage_aggregate *agg) { agg->arrays = NULL; - agg->count = 0;
+ agg->count = 0; return GL_TRUE; } GLvoid slang_storage_aggregate_destruct (slang_storage_aggregate *agg) { - GLuint i;
+ GLuint i; for (i = 0; i < agg->count; i++) slang_storage_array_destruct (agg->arrays + i); @@ -70,14 +70,14 @@ GLvoid slang_storage_aggregate_destruct (slang_storage_aggregate *agg) static slang_storage_array *slang_storage_aggregate_push_new (slang_storage_aggregate *agg) { - slang_storage_array *arr = NULL;
+ slang_storage_array *arr = NULL; agg->arrays = (slang_storage_array *) slang_alloc_realloc (agg->arrays, agg->count * sizeof ( slang_storage_array), (agg->count + 1) * sizeof (slang_storage_array)); if (agg->arrays != NULL) { arr = agg->arrays + agg->count; - if (!slang_storage_array_construct (arr))
+ if (!slang_storage_array_construct (arr)) return NULL; agg->count++; } @@ -100,7 +100,7 @@ static GLboolean aggregate_vector (slang_storage_aggregate *agg, slang_storage_t static GLboolean aggregate_matrix (slang_storage_aggregate *agg, slang_storage_type basic_type, GLuint dimension) { - slang_storage_array *arr = slang_storage_aggregate_push_new (agg);
+ slang_storage_array *arr = slang_storage_aggregate_push_new (agg); if (arr == NULL) return GL_FALSE; arr->type = slang_stor_aggregate; @@ -108,11 +108,11 @@ static GLboolean aggregate_matrix (slang_storage_aggregate *agg, slang_storage_t arr->aggregate = (slang_storage_aggregate *) slang_alloc_malloc (sizeof (slang_storage_aggregate)); if (arr->aggregate == NULL) return GL_FALSE; - if (!slang_storage_aggregate_construct (arr->aggregate))
- {
- slang_alloc_free (arr->aggregate);
- arr->aggregate = NULL;
- return GL_FALSE;
+ if (!slang_storage_aggregate_construct (arr->aggregate)) + { + slang_alloc_free (arr->aggregate); + arr->aggregate = NULL; + return GL_FALSE; } if (!aggregate_vector (arr->aggregate, basic_type, dimension)) return GL_FALSE; @@ -120,10 +120,10 @@ static GLboolean aggregate_matrix (slang_storage_aggregate *agg, slang_storage_t } static GLboolean aggregate_variables (slang_storage_aggregate *agg, slang_variable_scope *vars, - slang_function_scope *funcs, slang_struct_scope *structs, slang_variable_scope *globals,
+ slang_function_scope *funcs, slang_struct_scope *structs, slang_variable_scope *globals, slang_machine *mach, slang_assembly_file *file, slang_atom_pool *atoms) { - GLuint i;
+ GLuint i; for (i = 0; i < vars->num_variables; i++) if (!_slang_aggregate_variable (agg, &vars->variables[i].type.specifier, @@ -131,60 +131,60 @@ static GLboolean aggregate_variables (slang_storage_aggregate *agg, slang_variab return GL_FALSE; return GL_TRUE; } -
-GLboolean _slang_evaluate_int (slang_assembly_file *file, slang_machine *pmach,
- slang_assembly_name_space *space, slang_operation *array_size, GLuint *pint,
- slang_atom_pool *atoms)
-{
- slang_assembly_file_restore_point point;
- slang_machine mach;
- slang_assemble_ctx A;
-
- A.file = file;
- A.mach = pmach;
- A.atoms = atoms;
- A.space = *space;
- A.local.ret_size = 0;
- A.local.addr_tmp = 0;
- A.local.swizzle_tmp = 4;
-
- /* save the current assembly */
- if (!slang_assembly_file_restore_point_save (file, &point))
- return GL_FALSE;
-
- /* setup the machine */
- mach = *pmach;
- mach.ip = file->count;
-
- /* allocate local storage for expression */
- if (!slang_assembly_file_push_label (file, slang_asm_local_alloc, 20))
- return GL_FALSE;
- if (!slang_assembly_file_push_label (file, slang_asm_enter, 20))
- return GL_FALSE;
-
- /* insert the actual expression */
- if (!_slang_assemble_operation (&A, array_size, slang_ref_forbid))
- return GL_FALSE;
- if (!slang_assembly_file_push (file, slang_asm_exit))
- return GL_FALSE;
-
- /* execute the expression */
- if (!_slang_execute2 (file, &mach))
- return GL_FALSE;
-
- /* the evaluated expression is on top of the stack */
- *pint = (GLuint) mach.mem[mach.sp + SLANG_MACHINE_GLOBAL_SIZE]._float;
-
- /* restore the old assembly */
- if (!slang_assembly_file_restore_point_load (file, &point))
- return GL_FALSE;
-
- return GL_TRUE;
-}
+ +GLboolean _slang_evaluate_int (slang_assembly_file *file, slang_machine *pmach, + slang_assembly_name_space *space, slang_operation *array_size, GLuint *pint, + slang_atom_pool *atoms) +{ + slang_assembly_file_restore_point point; + slang_machine mach; + slang_assemble_ctx A; + + A.file = file; + A.mach = pmach; + A.atoms = atoms; + A.space = *space; + A.local.ret_size = 0; + A.local.addr_tmp = 0; + A.local.swizzle_tmp = 4; + + /* save the current assembly */ + if (!slang_assembly_file_restore_point_save (file, &point)) + return GL_FALSE; + + /* setup the machine */ + mach = *pmach; + mach.ip = file->count; + + /* allocate local storage for expression */ + if (!slang_assembly_file_push_label (file, slang_asm_local_alloc, 20)) + return GL_FALSE; + if (!slang_assembly_file_push_label (file, slang_asm_enter, 20)) + return GL_FALSE; + + /* insert the actual expression */ + if (!_slang_assemble_operation (&A, array_size, slang_ref_forbid)) + return GL_FALSE; + if (!slang_assembly_file_push (file, slang_asm_exit)) + return GL_FALSE; + + /* execute the expression */ + if (!_slang_execute2 (file, &mach)) + return GL_FALSE; + + /* the evaluated expression is on top of the stack */ + *pint = (GLuint) mach.mem[mach.sp + SLANG_MACHINE_GLOBAL_SIZE]._float; + + /* restore the old assembly */ + if (!slang_assembly_file_restore_point_load (file, &point)) + return GL_FALSE; + + return GL_TRUE; +} GLboolean _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_specifier *spec, GLuint array_len, slang_function_scope *funcs, slang_struct_scope *structs, - slang_variable_scope *vars, slang_machine *mach, slang_assembly_file *file,
+ slang_variable_scope *vars, slang_machine *mach, slang_assembly_file *file, slang_atom_pool *atoms) { switch (spec->type) @@ -227,11 +227,11 @@ GLboolean _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_sp case slang_spec_sampler2DShadow: return aggregate_vector (agg, slang_stor_int, 1); case slang_spec_struct: - return aggregate_variables (agg, spec->_struct->fields, funcs, structs, vars, mach,
+ return aggregate_variables (agg, spec->_struct->fields, funcs, structs, vars, mach, file, atoms); case slang_spec_array: { - slang_storage_array *arr;
+ slang_storage_array *arr; arr = slang_storage_aggregate_push_new (agg); if (arr == NULL) @@ -240,16 +240,16 @@ GLboolean _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_sp arr->aggregate = (slang_storage_aggregate *) slang_alloc_malloc (sizeof (slang_storage_aggregate)); if (arr->aggregate == NULL) return GL_FALSE; - if (!slang_storage_aggregate_construct (arr->aggregate))
- {
- slang_alloc_free (arr->aggregate);
- arr->aggregate = NULL;
- return GL_FALSE;
+ if (!slang_storage_aggregate_construct (arr->aggregate)) + { + slang_alloc_free (arr->aggregate); + arr->aggregate = NULL; + return GL_FALSE; } - if (!_slang_aggregate_variable (arr->aggregate, spec->_array, 0, funcs, structs,
+ if (!_slang_aggregate_variable (arr->aggregate, spec->_array, 0, funcs, structs, vars, mach, file, atoms)) - return GL_FALSE;
- arr->length = array_len;
+ return GL_FALSE; + arr->length = array_len; /* TODO: check if 0 < arr->length <= 65535 */ } return GL_TRUE; @@ -262,11 +262,11 @@ GLboolean _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_sp GLuint _slang_sizeof_aggregate (const slang_storage_aggregate *agg) { - GLuint i, size = 0;
+ GLuint i, size = 0; for (i = 0; i < agg->count; i++) { - GLuint element_size;
+ GLuint element_size; if (agg->arrays[i].type == slang_stor_aggregate) element_size = _slang_sizeof_aggregate (agg->arrays[i].aggregate); @@ -281,11 +281,11 @@ GLuint _slang_sizeof_aggregate (const slang_storage_aggregate *agg) GLboolean _slang_flatten_aggregate (slang_storage_aggregate *flat, const slang_storage_aggregate *agg) { - GLuint i;
+ GLuint i; for (i = 0; i < agg->count; i++) { - GLuint j;
+ GLuint j; for (j = 0; j < agg->arrays[i].length; j++) { @@ -296,7 +296,7 @@ GLboolean _slang_flatten_aggregate (slang_storage_aggregate *flat, const slang_s } else { - slang_storage_array *arr;
+ slang_storage_array *arr; arr = slang_storage_aggregate_push_new (flat); if (arr == NULL) |