#include "slang_compile.h"
#include "slang_storage.h"
#include "slang_error.h"
-
#include "slang_print.h"
-/*#include "assemble2.c"*/
+
/* slang_assembly */
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;
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;
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;
#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
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 */
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);
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();
#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,
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);
}
-#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,
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);
#include "imports.h"
#include "mtypes.h"
-#include "slang_export.h"
#include "slang_assemble.h"
#include "slang_compile_variable.h"
#include "slang_compile_struct.h"
#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_
{
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
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;
-}
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
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;
-}
_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
}
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:
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 \