Commit 72e7c203 authored by Nicolai Hähnle's avatar Nicolai Hähnle
Browse files

glean/fragprog: Do not require EXT_fog_coord

ARB_fragment_program only interacts with, but does not depend on
EXT_fog_coord, so simply skip the fog-related tests when the latter is
not present.
parent c00c294c
// 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.
......@@ -104,6 +104,7 @@ static const FragmentProgram Programs[] = {
ABS(Param2[3])
},
DONT_CARE_Z,
0
},
{
"ADD test",
......@@ -116,7 +117,8 @@ static const FragmentProgram Programs[] = {
CLAMP01(FragColor[2] + Param1[2]),
CLAMP01(FragColor[3] + Param1[3])
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"CMP test",
......@@ -127,7 +129,8 @@ static const FragmentProgram Programs[] = {
"CMP result.color, p2, zero, p1; \n"
"END \n",
{ Param0[0], Param1[1], Param1[2], Param0[3] },
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"COS test",
......@@ -143,7 +146,8 @@ static const FragmentProgram Programs[] = {
CLAMP01(0.8775),
CLAMP01(0.5403)
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"COS test 2",
......@@ -159,7 +163,8 @@ static const FragmentProgram Programs[] = {
CLAMP01(1.0),
CLAMP01(0.8775)
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"DP3 test",
......@@ -171,7 +176,8 @@ static const FragmentProgram Programs[] = {
Param1[1] * FragColor[1] +
Param1[2] * FragColor[2]))
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"DP4 test",
......@@ -184,7 +190,8 @@ static const FragmentProgram Programs[] = {
Param1[2] * FragColor[2] +
Param1[3] * FragColor[3]))
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"DPH test",
......@@ -200,7 +207,8 @@ static const FragmentProgram Programs[] = {
Param1[2] * FragColor[2] +
FragColor[3]) * 0.1))
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"DST test",
......@@ -215,7 +223,8 @@ static const FragmentProgram Programs[] = {
0.16, // v1.z
CLAMP01(2.5) // v2.w
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"EX2 test",
......@@ -233,7 +242,8 @@ static const FragmentProgram Programs[] = {
2.0 * 0.01,
16.0 * 0.01,
0.25 * 0.01 },
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"FLR test",
......@@ -249,7 +259,8 @@ static const FragmentProgram Programs[] = {
CLAMP01(-0.1),
0.1
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"FRC test",
......@@ -258,7 +269,8 @@ static const FragmentProgram Programs[] = {
"FRC result.color, values; \n"
"END \n",
{ 0.9, 0.1, 0.8, 0.4 },
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"LG2 test",
......@@ -277,7 +289,8 @@ static const FragmentProgram Programs[] = {
0.49,
0.2
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"LIT test 1",
......@@ -290,7 +303,8 @@ static const FragmentProgram Programs[] = {
0.433, // roughly Pow(values.y, values.w)
1.0
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"LIT test 2 (degenerate case: 0 ^ 0 -> 1)",
......@@ -303,7 +317,8 @@ static const FragmentProgram Programs[] = {
1.0, // 0^0
1.0
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"LIT test 3 (case x < 0)",
......@@ -316,7 +331,8 @@ static const FragmentProgram Programs[] = {
0.0,
1.0
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"LRP test",
......@@ -330,7 +346,8 @@ 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
DONT_CARE_Z,
0
},
{
"MAD test",
......@@ -344,7 +361,8 @@ static const FragmentProgram Programs[] = {
CLAMP01(FragColor[2] * Param1[2] + Param2[2]),
CLAMP01(FragColor[3] * Param1[3] + Param2[3])
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"MAX test",
......@@ -358,7 +376,8 @@ static const FragmentProgram Programs[] = {
MAX(Param1[2], Param2[2]),
MAX(Param1[3], Param2[3]),
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"MIN test",
......@@ -371,7 +390,8 @@ static const FragmentProgram Programs[] = {
MIN(Param1[2], FragColor[2]),
MIN(Param1[3], FragColor[3]),
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"MOV test",
......@@ -380,6 +400,7 @@ static const FragmentProgram Programs[] = {
"END \n",
FRAGCOLOR,
DONT_CARE_Z,
0
},
{
"MUL test",
......@@ -392,7 +413,8 @@ static const FragmentProgram Programs[] = {
CLAMP01(FragColor[2] * Param1[2]),
CLAMP01(FragColor[3] * Param1[3])
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"masked MUL test",
......@@ -407,7 +429,8 @@ static const FragmentProgram Programs[] = {
0.0,
0.0
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"POW test (exponentiation)",
......@@ -422,7 +445,8 @@ static const FragmentProgram Programs[] = {
0.5 * 0.5 * 0.5,
0.5 * 0.5 * 0.5 * 0.5,
CLAMP01(2.0) },
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"RCP test (reciprocal)",
......@@ -434,7 +458,8 @@ 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
DONT_CARE_Z,
0
},
{
"RSQ test 1 (reciprocal square root)",
......@@ -446,7 +471,8 @@ static const FragmentProgram Programs[] = {
"RSQ result.color.w, values.w; \n"
"END \n",
{ 1.0, 0.5, 0.3333, 0.1 },
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"RSQ test 2 (reciprocal square root of negative value)",
......@@ -462,7 +488,8 @@ static const FragmentProgram Programs[] = {
0.447,
1.0,
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"SCS test",
......@@ -476,7 +503,8 @@ static const FragmentProgram Programs[] = {
DONT_CARE_COLOR,
DONT_CARE_COLOR,
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"SGE test",
......@@ -490,7 +518,8 @@ static const FragmentProgram Programs[] = {
Param2[2] >= Param0[2] ? 1.0 : 0.0,
Param2[3] >= Param0[3] ? 1.0 : 0.0,
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"SIN test",
......@@ -506,7 +535,8 @@ static const FragmentProgram Programs[] = {
CLAMP01(0.4794),
CLAMP01(0.8414)
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"SIN test 2",
......@@ -522,7 +552,8 @@ static const FragmentProgram Programs[] = {
CLAMP01(0.4794),
CLAMP01(0.4794)
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"SLT test",
......@@ -535,7 +566,8 @@ static const FragmentProgram Programs[] = {
FragColor[2] < Param1[2] ? 1.0 : 0.0,
FragColor[3] < Param1[3] ? 1.0 : 0.0,
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"SUB test (with swizzle)",
......@@ -548,7 +580,8 @@ static const FragmentProgram Programs[] = {
CLAMP01(Param1[3] - FragColor[3]),
CLAMP01(Param1[2] - FragColor[2])
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"SWZ test",
......@@ -561,7 +594,8 @@ static const FragmentProgram Programs[] = {
CLAMP01(Param1[2]),
CLAMP01(0.0)
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"XPD test 1",
......@@ -575,7 +609,8 @@ static const FragmentProgram Programs[] = {
CLAMP01(Param1[0] * Param2[1] - Param1[1] * Param2[0]),
DONT_CARE_COLOR
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"Z-write test",
......@@ -589,7 +624,8 @@ static const FragmentProgram Programs[] = {
Param1[2],
Param1[3]
},
Param1[1]
Param1[1],
0
},
// ============= Numeric stress tests =================================
......@@ -609,7 +645,8 @@ static const FragmentProgram Programs[] = {
DONT_CARE_COLOR,
DONT_CARE_COLOR
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
{
"Infinity / nan test",
......@@ -623,7 +660,8 @@ static const FragmentProgram Programs[] = {
DONT_CARE_COLOR,
DONT_CARE_COLOR
},
DONT_CARE_Z
DONT_CARE_Z,
0
},
// ============= Fog tests ============================================
......@@ -640,7 +678,8 @@ static const FragmentProgram Programs[] = {
FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
FragColor[3]
},
DONT_CARE_Z
DONT_CARE_Z,
FragmentProgram::NeedsFogCoord
},
{
"Computed fog linear test",
......@@ -664,7 +703,8 @@ static const FragmentProgram Programs[] = {
FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
FragColor[3]
},
DONT_CARE_Z
DONT_CARE_Z,
FragmentProgram::NeedsFogCoord
},
#undef FOG_FACT
......@@ -681,7 +721,8 @@ static const FragmentProgram Programs[] = {
FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
FragColor[3]
},
DONT_CARE_Z
DONT_CARE_Z,
FragmentProgram::NeedsFogCoord
},
#undef FOG_FACT
#define FOG_FACT 0.3535 // = ex2(-Density * Coord)
......@@ -708,7 +749,8 @@ static const FragmentProgram Programs[] = {
FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
FragColor[3]
},
DONT_CARE_Z
DONT_CARE_Z,
FragmentProgram::NeedsFogCoord
},
#undef FOG_FACT
......@@ -725,7 +767,8 @@ static const FragmentProgram Programs[] = {
FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
FragColor[3]
},
DONT_CARE_Z
DONT_CARE_Z,
FragmentProgram::NeedsFogCoord
},
#undef FOG_FACT
#define FOG_FACT 0.2102 // = ex2(-(Density * Coord)^2)
......@@ -753,7 +796,8 @@ static const FragmentProgram Programs[] = {
FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
FragColor[3]
},
DONT_CARE_Z
DONT_CARE_Z,
FragmentProgram::NeedsFogCoord
},
#undef FOG_FACT
......@@ -799,8 +843,13 @@ FragmentProgramTest::setup(void)
glGetProgramivARB_func = (PFNGLGETPROGRAMIVARBPROC) GLUtils::getProcAddress("glGetProgramivARB");
assert(glGetProgramivARB_func);
glFogCoordf_func = (PFNGLFOGCOORDFPROC) GLUtils::getProcAddress("glFogCoordf");
assert(glFogCoordf_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";
}
GLuint progID;
glGenProgramsARB_func(1, &progID);
......@@ -828,15 +877,17 @@ FragmentProgramTest::setup(void)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDrawBuffer(GL_FRONT);
glReadBuffer(GL_FRONT);
glReadBuffer(GL_FRONT);
// other GL state
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);
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);
}
// compute error tolerances (may need fine-tuning)
int bufferBits[5];
......@@ -959,7 +1010,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)) {
......@@ -990,6 +1041,10 @@ 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 (Programs[i].flags && FragmentProgram::NeedsFogCoord) {
if (!glFogCoordf_func)
continue;
}
#if DEVEL_MODE
glViewport(0, i * 20, windowWidth, 20);
#endif
......
// 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,10 +55,14 @@ namespace GLEAN {
class FragmentProgram
{
public:
enum {
NeedsFogCoord = 1
};
const char *name;
const char *progString;
GLfloat expectedColor[4];
GLfloat expectedZ;
uint flags;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment