assorted code clean-ups
This commit is contained in:
@@ -849,7 +849,6 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
|
|||||||
ctx->Shader.CurrentProgram = NULL;
|
ctx->Shader.CurrentProgram = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXXX need to handle reference counting here! */
|
|
||||||
if (program) {
|
if (program) {
|
||||||
struct gl_shader_program *shProg;
|
struct gl_shader_program *shProg;
|
||||||
shProg = _mesa_lookup_shader_program(ctx, program);
|
shProg = _mesa_lookup_shader_program(ctx, program);
|
||||||
@@ -916,7 +915,7 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const GLfloat *fValues = (const GLfloat *) values; /* XXX */
|
const GLfloat *fValues = (const GLfloat *) values;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case GL_FLOAT_VEC4:
|
case GL_FLOAT_VEC4:
|
||||||
uniformVal[3] = fValues[3];
|
uniformVal[3] = fValues[3];
|
||||||
|
@@ -541,6 +541,11 @@ _slang_codegen_global_variable(slang_variable *var, struct gl_program *prog,
|
|||||||
else if (var->type.qualifier == slang_qual_const) {
|
else if (var->type.qualifier == slang_qual_const) {
|
||||||
if (prog) {
|
if (prog) {
|
||||||
/* user-defined constant */
|
/* user-defined constant */
|
||||||
|
const GLint size = _slang_sizeof_type_specifier(&var->type.specifier);
|
||||||
|
/*
|
||||||
|
const GLint index = _mesa_add_named_constant(prog->Parameters);
|
||||||
|
*/
|
||||||
|
printf("Global user constant\n");
|
||||||
abort(); /* XXX fix */
|
abort(); /* XXX fix */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -591,7 +596,10 @@ _slang_codegen_global_variable(slang_variable *var, struct gl_program *prog,
|
|||||||
if (dbg) printf("OUTPUT ");
|
if (dbg) printf("OUTPUT ");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
/* ordinary variable */
|
||||||
|
assert(prog); /* shouldn't be any pre-defined, unqualified vars */
|
||||||
if (dbg) printf("other ");
|
if (dbg) printf("other ");
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
if (dbg) printf("GLOBAL VAR %s idx %d\n", (char*) var->a_name, store?store->Index:-2);
|
if (dbg) printf("GLOBAL VAR %s idx %d\n", (char*) var->a_name, store?store->Index:-2);
|
||||||
|
|
||||||
@@ -2104,20 +2112,24 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Produce an IR tree from a function AST.
|
* Produce an IR tree from a function AST.
|
||||||
* Then call the code emitter to convert the IR tree into a gl_program.
|
* Then call the code emitter to convert the IR tree into gl_program
|
||||||
|
* instructions.
|
||||||
*/
|
*/
|
||||||
struct slang_ir_node_ *
|
struct slang_ir_node_ *
|
||||||
_slang_codegen_function(slang_assemble_ctx * A, slang_function * fun)
|
_slang_codegen_function(slang_assemble_ctx * A, slang_function * fun)
|
||||||
{
|
{
|
||||||
slang_ir_node *n, *endLabel;
|
slang_ir_node *n, *endLabel;
|
||||||
|
GLboolean success;
|
||||||
|
|
||||||
if (_mesa_strcmp((char *) fun->header.a_name, "main") != 0 &&
|
if (_mesa_strcmp((char *) fun->header.a_name, "main") != 0) {
|
||||||
_mesa_strcmp((char *) fun->header.a_name, "foo") != 0 &&
|
/* we only really generate code for main, all other functions get
|
||||||
_mesa_strcmp((char *) fun->header.a_name, "bar") != 0)
|
* inlined.
|
||||||
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
printf("\n*********** Assemble function2(%s)\n", (char*)fun->header.a_name);
|
|
||||||
#if 1
|
#if 1
|
||||||
|
printf("\n*********** codegen_function %s\n", (char *) fun->header.a_name);
|
||||||
slang_print_function(fun, 1);
|
slang_print_function(fun, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -2133,6 +2145,7 @@ _slang_codegen_function(slang_assemble_ctx * A, slang_function * fun)
|
|||||||
|
|
||||||
CurFunction = fun;
|
CurFunction = fun;
|
||||||
|
|
||||||
|
/* Create an end-of-function label */
|
||||||
if (!CurFunction->end_label)
|
if (!CurFunction->end_label)
|
||||||
CurFunction->end_label = slang_atom_pool_gen(A->atoms, "__endOfFunc_main_");
|
CurFunction->end_label = slang_atom_pool_gen(A->atoms, "__endOfFunc_main_");
|
||||||
|
|
||||||
@@ -2147,17 +2160,17 @@ _slang_codegen_function(slang_assemble_ctx * A, slang_function * fun)
|
|||||||
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
printf("************* New body for %s *****\n", (char*)fun->header.a_name);
|
printf("************* New AST for %s *****\n", (char*)fun->header.a_name);
|
||||||
slang_print_function(fun, 1);
|
slang_print_function(fun, 1);
|
||||||
|
|
||||||
printf("************* IR for %s *******\n", (char*)fun->header.a_name);
|
printf("************* IR for %s *******\n", (char*)fun->header.a_name);
|
||||||
slang_print_ir(n, 0);
|
slang_print_ir(n, 0);
|
||||||
printf("************* End assemble function2 ************\n\n");
|
printf("************* End assemble function2 ************\n\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_mesa_strcmp((char*) fun->header.a_name, "main") == 0) {
|
success = _slang_emit_code(n, A->codegen, A->program);
|
||||||
_slang_emit_code(n, A->codegen, A->program);
|
|
||||||
}
|
/* free codegen context */
|
||||||
|
_mesa_free(A->codegen);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@@ -751,7 +751,7 @@ emit(slang_gen_context *gc, slang_ir_node *n, struct gl_program *prog)
|
|||||||
case IR_CJUMP:
|
case IR_CJUMP:
|
||||||
return emit_cjump(n->Target, prog);
|
return emit_cjump(n->Target, prog);
|
||||||
default:
|
default:
|
||||||
printf("emit: ?\n");
|
_mesa_problem(NULL, "Unexpected IR opcode in emit()\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -771,29 +771,24 @@ GLboolean
|
|||||||
_slang_emit_code(slang_ir_node *n, slang_gen_context *gc,
|
_slang_emit_code(slang_ir_node *n, slang_gen_context *gc,
|
||||||
struct gl_program *prog)
|
struct gl_program *prog)
|
||||||
{
|
{
|
||||||
/*GET_CURRENT_CONTEXT(ctx);*/
|
GLboolean success;
|
||||||
|
|
||||||
/*
|
if (emit(gc, n, prog)) {
|
||||||
gc = _slang_new_codegen_context();
|
/* finish up by addeing the END opcode to program */
|
||||||
*/
|
|
||||||
|
|
||||||
printf("************ Begin generate code\n");
|
|
||||||
|
|
||||||
(void) emit(gc, n, prog);
|
|
||||||
|
|
||||||
{
|
|
||||||
struct prog_instruction *inst;
|
struct prog_instruction *inst;
|
||||||
inst = new_instruction(prog, OPCODE_END);
|
inst = new_instruction(prog, OPCODE_END);
|
||||||
|
success = GL_TRUE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* record an error? */
|
||||||
|
success = GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("************ End generate code (%u inst):\n", prog->NumInstructions);
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
printf("*********** End generate code (%u inst):\n", prog->NumInstructions);
|
||||||
_mesa_print_program(prog);
|
_mesa_print_program(prog);
|
||||||
_mesa_print_program_parameters(ctx,prog);
|
_mesa_print_program_parameters(ctx,prog);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_mesa_free(gc);
|
return success;
|
||||||
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user