summaryrefslogtreecommitdiff
path: root/src/mesa/shader
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c37
-rw-r--r--src/mesa/shader/slang/slang_compile.c114
-rw-r--r--src/mesa/shader/slang/slang_compile.h13
-rw-r--r--src/mesa/shader/slang/slang_emit.c18
-rw-r--r--src/mesa/shader/slang/slang_emit.h3
-rw-r--r--src/mesa/shader/slang/slang_preprocess.h23
-rw-r--r--src/mesa/shader/slang/slang_simplify.c6
-rw-r--r--src/mesa/shader/slang/slang_simplify.h3
-rw-r--r--src/mesa/shader/slang/slang_typeinfo.c123
-rw-r--r--src/mesa/shader/slang/slang_typeinfo.h9
10 files changed, 127 insertions, 222 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index d239a97500..efd330106b 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -47,7 +47,6 @@
#include "slang_typeinfo.h"
#include "slang_codegen.h"
#include "slang_compile.h"
-#include "slang_error.h"
#include "slang_label.h"
#include "slang_simplify.h"
#include "slang_emit.h"
@@ -1154,7 +1153,7 @@ make_writemask(const char *field)
*/
static slang_ir_node *
_slang_gen_asm(slang_assemble_ctx *A, slang_operation *oper,
- slang_operation *dest)
+ slang_operation *dest)
{
const slang_asm_info *info;
slang_ir_node *kids[3], *n;
@@ -1280,15 +1279,15 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name,
* Use 'name' to find the function to call
*/
fun = _slang_locate_function(A->space.funcs, atom, params, param_count,
- &A->space, A->atoms);
+ &A->space, A->atoms, A->log);
if (!fun) {
/* A function with exactly the right parameters/types was not found.
* Try adapting the parameters.
*/
fun = _slang_first_function(A->space.funcs, name);
- if (!_slang_adapt_call(oper, fun, &A->space, A->atoms)) {
- RETURN_ERROR2("Undefined function (or no matching parameters)",
- name, 0);
+ if (!_slang_adapt_call(oper, fun, &A->space, A->atoms, A->log)) {
+ slang_info_log_error(A->log, "Undefined function '%s'", name);
+ return NULL;
}
assert(fun);
}
@@ -1361,7 +1360,8 @@ _slang_gen_while(slang_assemble_ctx * A, const slang_operation *oper)
if (loop->BranchNode == 0 && isConst && constTrue) {
/* infinite loop detected */
A->CurLoop = prevLoop; /* clean-up */
- RETURN_ERROR("Infinite loop detected!", 0);
+ slang_info_log_error(A->log, "Infinite loop detected!");
+ return NULL;
}
/* pop loop, restore prev */
@@ -1816,7 +1816,8 @@ _slang_gen_declaration(slang_assemble_ctx *A, slang_operation *oper)
assert(oper->num_children == 1);
var = new_var(A, oper, oper->a_id);
if (!var) {
- RETURN_ERROR2("Undefined variable:", varName, 0);
+ slang_info_log_error(A->log, "undefined variable '%s'", varName);
+ return NULL;
}
/* XXX make copy of this initializer? */
rhs = _slang_gen_operation(A, &oper->children[0]);
@@ -1829,7 +1830,8 @@ _slang_gen_declaration(slang_assemble_ctx *A, slang_operation *oper)
slang_ir_node *var, *init, *rhs;
var = new_var(A, oper, oper->a_id);
if (!var) {
- RETURN_ERROR2("Undefined variable:", varName, 0);
+ slang_info_log_error(A->log, "undefined variable '%s'", varName);
+ return NULL;
}
#if 0
/* XXX make copy of this initializer? */
@@ -1870,7 +1872,8 @@ _slang_gen_variable(slang_assemble_ctx * A, slang_operation *oper)
slang_atom aVar = oper->var ? oper->var->a_name : oper->a_id;
slang_ir_node *n = new_var(A, oper, aVar);
if (!n) {
- RETURN_ERROR2("Undefined variable:", (char *) aVar, 0);
+ slang_info_log_error(A->log, "undefined variable '%s'", (char *) aVar);
+ return NULL;
}
return n;
}
@@ -2045,7 +2048,7 @@ _slang_gen_field(slang_assemble_ctx * A, slang_operation *oper)
slang_ir_node *n;
GLuint swizzle;
if (!_slang_is_swizzle((char *) oper->a_id, rows, &swz)) {
- RETURN_ERROR("Bad swizzle", 0);
+ slang_info_log_error(A->log, "Bad swizzle");
}
swizzle = MAKE_SWIZZLE4(swz.swizzle[0],
swz.swizzle[1],
@@ -2063,7 +2066,7 @@ _slang_gen_field(slang_assemble_ctx * A, slang_operation *oper)
slang_ir_node *n;
GLuint swizzle;
if (!_slang_is_swizzle((char *) oper->a_id, rows, &swz)) {
- RETURN_ERROR("Bad swizzle", 0);
+ slang_info_log_error(A->log, "Bad swizzle");
}
swizzle = MAKE_SWIZZLE4(swz.swizzle[0],
swz.swizzle[1],
@@ -2122,7 +2125,7 @@ _slang_gen_subscript(slang_assemble_ctx * A, slang_operation *oper)
index = (GLint) oper->children[1].literal[0];
if (oper->children[1].type != SLANG_OPER_LITERAL_INT ||
index >= max) {
- RETURN_ERROR("Invalid array index for vector type", 0);
+ slang_info_log_error(A->log, "Invalid array index for vector type");
}
n = _slang_gen_operation(A, &oper->children[0]);
@@ -2243,12 +2246,12 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
return _slang_gen_while(A, oper);
case SLANG_OPER_BREAK:
if (!A->CurLoop) {
- RETURN_ERROR("'break' not in loop", 0);
+ slang_info_log_error(A->log, "'break' not in loop");
}
return new_break(A->CurLoop);
case SLANG_OPER_CONTINUE:
if (!A->CurLoop) {
- RETURN_ERROR("'continue' not in loop", 0);
+ slang_info_log_error(A->log, "'continue' not in loop");
}
return new_cont(A->CurLoop);
case SLANG_OPER_DISCARD:
@@ -2621,7 +2624,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
n = new_seq(n, init);
}
- success = _slang_emit_code(n, A->vartable, A->program, GL_FALSE);
+ success = _slang_emit_code(n, A->vartable, A->program, GL_FALSE, A->log);
_slang_free_ir_tree(n);
}
@@ -2709,7 +2712,7 @@ _slang_codegen_function(slang_assemble_ctx * A, slang_function * fun)
#endif
/* Emit program instructions */
- success = _slang_emit_code(n, A->vartable, A->program, GL_TRUE);
+ success = _slang_emit_code(n, A->vartable, A->program, GL_TRUE, A->log);
_slang_free_ir_tree(n);
/* free codegen context */
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c
index a1cae5d338..1a4c7d31f1 100644
--- a/src/mesa/shader/slang/slang_compile.c
+++ b/src/mesa/shader/slang/slang_compile.c
@@ -37,8 +37,8 @@
#include "slang_compile.h"
#include "slang_preprocess.h"
#include "slang_storage.h"
-#include "slang_error.h"
#include "slang_emit.h"
+#include "slang_log.h"
#include "slang_vartable.h"
#include "slang_simplify.h"
@@ -115,110 +115,6 @@ _slang_code_object_dtr(slang_code_object * self)
slang_atom_pool_destruct(&self->atompool);
}
-/* slang_info_log */
-
-static char *out_of_memory = "Error: Out of memory.\n";
-
-void
-slang_info_log_construct(slang_info_log * log)
-{
- log->text = NULL;
- log->dont_free_text = 0;
-}
-
-void
-slang_info_log_destruct(slang_info_log * log)
-{
- if (!log->dont_free_text)
- slang_alloc_free(log->text);
-}
-
-static int
-slang_info_log_message(slang_info_log * log, const char *prefix,
- const char *msg)
-{
- GLuint size;
-
- if (log->dont_free_text)
- return 0;
- size = slang_string_length(msg) + 2;
- if (prefix != NULL)
- size += slang_string_length(prefix) + 2;
- if (log->text != NULL) {
- GLuint old_len = slang_string_length(log->text);
- log->text = (char *)
- slang_alloc_realloc(log->text, old_len + 1, old_len + size);
- }
- else {
- log->text = (char *) (slang_alloc_malloc(size));
- if (log->text != NULL)
- log->text[0] = '\0';
- }
- if (log->text == NULL)
- return 0;
- if (prefix != NULL) {
- slang_string_concat(log->text, prefix);
- slang_string_concat(log->text, ": ");
- }
- slang_string_concat(log->text, msg);
- slang_string_concat(log->text, "\n");
-#if 1
- abort(); /* XXX temporary */
-#endif
- return 1;
-}
-
-int
-slang_info_log_print(slang_info_log * log, const char *msg, ...)
-{
- va_list va;
- char buf[1024];
-
- va_start(va, msg);
- _mesa_vsprintf(buf, msg, va);
- va_end(va);
- return slang_info_log_message(log, NULL, buf);
-}
-
-int
-slang_info_log_error(slang_info_log * log, const char *msg, ...)
-{
- va_list va;
- char buf[1024];
-
- va_start(va, msg);
- _mesa_vsprintf(buf, msg, va);
- va_end(va);
- if (slang_info_log_message(log, "Error", buf))
- return 1;
- slang_info_log_memory(log);
- return 0;
-}
-
-int
-slang_info_log_warning(slang_info_log * log, const char *msg, ...)
-{
- va_list va;
- char buf[1024];
-
- va_start(va, msg);
- _mesa_vsprintf(buf, msg, va);
- va_end(va);
- if (slang_info_log_message(log, "Warning", buf))
- return 1;
- slang_info_log_memory(log);
- return 0;
-}
-
-void
-slang_info_log_memory(slang_info_log * log)
-{
- if (!slang_info_log_message(log, "Error", "Out of memory.")) {
- log->dont_free_text = 1;
- log->text = out_of_memory;
- }
- abort(); /* XXX temporary */
-}
/* slang_parse_ctx */
@@ -1838,8 +1734,7 @@ parse_function(slang_parse_ctx * C, slang_output_ctx * O, int definition,
A.space.vars = O->vars;
A.program = O->program;
A.vartable = O->vartable;
-
- _slang_reset_error();
+ A.log = C->L;
_slang_codegen_function(&A, *parsed_func_ret);
}
@@ -2002,7 +1897,7 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit,
slang_string_free(&preprocessed);
grammar_get_last_error((byte *) (buf), sizeof(buf), &pos);
slang_info_log_error(infolog, buf);
- RETURN_ERROR("syntax error (possibly in library code)", 0);
+ /* syntax error (possibly in library code) */
}
slang_string_free(&preprocessed);
@@ -2175,7 +2070,7 @@ _slang_compile(GLcontext *ctx, struct gl_shader *shader)
success = compile_shader(ctx, &obj, type, &info_log, shader);
- if (success) {
+ if (success && !info_log.text) {
#if 0
slang_create_uniforms(&object->expdata, shader);
_mesa_print_program(program);
@@ -2183,6 +2078,7 @@ _slang_compile(GLcontext *ctx, struct gl_shader *shader)
#endif
}
else {
+ success = GL_FALSE;
/* XXX more work on info log needed here */
if (info_log.text) {
if (shader->InfoLog) {
diff --git a/src/mesa/shader/slang/slang_compile.h b/src/mesa/shader/slang/slang_compile.h
index 7abb92bd3b..086e2d8dc4 100644
--- a/src/mesa/shader/slang/slang_compile.h
+++ b/src/mesa/shader/slang/slang_compile.h
@@ -88,19 +88,6 @@ _slang_code_object_ctr (slang_code_object *);
extern GLvoid
_slang_code_object_dtr (slang_code_object *);
-typedef struct slang_info_log_
-{
- char *text;
- int dont_free_text;
-} slang_info_log;
-
-void slang_info_log_construct (slang_info_log *);
-void slang_info_log_destruct (slang_info_log *);
-int slang_info_log_print (slang_info_log *, const char *, ...);
-int slang_info_log_error (slang_info_log *, const char *, ...);
-int slang_info_log_warning (slang_info_log *, const char *, ...);
-void slang_info_log_memory (slang_info_log *);
-
extern GLboolean
_slang_compile (GLcontext *ctx, struct gl_shader *shader);
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index f5b6fb4d65..b0776e9340 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -45,7 +45,6 @@
#include "prog_print.h"
#include "slang_builtin.h"
#include "slang_emit.h"
-#include "slang_error.h"
#define PEEPHOLE_OPTIMIZATIONS 1
@@ -1421,14 +1420,20 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n)
assert(n->Store->Index < 0);
if (!n->Var || n->Var->isTemp) {
/* a nameless/temporary variable, will be freed after first use */
- if (!_slang_alloc_temp(emitInfo->vt, n->Store))
- RETURN_ERROR("Ran out of registers, too many temporaries", 0);
+ if (!_slang_alloc_temp(emitInfo->vt, n->Store)) {
+ slang_info_log_error(emitInfo->log,
+ "Ran out of registers, too many temporaries");
+ return NULL;
+ }
}
else {
/* a regular variable */
_slang_add_variable(emitInfo->vt, n->Var);
- if (!_slang_alloc_var(emitInfo->vt, n->Store))
- RETURN_ERROR("Ran out of registers, too many variables", 0);
+ if (!_slang_alloc_var(emitInfo->vt, n->Store)) {
+ slang_info_log_error(emitInfo->log,
+ "Ran out of registers, too many variables");
+ return NULL;
+ }
/*
printf("IR_VAR_DECL %s %d store %p\n",
(char*) n->Var->a_name, n->Store->Index, (void*) n->Store);
@@ -1530,7 +1535,8 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n)
n->Store->Size,
&n->Store->Swizzle);
if (n->Store->Index < 0) {
- RETURN_ERROR("Ran out of space for constants.", 0);
+ slang_info_log_error(emitInfo->log, "Ran out of space for constants");
+ return NULL;
}
return NULL;
diff --git a/src/mesa/shader/slang/slang_emit.h b/src/mesa/shader/slang/slang_emit.h
index 1b792402da..13ba6d7d6c 100644
--- a/src/mesa/shader/slang/slang_emit.h
+++ b/src/mesa/shader/slang/slang_emit.h
@@ -42,7 +42,8 @@ _slang_new_ir_storage(enum register_file file, GLint index, GLint size);
extern GLboolean
_slang_emit_code(slang_ir_node *n, slang_var_table *vartable,
- struct gl_program *prog, GLboolean withEnd);
+ struct gl_program *prog, GLboolean withEnd,
+ slang_info_log *log);
#endif /* SLANG_EMIT_H */
diff --git a/src/mesa/shader/slang/slang_preprocess.h b/src/mesa/shader/slang/slang_preprocess.h
index f83e6e6e3f..d8eb12e4ff 100644
--- a/src/mesa/shader/slang/slang_preprocess.h
+++ b/src/mesa/shader/slang/slang_preprocess.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.6
+ * Version: 6.5.3
*
- * Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 2005-2007 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"),
@@ -22,24 +22,19 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#if !defined SLANG_PREPROCESS_H
+#ifndef SLANG_PREPROCESS_H
#define SLANG_PREPROCESS_H
#include "slang_compile.h"
+#include "slang_log.h"
-#if defined __cplusplus
-extern "C" {
-#endif
-GLboolean
+extern GLboolean
_slang_preprocess_version (const char *, GLuint *, GLuint *, slang_info_log *);
-GLboolean
-_slang_preprocess_directives (slang_string *output, const char *input, slang_info_log *);
+extern GLboolean
+_slang_preprocess_directives (slang_string *output, const char *input,
+ slang_info_log *);
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+#endif /* SLANG_PREPROCESS_H */
diff --git a/src/mesa/shader/slang/slang_simplify.c b/src/mesa/shader/slang/slang_simplify.c
index 07b4ae2760..87b117874f 100644
--- a/src/mesa/shader/slang/slang_simplify.c
+++ b/src/mesa/shader/slang/slang_simplify.c
@@ -292,7 +292,7 @@ _slang_simplify(slang_operation *oper,
GLboolean
_slang_adapt_call(slang_operation *callOper, const slang_function *fun,
const slang_name_space * space,
- slang_atom_pool * atoms)
+ slang_atom_pool * atoms, slang_info_log *log)
{
const GLboolean haveRetValue = _slang_function_has_return_value(fun);
const int numParams = fun->param_count - haveRetValue;
@@ -317,7 +317,7 @@ _slang_adapt_call(slang_operation *callOper, const slang_function *fun,
if (!slang_typeinfo_construct(&argType))
return GL_FALSE;
if (!_slang_typeof_operation_(&callOper->children[i], space,
- &argType, atoms)) {
+ &argType, atoms, log)) {
slang_typeinfo_destruct(&argType);
return GL_FALSE;
}
@@ -392,7 +392,7 @@ _slang_adapt_call(slang_operation *callOper, const slang_function *fun,
if (!slang_typeinfo_construct(&argType))
return GL_FALSE;
if (!_slang_typeof_operation_(&callOper->children[i], space,
- &argType, atoms)) {
+ &argType, atoms, log)) {
slang_typeinfo_destruct(&argType);
return GL_FALSE;
}
diff --git a/src/mesa/shader/slang/slang_simplify.h b/src/mesa/shader/slang/slang_simplify.h
index d6979a800a..b3840ee9df 100644
--- a/src/mesa/shader/slang/slang_simplify.h
+++ b/src/mesa/shader/slang/slang_simplify.h
@@ -16,8 +16,7 @@ _slang_simplify(slang_operation *oper,
extern GLboolean
_slang_adapt_call(slang_operation *callOper, const slang_function *fun,
const slang_name_space * space,
- slang_atom_pool * atoms);
-
+ slang_atom_pool * atoms, slang_info_log *log);
#endif /* SLANG_SIMPLIFY_H */
diff --git a/src/mesa/shader/slang/slang_typeinfo.c b/src/mesa/shader/slang/slang_typeinfo.c
index bbcc1c740c..fe3834994d 100644
--- a/src/mesa/shader/slang/slang_typeinfo.c
+++ b/src/mesa/shader/slang/slang_typeinfo.c
@@ -31,7 +31,7 @@
#include "imports.h"
#include "slang_typeinfo.h"
#include "slang_compile.h"
-#include "slang_error.h"
+#include "slang_log.h"
#include "prog_instruction.h"
@@ -302,14 +302,15 @@ typeof_existing_function(const char *name, const slang_operation * params,
GLuint num_params,
const slang_name_space * space,
slang_type_specifier * spec,
- slang_atom_pool * atoms)
+ slang_atom_pool * atoms,
+ slang_info_log *log)
{
slang_atom atom;
GLboolean exists;
atom = slang_atom_pool_atom(atoms, name);
if (!_slang_typeof_function(atom, params, num_params, space, spec,
- &exists, atoms))
+ &exists, atoms, log))
return GL_FALSE;
return exists;
}
@@ -319,7 +320,7 @@ _slang_typeof_operation(const slang_assemble_ctx * A,
const slang_operation * op,
slang_typeinfo * ti)
{
- return _slang_typeof_operation_(op, &A->space, ti, A->atoms);
+ return _slang_typeof_operation_(op, &A->space, ti, A->atoms, A->log);
}
@@ -335,7 +336,8 @@ GLboolean
_slang_typeof_operation_(const slang_operation * op,
const slang_name_space * space,
slang_typeinfo * ti,
- slang_atom_pool * atoms)
+ slang_atom_pool * atoms,
+ slang_info_log *log)
{
ti->can_be_referenced = GL_FALSE;
ti->is_swizzled = GL_FALSE;
@@ -364,7 +366,7 @@ _slang_typeof_operation_(const slang_operation * op,
case SLANG_OPER_DIVASSIGN:
case SLANG_OPER_PREINCREMENT:
case SLANG_OPER_PREDECREMENT:
- if (!_slang_typeof_operation_(op->children, space, ti, atoms))
+ if (!_slang_typeof_operation_(op->children, space, ti, atoms, log))
return GL_FALSE;
break;
case SLANG_OPER_LITERAL_BOOL:
@@ -431,18 +433,24 @@ _slang_typeof_operation_(const slang_operation * op,
{
slang_variable *var;
var = _slang_locate_variable(op->locals, op->a_id, GL_TRUE);
- if (var == NULL)
- RETURN_ERROR2("undefined variable", (char *) op->a_id, 0);
- if (!slang_type_specifier_copy(&ti->spec, &var->type.specifier))
- RETURN_OUT_OF_MEMORY();
+ if (!var) {
+ slang_info_log_error(log, "undefined variable '%s'",
+ (char *) op->a_id);
+ return GL_FALSE;
+ }
+ if (!slang_type_specifier_copy(&ti->spec, &var->type.specifier)) {
+ slang_info_log_memory(log);
+ return GL_FALSE;
+ }
ti->can_be_referenced = GL_TRUE;
ti->array_len = var->array_len;
}
break;
case SLANG_OPER_SEQUENCE:
/* TODO: check [0] and [1] if they match */
- if (!_slang_typeof_operation_(&op->children[1], space, ti, atoms))
- RETURN_NIL();
+ if (!_slang_typeof_operation_(&op->children[1], space, ti, atoms, log)) {
+ return GL_FALSE;
+ }
ti->can_be_referenced = GL_FALSE;
ti->is_swizzled = GL_FALSE;
break;
@@ -454,8 +462,9 @@ _slang_typeof_operation_(const slang_operation * op,
/*case SLANG_OPER_ANDASSIGN: */
case SLANG_OPER_SELECT:
/* TODO: check [1] and [2] if they match */
- if (!_slang_typeof_operation_(&op->children[1], space, ti, atoms))
- RETURN_NIL();
+ if (!_slang_typeof_operation_(&op->children[1], space, ti, atoms, log)) {
+ return GL_FALSE;
+ }
ti->can_be_referenced = GL_FALSE;
ti->is_swizzled = GL_FALSE;
break;
@@ -466,35 +475,35 @@ _slang_typeof_operation_(const slang_operation * op,
/*case SLANG_OPER_RSHIFT: */
case SLANG_OPER_ADD:
if (!typeof_existing_function("+", op->children, 2, space,
- &ti->spec, atoms))
- RETURN_NIL();
+ &ti->spec, atoms, log))
+ return GL_FALSE;
break;
case SLANG_OPER_SUBTRACT:
if (!typeof_existing_function("-", op->children, 2, space,
- &ti->spec, atoms))
- RETURN_NIL();
+ &ti->spec, atoms, log))
+ return GL_FALSE;
break;
case SLANG_OPER_MULTIPLY:
if (!typeof_existing_function("*", op->children, 2, space,
- &ti->spec, atoms))
- RETURN_NIL();
+ &ti->spec, atoms, log))
+ return GL_FALSE;
break;
case SLANG_OPER_DIVIDE:
if (!typeof_existing_function("/", op->children, 2, space,
- &ti->spec, atoms))
- RETURN_NIL();
+ &ti->spec, atoms, log))
+ return GL_FALSE;
break;
/*case SLANG_OPER_MODULUS: */
case SLANG_OPER_PLUS:
- if (!_slang_typeof_operation_(op->children, space, ti, atoms))
- RETURN_NIL();
+ if (!_slang_typeof_operation_(op->children, space, ti, atoms, log))
+ return GL_FALSE;
ti->can_be_referenced = GL_FALSE;
ti->is_swizzled = GL_FALSE;
break;
case SLANG_OPER_MINUS:
if (!typeof_existing_function("-", op->children, 1, space,
- &ti->spec, atoms))
- RETURN_NIL();
+ &ti->spec, atoms, log))
+ return GL_FALSE;
break;
/*case SLANG_OPER_COMPLEMENT: */
case SLANG_OPER_SUBSCRIPT:
@@ -502,23 +511,24 @@ _slang_typeof_operation_(const slang_operation * op,
slang_typeinfo _ti;
if (!slang_typeinfo_construct(&_ti))
- RETURN_NIL();
- if (!_slang_typeof_operation_(op->children, space, &_ti, atoms)) {
+ return GL_FALSE;
+ if (!_slang_typeof_operation_(op->children, space, &_ti, atoms, log)) {
slang_typeinfo_destruct(&_ti);
- RETURN_NIL();
+ return GL_FALSE;
}
ti->can_be_referenced = _ti.can_be_referenced;
if (_ti.spec.type == SLANG_SPEC_ARRAY) {
if (!slang_type_specifier_copy(&ti->spec, _ti.spec._array)) {
slang_typeinfo_destruct(&_ti);
- RETURN_NIL();
+ return GL_FALSE;
}
}
else {
if (!_slang_type_is_vector(_ti.spec.type)
&& !_slang_type_is_matrix(_ti.spec.type)) {
slang_typeinfo_destruct(&_ti);
- RETURN_ERROR("cannot index a non-array type", 0);
+ slang_info_log_error(log, "cannot index a non-array type");
+ return GL_FALSE;
}
ti->spec.type = _slang_type_base(_ti.spec.type);
}
@@ -530,8 +540,8 @@ _slang_typeof_operation_(const slang_operation * op,
GLboolean exists;
if (!_slang_typeof_function(op->a_id, op->children, op->num_children,
- space, &ti->spec, &exists, atoms))
- RETURN_NIL();
+ space, &ti->spec, &exists, atoms, log))
+ return GL_FALSE;
if (!exists) {
slang_struct *s =
slang_struct_scope_find(space->structs, op->a_id, GL_TRUE);
@@ -540,14 +550,14 @@ _slang_typeof_operation_(const slang_operation * op,
ti->spec._struct =
(slang_struct *) slang_alloc_malloc(sizeof(slang_struct));
if (ti->spec._struct == NULL)
- RETURN_NIL();
+ return GL_FALSE;
if (!slang_struct_construct(ti->spec._struct)) {
slang_alloc_free(ti->spec._struct);
ti->spec._struct = NULL;
- RETURN_NIL();
+ return GL_FALSE;
}
if (!slang_struct_copy(ti->spec._struct, s))
- RETURN_NIL();
+ return GL_FALSE;
}
else {
const char *name;
@@ -555,8 +565,10 @@ _slang_typeof_operation_(const slang_operation * op,
name = slang_atom_pool_id(atoms, op->a_id);
type = slang_type_specifier_type_from_string(name);
- if (type == SLANG_SPEC_VOID)
- RETURN_ERROR2("function not found", name, 0);
+ if (type == SLANG_SPEC_VOID) {
+ slang_info_log_error(log, "undefined function '%s'", name);
+ return GL_FALSE;
+ }
ti->spec.type = type;
}
}
@@ -567,10 +579,10 @@ _slang_typeof_operation_(const slang_operation * op,
slang_typeinfo _ti;
if (!slang_typeinfo_construct(&_ti))
- RETURN_NIL();
- if (!_slang_typeof_operation_(op->children, space, &_ti, atoms)) {
+ return GL_FALSE;
+ if (!_slang_typeof_operation_(op->children, space, &_ti, atoms, log)) {
slang_typeinfo_destruct(&_ti);
- RETURN_NIL();
+ return GL_FALSE;
}
if (_ti.spec.type == SLANG_SPEC_STRUCT) {
slang_variable *field;
@@ -579,11 +591,11 @@ _slang_typeof_operation_(const slang_operation * op,
GL_FALSE);
if (field == NULL) {
slang_typeinfo_destruct(&_ti);
- RETURN_NIL();
+ return GL_FALSE;
}
if (!slang_type_specifier_copy(&ti->spec, &field->type.specifier)) {
slang_typeinfo_destruct(&_ti);
- RETURN_NIL();
+ return GL_FALSE;
}
ti->can_be_referenced = _ti.can_be_referenced;
}
@@ -593,17 +605,19 @@ _slang_typeof_operation_(const slang_operation * op,
slang_type_specifier_type base;
/* determine the swizzle of the field expression */
-#if 000
+#if 000 /*XXX re-enable? */
if (!_slang_type_is_vector(_ti.spec.type)) {
slang_typeinfo_destruct(&_ti);
- RETURN_ERROR("Can't swizzle scalar expression", 0);
+ slang_info_log_error(log, "Can't swizzle scalar expression");
+ return GL_FALSE;
}
#endif
rows = _slang_type_dim(_ti.spec.type);
swizzle = slang_atom_pool_id(atoms, op->a_id);
if (!_slang_is_swizzle(swizzle, rows, &ti->swz)) {
slang_typeinfo_destruct(&_ti);
- RETURN_ERROR("Bad swizzle", 0);
+ slang_info_log_error(log, "bad swizzle '%s'", swizzle);
+ return GL_FALSE;
}
ti->is_swizzled = GL_TRUE;
ti->can_be_referenced = _ti.can_be_referenced
@@ -674,13 +688,13 @@ _slang_typeof_operation_(const slang_operation * op,
break;
case SLANG_OPER_POSTINCREMENT:
case SLANG_OPER_POSTDECREMENT:
- if (!_slang_typeof_operation_(op->children, space, ti, atoms))
- RETURN_NIL();
+ if (!_slang_typeof_operation_(op->children, space, ti, atoms, log))
+ return GL_FALSE;
ti->can_be_referenced = GL_FALSE;
ti->is_swizzled = GL_FALSE;
break;
default:
- RETURN_NIL();
+ return GL_FALSE;
}
return GL_TRUE;
@@ -693,7 +707,8 @@ _slang_typeof_operation_(const slang_operation * op,
slang_function *
_slang_locate_function(const slang_function_scope * funcs, slang_atom a_name,
const slang_operation * args, GLuint num_args,
- const slang_name_space * space, slang_atom_pool * atoms)
+ const slang_name_space * space, slang_atom_pool * atoms,
+ slang_info_log *log)
{
GLuint i;
@@ -713,7 +728,7 @@ _slang_locate_function(const slang_function_scope * funcs, slang_atom a_name,
if (!slang_typeinfo_construct(&ti))
return NULL;
- if (!_slang_typeof_operation_(&args[j], space, &ti, atoms)) {
+ if (!_slang_typeof_operation_(&args[j], space, &ti, atoms, log)) {
slang_typeinfo_destruct(&ti);
return NULL;
}
@@ -737,7 +752,7 @@ _slang_locate_function(const slang_function_scope * funcs, slang_atom a_name,
}
if (funcs->outer_scope != NULL)
return _slang_locate_function(funcs->outer_scope, a_name, args,
- num_args, space, atoms);
+ num_args, space, atoms, log);
return NULL;
}
@@ -757,10 +772,10 @@ _slang_typeof_function(slang_atom a_name, const slang_operation * params,
GLuint num_params,
const slang_name_space * space,
slang_type_specifier * spec, GLboolean * exists,
- slang_atom_pool * atoms)
+ slang_atom_pool *atoms, slang_info_log *log)
{
slang_function *fun = _slang_locate_function(space->funcs, a_name, params,
- num_params, space, atoms);
+ num_params, space, atoms, log);
*exists = fun != NULL;
if (!fun)
return GL_TRUE; /* yes, not false */
diff --git a/src/mesa/shader/slang/slang_typeinfo.h b/src/mesa/shader/slang/slang_typeinfo.h
index 3115b71e08..62cf0009d3 100644
--- a/src/mesa/shader/slang/slang_typeinfo.h
+++ b/src/mesa/shader/slang/slang_typeinfo.h
@@ -27,6 +27,7 @@
#include "imports.h"
#include "mtypes.h"
+#include "slang_log.h"
#include "slang_utility.h"
#include "slang_vartable.h"
@@ -60,6 +61,7 @@ typedef struct slang_assemble_ctx_
slang_name_space space;
struct gl_program *program;
slang_var_table *vartable;
+ slang_info_log *log;
struct slang_function_ *CurFunction;
struct slang_ir_node_ *CurLoop;
} slang_assemble_ctx;
@@ -70,7 +72,7 @@ _slang_locate_function(const struct slang_function_scope_ *funcs,
slang_atom name, const struct slang_operation_ *params,
GLuint num_params,
const slang_name_space *space,
- slang_atom_pool *);
+ slang_atom_pool *atoms, slang_info_log *log);
extern GLboolean
@@ -170,7 +172,8 @@ _slang_typeof_operation(const slang_assemble_ctx *,
extern GLboolean
_slang_typeof_operation_(const struct slang_operation_ *,
const slang_name_space *,
- slang_typeinfo *, slang_atom_pool *);
+ slang_typeinfo *, slang_atom_pool *,
+ slang_info_log *log);
/**
* Retrieves type of a function prototype, if one exists.
@@ -182,7 +185,7 @@ _slang_typeof_function(slang_atom a_name,
const struct slang_operation_ *params,
GLuint num_params, const slang_name_space *,
slang_type_specifier *spec, GLboolean *exists,
- slang_atom_pool *);
+ slang_atom_pool *, slang_info_log *log);
extern GLboolean
_slang_type_is_matrix(slang_type_specifier_type);