summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-02-09 13:28:19 -0700
committerBrian Paul <brianp@vmware.com>2009-02-09 13:28:19 -0700
commitc767fd98818de97d648f66c609eaed5fa7570755 (patch)
tree3d1b8c41d7a16649af43137b3787518160a91d0b /tests
parentcc4af3cfed781f725159a839ea031e0cccf763cf (diff)
import latest glsl1, vertprog1, fragprog1 sources from Glean
Diffstat (limited to 'tests')
-rw-r--r--tests/glean/tfragprog1.cpp175
-rw-r--r--tests/glean/tfragprog1.h14
-rw-r--r--tests/glean/tglsl1.cpp308
-rw-r--r--tests/glean/tglsl1.h2
-rw-r--r--tests/glean/tvertprog1.cpp3
5 files changed, 345 insertions, 157 deletions
diff --git a/tests/glean/tfragprog1.cpp b/tests/glean/tfragprog1.cpp
index fee35c4dd..216dc5061 100644
--- a/tests/glean/tfragprog1.cpp
+++ b/tests/glean/tfragprog1.cpp
@@ -1,7 +1,7 @@
// BEGIN_COPYRIGHT -*- glean -*-
-//
+//
// Copyright (C) 1999 Allen Akin All Rights Reserved.
-//
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -10,11 +10,11 @@
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the
// Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
// KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
@@ -23,7 +23,7 @@
// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
-//
+//
// END_COPYRIGHT
// tfragprog.cpp: Test GL_ARB_fragment_program extension.
@@ -39,11 +39,11 @@
// unique programs work correctly.
-#include "tfragprog1.h"
-#include <cassert>
#include <cstring>
+#include <cassert>
#include <cmath>
#include <math.h>
+#include "tfragprog1.h"
namespace GLEAN {
@@ -104,7 +104,6 @@ static const FragmentProgram Programs[] = {
ABS(Param2[3])
},
DONT_CARE_Z,
- 0
},
{
"ADD test",
@@ -117,8 +116,7 @@ static const FragmentProgram Programs[] = {
CLAMP01(FragColor[2] + Param1[2]),
CLAMP01(FragColor[3] + Param1[3])
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"CMP test",
@@ -129,8 +127,7 @@ static const FragmentProgram Programs[] = {
"CMP result.color, p2, zero, p1; \n"
"END \n",
{ Param0[0], Param1[1], Param1[2], Param0[3] },
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"COS test",
@@ -146,8 +143,7 @@ static const FragmentProgram Programs[] = {
CLAMP01(0.8775),
CLAMP01(0.5403)
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"COS test 2",
@@ -163,8 +159,7 @@ static const FragmentProgram Programs[] = {
CLAMP01(1.0),
CLAMP01(0.8775)
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"DP3 test",
@@ -176,8 +171,7 @@ static const FragmentProgram Programs[] = {
Param1[1] * FragColor[1] +
Param1[2] * FragColor[2]))
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"DP4 test",
@@ -190,8 +184,7 @@ static const FragmentProgram Programs[] = {
Param1[2] * FragColor[2] +
Param1[3] * FragColor[3]))
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"DPH test",
@@ -207,8 +200,7 @@ static const FragmentProgram Programs[] = {
Param1[2] * FragColor[2] +
FragColor[3]) * 0.1))
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"DST test",
@@ -223,8 +215,7 @@ static const FragmentProgram Programs[] = {
0.16, // v1.z
CLAMP01(2.5) // v2.w
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"EX2 test",
@@ -242,8 +233,7 @@ static const FragmentProgram Programs[] = {
2.0 * 0.01,
16.0 * 0.01,
0.25 * 0.01 },
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"FLR test",
@@ -259,8 +249,7 @@ static const FragmentProgram Programs[] = {
CLAMP01(-0.1),
0.1
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"FRC test",
@@ -269,8 +258,7 @@ static const FragmentProgram Programs[] = {
"FRC result.color, values; \n"
"END \n",
{ 0.9, 0.1, 0.8, 0.4 },
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"LG2 test",
@@ -289,8 +277,7 @@ static const FragmentProgram Programs[] = {
0.49,
0.2
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"LIT test 1",
@@ -303,8 +290,7 @@ static const FragmentProgram Programs[] = {
0.433, // roughly Pow(values.y, values.w)
1.0
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"LIT test 2 (degenerate case: 0 ^ 0 -> 1)",
@@ -317,8 +303,7 @@ static const FragmentProgram Programs[] = {
1.0, // 0^0
1.0
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"LIT test 3 (case x < 0)",
@@ -331,8 +316,7 @@ static const FragmentProgram Programs[] = {
0.0,
1.0
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"LRP test",
@@ -346,8 +330,7 @@ static const FragmentProgram Programs[] = {
1.0 * FragColor[2] + (1.0 - 1.0) * Param1[2],
0.0 * FragColor[3] + (1.0 - 0.0) * Param1[3]
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"MAD test",
@@ -361,8 +344,7 @@ static const FragmentProgram Programs[] = {
CLAMP01(FragColor[2] * Param1[2] + Param2[2]),
CLAMP01(FragColor[3] * Param1[3] + Param2[3])
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"MAX test",
@@ -376,8 +358,7 @@ static const FragmentProgram Programs[] = {
MAX(Param1[2], Param2[2]),
MAX(Param1[3], Param2[3]),
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"MIN test",
@@ -390,8 +371,7 @@ static const FragmentProgram Programs[] = {
MIN(Param1[2], FragColor[2]),
MIN(Param1[3], FragColor[3]),
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"MOV test",
@@ -400,7 +380,6 @@ static const FragmentProgram Programs[] = {
"END \n",
FRAGCOLOR,
DONT_CARE_Z,
- 0
},
{
"MUL test",
@@ -413,8 +392,7 @@ static const FragmentProgram Programs[] = {
CLAMP01(FragColor[2] * Param1[2]),
CLAMP01(FragColor[3] * Param1[3])
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"masked MUL test",
@@ -429,8 +407,7 @@ static const FragmentProgram Programs[] = {
0.0,
0.0
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"POW test (exponentiation)",
@@ -445,8 +422,7 @@ static const FragmentProgram Programs[] = {
0.5 * 0.5 * 0.5,
0.5 * 0.5 * 0.5 * 0.5,
CLAMP01(2.0) },
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"RCP test (reciprocal)",
@@ -458,8 +434,7 @@ static const FragmentProgram Programs[] = {
"RCP result.color.w, values.w; \n"
"END \n",
{ 1.0 / 8.0, CLAMP01(1.0 / -10.0), 1, 1.0 / 12.0 },
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"RSQ test 1 (reciprocal square root)",
@@ -471,8 +446,7 @@ static const FragmentProgram Programs[] = {
"RSQ result.color.w, values.w; \n"
"END \n",
{ 1.0, 0.5, 0.3333, 0.1 },
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"RSQ test 2 (reciprocal square root of negative value)",
@@ -488,8 +462,7 @@ static const FragmentProgram Programs[] = {
0.447,
1.0,
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"SCS test",
@@ -503,8 +476,7 @@ static const FragmentProgram Programs[] = {
DONT_CARE_COLOR,
DONT_CARE_COLOR,
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"SGE test",
@@ -518,8 +490,7 @@ static const FragmentProgram Programs[] = {
Param2[2] >= Param0[2] ? 1.0 : 0.0,
Param2[3] >= Param0[3] ? 1.0 : 0.0,
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"SIN test",
@@ -535,8 +506,7 @@ static const FragmentProgram Programs[] = {
CLAMP01(0.4794),
CLAMP01(0.8414)
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"SIN test 2",
@@ -552,8 +522,7 @@ static const FragmentProgram Programs[] = {
CLAMP01(0.4794),
CLAMP01(0.4794)
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"SLT test",
@@ -566,8 +535,7 @@ static const FragmentProgram Programs[] = {
FragColor[2] < Param1[2] ? 1.0 : 0.0,
FragColor[3] < Param1[3] ? 1.0 : 0.0,
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"SUB test (with swizzle)",
@@ -580,8 +548,7 @@ static const FragmentProgram Programs[] = {
CLAMP01(Param1[3] - FragColor[3]),
CLAMP01(Param1[2] - FragColor[2])
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"SWZ test",
@@ -594,8 +561,7 @@ static const FragmentProgram Programs[] = {
CLAMP01(Param1[2]),
CLAMP01(0.0)
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"XPD test 1",
@@ -609,8 +575,7 @@ static const FragmentProgram Programs[] = {
CLAMP01(Param1[0] * Param2[1] - Param1[1] * Param2[0]),
DONT_CARE_COLOR
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"Z-write test",
@@ -624,8 +589,7 @@ static const FragmentProgram Programs[] = {
Param1[2],
Param1[3]
},
- Param1[1],
- 0
+ Param1[1]
},
// ============= Numeric stress tests =================================
@@ -645,8 +609,7 @@ static const FragmentProgram Programs[] = {
DONT_CARE_COLOR,
DONT_CARE_COLOR
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
{
"Infinity / nan test",
@@ -660,8 +623,7 @@ static const FragmentProgram Programs[] = {
DONT_CARE_COLOR,
DONT_CARE_COLOR
},
- DONT_CARE_Z,
- 0
+ DONT_CARE_Z
},
// ============= Fog tests ============================================
@@ -678,8 +640,7 @@ static const FragmentProgram Programs[] = {
FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
FragColor[3]
},
- DONT_CARE_Z,
- FragmentProgram::NeedsFogCoord
+ DONT_CARE_Z
},
{
"Computed fog linear test",
@@ -703,8 +664,7 @@ static const FragmentProgram Programs[] = {
FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
FragColor[3]
},
- DONT_CARE_Z,
- FragmentProgram::NeedsFogCoord
+ DONT_CARE_Z
},
#undef FOG_FACT
@@ -721,8 +681,7 @@ static const FragmentProgram Programs[] = {
FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
FragColor[3]
},
- DONT_CARE_Z,
- FragmentProgram::NeedsFogCoord
+ DONT_CARE_Z
},
#undef FOG_FACT
#define FOG_FACT 0.3535 // = ex2(-Density * Coord)
@@ -749,8 +708,7 @@ static const FragmentProgram Programs[] = {
FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
FragColor[3]
},
- DONT_CARE_Z,
- FragmentProgram::NeedsFogCoord
+ DONT_CARE_Z
},
#undef FOG_FACT
@@ -767,8 +725,7 @@ static const FragmentProgram Programs[] = {
FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
FragColor[3]
},
- DONT_CARE_Z,
- FragmentProgram::NeedsFogCoord
+ DONT_CARE_Z
},
#undef FOG_FACT
#define FOG_FACT 0.2102 // = ex2(-(Density * Coord)^2)
@@ -796,8 +753,7 @@ static const FragmentProgram Programs[] = {
FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
FragColor[3]
},
- DONT_CARE_Z,
- FragmentProgram::NeedsFogCoord
+ DONT_CARE_Z
},
#undef FOG_FACT
@@ -843,13 +799,8 @@ FragmentProgramTest::setup(void)
glGetProgramivARB_func = (PFNGLGETPROGRAMIVARBPROC) GLUtils::getProcAddress("glGetProgramivARB");
assert(glGetProgramivARB_func);
- if (GLUtils::haveExtensions("GL_EXT_fog_coord")) {
- glFogCoordf_func = (PFNGLFOGCOORDFPROC) GLUtils::getProcAddress("glFogCoordf");
- assert(glFogCoordf_func);
- } else {
- glFogCoordf_func = 0;
- env->log << "Note: EXT_fog_coord not available, skipping some tests\n";
- }
+ glFogCoordf_func = (PFNGLFOGCOORDFPROC) GLUtils::getProcAddress("glFogCoordf");
+ assert(glFogCoordf_func);
GLuint progID;
glGenProgramsARB_func(1, &progID);
@@ -877,17 +828,15 @@ FragmentProgramTest::setup(void)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDrawBuffer(GL_FRONT);
- glReadBuffer(GL_FRONT);
+ glReadBuffer(GL_FRONT);
// other GL state
- if (glFogCoordf_func) {
- glFogf(GL_FOG_START, FogStart);
- glFogf(GL_FOG_END, FogEnd);
- glFogf(GL_FOG_DENSITY, FogDensity);
- glFogfv(GL_FOG_COLOR, FogColor);
- glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
- glFogCoordf_func(FogCoord);
- }
+ glFogf(GL_FOG_START, FogStart);
+ glFogf(GL_FOG_END, FogEnd);
+ glFogf(GL_FOG_DENSITY, FogDensity);
+ glFogfv(GL_FOG_COLOR, FogColor);
+ glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
+ glFogCoordf_func(FogCoord);
// compute error tolerances (may need fine-tuning)
int bufferBits[5];
@@ -1010,7 +959,7 @@ FragmentProgramTest::testProgram(const FragmentProgram &p)
printf("%s: Expect: %.3f %.3f %.3f %.3f found: %.3f %.3f %.3f %.3f\n",
p.name,
p.expectedColor[0], p.expectedColor[1],
- p.expectedColor[2], p.expectedColor[3],
+ p.expectedColor[2], p.expectedColor[3],
pixel[0], pixel[1], pixel[2], pixel[3]);
if (!equalColors(pixel, p.expectedColor)) {
@@ -1044,12 +993,8 @@ FragmentProgramTest::runOne(MultiTestResult &r, Window &w)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
#endif
for (int i = 0; Programs[i].name; i++) {
+
if (!single || strcmp(single, Programs[i].name) == 0) {
- if (Programs[i].flags &&
- FragmentProgram::NeedsFogCoord) {
- if (!glFogCoordf_func)
- continue;
- }
#if DEVEL_MODE
glViewport(0, i * 20, windowWidth, 20);
diff --git a/tests/glean/tfragprog1.h b/tests/glean/tfragprog1.h
index e41b5f1f7..37656eb0b 100644
--- a/tests/glean/tfragprog1.h
+++ b/tests/glean/tfragprog1.h
@@ -1,7 +1,7 @@
// BEGIN_COPYRIGHT -*- glean -*-
-//
+//
// Copyright (C) 1999 Allen Akin All Rights Reserved.
-//
+//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@@ -10,11 +10,11 @@
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
-//
+//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the
// Software.
-//
+//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
// KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
@@ -23,7 +23,7 @@
// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
// OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
-//
+//
// END_COPYRIGHT
// tfragprog.h: Test GL_ARB_fragment_program extension.
@@ -55,14 +55,10 @@ namespace GLEAN {
class FragmentProgram
{
public:
- enum {
- NeedsFogCoord = 1
- };
const char *name;
const char *progString;
GLfloat expectedColor[4];
GLfloat expectedZ;
- uint flags;
};
diff --git a/tests/glean/tglsl1.cpp b/tests/glean/tglsl1.cpp
index 2a3065638..d64aa79d6 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
@@ -33,9 +34,8 @@
#include "tglsl1.h"
#include <cassert>
-#include <cstring>
-#include <cmath>
-#include <cstdlib>
+#include <math.h>
+
namespace GLEAN {
@@ -82,7 +82,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
@@ -2070,7 +2070,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,
@@ -2083,7 +2083,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,
@@ -2096,7 +2096,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,
@@ -2109,7 +2109,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,
@@ -2122,7 +2122,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,
@@ -2135,7 +2135,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,
@@ -2235,6 +2235,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)",
@@ -2392,7 +2479,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",
@@ -2408,7 +2495,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",
@@ -2422,7 +2509,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",
@@ -2437,7 +2524,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",
@@ -2453,7 +2540,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",
@@ -2467,7 +2554,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
},
{
@@ -2487,7 +2574,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
},
{
@@ -2509,7 +2596,7 @@ static const ShaderProgram Programs[] = {
0.0
},
DONT_CARE_Z,
- FLAG_VERSION_2_1
+ FLAG_VERSION_1_20
},
{
@@ -2535,7 +2622,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
},
{
@@ -2555,7 +2642,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",
@@ -2574,7 +2661,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
},
{
@@ -2587,7 +2674,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",
@@ -2599,7 +2686,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",
@@ -2612,7 +2699,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",
@@ -2625,10 +2712,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
+ },
+
+ // 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
},
- // Illegal link test ===================================================
+ // 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"
@@ -2971,10 +3209,18 @@ GLSLTest::setup(void)
//env->log << "OpenGL 2.x not supported\n";
return false;
}
- if (verString[2] >= '1')
- version21 = GL_TRUE; // update when needed
- else
- version21 = GL_FALSE; // play it safe
+
+ // 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;
+ }
+ glsl_120 = (verString[2] >= '2');
if (!getFunctions()) {
env->log << "Unable to get pointer to an OpenGL 2.0 API function\n";
@@ -3400,7 +3646,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++;
diff --git a/tests/glean/tglsl1.h b/tests/glean/tglsl1.h
index 84a3d723f..cf1ed9245 100644
--- a/tests/glean/tglsl1.h
+++ b/tests/glean/tglsl1.h
@@ -66,7 +66,7 @@ public:
private:
GLfloat tolerance[5];
GLfloat looseTolerance[5];
- GLfloat version21; // OpenGL 2.1 or higher supported?
+ GLfloat glsl_120; // GLSL 1.20 or higher supported?
bool getFunctions(void);
void setupTextures(void);
void setupTextureMatrix1(void);
diff --git a/tests/glean/tvertprog1.cpp b/tests/glean/tvertprog1.cpp
index b0a6e358d..32053358d 100644
--- a/tests/glean/tvertprog1.cpp
+++ b/tests/glean/tvertprog1.cpp
@@ -31,10 +31,11 @@
//
// See tfragprog.cpp for comments (this test is very similar).
-#include "tvertprog1.h"
#include <cassert>
#include <cmath>
#include <cstring>
+#include <math.h>
+#include "tvertprog1.h"
namespace GLEAN {