* \author Michal Krol
*/
-#include "imports.h"
-#include "macros.h"
-#include "get.h"
+#include "main/imports.h"
+#include "main/macros.h"
+#include "main/get.h"
#include "slang_compile.h"
#include "slang_codegen.h"
#include "slang_simplify.h"
#include "slang_print.h"
+#ifndef GL_MAX_FRAGMENT_UNIFORM_VECTORS
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
+#endif
+#ifndef GL_MAX_VERTEX_UNIFORM_VECTORS
+#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
+#endif
+#ifndef GL_MAX_VARYING_VECTORS
+#define GL_MAX_VARYING_VECTORS 0x8DFC
+#endif
/**
{ "gl_MaxVaryingFloats", GL_MAX_VARYING_FLOATS },
{ "gl_MaxVertexTextureImageUnits", GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS },
{ "gl_MaxTextureImageUnits", GL_MAX_TEXTURE_IMAGE_UNITS },
+#if FEATURE_es2_glsl
+ { "gl_MaxVertexUniformVectors", GL_MAX_VERTEX_UNIFORM_VECTORS },
+ { "gl_MaxVaryingVectors", GL_MAX_VARYING_VECTORS },
+ { "gl_MaxFragmentUniformVectors", GL_MAX_FRAGMENT_UNIFORM_VECTORS },
+#endif
{ NULL, 0 }
};
GLuint i;
for (i = 0; info[i].Name; i++) {
if (strcmp(info[i].Name, name) == 0) {
/* found */
- GLint value = -1.0;
+ GLint value = -1;
_mesa_GetIntegerv(info[i].Token, &value);
ASSERT(value >= 0); /* sanity check that glGetFloatv worked */
return value;
oper->literal[0] =
oper->literal[1] =
oper->literal[2] =
- oper->literal[3] = value;
+ oper->literal[3] = (GLfloat) value;
oper->type = SLANG_OPER_LITERAL_INT;
return;
}
/* vec2(flt, flt) constructor */
if (oper->type == SLANG_OPER_CALL) {
if (strcmp((char *) oper->a_id, "vec2") == 0) {
- printf("SIMPLIFY vec2 constructor scope = %p\n",
- (void*) oper->locals);
oper->literal[0] = oper->children[0].literal[0];
oper->literal[1] = oper->children[1].literal[0];
oper->literal[2] = oper->literal[1];
}
}
}
+
+ if (oper->num_children == 1 && isFloat[0]) {
+ /* vec2/3/4(flt, flt) constructor */
+ if (oper->type == SLANG_OPER_CALL) {
+ const char *func = (const char *) oper->a_id;
+ if (strncmp(func, "vec", 3) == 0 && func[3] >= '2' && func[3] <= '4') {
+ oper->literal[0] =
+ oper->literal[1] =
+ oper->literal[2] =
+ oper->literal[3] = oper->children[0].literal[0];
+ oper->literal_size = func[3] - '0';
+ assert(oper->literal_size >= 2);
+ assert(oper->literal_size <= 4);
+ slang_operation_destruct(oper); /* XXX oper->locals goes NULL! */
+ oper->type = SLANG_OPER_LITERAL_FLOAT;
+ assert(oper->num_children == 0);
+ return;
+ }
+ }
+ }
}
if (dbg) printf("Adapt %d args to %d parameters\n",
callOper->num_children, numParams);
+ /* Only try adapting for constructors */
+ if (fun->kind != SLANG_FUNC_CONSTRUCTOR)
+ return GL_FALSE;
+
if (callOper->num_children != numParams) {
/* number of arguments doesn't match number of parameters */
&origArg);
callOper->children[i + j].children[1].type
= SLANG_OPER_LITERAL_INT;
- callOper->children[i + j].children[1].literal[0] = j;
+ callOper->children[i + j].children[1].literal[0] = (GLfloat) j;
}
}
}
}
- if (callOper->num_children < numParams) {
+ if (callOper->num_children < (GLuint) numParams) {
/* still not enough args for all params */
return GL_FALSE;
}
- else if (callOper->num_children > numParams) {
+ else if (callOper->num_children > (GLuint) numParams) {
/* now too many arguments */
/* XXX this isn't always an error, see spec */
return GL_FALSE;
slang_operation *child = slang_operation_new(1);
slang_operation_copy(child, &callOper->children[i]);
- child->locals->outer_scope = callOper->locals;
+ child->locals->outer_scope = callOper->children[i].locals;
callOper->children[i].type = SLANG_OPER_CALL;
callOper->children[i].a_id = slang_atom_pool_atom(atoms, constructorName);