From aff8e204d205b5d424d2c39a5d9e004caaa1eab1 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 13 Dec 2006 14:48:36 -0700 Subject: Checkpoint new GLSL compiler back-end to produce fp/vp-style assembly instructions. --- src/mesa/shader/slang/slang_assemble_assignment.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/mesa/shader/slang/slang_assemble_assignment.c') diff --git a/src/mesa/shader/slang/slang_assemble_assignment.c b/src/mesa/shader/slang/slang_assemble_assignment.c index a1038671c4..dbcc4bcf9d 100644 --- a/src/mesa/shader/slang/slang_assemble_assignment.c +++ b/src/mesa/shader/slang/slang_assemble_assignment.c @@ -31,6 +31,7 @@ #include "imports.h" #include "slang_assemble.h" #include "slang_storage.h" +#include "slang_error.h" /* * _slang_assemble_assignment() @@ -95,9 +96,9 @@ assign_basic(slang_assemble_ctx * A, slang_storage_type type, GLuint * index, */ dst_addr_loc = size - *index; - if (!slang_assembly_file_push_label2 - (A->file, ty, dst_addr_loc, dst_offset)) - return GL_FALSE; + if (!slang_assembly_file_push_label2(A->file, ty, dst_addr_loc, dst_offset)) + RETURN_NIL(); + *index += _slang_sizeof_type(type); return GL_TRUE; @@ -155,7 +156,7 @@ _slang_assemble_assignment(slang_assemble_ctx * A, const slang_operation * op) GLuint index, size; if (!slang_assembly_typeinfo_construct(&ti)) - return GL_FALSE; + RETURN_OUT_OF_MEMORY(); if (!_slang_typeof_operation(A, op, &ti)) goto end1; @@ -174,6 +175,8 @@ _slang_assemble_assignment(slang_assemble_ctx * A, const slang_operation * op) slang_storage_aggregate_destruct(&agg); end: slang_assembly_typeinfo_destruct(&ti); + if (!result) + RETURN_NIL(); return result; } -- cgit v1.2.3 From d9d33b6fc883ede7ef231965e0b27792c8e58299 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 31 Jan 2007 17:01:52 -0700 Subject: disable all x86 code, broken and will eventually be removed --- src/mesa/shader/slang/slang_assemble.c | 4 ++-- src/mesa/shader/slang/slang_assemble_assignment.c | 2 +- src/mesa/shader/slang/slang_compile.c | 5 ++--- src/mesa/shader/slang/slang_compile.h | 2 +- src/mesa/shader/slang/slang_execute.c | 6 +++--- src/mesa/shader/slang/slang_execute.h | 6 +++--- src/mesa/shader/slang/slang_execute_x86.c | 4 +++- src/mesa/shader/slang/slang_storage.c | 4 ++-- 8 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src/mesa/shader/slang/slang_assemble_assignment.c') diff --git a/src/mesa/shader/slang/slang_assemble.c b/src/mesa/shader/slang/slang_assemble.c index a9d2baedb9..27249078b3 100644 --- a/src/mesa/shader/slang/slang_assemble.c +++ b/src/mesa/shader/slang/slang_assemble.c @@ -481,7 +481,7 @@ dereference_basic(slang_assemble_ctx * A, slang_storage_type type, case slang_stor_float: ty = slang_asm_float_deref; break; -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ case slang_stor_vec4: ty = slang_asm_vec4_deref; break; @@ -829,7 +829,7 @@ equality_aggregate(slang_assemble_ctx * A, return GL_FALSE; } else { -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ if (arr->type == slang_stor_vec4) { if (!PLAB2(A->file, slang_asm_vec4_equal_int, size + *index, *index)) diff --git a/src/mesa/shader/slang/slang_assemble_assignment.c b/src/mesa/shader/slang/slang_assemble_assignment.c index dbcc4bcf9d..bfce04ec88 100644 --- a/src/mesa/shader/slang/slang_assemble_assignment.c +++ b/src/mesa/shader/slang/slang_assemble_assignment.c @@ -79,7 +79,7 @@ assign_basic(slang_assemble_ctx * A, slang_storage_type type, GLuint * index, case slang_stor_float: ty = slang_asm_float_copy; break; -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ case slang_stor_vec4: ty = slang_asm_vec4_copy; break; diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 43f8a30369..65329c9db1 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2137,8 +2137,7 @@ static const byte slang_vertex_builtin_gc[] = { #include "library/slang_vertex_builtin_gc.h" }; -#if defined(USE_X86_ASM) || defined(SLANG_X86) -foo +#if 0 /*defined(USE_X86_ASM) || defined(SLANG_X86)*/ static const byte slang_builtin_vec4_gc[] = { #include "library/slang_builtin_vec4_gc.h" }; @@ -2204,7 +2203,7 @@ compile_object(grammar * id, const char *source, slang_code_object * object, return GL_FALSE; } -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ /* compile x86 4-component vector overrides, link to target */ if (!compile_binary(slang_builtin_vec4_gc, &object->builtin[SLANG_BUILTIN_VEC4], diff --git a/src/mesa/shader/slang/slang_compile.h b/src/mesa/shader/slang/slang_compile.h index ba129df8e3..a8311e8546 100644 --- a/src/mesa/shader/slang/slang_compile.h +++ b/src/mesa/shader/slang/slang_compile.h @@ -70,7 +70,7 @@ _slang_code_unit_dtr (slang_code_unit *); #define SLANG_BUILTIN_COMMON 1 #define SLANG_BUILTIN_TARGET 2 -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ #define SLANG_BUILTIN_VEC4 3 #define SLANG_BUILTIN_TOTAL 4 #else diff --git a/src/mesa/shader/slang/slang_execute.c b/src/mesa/shader/slang/slang_execute.c index 09401b8910..1561df1945 100644 --- a/src/mesa/shader/slang/slang_execute.c +++ b/src/mesa/shader/slang/slang_execute.c @@ -41,7 +41,7 @@ slang_machine_ctr(slang_machine * self) { slang_machine_init(self); self->infolog = NULL; -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ self->x86.compiled_func = NULL; #endif } @@ -53,7 +53,7 @@ slang_machine_dtr(slang_machine * self) slang_info_log_destruct(self->infolog); slang_alloc_free(self->infolog); } -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ if (self->x86.compiled_func != NULL) _mesa_exec_free(self->x86.compiled_func); #endif @@ -357,7 +357,7 @@ _slang_execute2(const slang_assembly_file * file, slang_machine * mach) f = fopen(filename, "w"); #endif -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ if (mach->x86.compiled_func != NULL) { mach->x86.compiled_func(mach); return GL_TRUE; diff --git a/src/mesa/shader/slang/slang_execute.h b/src/mesa/shader/slang/slang_execute.h index 138f139308..1f8c3781a1 100644 --- a/src/mesa/shader/slang/slang_execute.h +++ b/src/mesa/shader/slang/slang_execute.h @@ -46,7 +46,7 @@ typedef union slang_machine_slot_ #define SLANG_MACHINE_MEMORY_SIZE (SLANG_MACHINE_GLOBAL_SIZE + SLANG_MACHINE_STACK_SIZE) -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ /** * Extra machine state for x86 execution. */ @@ -73,7 +73,7 @@ typedef struct slang_machine_ /** Machine memory */ slang_machine_slot mem[SLANG_MACHINE_MEMORY_SIZE]; struct slang_info_log_ *infolog; /**< printMESA() support */ -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ slang_machine_x86 x86; #endif } slang_machine; @@ -92,7 +92,7 @@ extern GLboolean _slang_execute2(const slang_assembly_file *, slang_machine *); -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ extern GLboolean _slang_x86_codegen(slang_machine *, slang_assembly_file *, GLuint); #endif diff --git a/src/mesa/shader/slang/slang_execute_x86.c b/src/mesa/shader/slang/slang_execute_x86.c index 958086ff07..c48c9667c7 100644 --- a/src/mesa/shader/slang/slang_execute_x86.c +++ b/src/mesa/shader/slang/slang_execute_x86.c @@ -34,7 +34,7 @@ #include "slang_library_noise.h" #include "slang_library_texsample.h" -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ #include "x86/rtasm/x86sse.h" @@ -353,10 +353,12 @@ codegen_assem(codegen_ctx * G, slang_assembly * a, slang_info_log ** infolog) x87_fyl2x(&G->f); x87_fstp(&G->f, x86_deref(G->r_esp)); break; +#if 00 case slang_asm_float_floor: x86_call(&G->f, (GLubyte *) do_floorf); x87_fstp(&G->f, x86_deref(G->r_esp)); break; +#endif case slang_asm_float_ceil: x86_call(&G->f, (GLubyte *) do_ceilf); x87_fstp(&G->f, x86_deref(G->r_esp)); diff --git a/src/mesa/shader/slang/slang_storage.c b/src/mesa/shader/slang/slang_storage.c index 71ac0692e1..dcfb3a0e5f 100644 --- a/src/mesa/shader/slang/slang_storage.c +++ b/src/mesa/shader/slang/slang_storage.c @@ -212,7 +212,7 @@ GLboolean _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_sp case slang_spec_vec3: return aggregate_vector (agg, slang_stor_float, 3); case slang_spec_vec4: -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ return aggregate_vector (agg, slang_stor_vec4, 1); #else return aggregate_vector (agg, slang_stor_float, 4); @@ -222,7 +222,7 @@ GLboolean _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_sp case slang_spec_mat3: return aggregate_matrix (agg, slang_stor_float, 3); case slang_spec_mat4: -#if defined(USE_X86_ASM) || defined(SLANG_X86) +#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ return aggregate_vector (agg, slang_stor_vec4, 4); #else return aggregate_matrix (agg, slang_stor_float, 4); -- cgit v1.2.3 From d265bdf81aac9467119f5cbb6c84a0c4df8282d1 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 2 Feb 2007 13:49:07 -0700 Subject: Remove all dependencies on the old slang interpreter/executor. --- src/mesa/shader/slang/slang_assemble.c | 8 +++---- src/mesa/shader/slang/slang_assemble.h | 1 - src/mesa/shader/slang/slang_assemble_assignment.c | 2 +- src/mesa/shader/slang/slang_assemble_constructor.c | 8 +++---- src/mesa/shader/slang/slang_compile.c | 28 +--------------------- src/mesa/shader/slang/slang_compile.h | 3 +-- src/mesa/shader/slang/slang_compile_function.c | 1 - src/mesa/shader/slang/slang_link.c | 2 -- src/mesa/shader/slang/slang_link.h | 1 - src/mesa/shader/slang/slang_storage.c | 13 +++++----- src/mesa/shader/slang/slang_storage.h | 2 -- 11 files changed, 17 insertions(+), 52 deletions(-) (limited to 'src/mesa/shader/slang/slang_assemble_assignment.c') diff --git a/src/mesa/shader/slang/slang_assemble.c b/src/mesa/shader/slang/slang_assemble.c index 27249078b3..e3b65a1238 100644 --- a/src/mesa/shader/slang/slang_assemble.c +++ b/src/mesa/shader/slang/slang_assemble.c @@ -185,7 +185,7 @@ sizeof_variable(const slang_assemble_ctx * A, slang_type_specifier * spec, if (!slang_storage_aggregate_construct(&agg)) return GL_FALSE; if (!_slang_aggregate_variable(&agg, spec, array_len, A->space.funcs, - A->space.structs, A->space.vars, A->mach, + A->space.structs, A->space.vars, A->file, A->atoms)) { slang_storage_aggregate_destruct(&agg); return GL_FALSE; @@ -551,7 +551,7 @@ _slang_dereference(slang_assemble_ctx * A, slang_operation * op) if (!slang_storage_aggregate_construct(&agg)) goto end1; if (!_slang_aggregate_variable(&agg, &ti.spec, ti.array_len, A->space.funcs, - A->space.structs, A->space.vars, A->mach, + A->space.structs, A->space.vars, A->file, A->atoms)) goto end; @@ -871,7 +871,7 @@ equality(slang_assemble_ctx * A, slang_operation * op, GLboolean equal) goto end1; if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, A->space.structs, A->space.vars, - A->mach, A->file, A->atoms)) + A->file, A->atoms)) goto end; /* compute the size of the agregate - there are two such aggregates @@ -1094,7 +1094,7 @@ handle_field(slang_assemble_ctx * A, slang_assembly_typeinfo * tia, if (!_slang_aggregate_variable(&agg, &field->type.specifier, field->array_len, A->space.funcs, A->space.structs, A->space.vars, - A->mach, A->file, A->atoms)) { + A->file, A->atoms)) { slang_storage_aggregate_destruct(&agg); RETURN_NIL(); } diff --git a/src/mesa/shader/slang/slang_assemble.h b/src/mesa/shader/slang/slang_assemble.h index 4f1512afca..7e380b3c33 100644 --- a/src/mesa/shader/slang/slang_assemble.h +++ b/src/mesa/shader/slang/slang_assemble.h @@ -247,7 +247,6 @@ typedef struct slang_assembly_name_space_ typedef struct slang_assemble_ctx_ { slang_assembly_file *file; - struct slang_machine_ *mach; slang_atom_pool *atoms; slang_assembly_name_space space; slang_assembly_flow_control flow; diff --git a/src/mesa/shader/slang/slang_assemble_assignment.c b/src/mesa/shader/slang/slang_assemble_assignment.c index bfce04ec88..93a1ef3a08 100644 --- a/src/mesa/shader/slang/slang_assemble_assignment.c +++ b/src/mesa/shader/slang/slang_assemble_assignment.c @@ -164,7 +164,7 @@ _slang_assemble_assignment(slang_assemble_ctx * A, const slang_operation * op) goto end1; if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, A->space.structs, A->space.vars, - A->mach, A->file, A->atoms)) + A->file, A->atoms)) goto end; index = 0; diff --git a/src/mesa/shader/slang/slang_assemble_constructor.c b/src/mesa/shader/slang/slang_assemble_constructor.c index e045f2f6d2..63407580ca 100644 --- a/src/mesa/shader/slang/slang_assemble_constructor.c +++ b/src/mesa/shader/slang/slang_assemble_constructor.c @@ -182,7 +182,7 @@ sizeof_argument(slang_assemble_ctx * A, GLuint * size, slang_operation * op) goto end1; if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, A->space.structs, A->space.vars, - A->mach, A->file, A->atoms)) + A->file, A->atoms)) goto end; *size = _slang_sizeof_aggregate(&agg); @@ -214,7 +214,7 @@ constructor_aggregate(slang_assemble_ctx * A, goto end1; if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, A->space.structs, A->space.vars, - A->mach, A->file, A->atoms)) + A->file, A->atoms)) goto end2; if (!slang_storage_aggregate_construct(&flat_agg)) @@ -276,7 +276,7 @@ _slang_assemble_constructor(slang_assemble_ctx * A, const slang_operation * op) goto end1; if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, A->space.structs, A->space.vars, - A->mach, A->file, A->atoms)) + A->file, A->atoms)) goto end2; /* calculate size of the constructor */ @@ -316,7 +316,7 @@ _slang_assemble_constructor(slang_assemble_ctx * A, const slang_operation * op) goto end1; if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, A->space.structs, A->space.vars, - A->mach, A->file, A->atoms)) + A->file, A->atoms)) goto end2; /* calculate size of the constructor */ diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 4203c3cc6f..8148c65a55 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -103,7 +103,6 @@ _slang_code_object_ctr(slang_code_object * self) #if 01 _slang_assembly_file_ctr(&self->assembly); #endif - slang_machine_ctr(&self->machine); self->varpool.next_addr = 0; slang_atom_pool_construct(&self->atompool); slang_export_data_table_ctr(&self->expdata); @@ -123,7 +122,6 @@ _slang_code_object_dtr(slang_code_object * self) #if 01 slang_assembly_file_destruct(&self->assembly); #endif - slang_machine_dtr(&self->machine); slang_atom_pool_destruct(&self->atompool); slang_export_data_table_dtr(&self->expdata); slang_export_code_table_ctr(&self->expcode); @@ -252,7 +250,6 @@ typedef struct slang_output_ctx_ slang_struct_scope *structs; slang_assembly_file *assembly; slang_var_pool *global_pool; - slang_machine *machine; struct gl_program *program; slang_var_table *vartable; } slang_output_ctx; @@ -386,7 +383,7 @@ calculate_var_size(slang_parse_ctx * C, slang_output_ctx * O, if (!slang_storage_aggregate_construct(&agg)) return GL_FALSE; if (!_slang_aggregate_variable(&agg, &var->type.specifier, var->array_len, - O->funs, O->structs, O->vars, O->machine, + O->funs, O->structs, O->vars, O->assembly, C->atoms)) { slang_storage_aggregate_destruct(&agg); return GL_FALSE; @@ -1556,7 +1553,6 @@ initialize_global(slang_assemble_ctx * A, slang_variable * var) #if 01 slang_assembly_file_restore_point point; #endif - slang_machine mach; slang_assembly_local_info save_local = A->local; slang_operation op_id, op_assign; GLboolean result; @@ -1567,10 +1563,6 @@ initialize_global(slang_assemble_ctx * A, slang_variable * var) return GL_FALSE; #endif - /* setup the machine */ - mach = *A->mach; - mach.ip = A->file->count; - /* allocate local storage for expression */ A->local.ret_size = 0; A->local.addr_tmp = 0; @@ -1635,12 +1627,6 @@ initialize_global(slang_assemble_ctx * A, slang_variable * var) if (!slang_assembly_file_push(A->file, slang_asm_exit)) return GL_FALSE; - /* execute the expression */ -#if 0 - if (!_slang_execute2(A->file, &mach)) - return GL_FALSE; -#endif - #if 01 /* restore the old assembly */ if (!slang_assembly_file_restore_point_load(A->file, &point)) @@ -1648,10 +1634,6 @@ initialize_global(slang_assemble_ctx * A, slang_variable * var) #endif A->local = save_local; - /* now we copy the contents of the initialized variable back to the original machine */ - _mesa_memcpy((GLubyte *) A->mach->mem + var->address, - (GLubyte *) mach.mem + var->address, var->size); - return GL_TRUE; } @@ -1743,7 +1725,6 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O, slang_assemble_ctx A; A.file = O->assembly; - A.mach = O->machine; A.atoms = C->atoms; A.space.funcs = O->funs; A.space.structs = O->structs; @@ -1773,7 +1754,6 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O, slang_assemble_ctx A; A.file = O->assembly; - A.mach = O->machine; A.atoms = C->atoms; A.space.funcs = O->funs; A.space.structs = O->structs; @@ -1781,10 +1761,6 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O, if (!initialize_global(&A, var)) return 0; } - else { - _mesa_memset((GLubyte *) (O->machine->mem) + var->address, 0, - var->size); - } } return 1; } @@ -1909,7 +1885,6 @@ parse_function(slang_parse_ctx * C, slang_output_ctx * O, int definition, slang_assemble_ctx A; A.file = O->assembly; - A.mach = O->machine; A.atoms = C->atoms; A.space.funcs = O->funs; A.space.structs = O->structs; @@ -2003,7 +1978,6 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit, o.vars = &unit->vars; o.assembly = &unit->object->assembly; o.global_pool = &unit->object->varpool; - o.machine = &unit->object->machine; o.program = program; o.vartable = _slang_new_var_table(maxRegs); _slang_push_var_table(o.vartable); diff --git a/src/mesa/shader/slang/slang_compile.h b/src/mesa/shader/slang/slang_compile.h index a8311e8546..450119d650 100644 --- a/src/mesa/shader/slang/slang_compile.h +++ b/src/mesa/shader/slang/slang_compile.h @@ -28,7 +28,7 @@ #include "imports.h" #include "mtypes.h" #include "slang_export.h" -#include "slang_execute.h" +#include "slang_assemble.h" #include "slang_compile_variable.h" #include "slang_compile_struct.h" #include "slang_compile_operation.h" @@ -82,7 +82,6 @@ typedef struct slang_code_object_ slang_code_unit builtin[SLANG_BUILTIN_TOTAL]; slang_code_unit unit; slang_assembly_file assembly; - slang_machine machine; slang_var_pool varpool; slang_atom_pool atompool; slang_export_data_table expdata; diff --git a/src/mesa/shader/slang/slang_compile_function.c b/src/mesa/shader/slang/slang_compile_function.c index 3642b12e92..c9b33f3b2f 100644 --- a/src/mesa/shader/slang/slang_compile_function.c +++ b/src/mesa/shader/slang/slang_compile_function.c @@ -246,7 +246,6 @@ _slang_build_export_code_table(slang_export_code_table * tbl, return GL_FALSE; A.file = &unit->object->assembly; - A.mach = &unit->object->machine; A.atoms = &unit->object->atompool; A.space.funcs = &unit->funs; A.space.structs = &unit->structs; diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 008b7ab369..8894f78088 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -646,7 +646,6 @@ _slang_program_ctr (slang_program *self) self->common_fixed_entries[i][j] = ~0; for (j = 0; j < SLANG_COMMON_CODE_MAX; j++) self->code[i][j] = ~0; - self->machines[i] = NULL; self->assemblies[i] = NULL; } for (i = 0; i < SLANG_VERTEX_FIXED_MAX; i++) @@ -859,7 +858,6 @@ _slang_link (slang_program *prog, slang_code_object **objects, GLuint count) return GL_FALSE; resolve_common_fixed (prog->common_fixed_entries[index], &objects[i]->expdata); resolve_common_code (prog->code[index], &objects[i]->expcode); - prog->machines[index] = &objects[i]->machine; prog->assemblies[index] = &objects[i]->assembly; } diff --git a/src/mesa/shader/slang/slang_link.h b/src/mesa/shader/slang/slang_link.h index d9819289ca..8c7d0c01cf 100644 --- a/src/mesa/shader/slang/slang_link.h +++ b/src/mesa/shader/slang/slang_link.h @@ -332,7 +332,6 @@ typedef struct GLuint vertex_fixed_entries[SLANG_VERTEX_FIXED_MAX]; GLuint fragment_fixed_entries[SLANG_FRAGMENT_FIXED_MAX]; GLuint code[SLANG_SHADER_MAX][SLANG_COMMON_CODE_MAX]; - slang_machine *machines[SLANG_SHADER_MAX]; slang_assembly_file *assemblies[SLANG_SHADER_MAX]; } slang_program; diff --git a/src/mesa/shader/slang/slang_storage.c b/src/mesa/shader/slang/slang_storage.c index 8196975766..899c36cbd3 100644 --- a/src/mesa/shader/slang/slang_storage.c +++ b/src/mesa/shader/slang/slang_storage.c @@ -135,7 +135,7 @@ 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_machine * mach, + slang_variable_scope * globals, slang_assembly_file * file, slang_atom_pool * atoms) { GLuint i; @@ -143,7 +143,7 @@ aggregate_variables(slang_storage_aggregate * agg, for (i = 0; i < vars->num_variables; i++) if (!_slang_aggregate_variable(agg, &vars->variables[i]->type.specifier, vars->variables[i]->array_len, funcs, - structs, globals, mach, file, atoms)) + structs, globals, file, atoms)) return GL_FALSE; return GL_TRUE; } @@ -153,7 +153,7 @@ _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_variable_scope * vars, slang_assembly_file * file, slang_atom_pool * atoms) { switch (spec->type) { @@ -204,7 +204,7 @@ _slang_aggregate_variable(slang_storage_aggregate * agg, return aggregate_vector(agg, slang_stor_int, 1); case slang_spec_struct: return aggregate_variables(agg, spec->_struct->fields, funcs, structs, - vars, mach, file, atoms); + vars, file, atoms); case slang_spec_array: { slang_storage_array *arr; @@ -223,9 +223,8 @@ _slang_aggregate_variable(slang_storage_aggregate * agg, arr->aggregate = NULL; return GL_FALSE; } - if (!_slang_aggregate_variable - (arr->aggregate, spec->_array, 0, funcs, structs, vars, mach, - file, atoms)) + if (!_slang_aggregate_variable(arr->aggregate, spec->_array, 0, + funcs, structs, vars, file, atoms)) return GL_FALSE; arr->length = array_len; /* TODO: check if 0 < arr->length <= 65535 */ diff --git a/src/mesa/shader/slang/slang_storage.h b/src/mesa/shader/slang/slang_storage.h index 0137003a9d..3fe60c78fe 100644 --- a/src/mesa/shader/slang/slang_storage.h +++ b/src/mesa/shader/slang/slang_storage.h @@ -27,7 +27,6 @@ #include "slang_compile.h" #include "slang_assemble.h" -#include "slang_execute.h" #if defined __cplusplus extern "C" { @@ -99,7 +98,6 @@ _slang_aggregate_variable(slang_storage_aggregate *agg, slang_function_scope *funcs, slang_struct_scope *structs, slang_variable_scope *vars, - slang_machine *mach, slang_assembly_file *file, slang_atom_pool *atoms); -- cgit v1.2.3 From 1b24e2d5a7a7f97c179d7881a014f4aa025cacf7 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 2 Feb 2007 14:24:24 -0700 Subject: remove slang_export.c and related code --- src/mesa/shader/slang/slang_assemble.c | 16 +----- src/mesa/shader/slang/slang_assemble_assignment.c | 5 -- src/mesa/shader/slang/slang_compile.c | 51 ----------------- src/mesa/shader/slang/slang_compile.h | 8 --- src/mesa/shader/slang/slang_compile_function.c | 46 ---------------- src/mesa/shader/slang/slang_compile_function.h | 6 -- src/mesa/shader/slang/slang_compile_variable.c | 67 ----------------------- src/mesa/shader/slang/slang_compile_variable.h | 5 -- src/mesa/shader/slang/slang_storage.c | 8 --- src/mesa/sources | 1 - 10 files changed, 1 insertion(+), 212 deletions(-) (limited to 'src/mesa/shader/slang/slang_assemble_assignment.c') diff --git a/src/mesa/shader/slang/slang_assemble.c b/src/mesa/shader/slang/slang_assemble.c index e3b65a1238..e65bf38ad5 100644 --- a/src/mesa/shader/slang/slang_assemble.c +++ b/src/mesa/shader/slang/slang_assemble.c @@ -33,9 +33,8 @@ #include "slang_compile.h" #include "slang_storage.h" #include "slang_error.h" - #include "slang_print.h" -/*#include "assemble2.c"*/ + /* slang_assembly */ @@ -481,11 +480,6 @@ dereference_basic(slang_assemble_ctx * A, slang_storage_type type, case slang_stor_float: ty = slang_asm_float_deref; break; -#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ - case slang_stor_vec4: - ty = slang_asm_vec4_deref; - break; -#endif default: _mesa_problem(NULL, "Unexpected arr->type in dereference_basic"); ty = slang_asm_none; @@ -829,14 +823,6 @@ equality_aggregate(slang_assemble_ctx * A, return GL_FALSE; } else { -#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ - if (arr->type == slang_stor_vec4) { - if (!PLAB2(A->file, slang_asm_vec4_equal_int, - size + *index, *index)) - return GL_FALSE; - } - else -#endif if (!PLAB2(A->file, slang_asm_float_equal_int, size + *index, *index)) return GL_FALSE; diff --git a/src/mesa/shader/slang/slang_assemble_assignment.c b/src/mesa/shader/slang/slang_assemble_assignment.c index 93a1ef3a08..6efc0f558a 100644 --- a/src/mesa/shader/slang/slang_assemble_assignment.c +++ b/src/mesa/shader/slang/slang_assemble_assignment.c @@ -79,11 +79,6 @@ assign_basic(slang_assemble_ctx * A, slang_storage_type type, GLuint * index, case slang_stor_float: ty = slang_asm_float_copy; break; -#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ - case slang_stor_vec4: - ty = slang_asm_vec4_copy; - break; -#endif default: _mesa_problem(NULL, "Unexpected arr->type in assign_basic"); ty = slang_asm_none; diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 8148c65a55..9f7f18167d 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -105,10 +105,6 @@ _slang_code_object_ctr(slang_code_object * self) #endif self->varpool.next_addr = 0; slang_atom_pool_construct(&self->atompool); - slang_export_data_table_ctr(&self->expdata); - self->expdata.atoms = &self->atompool; - slang_export_code_table_ctr(&self->expcode); - self->expcode.atoms = &self->atompool; } GLvoid @@ -123,8 +119,6 @@ _slang_code_object_dtr(slang_code_object * self) slang_assembly_file_destruct(&self->assembly); #endif slang_atom_pool_destruct(&self->atompool); - slang_export_data_table_dtr(&self->expdata); - slang_export_code_table_ctr(&self->expcode); } /* slang_info_log */ @@ -1730,9 +1724,6 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O, A.space.structs = O->structs; A.space.vars = O->vars; A.program = O->program; -#if 0 - A.codegen = O->codegen; -#endif A.vartable = O->vartable; _slang_codegen_global_variable(&A, var, C->type); @@ -1890,9 +1881,6 @@ parse_function(slang_parse_ctx * C, slang_output_ctx * O, int definition, A.space.structs = O->structs; A.space.vars = O->vars; A.program = O->program; -#if 0 - A.codegen = O->codegen; -#endif A.vartable = O->vartable; _slang_reset_error(); @@ -2115,12 +2103,6 @@ static const byte slang_vertex_builtin_gc[] = { #include "library/slang_vertex_builtin_gc.h" }; -#if 0 /*defined(USE_X86_ASM) || defined(SLANG_X86)*/ -static const byte slang_builtin_vec4_gc[] = { -#include "library/slang_builtin_vec4_gc.h" -}; -#endif - static GLboolean compile_object(grammar * id, const char *source, slang_code_object * object, slang_unit_type type, slang_info_log * infolog, @@ -2181,15 +2163,6 @@ compile_object(grammar * id, const char *source, slang_code_object * object, return GL_FALSE; } -#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ - /* compile x86 4-component vector overrides, link to target */ - if (!compile_binary(slang_builtin_vec4_gc, - &object->builtin[SLANG_BUILTIN_VEC4], - slang_unit_fragment_builtin, infolog, NULL, - &object->builtin[SLANG_BUILTIN_TARGET])) - return GL_FALSE; -#endif - /* disable language extensions */ #if NEW_SLANG /* allow-built-ins */ grammar_set_reg8(*id, (const byte *) "parsing_builtin", 1); @@ -2205,24 +2178,6 @@ compile_object(grammar * id, const char *source, slang_code_object * object, } -#if 0 -static void -slang_create_uniforms(const slang_export_data_table *exports, - struct gl_program *program) -{ - /* XXX only add uniforms that are actually going to get used */ - GLuint i; - for (i = 0; i < exports->count; i++) { - if (exports->entries[i].access == slang_exp_uniform) { - const char *name = (char *) exports->entries[i].quant.name; - GLint j = _mesa_add_uniform(program->Parameters, name, 4); - assert(j >= 0); - } - } -} -#endif - - static GLboolean compile_shader(GLcontext *ctx, slang_code_object * object, slang_unit_type type, slang_info_log * infolog, @@ -2243,12 +2198,6 @@ compile_shader(GLcontext *ctx, slang_code_object * object, if (!success) return GL_FALSE; - if (!_slang_build_export_data_table(&object->expdata, &object->unit.vars)) - return GL_FALSE; - if (!_slang_build_export_code_table(&object->expcode, &object->unit.funs, - &object->unit)) - return GL_FALSE; - #if NEW_SLANG { slang_create_uniforms(&object->expdata, shader); diff --git a/src/mesa/shader/slang/slang_compile.h b/src/mesa/shader/slang/slang_compile.h index 450119d650..3ebe72eca4 100644 --- a/src/mesa/shader/slang/slang_compile.h +++ b/src/mesa/shader/slang/slang_compile.h @@ -27,7 +27,6 @@ #include "imports.h" #include "mtypes.h" -#include "slang_export.h" #include "slang_assemble.h" #include "slang_compile_variable.h" #include "slang_compile_struct.h" @@ -70,12 +69,7 @@ _slang_code_unit_dtr (slang_code_unit *); #define SLANG_BUILTIN_COMMON 1 #define SLANG_BUILTIN_TARGET 2 -#if 0/*defined(USE_X86_ASM) || defined(SLANG_X86)*/ -#define SLANG_BUILTIN_VEC4 3 -#define SLANG_BUILTIN_TOTAL 4 -#else #define SLANG_BUILTIN_TOTAL 3 -#endif typedef struct slang_code_object_ { @@ -84,8 +78,6 @@ typedef struct slang_code_object_ slang_assembly_file assembly; slang_var_pool varpool; slang_atom_pool atompool; - slang_export_data_table expdata; - slang_export_code_table expcode; } slang_code_object; extern GLvoid diff --git a/src/mesa/shader/slang/slang_compile_function.c b/src/mesa/shader/slang/slang_compile_function.c index c9b33f3b2f..00a85c2e7d 100644 --- a/src/mesa/shader/slang/slang_compile_function.c +++ b/src/mesa/shader/slang/slang_compile_function.c @@ -214,49 +214,3 @@ slang_function_scope_find(slang_function_scope * funcs, slang_function * fun, return slang_function_scope_find(funcs->outer_scope, fun, 1); return NULL; } - -/* - * _slang_build_export_code_table() - */ - -GLboolean -_slang_build_export_code_table(slang_export_code_table * tbl, - slang_function_scope * funs, - slang_code_unit * unit) -{ - slang_atom mainAtom; - GLuint i; - - mainAtom = slang_atom_pool_atom(tbl->atoms, "main"); - if (mainAtom == SLANG_ATOM_NULL) - return GL_FALSE; - - for (i = 0; i < funs->num_functions; i++) { - if (funs->functions[i].header.a_name == mainAtom) { - slang_function *fun = &funs->functions[i]; - slang_export_code_entry *e; - slang_assemble_ctx A; - - e = slang_export_code_table_add(tbl); - if (e == NULL) - return GL_FALSE; - e->address = unit->object->assembly.count; - e->name = slang_atom_pool_atom(tbl->atoms, "@main"); - if (e->name == SLANG_ATOM_NULL) - return GL_FALSE; - - A.file = &unit->object->assembly; - A.atoms = &unit->object->atompool; - A.space.funcs = &unit->funs; - A.space.structs = &unit->structs; - A.space.vars = &unit->vars; - slang_assembly_file_push_label(&unit->object->assembly, - slang_asm_local_alloc, 20); - slang_assembly_file_push_label(&unit->object->assembly, - slang_asm_enter, 20); - _slang_assemble_function_call(&A, fun, NULL, 0, GL_FALSE); - slang_assembly_file_push(&unit->object->assembly, slang_asm_exit); - } - } - return GL_TRUE; -} diff --git a/src/mesa/shader/slang/slang_compile_function.h b/src/mesa/shader/slang/slang_compile_function.h index 8f0e3b326d..99a6b2a034 100644 --- a/src/mesa/shader/slang/slang_compile_function.h +++ b/src/mesa/shader/slang/slang_compile_function.h @@ -102,12 +102,6 @@ slang_function_scope_find_by_name(slang_function_scope *, slang_atom, int); extern slang_function * slang_function_scope_find(slang_function_scope *, slang_function *, int); -extern GLboolean -_slang_build_export_code_table(slang_export_code_table *, - slang_function_scope *, - struct slang_code_unit_ *); - - #ifdef __cplusplus } #endif diff --git a/src/mesa/shader/slang/slang_compile_variable.c b/src/mesa/shader/slang/slang_compile_variable.c index b19615b085..c8ffaf296a 100644 --- a/src/mesa/shader/slang/slang_compile_variable.c +++ b/src/mesa/shader/slang/slang_compile_variable.c @@ -383,70 +383,3 @@ gl_type_from_specifier(const slang_type_specifier * type) return GL_FLOAT; } } - -static GLboolean -build_quant(slang_export_data_quant * q, const slang_variable * var) -{ - const slang_type_specifier *spec = &var->type.specifier; - - q->name = var->a_name; - q->size = var->size; - if (spec->type == slang_spec_array) { - q->array_len = var->array_len; -#if 1 - if (var->array_len > 0) -#endif - q->size /= var->array_len; - spec = spec->_array; - } - if (spec->type == slang_spec_struct) { - GLuint i; - - q->u.field_count = spec->_struct->fields->num_variables; - q->structure = (slang_export_data_quant *) - slang_alloc_malloc(q->u.field_count - * sizeof(slang_export_data_quant)); - if (q->structure == NULL) - return GL_FALSE; - - for (i = 0; i < q->u.field_count; i++) - slang_export_data_quant_ctr(&q->structure[i]); - for (i = 0; i < q->u.field_count; i++) { - if (!build_quant(&q->structure[i], - spec->_struct->fields->variables[i])) - return GL_FALSE; - } - } - else - q->u.basic_type = gl_type_from_specifier(spec); - return GL_TRUE; -} - -GLboolean -_slang_build_export_data_table(slang_export_data_table * tbl, - slang_variable_scope * vars) -{ - GLuint i; - - for (i = 0; i < vars->num_variables; i++) { - const slang_variable *var = vars->variables[i]; - slang_export_data_entry *e; - - e = slang_export_data_table_add(tbl); - if (e == NULL) - return GL_FALSE; - if (!build_quant(&e->quant, var)) - return GL_FALSE; - if (var->type.qualifier == slang_qual_uniform) - e->access = slang_exp_uniform; - else if (var->type.qualifier == slang_qual_attribute) - e->access = slang_exp_attribute; - else - e->access = slang_exp_varying; - e->address = var->address; - } - - if (vars->outer_scope != NULL) - return _slang_build_export_data_table(tbl, vars->outer_scope); - return GL_TRUE; -} diff --git a/src/mesa/shader/slang/slang_compile_variable.h b/src/mesa/shader/slang/slang_compile_variable.h index 82800b32b5..841f9840a6 100644 --- a/src/mesa/shader/slang/slang_compile_variable.h +++ b/src/mesa/shader/slang/slang_compile_variable.h @@ -126,11 +126,6 @@ extern slang_variable * _slang_locate_variable(const slang_variable_scope *, const slang_atom a_name, GLboolean all); -extern GLboolean -_slang_build_export_data_table(slang_export_data_table *, - slang_variable_scope *); - - #ifdef __cplusplus } diff --git a/src/mesa/shader/slang/slang_storage.c b/src/mesa/shader/slang/slang_storage.c index 899c36cbd3..472d08e6c1 100644 --- a/src/mesa/shader/slang/slang_storage.c +++ b/src/mesa/shader/slang/slang_storage.c @@ -180,21 +180,13 @@ _slang_aggregate_variable(slang_storage_aggregate * agg, case slang_spec_vec3: return aggregate_vector(agg, slang_stor_float, 3); case slang_spec_vec4: -#if 0 /*defined(USE_X86_ASM) || defined(SLANG_X86) */ - return aggregate_vector(agg, slang_stor_vec4, 1); -#else return aggregate_vector(agg, slang_stor_float, 4); -#endif 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: -#if 0 /*defined(USE_X86_ASM) || defined(SLANG_X86) */ - return aggregate_vector(agg, slang_stor_vec4, 4); -#else return aggregate_matrix(agg, slang_stor_float, 4); -#endif case slang_spec_sampler1D: case slang_spec_sampler2D: case slang_spec_sampler3D: diff --git a/src/mesa/sources b/src/mesa/sources index a7936101ca..9b77d21786 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -179,7 +179,6 @@ SLANG_SOURCES = \ shader/slang/slang_compile_variable.c \ shader/slang/slang_emit.c \ shader/slang/slang_error.c \ - shader/slang/slang_export.c \ shader/slang/slang_library_noise.c \ shader/slang/slang_library_texsample.c \ shader/slang/slang_link2.c \ -- cgit v1.2.3 From 452217e29a9fc948140460c5d3ffc50cac9dcb61 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 2 Feb 2007 15:10:34 -0700 Subject: removed obsolete shader assembly files --- src/mesa/shader/slang/slang_assemble_assignment.c | 221 ---------- src/mesa/shader/slang/slang_assemble_assignment.h | 45 --- src/mesa/shader/slang/slang_assemble_conditional.c | 448 --------------------- src/mesa/shader/slang/slang_assemble_conditional.h | 51 --- src/mesa/shader/slang/slang_assemble_constructor.c | 421 ------------------- src/mesa/shader/slang/slang_assemble_constructor.h | 57 --- 6 files changed, 1243 deletions(-) delete mode 100644 src/mesa/shader/slang/slang_assemble_assignment.c delete mode 100644 src/mesa/shader/slang/slang_assemble_assignment.h delete mode 100644 src/mesa/shader/slang/slang_assemble_conditional.c delete mode 100644 src/mesa/shader/slang/slang_assemble_conditional.h delete mode 100644 src/mesa/shader/slang/slang_assemble_constructor.c delete mode 100644 src/mesa/shader/slang/slang_assemble_constructor.h (limited to 'src/mesa/shader/slang/slang_assemble_assignment.c') diff --git a/src/mesa/shader/slang/slang_assemble_assignment.c b/src/mesa/shader/slang/slang_assemble_assignment.c deleted file mode 100644 index 6efc0f558a..0000000000 --- a/src/mesa/shader/slang/slang_assemble_assignment.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 2005-2006 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_assemble_assignment.c - * slang assignment expressions assembler - * \author Michal Krol - */ - -#include "imports.h" -#include "slang_assemble.h" -#include "slang_storage.h" -#include "slang_error.h" - -/* - * _slang_assemble_assignment() - * - * Copies values on the stack ( to ) to a memory - * location pointed by . - * - * in: - * +------------------+ - * | addr of variable | - * +------------------+ - * | component N-1 | - * | ... | - * | component 0 | - * +------------------+ - * - * out: - * +------------------+ - * | addr of variable | - * +------------------+ - */ - - - -static GLboolean -assign_basic(slang_assemble_ctx * A, slang_storage_type type, GLuint * index, - GLuint size) -{ - GLuint dst_offset, dst_addr_loc; - slang_assembly_type ty; - - /* Calculate the offset within destination variable to write. */ - if (A->swz.num_components != 0) - dst_offset = A->swz.swizzle[*index / 4] * 4; - else - dst_offset = *index; - - switch (type) { - case slang_stor_bool: - ty = slang_asm_bool_copy; - break; - case slang_stor_int: - ty = slang_asm_int_copy; - break; - case slang_stor_float: - ty = slang_asm_float_copy; - break; - default: - _mesa_problem(NULL, "Unexpected arr->type in assign_basic"); - ty = slang_asm_none; - } - - /* Calculate the distance from top of the stack to the destination - * address. As the copy operation progresses, components of the - * source are being successively popped off the stack by the amount - * of *index increase step. - */ - dst_addr_loc = size - *index; - - if (!slang_assembly_file_push_label2(A->file, ty, dst_addr_loc, dst_offset)) - RETURN_NIL(); - - *index += _slang_sizeof_type(type); - - return GL_TRUE; -} - - -static GLboolean -assign_aggregate(slang_assemble_ctx * A, const slang_storage_aggregate * agg, - GLuint * index, GLuint size) -{ - GLuint i; - - for (i = 0; i < agg->count; i++) { - const slang_storage_array *arr = &agg->arrays[i]; - GLuint j; - - for (j = 0; j < arr->length; j++) { - if (arr->type == slang_stor_aggregate) { - if (!assign_aggregate(A, arr->aggregate, index, size)) - return GL_FALSE; - } - else { - /* When the destination is swizzled, we are forced to do - * float_copy, even if vec4 extension is enabled with - * vec4_copy operation. - */ - if (A->swz.num_components != 0 && arr->type == slang_stor_vec4) { - if (!assign_basic(A, slang_stor_float, index, size)) - return GL_FALSE; - if (!assign_basic(A, slang_stor_float, index, size)) - return GL_FALSE; - if (!assign_basic(A, slang_stor_float, index, size)) - return GL_FALSE; - if (!assign_basic(A, slang_stor_float, index, size)) - return GL_FALSE; - } - else { - if (!assign_basic(A, arr->type, index, size)) - return GL_FALSE; - } - } - } - } - - return GL_TRUE; -} - - -GLboolean -_slang_assemble_assignment(slang_assemble_ctx * A, const slang_operation * op) -{ - slang_assembly_typeinfo ti; - GLboolean result = GL_FALSE; - slang_storage_aggregate agg; - GLuint index, size; - - if (!slang_assembly_typeinfo_construct(&ti)) - RETURN_OUT_OF_MEMORY(); - if (!_slang_typeof_operation(A, op, &ti)) - goto end1; - - if (!slang_storage_aggregate_construct(&agg)) - goto end1; - if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, - A->space.structs, A->space.vars, - A->file, A->atoms)) - goto end; - - index = 0; - size = _slang_sizeof_aggregate(&agg); - result = assign_aggregate(A, &agg, &index, size); - - end1: - slang_storage_aggregate_destruct(&agg); - end: - slang_assembly_typeinfo_destruct(&ti); - if (!result) - RETURN_NIL(); - return result; -} - - -/** - * Performs unary (pre ++ and --) or binary (=, +=, -=, *=, /=) - * assignment on the operation's children. - */ -GLboolean -_slang_assemble_assign(slang_assemble_ctx * A, slang_operation * op, - const char *oper, slang_ref_type ref) -{ - slang_swizzle swz; - - if (ref == slang_ref_forbid) { - if (!slang_assembly_file_push_label2 - (A->file, slang_asm_local_addr, A->local.addr_tmp, 4)) - return GL_FALSE; - } - - if (slang_string_compare("=", oper) == 0) { - if (!_slang_assemble_operation(A, &op->children[0], slang_ref_force)) - return GL_FALSE; - swz = A->swz; - if (!_slang_assemble_operation(A, &op->children[1], slang_ref_forbid)) - return GL_FALSE; - A->swz = swz; - if (!_slang_assemble_assignment(A, op->children)) - return GL_FALSE; - } - else { - if (!_slang_assemble_function_call_name - (A, oper, op->children, op->num_children, GL_TRUE)) - return GL_FALSE; - } - - if (ref == slang_ref_forbid) { - if (!slang_assembly_file_push(A->file, slang_asm_addr_copy)) - return GL_FALSE; - if (!slang_assembly_file_push_label(A->file, slang_asm_local_free, 4)) - return GL_FALSE; - if (!_slang_dereference(A, op->children)) - return GL_FALSE; - } - - return GL_TRUE; -} diff --git a/src/mesa/shader/slang/slang_assemble_assignment.h b/src/mesa/shader/slang/slang_assemble_assignment.h deleted file mode 100644 index 3c1ecdedab..0000000000 --- a/src/mesa/shader/slang/slang_assemble_assignment.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 2005-2006 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. - */ - -#ifndef SLANG_ASSEMBLE_ASSIGNMENT_H -#define SLANG_ASSEMBLE_ASSIGNMENT_H - -#if defined __cplusplus -extern "C" { -#endif - - -extern GLboolean -_slang_assemble_assignment(slang_assemble_ctx *, const struct slang_operation_ *); - -extern GLboolean -_slang_assemble_assign(slang_assemble_ctx *, struct slang_operation_ *, - const char *, slang_ref_type); - - -#ifdef __cplusplus -} -#endif - -#endif /* SLANG_ASSEMBLE_ASSIGNMENT_H */ diff --git a/src/mesa/shader/slang/slang_assemble_conditional.c b/src/mesa/shader/slang/slang_assemble_conditional.c deleted file mode 100644 index f3400e8753..0000000000 --- a/src/mesa/shader/slang/slang_assemble_conditional.c +++ /dev/null @@ -1,448 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 2005-2006 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_assemble_conditional.c - * slang condtional expressions assembler - * \author Michal Krol - */ - -#include "imports.h" -#include "slang_assemble.h" -#include "slang_compile.h" - -/* - * _slang_assemble_logicaland() - * - * and: - * - * jumpz zero - * - * jump end - * zero: - * push 0 - * end: - */ - -GLboolean _slang_assemble_logicaland (slang_assemble_ctx *A, slang_operation *op) -{ - GLuint zero_jump, end_jump; - - /* evaluate left expression */ - if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid)) - return GL_FALSE; - - /* jump to pushing 0 if not true */ - zero_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero)) - return GL_FALSE; - - /* evaluate right expression */ - if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid)) - return GL_FALSE; - - /* jump to the end of the expression */ - end_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump)) - return GL_FALSE; - - /* push 0 on stack */ - A->file->code[zero_jump].param[0] = A->file->count; - if (!slang_assembly_file_push_literal (A->file, slang_asm_bool_push, (GLfloat) 0)) - return GL_FALSE; - - /* the end of the expression */ - A->file->code[end_jump].param[0] = A->file->count; - - return GL_TRUE; -} - -/* - * _slang_assemble_logicalor() - * - * or: - * - * jumpz right - * push 1 - * jump end - * right: - * - * end: - */ - -GLboolean _slang_assemble_logicalor (slang_assemble_ctx *A, slang_operation *op) -{ - GLuint right_jump, end_jump; - - /* evaluate left expression */ - if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid)) - return GL_FALSE; - - /* jump to evaluation of right expression if not true */ - right_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero)) - return GL_FALSE; - - /* push 1 on stack */ - if (!slang_assembly_file_push_literal (A->file, slang_asm_bool_push, (GLfloat) 1)) - return GL_FALSE; - - /* jump to the end of the expression */ - end_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump)) - return GL_FALSE; - - /* evaluate right expression */ - A->file->code[right_jump].param[0] = A->file->count; - if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid)) - return GL_FALSE; - - /* the end of the expression */ - A->file->code[end_jump].param[0] = A->file->count; - - return GL_TRUE; -} - -/* - * _slang_assemble_select() - * - * select: - * - * jumpz false - * - * jump end - * false: - * - * end: - */ - -GLboolean _slang_assemble_select (slang_assemble_ctx *A, slang_operation *op) -{ - GLuint cond_jump, end_jump; - - /* execute condition expression */ - if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid)) - return GL_FALSE; - - /* jump to false expression if not true */ - cond_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero)) - return GL_FALSE; - - /* execute true expression */ - if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid)) - return GL_FALSE; - - /* jump to the end of the expression */ - end_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump)) - return GL_FALSE; - - /* resolve false point */ - A->file->code[cond_jump].param[0] = A->file->count; - - /* execute false expression */ - if (!_slang_assemble_operation (A, &op->children[2], slang_ref_forbid)) - return GL_FALSE; - - /* resolve the end of the expression */ - A->file->code[end_jump].param[0] = A->file->count; - - return GL_TRUE; -} - -/* - * _slang_assemble_for() - * - * for: - * - * jump start - * break: - * jump end - * continue: - * - * start: - * - * jumpz end - * - * jump continue - * end: - */ - -GLboolean _slang_assemble_for (slang_assemble_ctx *A, slang_operation *op) -{ - GLuint start_jump, end_jump, cond_jump; - GLuint break_label, cont_label; - slang_assembly_flow_control save_flow = A->flow; - - /* execute initialization statement */ - if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid/*slang_ref_freelance*/)) - return GL_FALSE; - if (!_slang_cleanup_stack (A, &op->children[0])) - return GL_FALSE; - - /* skip the "go to the end of the loop" and loop-increment statements */ - start_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump)) - return GL_FALSE; - - /* go to the end of the loop - break statements are directed here */ - break_label = A->file->count; - end_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump)) - return GL_FALSE; - - /* resolve the beginning of the loop - continue statements are directed here */ - cont_label = A->file->count; - - /* execute loop-increment statement */ - if (!_slang_assemble_operation (A, &op->children[2], slang_ref_forbid/*slang_ref_freelance*/)) - return GL_FALSE; - if (!_slang_cleanup_stack (A, &op->children[2])) - return GL_FALSE; - - /* resolve the condition point */ - A->file->code[start_jump].param[0] = A->file->count; - - /* execute condition statement */ - if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid)) - return GL_FALSE; - - /* jump to the end of the loop if not true */ - cond_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero)) - return GL_FALSE; - - /* execute loop body */ - A->flow.loop_start = cont_label; - A->flow.loop_end = break_label; - if (!_slang_assemble_operation (A, &op->children[3], slang_ref_forbid/*slang_ref_freelance*/)) - return GL_FALSE; - if (!_slang_cleanup_stack (A, &op->children[3])) - return GL_FALSE; - A->flow = save_flow; - - /* go to the beginning of the loop */ - if (!slang_assembly_file_push_label (A->file, slang_asm_jump, cont_label)) - return GL_FALSE; - - /* resolve the end of the loop */ - A->file->code[end_jump].param[0] = A->file->count; - A->file->code[cond_jump].param[0] = A->file->count; - - return GL_TRUE; -} - -/* - * _slang_assemble_do() - * - * do: - * jump start - * break: - * jump end - * continue: - * jump condition - * start: - * - * condition: - * - * jumpz end - * jump start - * end: - */ - -GLboolean _slang_assemble_do (slang_assemble_ctx *A, slang_operation *op) -{ - GLuint skip_jump, end_jump, cont_jump, cond_jump; - GLuint break_label, cont_label; - slang_assembly_flow_control save_flow = A->flow; - - /* skip the "go to the end of the loop" and "go to condition" statements */ - skip_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump)) - return GL_FALSE; - - /* go to the end of the loop - break statements are directed here */ - break_label = A->file->count; - end_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump)) - return GL_FALSE; - - /* go to condition - continue statements are directed here */ - cont_label = A->file->count; - cont_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump)) - return GL_FALSE; - - /* resolve the beginning of the loop */ - A->file->code[skip_jump].param[0] = A->file->count; - - /* execute loop body */ - A->flow.loop_start = cont_label; - A->flow.loop_end = break_label; - if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid/*slang_ref_freelance*/)) - return GL_FALSE; - if (!_slang_cleanup_stack (A, &op->children[0])) - return GL_FALSE; - A->flow = save_flow; - - /* resolve condition point */ - A->file->code[cont_jump].param[0] = A->file->count; - - /* execute condition statement */ - if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid)) - return GL_FALSE; - - /* jump to the end of the loop if not true */ - cond_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero)) - return GL_FALSE; - - /* jump to the beginning of the loop */ - if (!slang_assembly_file_push_label (A->file, slang_asm_jump, A->file->code[skip_jump].param[0])) - return GL_FALSE; - - /* resolve the end of the loop */ - A->file->code[end_jump].param[0] = A->file->count; - A->file->code[cond_jump].param[0] = A->file->count; - - return GL_TRUE; -} - -/* - * _slang_assemble_while() - * - * while: - * jump continue - * break: - * jump end - * continue: - * - * jumpz end - * - * jump continue - * end: - */ - -GLboolean _slang_assemble_while (slang_assemble_ctx *A, slang_operation *op) -{ - GLuint skip_jump, end_jump, cond_jump; - GLuint break_label; - slang_assembly_flow_control save_flow = A->flow; - - /* skip the "go to the end of the loop" statement */ - skip_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump)) - return GL_FALSE; - - /* go to the end of the loop - break statements are directed here */ - break_label = A->file->count; - end_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump)) - return GL_FALSE; - - /* resolve the beginning of the loop - continue statements are directed here */ - A->file->code[skip_jump].param[0] = A->file->count; - - /* execute condition statement */ - if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid)) - return GL_FALSE; - - /* jump to the end of the loop if not true */ - cond_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero)) - return GL_FALSE; - - /* execute loop body */ - A->flow.loop_start = A->file->code[skip_jump].param[0]; - A->flow.loop_end = break_label; - if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid/*slang_ref_freelance*/)) - return GL_FALSE; - if (!_slang_cleanup_stack (A, &op->children[1])) - return GL_FALSE; - A->flow = save_flow; - - /* jump to the beginning of the loop */ - if (!slang_assembly_file_push_label (A->file, slang_asm_jump, A->file->code[skip_jump].param[0])) - return GL_FALSE; - - /* resolve the end of the loop */ - A->file->code[end_jump].param[0] = A->file->count; - A->file->code[cond_jump].param[0] = A->file->count; - - return GL_TRUE; -} - -/* - * _slang_assemble_if() - * - * if: - * - * jumpz else - * - * jump end - * else: - * - * end: - */ - -GLboolean _slang_assemble_if (slang_assemble_ctx *A, slang_operation *op) -{ - GLuint cond_jump, else_jump; - - /* execute condition statement */ - if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid)) - return GL_FALSE; - - /* jump to false-statement if not true */ - cond_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero)) - return GL_FALSE; - - /* execute true-statement */ - if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid/*slang_ref_freelance*/)) - return GL_FALSE; - if (!_slang_cleanup_stack (A, &op->children[1])) - return GL_FALSE; - - /* skip if-false statement */ - else_jump = A->file->count; - if (!slang_assembly_file_push (A->file, slang_asm_jump)) - return GL_FALSE; - - /* resolve start of false-statement */ - A->file->code[cond_jump].param[0] = A->file->count; - - /* execute false-statement */ - if (!_slang_assemble_operation (A, &op->children[2], slang_ref_forbid/*slang_ref_freelance*/)) - return GL_FALSE; - if (!_slang_cleanup_stack (A, &op->children[2])) - return GL_FALSE; - - /* resolve end of if-false statement */ - A->file->code[else_jump].param[0] = A->file->count; - - return GL_TRUE; -} - diff --git a/src/mesa/shader/slang/slang_assemble_conditional.h b/src/mesa/shader/slang/slang_assemble_conditional.h deleted file mode 100644 index ce9e4de6c9..0000000000 --- a/src/mesa/shader/slang/slang_assemble_conditional.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 2005-2006 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_ASSEMBLE_CONDITIONAL_H -#define SLANG_ASSEMBLE_CONDITIONAL_H - -#if defined __cplusplus -extern "C" { -#endif - -GLboolean _slang_assemble_logicaland (slang_assemble_ctx *, struct slang_operation_ *); - -GLboolean _slang_assemble_logicalor (slang_assemble_ctx *, struct slang_operation_ *); - -GLboolean _slang_assemble_select (slang_assemble_ctx *, struct slang_operation_ *); - -GLboolean _slang_assemble_for (slang_assemble_ctx *, struct slang_operation_ *); - -GLboolean _slang_assemble_do (slang_assemble_ctx *, struct slang_operation_ *); - -GLboolean _slang_assemble_while (slang_assemble_ctx *, struct slang_operation_ *); - -GLboolean _slang_assemble_if (slang_assemble_ctx *, struct slang_operation_ *); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/mesa/shader/slang/slang_assemble_constructor.c b/src/mesa/shader/slang/slang_assemble_constructor.c deleted file mode 100644 index 63407580ca..0000000000 --- a/src/mesa/shader/slang/slang_assemble_constructor.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 2005-2006 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_assemble_constructor.c - * slang constructor and vector swizzle assembler - * \author Michal Krol - */ - -#include "imports.h" -#include "slang_assemble.h" -#include "slang_storage.h" -#include "prog_instruction.h" - - -/** - * Checks if a field selector is a general swizzle (an r-value swizzle - * with replicated components or an l-value swizzle mask) for a - * vector. Returns GL_TRUE if this is the case, is filled with - * swizzle information. Returns GL_FALSE otherwise. - */ -GLboolean -_slang_is_swizzle(const char *field, GLuint rows, slang_swizzle * swz) -{ - GLuint i; - GLboolean xyzw = GL_FALSE, rgba = GL_FALSE, stpq = GL_FALSE; - - /* init to undefined. - * We rely on undefined/nil values to distinguish between - * regular swizzles and writemasks. - * For example, the swizzle ".xNNN" is the writemask ".x". - * That's different than the swizzle ".xxxx". - */ - for (i = 0; i < 4; i++) - swz->swizzle[i] = SWIZZLE_NIL; - - /* the swizzle can be at most 4-component long */ - swz->num_components = slang_string_length(field); - if (swz->num_components > 4) - return GL_FALSE; - - for (i = 0; i < swz->num_components; i++) { - /* mark which swizzle group is used */ - switch (field[i]) { - case 'x': - case 'y': - case 'z': - case 'w': - xyzw = GL_TRUE; - break; - case 'r': - case 'g': - case 'b': - case 'a': - rgba = GL_TRUE; - break; - case 's': - case 't': - case 'p': - case 'q': - stpq = GL_TRUE; - break; - default: - return GL_FALSE; - } - - /* collect swizzle component */ - switch (field[i]) { - case 'x': - case 'r': - case 's': - swz->swizzle[i] = 0; - break; - case 'y': - case 'g': - case 't': - swz->swizzle[i] = 1; - break; - case 'z': - case 'b': - case 'p': - swz->swizzle[i] = 2; - break; - case 'w': - case 'a': - case 'q': - swz->swizzle[i] = 3; - break; - } - - /* check if the component is valid for given vector's row count */ - if (rows <= swz->swizzle[i]) - return GL_FALSE; - } - - /* only one swizzle group can be used */ - if ((xyzw && rgba) || (xyzw && stpq) || (rgba && stpq)) - return GL_FALSE; - - return GL_TRUE; -} - - - -/** - * Checks if a general swizzle is an l-value swizzle - these swizzles - * do not have duplicated fields. Returns GL_TRUE if this is a - * swizzle mask. Returns GL_FALSE otherwise - */ -GLboolean -_slang_is_swizzle_mask(const slang_swizzle * swz, GLuint rows) -{ - GLuint i, c = 0; - - /* the swizzle may not be longer than the vector dim */ - if (swz->num_components > rows) - return GL_FALSE; - - /* the swizzle components cannot be duplicated */ - for (i = 0; i < swz->num_components; i++) { - if ((c & (1 << swz->swizzle[i])) != 0) - return GL_FALSE; - c |= 1 << swz->swizzle[i]; - } - - return GL_TRUE; -} - - - -/** - * Combines (multiplies) two swizzles to form single swizzle. - * Example: "vec.wzyx.yx" --> "vec.zw". - */ -GLvoid -_slang_multiply_swizzles(slang_swizzle * dst, const slang_swizzle * left, - const slang_swizzle * right) -{ - GLuint i; - - dst->num_components = right->num_components; - for (i = 0; i < right->num_components; i++) - dst->swizzle[i] = left->swizzle[right->swizzle[i]]; -} - - - -static GLboolean -sizeof_argument(slang_assemble_ctx * A, GLuint * size, slang_operation * op) -{ - slang_assembly_typeinfo ti; - GLboolean result = GL_FALSE; - slang_storage_aggregate agg; - - if (!slang_assembly_typeinfo_construct(&ti)) - return GL_FALSE; - if (!_slang_typeof_operation(A, op, &ti)) - goto end1; - - if (!slang_storage_aggregate_construct(&agg)) - goto end1; - if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, - A->space.structs, A->space.vars, - A->file, A->atoms)) - goto end; - - *size = _slang_sizeof_aggregate(&agg); - result = GL_TRUE; - - end: - slang_storage_aggregate_destruct(&agg); - end1: - slang_assembly_typeinfo_destruct(&ti); - return result; -} - - -static GLboolean -constructor_aggregate(slang_assemble_ctx * A, - const slang_storage_aggregate * flat, - slang_operation * op, GLuint garbage_size) -{ - slang_assembly_typeinfo ti; - GLboolean result = GL_FALSE; - slang_storage_aggregate agg, flat_agg; - - if (!slang_assembly_typeinfo_construct(&ti)) - return GL_FALSE; - if (!_slang_typeof_operation(A, op, &ti)) - goto end1; - - if (!slang_storage_aggregate_construct(&agg)) - goto end1; - if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, - A->space.structs, A->space.vars, - A->file, A->atoms)) - goto end2; - - if (!slang_storage_aggregate_construct(&flat_agg)) - goto end2; - if (!_slang_flatten_aggregate(&flat_agg, &agg)) - goto end; - - if (!_slang_assemble_operation(A, op, slang_ref_forbid)) - goto end; - - /* TODO: convert (generic) elements */ - - /* free the garbage */ - if (garbage_size != 0) { - GLuint i; - - /* move the non-garbage part to the end of the argument */ - if (!slang_assembly_file_push_label(A->file, slang_asm_addr_push, 0)) - goto end; - for (i = flat_agg.count * 4 - garbage_size; i > 0; i -= 4) { - if (!slang_assembly_file_push_label2(A->file, slang_asm_float_move, - garbage_size + i, i)) { - goto end; - } - } - if (!slang_assembly_file_push_label - (A->file, slang_asm_local_free, garbage_size + 4)) - goto end; - } - - result = GL_TRUE; - end: - slang_storage_aggregate_destruct(&flat_agg); - end2: - slang_storage_aggregate_destruct(&agg); - end1: - slang_assembly_typeinfo_destruct(&ti); - return result; -} - - -GLboolean -_slang_assemble_constructor(slang_assemble_ctx * A, const slang_operation * op) -{ - slang_assembly_typeinfo ti; - GLboolean result = GL_FALSE; - slang_storage_aggregate agg, flat; - GLuint size, i; - GLuint arg_sums[2]; - - /* get typeinfo of the constructor (the result of constructor expression) */ - if (!slang_assembly_typeinfo_construct(&ti)) - return GL_FALSE; - if (!_slang_typeof_operation(A, op, &ti)) - goto end1; - - /* create an aggregate of the constructor */ - if (!slang_storage_aggregate_construct(&agg)) - goto end1; - if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, - A->space.structs, A->space.vars, - A->file, A->atoms)) - goto end2; - - /* calculate size of the constructor */ - size = _slang_sizeof_aggregate(&agg); - - /* flatten the constructor */ - if (!slang_storage_aggregate_construct(&flat)) - goto end2; - if (!_slang_flatten_aggregate(&flat, &agg)) - goto end; - - /* collect the last two constructor's argument size sums */ - arg_sums[0] = 0; /* will hold all but the last argument's size sum */ - arg_sums[1] = 0; /* will hold all argument's size sum */ - for (i = 0; i < op->num_children; i++) { - GLuint arg_size = 0; - - if (!sizeof_argument(A, &arg_size, &op->children[i])) - goto end; - if (i > 0) - arg_sums[0] = arg_sums[1]; - arg_sums[1] += arg_size; - } - - /* check if there are too many arguments */ - if (arg_sums[0] >= size) { - /* TODO: info log: too many arguments in constructor list */ - goto end; - } - - /* check if there are too few arguments */ - if (arg_sums[1] < size) { - /* TODO: info log: too few arguments in constructor list */ - /* DEBUG */ - { - if (!slang_storage_aggregate_construct(&agg)) - goto end1; - if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, - A->space.structs, A->space.vars, - A->file, A->atoms)) - goto end2; - - /* calculate size of the constructor */ - size = _slang_sizeof_aggregate(&agg); - } - goto end; - } - - /* traverse the children that form the constructor expression */ - for (i = op->num_children; i > 0; i--) { - GLuint garbage_size; - - /* the last argument may be too big - calculate the unnecessary - * data size - */ - if (i == op->num_children) - garbage_size = arg_sums[1] - size; - else - garbage_size = 0; - - if (!constructor_aggregate(A, &flat, &op->children[i - 1], garbage_size)) - goto end; - } - - result = GL_TRUE; - end: - slang_storage_aggregate_destruct(&flat); - end2: - slang_storage_aggregate_destruct(&agg); - end1: - slang_assembly_typeinfo_destruct(&ti); - return result; -} - - - -GLboolean -_slang_assemble_constructor_from_swizzle(slang_assemble_ctx * A, - const slang_swizzle * swz, - const slang_type_specifier * spec, - const slang_type_specifier * master_spec) -{ - const GLuint master_rows = _slang_type_dim(master_spec->type); - GLuint i; - - for (i = 0; i < master_rows; i++) { - switch (_slang_type_base(master_spec->type)) { - case slang_spec_bool: - if (!slang_assembly_file_push_label2(A->file, slang_asm_bool_copy, - (master_rows - i) * 4, i * 4)) - return GL_FALSE; - break; - case slang_spec_int: - if (!slang_assembly_file_push_label2(A->file, slang_asm_int_copy, - (master_rows - i) * 4, i * 4)) - return GL_FALSE; - break; - case slang_spec_float: - if (!slang_assembly_file_push_label2(A->file, slang_asm_float_copy, - (master_rows - i) * 4, i * 4)) - return GL_FALSE; - break; - default: - break; - } - } - - if (!slang_assembly_file_push_label(A->file, slang_asm_local_free, 4)) - return GL_FALSE; - - for (i = swz->num_components; i > 0; i--) { - const GLuint n = i - 1; - - if (!slang_assembly_file_push_label2(A->file, slang_asm_local_addr, - A->local.swizzle_tmp, 16)) - return GL_FALSE; - if (!slang_assembly_file_push_label(A->file, slang_asm_addr_push, - swz->swizzle[n] * 4)) - return GL_FALSE; - if (!slang_assembly_file_push(A->file, slang_asm_addr_add)) - return GL_FALSE; - - switch (_slang_type_base(master_spec->type)) { - case slang_spec_bool: - if (!slang_assembly_file_push(A->file, slang_asm_bool_deref)) - return GL_FALSE; - break; - case slang_spec_int: - if (!slang_assembly_file_push(A->file, slang_asm_int_deref)) - return GL_FALSE; - break; - case slang_spec_float: - if (!slang_assembly_file_push(A->file, slang_asm_float_deref)) - return GL_FALSE; - break; - default: - break; - } - } - - return GL_TRUE; -} diff --git a/src/mesa/shader/slang/slang_assemble_constructor.h b/src/mesa/shader/slang/slang_assemble_constructor.h deleted file mode 100644 index c0deb91344..0000000000 --- a/src/mesa/shader/slang/slang_assemble_constructor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 2005-2006 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. - */ - -#ifndef SLANG_ASSEMBLE_CONSTRUCTOR_H -#define SLANG_ASSEMBLE_CONSTRUCTOR_H - -#if defined __cplusplus -extern "C" { -#endif - - -extern GLboolean -_slang_is_swizzle(const char *field, GLuint rows, slang_swizzle *swz); - -extern GLboolean -_slang_is_swizzle_mask(const slang_swizzle *swz, GLuint rows); - -extern GLvoid -_slang_multiply_swizzles(slang_swizzle *, const slang_swizzle *, - const slang_swizzle *); - -extern GLboolean -_slang_assemble_constructor(slang_assemble_ctx *, - const struct slang_operation_ *); - -extern GLboolean -_slang_assemble_constructor_from_swizzle(slang_assemble_ctx *, - const slang_swizzle *, - const slang_type_specifier *, - const slang_type_specifier *); - -#ifdef __cplusplus -} -#endif - -#endif /* SLANG_ASSEMBLE_CONSTRUCTOR_H */ -- cgit v1.2.3