return 0;
}
+void TypeComparer::visit(Literal &literal)
+{
+ if(Literal *lit1 = multi_visit(literal))
+ {
+ if(!lit1->type || !literal.type)
+ r_result = false;
+ else
+ {
+ compare(*lit1->type, *literal.type);
+ if(r_result)
+ r_result = (literal.value.check_type<int>() && lit1->value.value<int>()==literal.value.value<int>());
+ }
+ }
+}
+
+void TypeComparer::visit(VariableReference &var)
+{
+ if(VariableReference *var1 = multi_visit(var))
+ {
+ if(!var1->declaration || !var.declaration)
+ r_result = false;
+ else if(!var1->declaration->constant || !var.declaration->constant)
+ r_result = false;
+ else if(!var1->declaration->init_expression || !var.declaration->init_expression)
+ r_result = false;
+ else
+ compare(*var1->declaration->init_expression, *var.declaration->init_expression);
+ }
+}
+
void TypeComparer::visit(BasicTypeDeclaration &basic)
{
if(BasicTypeDeclaration *basic1 = multi_visit(basic))
r_result = false;
else
{
- // TODO Compare array sizes
- if(var1->type_declaration!=var.type_declaration)
+ if(var1->array)
+ {
+ r_result = false;
+ if(var1->array_size && var.array_size)
+ compare(*var1->array_size, *var.array_size);
+ }
+ if(r_result && var1->type_declaration!=var.type_declaration)
compare(*var1->type_declaration, *var.type_declaration);
// TODO Compare layout qualifiers for interface block members
}
--- /dev/null
+const int n_lights = 2;
+struct LightParams
+{
+ vec3 direction;
+ vec3 color;
+};
+uniform Lighting
+{
+ LightParams lights[n_lights];
+};
+uniform vec3 ambient;
+uniform mat4 model_matrix;
+uniform mat4 view_matrix;
+uniform mat4 proj_matrix;
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+layout(location=1) in vec3 normal;
+out vec3 eye_light_dir[n_lights];
+void main()
+{
+ for(int i=0; i<n_lights; ++i)
+ eye_light_dir[i] = mat3(view_matrix)*lights[i].direction;
+ out vec3 eye_normal = mat3(view_matrix*model_matrix)*normal;
+ gl_Position = proj_matrix*view_matrix*model_matrix*position;
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
+void main()
+{
+ vec3 color = ambient;
+ for(int i=0; i<n_lights; ++i)
+ color += max(dot(normalize(eye_normal), eye_light_dir[i]), 0.0)*lights[i].color;
+ frag_color = vec4(color, 1.0);
+}
+
+/* Expected output: vertex
+struct LightParams
+{
+ vec3 direction;
+ vec3 color;
+};
+layout(binding=5) uniform Lighting
+{
+ LightParams lights[2];
+};
+layout(location=0) uniform mat4 model_matrix;
+layout(location=4) uniform mat4 view_matrix;
+layout(location=8) uniform mat4 proj_matrix;
+layout(location=0) in vec4 position;
+layout(location=1) in vec3 normal;
+layout(location=0) out vec3 eye_light_dir[2];
+layout(location=2) out vec3 eye_normal;
+void main()
+{
+ for(int i = 0; i<2; ++i)
+ eye_light_dir[i] = mat3(view_matrix[0].xyz, view_matrix[1].xyz, view_matrix[2].xyz)*lights[i].direction;
+ mat4 _temp = view_matrix*model_matrix;
+ eye_normal = mat3(_temp[0].xyz, _temp[1].xyz, _temp[2].xyz)*normal;
+ gl_Position = proj_matrix*view_matrix*model_matrix*position;
+}
+*/
+
+/* Expected output: fragment
+struct LightParams
+{
+ vec3 direction;
+ vec3 color;
+};
+layout(binding=5) uniform Lighting
+{
+ LightParams lights[2];
+};
+layout(location=12) uniform vec3 ambient;
+layout(location=0) out vec4 frag_color;
+layout(location=2) in vec3 eye_normal;
+layout(location=0) in vec3 eye_light_dir[2];
+void main()
+{
+ vec3 color = ambient;
+ for(int i = 0; i<2; ++i)
+ color += max(dot(normalize(eye_normal), eye_light_dir[i]), 0.0)*lights[i].color;
+ frag_color = vec4(color, 1.0);
+}
+*/