summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader/slang/slang_compile.c')
-rw-r--r--src/mesa/shader/slang/slang_compile.c66
1 files changed, 41 insertions, 25 deletions
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c
index b8044b1060..ab848579b7 100644
--- a/src/mesa/shader/slang/slang_compile.c
+++ b/src/mesa/shader/slang/slang_compile.c
@@ -144,6 +144,7 @@ typedef struct slang_output_ctx_
slang_function_scope *funs;
slang_struct_scope *structs;
struct gl_program *program;
+ struct gl_sl_pragmas *pragmas;
slang_var_table *vartable;
GLuint default_precision[TYPE_SPECIFIER_COUNT];
GLboolean allow_precision;
@@ -1005,7 +1006,7 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O,
/* parse child statements, do not create new variable scope */
oper->type = SLANG_OPER_BLOCK_NO_NEW_SCOPE;
while (*C->I != OP_END)
- if (!parse_child_operation(C, O, oper, 1))
+ if (!parse_child_operation(C, O, oper, GL_TRUE))
RETURN0;
C->I++;
break;
@@ -1017,7 +1018,7 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O,
oper->type = SLANG_OPER_BLOCK_NEW_SCOPE;
o.vars = oper->locals;
while (*C->I != OP_END)
- if (!parse_child_operation(C, &o, oper, 1))
+ if (!parse_child_operation(C, &o, oper, GL_TRUE))
RETURN0;
C->I++;
}
@@ -1074,7 +1075,7 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O,
if (oper->a_id == SLANG_ATOM_NULL)
RETURN0;
while (*C->I != OP_END) {
- if (!parse_child_operation(C, O, oper, 0))
+ if (!parse_child_operation(C, O, oper, GL_FALSE))
RETURN0;
}
C->I++;
@@ -1090,21 +1091,21 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O,
break;
case OP_RETURN:
oper->type = SLANG_OPER_RETURN;
- if (!parse_child_operation(C, O, oper, 0))
+ if (!parse_child_operation(C, O, oper, GL_FALSE))
RETURN0;
break;
case OP_EXPRESSION:
oper->type = SLANG_OPER_EXPRESSION;
- if (!parse_child_operation(C, O, oper, 0))
+ if (!parse_child_operation(C, O, oper, GL_FALSE))
RETURN0;
break;
case OP_IF:
oper->type = SLANG_OPER_IF;
- if (!parse_child_operation(C, O, oper, 0))
+ if (!parse_child_operation(C, O, oper, GL_FALSE))
RETURN0;
- if (!parse_child_operation(C, O, oper, 1))
+ if (!parse_child_operation(C, O, oper, GL_TRUE))
RETURN0;
- if (!parse_child_operation(C, O, oper, 1))
+ if (!parse_child_operation(C, O, oper, GL_TRUE))
RETURN0;
break;
case OP_WHILE:
@@ -1113,17 +1114,17 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O,
oper->type = SLANG_OPER_WHILE;
o.vars = oper->locals;
- if (!parse_child_operation(C, &o, oper, 1))
+ if (!parse_child_operation(C, &o, oper, GL_TRUE))
RETURN0;
- if (!parse_child_operation(C, &o, oper, 1))
+ if (!parse_child_operation(C, &o, oper, GL_TRUE))
RETURN0;
}
break;
case OP_DO:
oper->type = SLANG_OPER_DO;
- if (!parse_child_operation(C, O, oper, 1))
+ if (!parse_child_operation(C, O, oper, GL_TRUE))
RETURN0;
- if (!parse_child_operation(C, O, oper, 0))
+ if (!parse_child_operation(C, O, oper, GL_FALSE))
RETURN0;
break;
case OP_FOR:
@@ -1132,13 +1133,13 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O,
oper->type = SLANG_OPER_FOR;
o.vars = oper->locals;
- if (!parse_child_operation(C, &o, oper, 1))
+ if (!parse_child_operation(C, &o, oper, GL_TRUE))
RETURN0;
- if (!parse_child_operation(C, &o, oper, 1))
+ if (!parse_child_operation(C, &o, oper, GL_TRUE))
RETURN0;
- if (!parse_child_operation(C, &o, oper, 0))
+ if (!parse_child_operation(C, &o, oper, GL_FALSE))
RETURN0;
- if (!parse_child_operation(C, &o, oper, 1))
+ if (!parse_child_operation(C, &o, oper, GL_TRUE))
RETURN0;
}
break;
@@ -1429,7 +1430,7 @@ parse_expression(slang_parse_ctx * C, slang_output_ctx * O,
C->I++;
while (*C->I != OP_END)
- if (!parse_child_operation(C, O, op, 0))
+ if (!parse_child_operation(C, O, op, GL_FALSE))
RETURN0;
C->I++;
#if 0
@@ -1449,7 +1450,7 @@ parse_expression(slang_parse_ctx * C, slang_output_ctx * O,
case OP_CALL:
{
GLboolean array_constructor = GL_FALSE;
- GLint array_constructor_size;
+ GLint array_constructor_size = 0;
op->type = SLANG_OPER_CALL;
op->a_id = parse_identifier(C);
@@ -1470,9 +1471,9 @@ parse_expression(slang_parse_ctx * C, slang_output_ctx * O,
RETURN0;
}
else {
+ /* parse the array constructor size */
slang_operation array_size;
array_constructor = GL_TRUE;
- /* parse the array constructor size */
slang_operation_construct(&array_size);
if (!parse_expression(C, O, &array_size)) {
slang_operation_destruct(&array_size);
@@ -1494,7 +1495,7 @@ parse_expression(slang_parse_ctx * C, slang_output_ctx * O,
RETURN0;
}
while (*C->I != OP_END)
- if (!parse_child_operation(C, O, op, 0))
+ if (!parse_child_operation(C, O, op, GL_FALSE))
RETURN0;
C->I++;
@@ -2059,6 +2060,7 @@ 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;
+ A.pragmas = O->pragmas;
A.vartable = O->vartable;
A.log = C->L;
A.curFuncEndLabel = NULL;
@@ -2349,6 +2351,7 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit,
o.structs = &unit->structs;
o.vars = &unit->vars;
o.program = shader ? shader->Program : NULL;
+ o.pragmas = shader ? &shader->Pragmas : NULL;
o.vartable = _slang_new_var_table(maxRegs);
_slang_push_var_table(o.vartable);
@@ -2417,6 +2420,7 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit,
A.space.structs = o.structs;
A.space.vars = o.vars;
A.program = o.program;
+ A.pragmas = &shader->Pragmas;
A.vartable = o.vartable;
A.log = C->L;
@@ -2474,7 +2478,9 @@ static GLboolean
compile_with_grammar(grammar id, const char *source, slang_code_unit * unit,
slang_unit_type type, slang_info_log * infolog,
slang_code_unit * builtin,
- struct gl_shader *shader)
+ struct gl_shader *shader,
+ const struct gl_extensions *extensions,
+ struct gl_sl_pragmas *pragmas)
{
byte *prod;
GLuint size, start, version;
@@ -2502,7 +2508,8 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit,
/* Now preprocess the source string. */
slang_string_init(&preprocessed);
- if (!_slang_preprocess_directives(&preprocessed, &source[start], infolog)) {
+ if (!_slang_preprocess_directives(&preprocessed, &source[start],
+ infolog, extensions, pragmas)) {
slang_string_free(&preprocessed);
slang_info_log_error(infolog, "failed to preprocess the source.");
return GL_FALSE;
@@ -2575,7 +2582,9 @@ static const byte slang_vertex_builtin_gc[] = {
static GLboolean
compile_object(grammar * id, const char *source, slang_code_object * object,
slang_unit_type type, slang_info_log * infolog,
- struct gl_shader *shader)
+ struct gl_shader *shader,
+ const struct gl_extensions *extensions,
+ struct gl_sl_pragmas *pragmas)
{
slang_code_unit *builtins = NULL;
GLuint base_version = 110;
@@ -2674,7 +2683,7 @@ compile_object(grammar * id, const char *source, slang_code_object * object,
/* compile the actual shader - pass-in built-in library for external shader */
return compile_with_grammar(*id, source, &object->unit, type, infolog,
- builtins, shader);
+ builtins, shader, extensions, pragmas);
}
@@ -2697,7 +2706,8 @@ compile_shader(GLcontext *ctx, slang_code_object * object,
_slang_code_object_dtr(object);
_slang_code_object_ctr(object);
- success = compile_object(&id, shader->Source, object, type, infolog, shader);
+ success = compile_object(&id, shader->Source, object, type, infolog, shader,
+ &ctx->Extensions, &shader->Pragmas);
if (id != 0)
grammar_destroy(id);
if (!success)
@@ -2784,6 +2794,12 @@ _slang_compile(GLcontext *ctx, struct gl_shader *shader)
_mesa_print_program(shader->Program);
#endif
+ shader->CompileStatus = success;
+
+ if (ctx->Shader.Flags & GLSL_LOG) {
+ _mesa_write_shader_to_file(shader);
+ }
+
return success;
}