From 589a3a3f6e9c7191462b0123976847b5ab776f65 Mon Sep 17 00:00:00 2001 From: Jouk Jansen Date: Wed, 1 Jun 2005 12:05:34 +0000 Subject: Committing in . Update OpneVMS compilesupport Modified Files: Mesa/src/mesa/shader/descrip.mms Mesa/src/mesa/shader/slang/descrip.mms Mesa/src/mesa/shader/slang/slang_compile.c Mesa/src/mesa/shader/slang/slang_storage.c Mesa/src/mesa/shader/slang/slang_storage.h ---------------------------------------------------------------------- --- src/mesa/shader/slang/descrip.mms | 7 +- src/mesa/shader/slang/slang_compile.c | 20 +- src/mesa/shader/slang/slang_storage.c | 510 +++++++++++++++++----------------- src/mesa/shader/slang/slang_storage.h | 218 +++++++-------- 4 files changed, 378 insertions(+), 377 deletions(-) (limited to 'src/mesa/shader/slang') diff --git a/src/mesa/shader/slang/descrip.mms b/src/mesa/shader/slang/descrip.mms index 2a7683ad3a..6f2b90296c 100644 --- a/src/mesa/shader/slang/descrip.mms +++ b/src/mesa/shader/slang/descrip.mms @@ -1,6 +1,6 @@ # Makefile for core library for VMS # contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl -# Last revision : 20 May 2005 +# Last revision : 1 June 2005 .first define gl [----.include.gl] @@ -14,7 +14,7 @@ VPATH = RCS -INCDIR = [----.include],[--.main],[--.glapi],[-.slang],[-] +INCDIR = [----.include],[--.main],[--.glapi],[-.slang],[-.grammar],[-] LIBDIR = [----.lib] CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short) @@ -25,7 +25,7 @@ OBJECTS = \ slang_compile.obj,slang_preprocess.obj,slang_utility.obj,\ slang_execute.obj,slang_assemble.obj,slang_assemble_conditional.obj,\ slang_assemble_constructor.obj,slang_assemble_typeinfo.obj,\ - slang_storage.obj + slang_storage.obj,slang_assemble_assignment.obj ##### RULES ##### @@ -49,3 +49,4 @@ slang_assemble_conditional.obj : slang_assemble_conditional.c slang_assemble_constructor.obj : slang_assemble_constructor.c slang_assemble_typeinfo.obj : slang_assemble_typeinfo.c slang_storage.obj : slang_storage.c +slang_assemble_assignment.obj : slang_assemble_assignment.c diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index ed82712b20..2377173cf0 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2103,7 +2103,7 @@ if (x == 1) space.structs = structs; space.vars = scope; if (x == 1) -xxx_first (&file); +xxx_first (&file); (**parsed_func_ret).address = file.count; if (!_slang_assemble_function (&file, *parsed_func_ret, &space)) { @@ -2111,7 +2111,7 @@ xxx_first (&file); return 0; } if (slang_string_compare ("main", (**parsed_func_ret).header.name) == 0) -{ +{ xxx_prolog (&file, (**parsed_func_ret).address); _slang_execute (&file); slang_assembly_file_destruct (&file); @@ -2254,9 +2254,9 @@ static const char *slang_shader_syn = static const byte slang_core_gc_bin[] = { #include "library/slang_core_gc_bin.h" };*/ -static const byte slang_core_gc[] = { -#include "library/slang_core_gc.h" -}; +static const byte slang_core_gc[] = { +#include "library/slang_core_gc.h" +}; static const byte slang_common_builtin_gc_bin[] = { #include "library/slang_common_builtin_gc_bin.h" @@ -2269,7 +2269,7 @@ static const byte slang_fragment_builtin_gc_bin[] = { static const byte slang_vertex_builtin_gc_bin[] = { #include "library/slang_vertex_builtin_gc_bin.h" }; - + int _slang_compile (const char *source, slang_translation_unit *unit, slang_unit_type type, slang_info_log *log) { @@ -2301,8 +2301,8 @@ int _slang_compile (const char *source, slang_translation_unit *unit, slang_unit if (type == slang_unit_fragment_shader || type == slang_unit_vertex_shader) { /*if (!compile_binary (slang_core_gc_bin, builtin_units, - slang_unit_fragment_builtin, log, NULL))*/ - if (!compile_with_grammar (id, slang_core_gc, builtin_units, slang_unit_fragment_builtin, + slang_unit_fragment_builtin, log, NULL))*/ + if (!compile_with_grammar (id, (const char*) slang_core_gc, builtin_units, slang_unit_fragment_builtin, log, NULL)) { grammar_destroy (id); @@ -2318,7 +2318,7 @@ int _slang_compile (const char *source, slang_translation_unit *unit, slang_unit if (type == slang_unit_fragment_shader) { if (!compile_binary (slang_fragment_builtin_gc_bin, builtin_units + 2, - slang_unit_fragment_builtin, log, NULL)) + slang_unit_fragment_builtin, log, NULL)) { slang_translation_unit_destruct (builtin_units); slang_translation_unit_destruct (builtin_units + 1); @@ -2329,7 +2329,7 @@ int _slang_compile (const char *source, slang_translation_unit *unit, slang_unit else if (type == slang_unit_vertex_shader) { if (!compile_binary (slang_vertex_builtin_gc_bin, builtin_units + 2, - slang_unit_vertex_builtin, log, NULL)) + slang_unit_vertex_builtin, log, NULL)) { slang_translation_unit_destruct (builtin_units); slang_translation_unit_destruct (builtin_units + 1); diff --git a/src/mesa/shader/slang/slang_storage.c b/src/mesa/shader/slang/slang_storage.c index f06147556e..3b2fda415b 100644 --- a/src/mesa/shader/slang/slang_storage.c +++ b/src/mesa/shader/slang/slang_storage.c @@ -1,255 +1,255 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file slang_storage.c - * slang variable storage - * \author Michal Krol - */ - -#include "imports.h" -#include "slang_utility.h" -#include "slang_storage.h" -#include "slang_assemble.h" - -/* slang_storage_array */ - -void slang_storage_array_construct (slang_storage_array *arr) -{ - arr->type = slang_stor_aggregate; - arr->aggregate = NULL; - arr->length = 0; -} - -void slang_storage_array_destruct (slang_storage_array *arr) -{ - if (arr->aggregate != NULL) - { - slang_storage_aggregate_destruct (arr->aggregate); - slang_alloc_free (arr->aggregate); - } -} - -/* slang_storage_aggregate */ - -void slang_storage_aggregate_construct (slang_storage_aggregate *agg) -{ - agg->arrays = NULL; - agg->count = 0; -} - -void slang_storage_aggregate_destruct (slang_storage_aggregate *agg) -{ - unsigned int i; - for (i = 0; i < agg->count; i++) - slang_storage_array_destruct (agg->arrays + i); - slang_alloc_free (agg->arrays); -} - -static slang_storage_array *slang_storage_aggregate_push_new (slang_storage_aggregate *agg) -{ - 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; - slang_storage_array_construct (arr); - agg->count++; - } - return arr; -} - -/* _slang_aggregate_variable() */ - -static int aggregate_vector (slang_storage_aggregate *agg, slang_storage_type basic_type, - unsigned int row_count) -{ - slang_storage_array *arr = slang_storage_aggregate_push_new (agg); - if (arr == NULL) - return 0; - arr->type = basic_type; - arr->length = row_count; - return 1; -} - -static int aggregate_matrix (slang_storage_aggregate *agg, slang_storage_type basic_type, - unsigned int dimension) -{ - slang_storage_array *arr = slang_storage_aggregate_push_new (agg); - if (arr == NULL) - return 0; - arr->type = slang_stor_aggregate; - arr->length = dimension; - arr->aggregate = (slang_storage_aggregate *) slang_alloc_malloc (sizeof ( - slang_storage_aggregate)); - if (arr->aggregate == NULL) - return 0; - slang_storage_aggregate_construct (arr->aggregate); - if (!aggregate_vector (arr->aggregate, basic_type, dimension)) - return 0; - return 1; -} - -static int aggregate_variables (slang_storage_aggregate *agg, const slang_variable_scope *vars, - slang_function_scope *funcs, slang_struct_scope *structs) -{ - unsigned int i; - for (i = 0; i < vars->num_variables; i++) - if (!_slang_aggregate_variable (agg, &vars->variables[i].type.specifier, - vars->variables[i].array_size, funcs, structs)) - return 0; - return 1; -} - -int _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_specifier *spec, - slang_operation *array_size, slang_function_scope *funcs, slang_struct_scope *structs) -{ - switch (spec->type) - { - case slang_spec_bool: - return aggregate_vector (agg, slang_stor_bool, 1); - case slang_spec_bvec2: - return aggregate_vector (agg, slang_stor_bool, 2); - case slang_spec_bvec3: - return aggregate_vector (agg, slang_stor_bool, 3); - case slang_spec_bvec4: - return aggregate_vector (agg, slang_stor_bool, 4); - case slang_spec_int: - return aggregate_vector (agg, slang_stor_int, 1); - case slang_spec_ivec2: - return aggregate_vector (agg, slang_stor_int, 2); - case slang_spec_ivec3: - return aggregate_vector (agg, slang_stor_int, 3); - case slang_spec_ivec4: - return aggregate_vector (agg, slang_stor_int, 4); - case slang_spec_float: - return aggregate_vector (agg, slang_stor_float, 1); - case slang_spec_vec2: - return aggregate_vector (agg, slang_stor_float, 2); - case slang_spec_vec3: - return aggregate_vector (agg, slang_stor_float, 3); - case slang_spec_vec4: - return aggregate_vector (agg, slang_stor_float, 4); - case slang_spec_mat2: - return aggregate_matrix (agg, slang_stor_float, 2); - case slang_spec_mat3: - return aggregate_matrix (agg, slang_stor_float, 3); - case slang_spec_mat4: - return aggregate_matrix (agg, slang_stor_float, 4); - case slang_spec_sampler1D: - case slang_spec_sampler2D: - case slang_spec_sampler3D: - case slang_spec_samplerCube: - case slang_spec_sampler1DShadow: - 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); - case slang_spec_array: - { - slang_storage_array *arr; - slang_assembly_file file; - slang_assembly_flow_control flow; - slang_assembly_name_space space; - slang_assembly_local_info info; - slang_assembly_stack_info stk; - - arr = slang_storage_aggregate_push_new (agg); - if (arr == NULL) - return 0; - arr->type = slang_stor_aggregate; - arr->aggregate = (slang_storage_aggregate *) slang_alloc_malloc (sizeof ( - slang_storage_aggregate)); - if (arr->aggregate == NULL) - return 0; - slang_storage_aggregate_construct (arr->aggregate); - if (!_slang_aggregate_variable (arr->aggregate, spec->_array, NULL, funcs, structs)) - return 0; - slang_assembly_file_construct (&file); - space.funcs = funcs; - space.structs = structs; - /* XXX: vars! */ - space.vars = NULL; - if (!_slang_assemble_operation (&file, array_size, 0, &flow, &space, &info, &stk)) - { - slang_assembly_file_destruct (&file); - return 0; - } - /* TODO: evaluate array size */ - slang_assembly_file_destruct (&file); - arr->length = 256; - } - return 1; - default: - return 0; - } -} - -/* _slang_sizeof_aggregate() */ - -unsigned int _slang_sizeof_aggregate (const slang_storage_aggregate *agg) -{ - unsigned int i, size = 0; - for (i = 0; i < agg->count; i++) - { - unsigned int element_size; - if (agg->arrays[i].type == slang_stor_aggregate) - element_size = _slang_sizeof_aggregate (agg->arrays[i].aggregate); - else - element_size = sizeof (GLfloat); - size += element_size * agg->arrays[i].length; - } - return size; -} - -/* _slang_flatten_aggregate () */ - -int _slang_flatten_aggregate (slang_storage_aggregate *flat, const slang_storage_aggregate *agg) -{ - unsigned int i; - for (i = 0; i < agg->count; i++) - { - unsigned int j; - for (j = 0; j < agg->arrays[i].length; j++) - { - if (agg->arrays[i].type == slang_stor_aggregate) - { - if (!_slang_flatten_aggregate (flat, agg->arrays[i].aggregate)) - return 0; - } - else - { - slang_storage_array *arr; - arr = slang_storage_aggregate_push_new (flat); - if (arr == NULL) - return 0; - arr->type = agg->arrays[i].type; - arr->length = 1; - } - } - } - return 1; -} - +/* + * Mesa 3-D graphics library + * Version: 6.3 + * + * Copyright (C) 2005 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file slang_storage.c + * slang variable storage + * \author Michal Krol + */ + +#include "imports.h" +#include "slang_utility.h" +#include "slang_storage.h" +#include "slang_assemble.h" + +/* slang_storage_array */ + +void slang_storage_array_construct (slang_storage_array *arr) +{ + arr->type = slang_stor_aggregate; + arr->aggregate = NULL; + arr->length = 0; +} + +void slang_storage_array_destruct (slang_storage_array *arr) +{ + if (arr->aggregate != NULL) + { + slang_storage_aggregate_destruct (arr->aggregate); + slang_alloc_free (arr->aggregate); + } +} + +/* slang_storage_aggregate */ + +void slang_storage_aggregate_construct (slang_storage_aggregate *agg) +{ + agg->arrays = NULL; + agg->count = 0; +} + +void slang_storage_aggregate_destruct (slang_storage_aggregate *agg) +{ + unsigned int i; + for (i = 0; i < agg->count; i++) + slang_storage_array_destruct (agg->arrays + i); + slang_alloc_free (agg->arrays); +} + +static slang_storage_array *slang_storage_aggregate_push_new (slang_storage_aggregate *agg) +{ + 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; + slang_storage_array_construct (arr); + agg->count++; + } + return arr; +} + +/* _slang_aggregate_variable() */ + +static int aggregate_vector (slang_storage_aggregate *agg, slang_storage_type basic_type, + unsigned int row_count) +{ + slang_storage_array *arr = slang_storage_aggregate_push_new (agg); + if (arr == NULL) + return 0; + arr->type = basic_type; + arr->length = row_count; + return 1; +} + +static int aggregate_matrix (slang_storage_aggregate *agg, slang_storage_type basic_type, + unsigned int dimension) +{ + slang_storage_array *arr = slang_storage_aggregate_push_new (agg); + if (arr == NULL) + return 0; + arr->type = slang_stor_aggregate; + arr->length = dimension; + arr->aggregate = (slang_storage_aggregate *) slang_alloc_malloc (sizeof ( + slang_storage_aggregate)); + if (arr->aggregate == NULL) + return 0; + slang_storage_aggregate_construct (arr->aggregate); + if (!aggregate_vector (arr->aggregate, basic_type, dimension)) + return 0; + return 1; +} + +static int aggregate_variables (slang_storage_aggregate *agg, const slang_variable_scope *vars, + slang_function_scope *funcs, slang_struct_scope *structs) +{ + unsigned int i; + for (i = 0; i < vars->num_variables; i++) + if (!_slang_aggregate_variable (agg, &vars->variables[i].type.specifier, + vars->variables[i].array_size, funcs, structs)) + return 0; + return 1; +} + +int _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_specifier *spec, + slang_operation *array_size, slang_function_scope *funcs, slang_struct_scope *structs) +{ + switch (spec->type) + { + case slang_spec_bool: + return aggregate_vector (agg, slang_stor_bool, 1); + case slang_spec_bvec2: + return aggregate_vector (agg, slang_stor_bool, 2); + case slang_spec_bvec3: + return aggregate_vector (agg, slang_stor_bool, 3); + case slang_spec_bvec4: + return aggregate_vector (agg, slang_stor_bool, 4); + case slang_spec_int: + return aggregate_vector (agg, slang_stor_int, 1); + case slang_spec_ivec2: + return aggregate_vector (agg, slang_stor_int, 2); + case slang_spec_ivec3: + return aggregate_vector (agg, slang_stor_int, 3); + case slang_spec_ivec4: + return aggregate_vector (agg, slang_stor_int, 4); + case slang_spec_float: + return aggregate_vector (agg, slang_stor_float, 1); + case slang_spec_vec2: + return aggregate_vector (agg, slang_stor_float, 2); + case slang_spec_vec3: + return aggregate_vector (agg, slang_stor_float, 3); + case slang_spec_vec4: + return aggregate_vector (agg, slang_stor_float, 4); + case slang_spec_mat2: + return aggregate_matrix (agg, slang_stor_float, 2); + case slang_spec_mat3: + return aggregate_matrix (agg, slang_stor_float, 3); + case slang_spec_mat4: + return aggregate_matrix (agg, slang_stor_float, 4); + case slang_spec_sampler1D: + case slang_spec_sampler2D: + case slang_spec_sampler3D: + case slang_spec_samplerCube: + case slang_spec_sampler1DShadow: + 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); + case slang_spec_array: + { + slang_storage_array *arr; + slang_assembly_file file; + slang_assembly_flow_control flow; + slang_assembly_name_space space; + slang_assembly_local_info info; + slang_assembly_stack_info stk; + + arr = slang_storage_aggregate_push_new (agg); + if (arr == NULL) + return 0; + arr->type = slang_stor_aggregate; + arr->aggregate = (slang_storage_aggregate *) slang_alloc_malloc (sizeof ( + slang_storage_aggregate)); + if (arr->aggregate == NULL) + return 0; + slang_storage_aggregate_construct (arr->aggregate); + if (!_slang_aggregate_variable (arr->aggregate, spec->_array, NULL, funcs, structs)) + return 0; + slang_assembly_file_construct (&file); + space.funcs = funcs; + space.structs = structs; + /* XXX: vars! */ + space.vars = NULL; + if (!_slang_assemble_operation (&file, array_size, 0, &flow, &space, &info, &stk)) + { + slang_assembly_file_destruct (&file); + return 0; + } + /* TODO: evaluate array size */ + slang_assembly_file_destruct (&file); + arr->length = 256; + } + return 1; + default: + return 0; + } +} + +/* _slang_sizeof_aggregate() */ + +unsigned int _slang_sizeof_aggregate (const slang_storage_aggregate *agg) +{ + unsigned int i, size = 0; + for (i = 0; i < agg->count; i++) + { + unsigned int element_size; + if (agg->arrays[i].type == slang_stor_aggregate) + element_size = _slang_sizeof_aggregate (agg->arrays[i].aggregate); + else + element_size = sizeof (GLfloat); + size += element_size * agg->arrays[i].length; + } + return size; +} + +/* _slang_flatten_aggregate () */ + +int _slang_flatten_aggregate (slang_storage_aggregate *flat, const slang_storage_aggregate *agg) +{ + unsigned int i; + for (i = 0; i < agg->count; i++) + { + unsigned int j; + for (j = 0; j < agg->arrays[i].length; j++) + { + if (agg->arrays[i].type == slang_stor_aggregate) + { + if (!_slang_flatten_aggregate (flat, agg->arrays[i].aggregate)) + return 0; + } + else + { + slang_storage_array *arr; + arr = slang_storage_aggregate_push_new (flat); + if (arr == NULL) + return 0; + arr->type = agg->arrays[i].type; + arr->length = 1; + } + } + } + return 1; +} + diff --git a/src/mesa/shader/slang/slang_storage.h b/src/mesa/shader/slang/slang_storage.h index c1b123f2a0..77962c1986 100644 --- a/src/mesa/shader/slang/slang_storage.h +++ b/src/mesa/shader/slang/slang_storage.h @@ -1,109 +1,109 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 2005 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#if !defined SLANG_STORAGE_H -#define SLANG_STORAGE_H - -#include "slang_compile.h" - -#if defined __cplusplus -extern "C" { -#endif - -/* - Program variable data storage is kept completely transparent to the front-end compiler. It is - up to the back-end how the data is actually allocated. The slang_storage_type enum - provides the basic information about how the memory is interpreted. This abstract piece - of memory is called a data slot. A data slot of a particular type has a fixed size. - - For now, only the three basic types are supported, that is bool, int and float. Other built-in - types like vector or matrix can easily be decomposed into a series of basic types. -*/ -typedef enum slang_storage_type_ -{ - slang_stor_aggregate, - slang_stor_bool, - slang_stor_int, - slang_stor_float -} slang_storage_type; - -/* - The slang_storage_array structure groups data slots of the same type into an array. This - array has a fixed length. Arrays are required to have a size equal to the sum of sizes of its - elements. They are also required to support indirect addressing. That is, if B references - first data slot in the array, S is the size of the data slot and I is the integral index that - is not known at compile time, B+I*S references I-th data slot. - - This structure is also used to break down built-in data types that are not supported directly. - Vectors, like vec3, are constructed from arrays of their basic types. Matrices are formed of - an array of column vectors, which are in turn processed as other vectors. -*/ -typedef struct slang_storage_array_ -{ - slang_storage_type type; - struct slang_storage_aggregate_ *aggregate; /* slang_stor_aggregate */ - unsigned int length; -} slang_storage_array; - -void slang_storage_array_construct (slang_storage_array *); -void slang_storage_array_destruct (slang_storage_array *); - -/* - The slang_storage_aggregate structure relaxes the indirect addressing requirement for - slang_storage_array structure. Aggregates are always accessed statically - its member - addresses are well-known at compile time. For example, user-defined types are implemented as - aggregates. Aggregates can collect data of a different type. -*/ -typedef struct slang_storage_aggregate_ -{ - slang_storage_array *arrays; - unsigned int count; -} slang_storage_aggregate; - -void slang_storage_aggregate_construct (slang_storage_aggregate *); -void slang_storage_aggregate_destruct (slang_storage_aggregate *); - -int _slang_aggregate_variable (slang_storage_aggregate *, struct slang_type_specifier_ *, - struct slang_operation_ *, struct slang_function_scope_ *, slang_struct_scope *); - -/* - returns total size (in machine units) of the given aggregate - returns 0 on error -*/ -unsigned int _slang_sizeof_aggregate (const slang_storage_aggregate *); - -/* - converts structured aggregate to a flat one, with arrays of generic type being - one-element long - returns 1 on success - returns 0 otherwise -*/ -int _slang_flatten_aggregate (slang_storage_aggregate *, const slang_storage_aggregate *); - -#ifdef __cplusplus -} -#endif - -#endif - +/* + * Mesa 3-D graphics library + * Version: 6.3 + * + * Copyright (C) 2005 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#if !defined SLANG_STORAGE_H +#define SLANG_STORAGE_H + +#include "slang_compile.h" + +#if defined __cplusplus +extern "C" { +#endif + +/* + Program variable data storage is kept completely transparent to the front-end compiler. It is + up to the back-end how the data is actually allocated. The slang_storage_type enum + provides the basic information about how the memory is interpreted. This abstract piece + of memory is called a data slot. A data slot of a particular type has a fixed size. + + For now, only the three basic types are supported, that is bool, int and float. Other built-in + types like vector or matrix can easily be decomposed into a series of basic types. +*/ +typedef enum slang_storage_type_ +{ + slang_stor_aggregate, + slang_stor_bool, + slang_stor_int, + slang_stor_float +} slang_storage_type; + +/* + The slang_storage_array structure groups data slots of the same type into an array. This + array has a fixed length. Arrays are required to have a size equal to the sum of sizes of its + elements. They are also required to support indirect addressing. That is, if B references + first data slot in the array, S is the size of the data slot and I is the integral index that + is not known at compile time, B+I*S references I-th data slot. + + This structure is also used to break down built-in data types that are not supported directly. + Vectors, like vec3, are constructed from arrays of their basic types. Matrices are formed of + an array of column vectors, which are in turn processed as other vectors. +*/ +typedef struct slang_storage_array_ +{ + slang_storage_type type; + struct slang_storage_aggregate_ *aggregate; /* slang_stor_aggregate */ + unsigned int length; +} slang_storage_array; + +void slang_storage_array_construct (slang_storage_array *); +void slang_storage_array_destruct (slang_storage_array *); + +/* + The slang_storage_aggregate structure relaxes the indirect addressing requirement for + slang_storage_array structure. Aggregates are always accessed statically - its member + addresses are well-known at compile time. For example, user-defined types are implemented as + aggregates. Aggregates can collect data of a different type. +*/ +typedef struct slang_storage_aggregate_ +{ + slang_storage_array *arrays; + unsigned int count; +} slang_storage_aggregate; + +void slang_storage_aggregate_construct (slang_storage_aggregate *); +void slang_storage_aggregate_destruct (slang_storage_aggregate *); + +int _slang_aggregate_variable (slang_storage_aggregate *, struct slang_type_specifier_ *, + struct slang_operation_ *, struct slang_function_scope_ *, slang_struct_scope *); + +/* + returns total size (in machine units) of the given aggregate + returns 0 on error +*/ +unsigned int _slang_sizeof_aggregate (const slang_storage_aggregate *); + +/* + converts structured aggregate to a flat one, with arrays of generic type being + one-element long + returns 1 on success + returns 0 otherwise +*/ +int _slang_flatten_aggregate (slang_storage_aggregate *, const slang_storage_aggregate *); + +#ifdef __cplusplus +} +#endif + +#endif + -- cgit v1.2.3