summaryrefslogtreecommitdiff
path: root/tests/glean/tglsl1.cpp
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2009-02-16 15:23:39 -0800
committerEric Anholt <eric@anholt.net>2009-03-07 03:30:55 -0800
commitaa7c71facfe968af8f82c5a07b02cad039a3134e (patch)
tree9d6b0f210d05ec689520e7db6f1634845f3d91c1 /tests/glean/tglsl1.cpp
parenta2c35c6fe4b81bd9516ece02ca209dc0bbb2a9f0 (diff)
Update glean tests to CVS HEAD from 2009-03-07.
Diffstat (limited to 'tests/glean/tglsl1.cpp')
-rw-r--r--tests/glean/tglsl1.cpp457
1 files changed, 423 insertions, 34 deletions
diff --git a/tests/glean/tglsl1.cpp b/tests/glean/tglsl1.cpp
index 469485f94..42bc9c4ed 100644
--- a/tests/glean/tglsl1.cpp
+++ b/tests/glean/tglsl1.cpp
@@ -1,6 +1,7 @@
// BEGIN_COPYRIGHT -*- glean -*-
//
// Copyright (C) 1999 Allen Akin All Rights Reserved.
+// Copyright (C) 2008 VMWare, Inc. All Rights Reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@@ -31,9 +32,11 @@
#define GL_GLEXT_PROTOTYPES
-#include "tglsl1.h"
+#include <stdlib.h>
#include <cassert>
+#include <cstring>
#include <math.h>
+#include "tglsl1.h"
namespace GLEAN {
@@ -81,7 +84,7 @@ static PFNGLUNIFORMMATRIX4X3FVPROC glUniformMatrix4x3fv_func = NULL;
#define FLAG_LOOSE 0x1 // to indicate a looser tolerance test is needed
#define FLAG_ILLEGAL_SHADER 0x2 // the shader test should not compile
#define FLAG_ILLEGAL_LINK 0x4 // the shaders should not link
-#define FLAG_VERSION_2_1 0x8 // OpenGL 2.1 test (or GLSL 1.20)
+#define FLAG_VERSION_1_20 0x8 // GLSL 1.20 test
#define FLAG_WINDING_CW 0x10 // clockwise-winding polygon
#define FLAG_VERTEX_TEXTURE 0x20
@@ -333,6 +336,47 @@ static const ShaderProgram Programs[] = {
FLAG_NONE
},
+ {
+ "Swizzled expression",
+ NO_VERTEX_SHADER,
+ "void main() { \n"
+ " vec4 a = vec4(1, 1, 1, 1); \n"
+ " vec4 b = vec4(0.5, 0.2, 0.1, 0.8); \n"
+ " vec4 c = (a * b).wzyx; \n"
+ " gl_FragColor = c; \n"
+ "} \n",
+ { 0.8, 0.1, 0.2, 0.5 },
+ DONT_CARE_Z,
+ FLAG_NONE
+ },
+
+ {
+ "Swizzled swizzle",
+ NO_VERTEX_SHADER,
+ "void main() { \n"
+ " vec4 a = vec4(0.1, 0.2, 0.3, 0.4); \n"
+ " vec4 b = a.wzyx.yxwz; \n"
+ " gl_FragColor = b; \n"
+ "} \n",
+ { 0.3, 0.4, 0.1, 0.2 },
+ DONT_CARE_Z,
+ FLAG_NONE
+ },
+
+ {
+ "Swizzled swizzled swizzle",
+ NO_VERTEX_SHADER,
+ "void main() { \n"
+ " vec4 a = vec4(0.1, 0.2, 0.3, 0.4); \n"
+ " vec4 b = a.wzyx.yxwz.xxyz; \n"
+ " gl_FragColor = b; \n"
+ "} \n",
+ { 0.3, 0.3, 0.4, 0.1 },
+ DONT_CARE_Z,
+ FLAG_NONE
+ },
+
+
// Z-write ============================================================
{
"gl_FragDepth writing",
@@ -1057,6 +1101,19 @@ static const ShaderProgram Programs[] = {
},
{
+ "conditional expression (2)",
+ NO_VERTEX_SHADER,
+ "void main() { \n"
+ " gl_FragColor = vec4(0.0); \n"
+ " bool b = true; \n"
+ " gl_FragColor.y = b ? 1.0 : 0.5; \n"
+ "} \n",
+ { 0.0, 1.0, 0.0, 0.0 },
+ DONT_CARE_Z,
+ FLAG_NONE
+ },
+
+ {
"sequence (comma) operator",
NO_VERTEX_SHADER,
"void main() { \n"
@@ -1088,6 +1145,45 @@ static const ShaderProgram Programs[] = {
FLAG_NONE
},
+ {
+ "array with variable indexing",
+ NO_VERTEX_SHADER,
+ "uniform vec4 uniform1; \n"
+ "void main() { \n"
+ " float ar[4]; \n"
+ " ar[0] = 0.0; \n"
+ " ar[1] = 0.1; \n"
+ " ar[2] = 0.5; \n"
+ " ar[3] = 0.7; \n"
+ " int indx = int(uniform1.y * 8.0); // should be 2 \n"
+ " gl_FragColor = vec4(ar[indx]); \n"
+ "} \n",
+ { 0.5, 0.5, 0.5, 0.5 },
+ DONT_CARE_Z,
+ FLAG_NONE
+ },
+
+ {
+ "array with swizzled variable indexing",
+ NO_VERTEX_SHADER,
+ "uniform vec4 uniform1; \n"
+ "void main() { \n"
+ " float ar[4]; \n"
+ " ar[0] = 0.0; \n"
+ " ar[1] = 0.8; \n"
+ " ar[2] = 0.5; \n"
+ " ar[3] = 0.7; \n"
+ " ivec2 indx; \n"
+ " indx.x = 1; \n"
+ " indx.y = int(uniform1.y * 8.0); // should be 2 \n"
+ " float p = ar[indx.x] * ar[indx.y]; \n"
+ " gl_FragColor = vec4(p); \n"
+ "} \n",
+ { 0.4, 0.4, 0.4, 0.4 },
+ DONT_CARE_Z,
+ FLAG_NONE
+ },
+
#if 0 // XXX enable someday
{
"vector subscript *=",
@@ -2069,7 +2165,7 @@ static const ShaderProgram Programs[] = {
"void main() { \n"
" vec4 a = vec4( 1.0, 0.0, 0.2, 0.5); \n"
" vec4 b = vec4( 1.0, 3.0, 0.0, 0.5); \n"
- " gl_FragColor = equal(a, b); \n"
+ " gl_FragColor = vec4(equal(a, b)); \n"
"} \n",
{ 1.0, 0.0, 0.0, 1.0 },
DONT_CARE_Z,
@@ -2082,7 +2178,7 @@ static const ShaderProgram Programs[] = {
"void main() { \n"
" vec4 a = vec4( 1.0, 0.0, 0.2, 0.5); \n"
" vec4 b = vec4( 1.0, 3.0, 0.0, 0.5); \n"
- " gl_FragColor = notEqual(a, b); \n"
+ " gl_FragColor = vec4(notEqual(a, b)); \n"
"} \n",
{ 0.0, 1.0, 1.0, 0.0 },
DONT_CARE_Z,
@@ -2095,7 +2191,7 @@ static const ShaderProgram Programs[] = {
"void main() { \n"
" vec4 a = vec4( 0.5, 1.0, 0.4, 0.0); \n"
" vec4 b = vec4( 1.0, 0.2, 0.4, 0.0); \n"
- " gl_FragColor = lessThanEqual(a, b); \n"
+ " gl_FragColor = vec4(lessThanEqual(a, b)); \n"
"} \n",
{ 1.0, 0.0, 1.0, 1.0 },
DONT_CARE_Z,
@@ -2108,7 +2204,7 @@ static const ShaderProgram Programs[] = {
"void main() { \n"
" vec4 a = vec4( 0.5, 1.0, 0.4, 0.0); \n"
" vec4 b = vec4( 1.0, 0.2, 0.4, 0.0); \n"
- " gl_FragColor = greaterThanEqual(a, b); \n"
+ " gl_FragColor = vec4(greaterThanEqual(a, b)); \n"
"} \n",
{ 0.0, 1.0, 1.0, 1.0 },
DONT_CARE_Z,
@@ -2121,7 +2217,7 @@ static const ShaderProgram Programs[] = {
"void main() { \n"
" vec4 a = vec4( 0.5, 1.0, 0.4, 0.0); \n"
" vec4 b = vec4( 1.0, 0.2, 0.4, 0.0); \n"
- " gl_FragColor = lessThan(a, b); \n"
+ " gl_FragColor = vec4(lessThan(a, b)); \n"
"} \n",
{ 1.0, 0.0, 0.0, 0.0 },
DONT_CARE_Z,
@@ -2134,7 +2230,7 @@ static const ShaderProgram Programs[] = {
"void main() { \n"
" vec4 a = vec4( 0.5, 1.0, 0.4, 0.0); \n"
" vec4 b = vec4( 1.0, 0.2, 0.4, 0.0); \n"
- " gl_FragColor = greaterThan(a, b); \n"
+ " gl_FragColor = vec4(greaterThan(a, b)); \n"
"} \n",
{ 0.0, 1.0, 0.0, 0.0 },
DONT_CARE_Z,
@@ -2234,6 +2330,93 @@ static const ShaderProgram Programs[] = {
FLAG_NONE
},
+ {
+ "struct (1)",
+ NO_VERTEX_SHADER,
+ "struct s1 { \n"
+ " float f1; \n"
+ " vec4 v4; \n"
+ "}; \n"
+ "\n"
+ "void main() { \n"
+ " s1 a, b; \n"
+ " a.v4 = vec4(0.25, 0.5, 0.75, 1.0); \n"
+ " a.f1 = 0.0; \n"
+ " b = a; \n"
+ " gl_FragColor = b.v4; \n"
+ "} \n",
+ { 0.25, 0.5, 0.75, 1.0 },
+ DONT_CARE_Z,
+ FLAG_NONE
+ },
+
+ {
+ "struct (2)",
+ NO_VERTEX_SHADER,
+ "struct s1 { \n"
+ " float f1; \n"
+ " vec4 v4; \n"
+ "}; \n"
+ "\n"
+ "void main() { \n"
+ " s1 a[2]; \n"
+ " a[0].v4 = vec4(0.25, 0.5, 0.75, 1.0); \n"
+ " a[0].f1 = 0.0; \n"
+ " a[1] = a[0]; \n"
+ " gl_FragColor = a[1].v4; \n"
+ "} \n",
+ { 0.25, 0.5, 0.75, 1.0 },
+ DONT_CARE_Z,
+ FLAG_NONE
+ },
+
+ {
+ "struct (3)",
+ NO_VERTEX_SHADER,
+ "struct s1 { \n"
+ " float f1; \n"
+ " vec4 v4; \n"
+ "}; \n"
+ "\n"
+ "void main() { \n"
+ " vec4 scale = vec4(0.5); \n"
+ " vec4 bias = vec4(0.1); \n"
+ " s1 a; \n"
+ " a.v4 = vec4(0.25, 0.5, 0.75, 1.0); \n"
+ " a.f1 = 0.0; \n"
+ " gl_FragColor = a.v4 * scale + bias; \n"
+ "} \n",
+ { 0.225, 0.35, 0.475, 0.6 },
+ DONT_CARE_Z,
+ FLAG_NONE
+ },
+
+ {
+ "struct (4)",
+ NO_VERTEX_SHADER,
+ "struct s1 { \n"
+ " float foo; \n"
+ " vec4 v4; \n"
+ "}; \n"
+ "struct s2 { \n"
+ " float bar; \n"
+ " s1 s; \n"
+ " float baz; \n"
+ "}; \n"
+ "\n"
+ "void main() { \n"
+ " s2 a; \n"
+ " a.s.v4 = vec4(0.25, 0.5, 0.75, 1.0); \n"
+ " a.bar = 0.0; \n"
+ " a.baz = 0.0; \n"
+ " a.s.foo = 0.0; \n"
+ " gl_FragColor = a.s.v4; \n"
+ "} \n",
+ { 0.25, 0.5, 0.75, 1.0 },
+ DONT_CARE_Z,
+ FLAG_NONE
+ },
+
// Preprocessor tests ================================================
{
"Preprocessor test (1)",
@@ -2391,7 +2574,7 @@ static const ShaderProgram Programs[] = {
"} \n",
{ 0.5, 0.6, 0.7, 0.8 },
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
"mat4x2 construct",
@@ -2407,7 +2590,7 @@ static const ShaderProgram Programs[] = {
"} \n",
{ 0.3, 0.4, 0.5, 0.6 },
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
"mat2x3 construct",
@@ -2421,7 +2604,7 @@ static const ShaderProgram Programs[] = {
"} \n",
{ 0.4, 0.5, 0.6, 1.0 },
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
"mat3x2 construct",
@@ -2436,7 +2619,7 @@ static const ShaderProgram Programs[] = {
"} \n",
{ 0.3, 0.4, 0.5, 0.6 },
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
"mat4x3 construct",
@@ -2452,7 +2635,7 @@ static const ShaderProgram Programs[] = {
"} \n",
{ 0.4, 0.5, 0.6, 1.0 },
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
"mat3x4 construct",
@@ -2466,7 +2649,7 @@ static const ShaderProgram Programs[] = {
"} \n",
{ 0.5, 0.6, 0.7, 0.8 },
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
@@ -2486,7 +2669,7 @@ static const ShaderProgram Programs[] = {
0.2 * 0.9 + -0.2 * 1.0 + 0.4 * 0.0 + 0.1 * 1.0,
1.0 },
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
@@ -2508,7 +2691,7 @@ static const ShaderProgram Programs[] = {
0.0
},
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
@@ -2534,7 +2717,7 @@ static const ShaderProgram Programs[] = {
(0.2 * 0.5 + 0.4 * 0.4 + 0.6 * 0.3 + 0.8 * 0.2) * 0.5
},
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
@@ -2554,7 +2737,7 @@ static const ShaderProgram Programs[] = {
0.2 * 0.5 + 0.5 * 0.6,
0.2 * 0.7 + 0.5 * 0.8 },
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
"vec3 * mat4x3 multiply",
@@ -2573,7 +2756,7 @@ static const ShaderProgram Programs[] = {
0.2 * 0.7 + 0.5 * 0.8 + 0.1 * 0.9,
0.2 * 1.0 + 0.5 * 0.1 + 0.1 * 0.2 },
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
@@ -2586,7 +2769,7 @@ static const ShaderProgram Programs[] = {
"} \n",
{ 0.0, 0.1, 0.2, 0.3 }, // first column of 2x4 matrix
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
"uniform matrix 2x4, transposed",
@@ -2598,7 +2781,7 @@ static const ShaderProgram Programs[] = {
"} \n",
{ 0.0, 0.2, 0.4, 0.6 }, // first row of 4x2 matrix
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
"uniform matrix 4x3",
@@ -2611,7 +2794,7 @@ static const ShaderProgram Programs[] = {
"} \n",
{ 0.3, 0.4, 0.5, 1.0 }, // second column of 4x3 matrix
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
"uniform matrix 4x3, transposed",
@@ -2624,10 +2807,161 @@ static const ShaderProgram Programs[] = {
"} \n",
{ 0.1, 0.5, 0.9, 1.0 },
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
- // Illegal link test ===================================================
+ // Tests for GLSL 1.20 new array features
+ {
+ "GLSL 1.20 arrays",
+ NO_VERTEX_SHADER,
+ "#version 120 \n"
+ "float [2] x; \n"
+ "void main() { \n"
+ " x[0] = 1.0; \n"
+ " x[1] = 2.0; \n"
+ " gl_FragColor.x = x[0]; \n"
+ " gl_FragColor.y = 0.25 * x[1]; \n"
+ " gl_FragColor.z = 0.1 * (x[0] + x[1]); \n"
+ " gl_FragColor.w = 1.0; \n"
+ "} \n",
+ { 1.0, 0.5, 0.3, 1.0 },
+ DONT_CARE_Z,
+ FLAG_VERSION_1_20
+ },
+ {
+ "GLSL 1.20 array constructor 1",
+ NO_VERTEX_SHADER,
+ "#version 120 \n"
+ "float [2] x = float[2](1.0, 2.0); \n"
+ "void main() { \n"
+ " gl_FragColor.x = x[0]; \n"
+ " gl_FragColor.y = 0.25 * x[1]; \n"
+ " gl_FragColor.z = 0.1 * (x[0] + x[1]); \n"
+ " gl_FragColor.w = 1.0; \n"
+ "} \n",
+ { 1.0, 0.5, 0.3, 1.0 },
+ DONT_CARE_Z,
+ FLAG_VERSION_1_20
+ },
+ {
+ "GLSL 1.20 array constructor 2",
+ NO_VERTEX_SHADER,
+ "#version 120 \n"
+ "vec4 [2] colors = vec4[2](vec4(0.5, 0.4, 0.3, 0.2), \n"
+ " vec4(0.7, 0.8, 0.9, 1.0)); \n"
+ "void main() { \n"
+ " gl_FragColor = colors[1]; \n"
+ "} \n",
+ { 0.7, 0.8, 0.9, 1.0 },
+ DONT_CARE_Z,
+ FLAG_VERSION_1_20
+ },
+ {
+ "GLSL 1.20 const array constructor 1",
+ NO_VERTEX_SHADER,
+ "#version 120 \n"
+ "const float [2] x = float[2](1.0, 2.0); \n"
+ "void main() { \n"
+ " gl_FragColor.x = x[0]; \n"
+ " gl_FragColor.y = 0.25 * x[1]; \n"
+ " gl_FragColor.z = 0.1 * (x[0] + x[1]); \n"
+ " gl_FragColor.w = 1.0; \n"
+ "} \n",
+ { 1.0, 0.5, 0.3, 1.0 },
+ DONT_CARE_Z,
+ FLAG_VERSION_1_20
+ },
+ {
+ "GLSL 1.20 const array constructor 2",
+ NO_VERTEX_SHADER,
+ "#version 120 \n"
+ "const vec4 [2] colors = vec4[2](vec4(0.5, 0.4, 0.3, 0.2), \n"
+ " vec4(0.7, 0.8, 0.9, 1.0)); \n"
+ "void main() { \n"
+ " gl_FragColor = colors[1]; \n"
+ "} \n",
+ { 0.7, 0.8, 0.9, 1.0 },
+ DONT_CARE_Z,
+ FLAG_VERSION_1_20
+ },
+ {
+ "GLSL 1.20 uniform array constructor",
+ NO_VERTEX_SHADER,
+ "#version 120 \n"
+ "uniform float [2] x = float[2](1.0, 2.0); \n"
+ "void main() { \n"
+ " gl_FragColor.x = x[0]; \n"
+ " gl_FragColor.y = 0.25 * x[1]; \n"
+ " gl_FragColor.z = 0.1 * (x[0] + x[1]); \n"
+ " gl_FragColor.w = 1.0; \n"
+ "} \n",
+ { 1.0, 0.5, 0.3, 1.0 },
+ DONT_CARE_Z,
+ FLAG_VERSION_1_20
+ },
+ {
+ "GLSL 1.20 array.length()",
+ NO_VERTEX_SHADER,
+ "#version 120 \n"
+ "const float [2] x = float[2](1.0, 2.0); \n"
+ "void main() { \n"
+ " int l = x.length(); \n"
+ " gl_FragColor = vec4(l * 0.25); \n"
+ "} \n",
+ { 0.5, 0.5, 0.5, 0.5 },
+ DONT_CARE_Z,
+ FLAG_VERSION_1_20
+ },
+ {
+ "GLSL 1.20 array error check",
+ NO_VERTEX_SHADER,
+ "#version 120 \n"
+ "// Note array size disagreement here: \n"
+ "const float [2] x = float[3](1.0, 2.0); \n"
+ "void main() { \n"
+ " gl_FragColor = vec4(1); \n"
+ "} \n",
+ { 1.0, 1.0, 1.0, 1.0 },
+ DONT_CARE_Z,
+ FLAG_VERSION_1_20 | FLAG_ILLEGAL_SHADER
+ },
+
+ // Other new GLSL 1.20 features (just parse/compile tests)
+ {
+ "GLSL 1.20 precision qualifiers",
+ NO_VERTEX_SHADER,
+ "#version 120 \n"
+ "highp float f1; \n"
+ "mediump float f2; \n"
+ "lowp float f3; \n"
+ "precision mediump float; \n"
+ "precision lowp int; \n"
+ "precision highp float; \n"
+ "void main() { \n"
+ " gl_FragColor = vec4(1); \n"
+ "} \n",
+ { 1.0, 1.0, 1.0, 1.0 },
+ DONT_CARE_Z,
+ FLAG_VERSION_1_20
+ },
+ {
+ "GLSL 1.20 invariant, centroid qualifiers",
+ NO_VERTEX_SHADER,
+ "#version 120 \n"
+ "invariant varying vec4 v1; \n"
+ "centroid varying vec4 v2; \n"
+ "invariant centroid varying vec4 v3; \n"
+ "varying vec4 v4; \n"
+ "invariant v4; \n"
+ "void main() { \n"
+ " gl_FragColor = vec4(1); \n"
+ "} \n",
+ { 1.0, 1.0, 1.0, 1.0 },
+ DONT_CARE_Z,
+ FLAG_VERSION_1_20
+ },
+
+ // Illegal link test ==================================================
{
"gl_Position not written check",
"void main() { \n"
@@ -2657,6 +2991,42 @@ static const ShaderProgram Programs[] = {
FLAG_ILLEGAL_LINK
},
+ {
+ "varying read but not written",
+ // vert shader:
+ "varying vec4 foo; \n"
+ "void main() { \n"
+ " gl_Position = ftransform(); \n"
+ "} \n",
+ // frag shader:
+ "varying vec4 foo; \n"
+ "void main() { \n"
+ " gl_FragColor = foo; \n"
+ "} \n",
+ { 0.0, 0.0, 0.0, 0.0 },
+ DONT_CARE_Z,
+ FLAG_ILLEGAL_LINK
+ },
+
+ {
+ "texcoord varying",
+ // Does the linker correctly recognize that texcoord[1] is
+ // written by the vertex shader and read by the fragment shader?
+ // vert shader:
+ "void main() { \n"
+ " int i = 1; \n"
+ " gl_TexCoord[i] = vec4(0.5, 0, 0, 0); \n"
+ " gl_Position = ftransform(); \n"
+ "} \n",
+ // frag shader:
+ "void main() { \n"
+ " gl_FragColor = gl_TexCoord[1]; \n"
+ "} \n",
+ { 0.5, 0.0, 0.0, 0.0 },
+ DONT_CARE_Z,
+ FLAG_NONE
+ },
+
{ NULL, NULL, NULL, {0,0,0,0}, 0, FLAG_NONE } // end of list sentinal
};
@@ -2964,16 +3334,17 @@ GLSLTest::setupTextureMatrix1(void)
bool
GLSLTest::setup(void)
{
- // check that we have OpenGL 2.0
- const char *verString = (const char *) glGetString(GL_VERSION);
- if (verString[0] != '2' || verString[1] != '.') {
- //env->log << "OpenGL 2.x not supported\n";
+ // check GLSL version
+#ifdef GL_SHADING_LANGUAGE_VERSION
+ const char *glslVersion = (const char *) glGetString(GL_SHADING_LANGUAGE_VERSION);
+#else
+ const char *glslVersion = NULL;
+#endif
+ if (!glslVersion || glslVersion[0] != '1') {
+ env->log << "GLSL 1.x not supported\n";
return false;
}
- if (verString[2] >= '1')
- version21 = GL_TRUE; // update when needed
- else
- version21 = GL_FALSE; // play it safe
+ glsl_120 = (glslVersion[2] >= '2');
if (!getFunctions()) {
env->log << "Unable to get pointer to an OpenGL 2.0 API function\n";
@@ -3399,7 +3770,7 @@ GLSLTest::runOne(MultiTestResult &r, Window &w)
else {
// loop over all tests
for (int i = 0; Programs[i].name; i++) {
- if ((Programs[i].flags & FLAG_VERSION_2_1) && !version21)
+ if ((Programs[i].flags & FLAG_VERSION_1_20) && !glsl_120)
continue; // skip non-applicable tests
if (testProgram(Programs[i])) {
r.numPassed++;
@@ -3413,9 +3784,27 @@ GLSLTest::runOne(MultiTestResult &r, Window &w)
}
+// We need OpenGL 2.0, 2.1 or 3.0
+bool
+GLSLTest::isApplicable() const
+{
+ const char *version = (const char *) glGetString(GL_VERSION);
+ if (strncmp(version, "2.0", 3) == 0 ||
+ strncmp(version, "2.1", 3) == 0 ||
+ strncmp(version, "3.0", 3) == 0) {
+ return true;
+ }
+ else {
+ env->log << name
+ << ": skipped. Requires GL 2.0, 2.1 or 3.0.\n";
+ return false;
+ }
+}
+
+
// The test object itself:
GLSLTest glslTest("glsl1", "window, rgb, z",
- "", // no extension filter (we'll test for version 2.x during setup)
+ "", // no extension filter but see isApplicable()
"GLSL test 1: test basic Shading Language functionality.\n"
);