summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_codegen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/shader/slang/slang_codegen.c')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c64
1 files changed, 44 insertions, 20 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 9c17dceb19..db25106d03 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2826,7 +2826,7 @@ _slang_gen_declaration(slang_assemble_ctx *A, slang_operation *oper)
/* type check/compare var and initializer */
if (!_slang_assignment_compatible(A, oper, initializer)) {
- slang_info_log_error(A->log, "illegal types in assignment");
+ slang_info_log_error(A->log, "incompatible types in assignment");
return NULL;
}
@@ -2926,6 +2926,24 @@ _slang_gen_swizzle(slang_ir_node *child, GLuint swizzle)
}
+static GLboolean
+is_store_writable(const slang_assemble_ctx *A, const slang_ir_storage *store)
+{
+ while (store->Parent)
+ store = store->Parent;
+
+ if (!(store->File == PROGRAM_OUTPUT ||
+ store->File == PROGRAM_TEMPORARY ||
+ (store->File == PROGRAM_VARYING &&
+ A->program->Target == GL_VERTEX_PROGRAM_ARB))) {
+ return GL_FALSE;
+ }
+ else {
+ return GL_TRUE;
+ }
+}
+
+
/**
* Generate IR tree for an assignment (=).
*/
@@ -2976,26 +2994,26 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
if (!_slang_assignment_compatible(A,
&oper->children[0],
&oper->children[1])) {
- slang_info_log_error(A->log, "illegal types in assignment");
+ slang_info_log_error(A->log, "incompatible types in assignment");
return NULL;
}
lhs = _slang_gen_operation(A, &oper->children[0]);
- if (lhs) {
- if (!lhs->Store) {
- slang_info_log_error(A->log,
- "invalid left hand side for assignment");
- return NULL;
- }
- if (!(lhs->Store->File == PROGRAM_OUTPUT ||
- lhs->Store->File == PROGRAM_TEMPORARY ||
- (lhs->Store->File == PROGRAM_VARYING &&
- A->program->Target == GL_VERTEX_PROGRAM_ARB) ||
- lhs->Store->File == PROGRAM_UNDEFINED)) {
- slang_info_log_error(A->log,
- "illegal assignment to read-only l-value");
- return NULL;
- }
+ if (!lhs) {
+ return NULL;
+ }
+
+ if (!lhs->Store) {
+ slang_info_log_error(A->log,
+ "invalid left hand side for assignment");
+ return NULL;
+ }
+
+ /* check that lhs is writable */
+ if (!is_store_writable(A, lhs->Store)) {
+ slang_info_log_error(A->log,
+ "illegal assignment to read-only l-value");
+ return NULL;
}
rhs = _slang_gen_operation(A, &oper->children[1]);
@@ -3264,7 +3282,7 @@ _slang_gen_compare(slang_assemble_ctx *A, slang_operation *oper,
t0.spec.type != SLANG_SPEC_FLOAT) ||
(t1.spec.type != SLANG_SPEC_INT &&
t1.spec.type != SLANG_SPEC_FLOAT)) {
- slang_info_log_error(A->log, "Illegal type(s) for inequality operator");
+ slang_info_log_error(A->log, "Incompatible type(s) for inequality operator");
return NULL;
}
}
@@ -3663,7 +3681,13 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
/* user-defined uniform */
if (datatype == GL_NONE) {
if (var->type.specifier.type == SLANG_SPEC_STRUCT) {
- _mesa_problem(NULL, "user-declared uniform structs not supported yet");
+ /* temporary work-around */
+ GLenum datatype = GL_FLOAT;
+ GLint uniformLoc = _mesa_add_uniform(prog->Parameters, varName,
+ totalSize, datatype);
+ store = _slang_new_ir_storage_swz(PROGRAM_UNIFORM, uniformLoc,
+ totalSize, swizzle);
+
/* XXX what we need to do is unroll the struct into its
* basic types, creating a uniform variable for each.
* For example:
@@ -3682,8 +3706,8 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
slang_info_log_error(A->log,
"invalid datatype for uniform variable %s",
varName);
+ return GL_FALSE;
}
- return GL_FALSE;
}
else {
GLint uniformLoc = _mesa_add_uniform(prog->Parameters, varName,