const GLint totalSize = array_size(size, var->array_len);
const GLuint swizzle = _slang_var_swizzle(totalSize, 0);
- if (var->initializer) {
- slang_info_log_error(A->log, "illegal initializer for uniform '%s'", varName);
- return GL_FALSE;
- }
-
if (prog) {
/* user-defined uniform */
if (datatype == GL_NONE) {
* "f.a" (GL_FLOAT_VEC3)
* "f.b" (GL_FLOAT_VEC4)
*/
+
+ if (var->initializer) {
+ slang_info_log_error(A->log,
+ "unsupported initializer for uniform '%s'", varName);
+ return GL_FALSE;
+ }
}
else {
slang_info_log_error(A->log,
totalSize, datatype);
store = _slang_new_ir_storage_swz(PROGRAM_UNIFORM, uniformLoc,
totalSize, swizzle);
+ if (var->initializer) {
+ _slang_simplify(var->initializer, &A->space, A->atoms);
+ if (var->initializer->type == SLANG_OPER_LITERAL_FLOAT ||
+ var->initializer->type == SLANG_OPER_LITERAL_INT) {
+ /* simple float/vector initializer */
+ GLfloat *uniformValue =
+ prog->Parameters->ParameterValues[uniformLoc];
+ COPY_4V(uniformValue, var->initializer->literal);
+ }
+ else {
+ /* complex initializer */
+ slang_info_log_error(A->log,
+ "unsupported initializer for uniform '%s'", varName);
+ return GL_FALSE;
+ }
+ }
}
}
else {