[Piglit] [PATCH 4/7] Remove remaining Glean tests.
Fabian Bieler
fabianbieler at fastmail.fm
Sat Dec 9 12:52:30 UTC 2017
Tests removed are:
api2, makeCurrent, fbo, fragProg1, pixelFormats, shaderAPI, texCube,
texture_srgb, vertArrayBGRA and vertattrib.
---
tests/all.py | 78 +-
tests/glean/CMakeLists.gl.txt | 11 -
tests/glean/tapi2.cpp | 890 ---------------------
tests/glean/tapi2.h | 87 ---
tests/glean/tbasic.cpp | 60 --
tests/glean/tbasic.h | 69 --
tests/glean/tbinding.cpp | 206 -----
tests/glean/tbinding.h | 73 --
tests/glean/tfbo.cpp | 1367 --------------------------------
tests/glean/tfbo.h | 83 --
tests/glean/tfragprog1.cpp | 1125 ---------------------------
tests/glean/tfragprog1.h | 92 ---
tests/glean/tpixelformats.cpp | 1675 ----------------------------------------
tests/glean/tpixelformats.h | 98 ---
tests/glean/tshaderapi.cpp | 470 -----------
tests/glean/tshaderapi.h | 98 ---
tests/glean/ttexcube.cpp | 426 ----------
tests/glean/ttexcube.h | 66 --
tests/glean/ttexture_srgb.cpp | 356 ---------
tests/glean/ttexture_srgb.h | 71 --
tests/glean/tvertarraybgra.cpp | 186 -----
tests/glean/tvertarraybgra.h | 74 --
tests/glean/tvertattrib.cpp | 1398 ---------------------------------
tests/glean/tvertattrib.h | 95 ---
tests/no_error.py | 3 +-
tests/quick.py | 4 +-
26 files changed, 3 insertions(+), 9158 deletions(-)
delete mode 100644 tests/glean/tapi2.cpp
delete mode 100644 tests/glean/tapi2.h
delete mode 100644 tests/glean/tbasic.cpp
delete mode 100644 tests/glean/tbasic.h
delete mode 100644 tests/glean/tbinding.cpp
delete mode 100644 tests/glean/tbinding.h
delete mode 100644 tests/glean/tfbo.cpp
delete mode 100644 tests/glean/tfbo.h
delete mode 100644 tests/glean/tfragprog1.cpp
delete mode 100644 tests/glean/tfragprog1.h
delete mode 100644 tests/glean/tpixelformats.cpp
delete mode 100644 tests/glean/tpixelformats.h
delete mode 100644 tests/glean/tshaderapi.cpp
delete mode 100644 tests/glean/tshaderapi.h
delete mode 100644 tests/glean/ttexcube.cpp
delete mode 100644 tests/glean/ttexcube.h
delete mode 100644 tests/glean/ttexture_srgb.cpp
delete mode 100644 tests/glean/ttexture_srgb.h
delete mode 100644 tests/glean/tvertarraybgra.cpp
delete mode 100644 tests/glean/tvertarraybgra.h
delete mode 100644 tests/glean/tvertattrib.cpp
delete mode 100644 tests/glean/tvertattrib.h
diff --git a/tests/all.py b/tests/all.py
index 9d54415..145e4dc 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -18,7 +18,7 @@ from framework import options
from framework import wflinfo
from framework.profile import TestProfile
from framework.driver_classifier import DriverClassifier
-from framework.test import (PiglitGLTest, GleanTest, PiglitBaseTest,
+from framework.test import (PiglitGLTest, PiglitBaseTest,
GLSLParserTest, GLSLParserNoConfigError)
from framework.test.shader_test import ShaderTest, MultiShaderTest
from .py_modules.constants import TESTS_DIR, GENERATED_TESTS_DIR
@@ -370,82 +370,6 @@ for basedir in [os.path.join(TESTS_DIR, 'apitrace', 'traces')]:
# List of all of the MSAA sample counts we wish to test
MSAA_SAMPLE_COUNTS = ['2', '4', '6', '8', '16', '32']
-with profile.test_list.group_manager(GleanTest, 'glean') as g:
- g('basic')
- g('api2')
- g('makeCurrent')
- g('bufferObject')
- g('depthStencil')
- g('fbo')
- g('getString')
- g('pixelFormats')
- # exactRGBA is not included intentionally, because it's too strict and
- # the equivalent functionality is covered by other tests
- g('shaderAPI')
- g('texCube')
- g('texture_srgb')
- g('vertArrayBGRA')
- g('vertattrib')
-
-glean_fp_tests = ['ABS test',
- 'ADD test',
- 'ADD with saturation',
- 'ADD an immediate',
- 'ADD negative immediate',
- 'ADD negative immediate (2)',
- 'CMP test',
- 'COS test',
- 'COS test 2',
- 'DP3 test',
- 'DP3 test (2)',
- 'DP4 test',
- 'DPH test',
- 'DST test',
- 'EX2 test',
- 'FLR test',
- 'FRC test',
- 'LG2 test',
- 'LIT test 1',
- 'LIT test 2 (degenerate case: 0 ^ 0 -> 1)',
- 'LIT test 3 (case x < 0)',
- 'MAD test',
- 'MAX test',
- 'MIN test',
- 'MOV test',
- 'MUL test',
- 'masked MUL test',
- 'POW test (exponentiation)',
- 'RCP test (reciprocal)',
- 'RCP test 2 (reciprocal)',
- 'RSQ test 1 (reciprocal square root)',
- 'RSQ test 2 (reciprocal square root of negative value)',
- 'SCS test',
- 'SGE test',
- 'SIN test',
- 'SIN test 2',
- 'SLT test',
- 'SUB test (with swizzle)',
- 'SUB with saturation',
- 'SWZ test',
- 'swizzled move test',
- 'swizzled add test',
- 'XPD test 1',
- 'Z-write test',
- 'Divide by zero test',
- 'Infinity and nan test',
- 'ARB_fog_linear test',
- 'Computed fog linear test',
- 'ARB_fog_exp test',
- 'Computed fog exp test',
- 'ARB_fog_exp2 test',
- 'Computed fog exp2 test']
-
-for pairs in [(['fragProg1'], glean_fp_tests)]:
- for prefix, name in itertools.product(*pairs):
- groupname = grouptools.join('glean', '{0}-{1}'.format(prefix, name))
- profile.test_list[groupname] = GleanTest(prefix)
- profile.test_list[groupname].env['PIGLIT_TEST'] = name
-
with profile.test_list.group_manager(PiglitGLTest, 'security') as g:
g(['initialized-texmemory'], run_concurrent=False)
g(['initialized-fbo'], run_concurrent=False)
diff --git a/tests/glean/CMakeLists.gl.txt b/tests/glean/CMakeLists.gl.txt
index 9250dfe..bd7e441 100644
--- a/tests/glean/CMakeLists.gl.txt
+++ b/tests/glean/CMakeLists.gl.txt
@@ -26,19 +26,8 @@ piglit_add_executable (glean
misc.cpp
options.cpp
rc.cpp
- tapi2.cpp
- tbasic.cpp
- tbinding.cpp
test.cpp
- tfbo.cpp
- tfragprog1.cpp
tmultitest.cpp
- tpixelformats.cpp
- tshaderapi.cpp
- ttexcube.cpp
- ttexture_srgb.cpp
- tvertarraybgra.cpp
- tvertattrib.cpp
winsys.cpp
gl.cpp
image_misc.cpp
diff --git a/tests/glean/tapi2.cpp b/tests/glean/tapi2.cpp
deleted file mode 100644
index ab87279..0000000
--- a/tests/glean/tapi2.cpp
+++ /dev/null
@@ -1,890 +0,0 @@
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-// tapi2.h: Test OpenGL 2.x API functions/features
-// Brian Paul 9 March 2007
-
-#define GL_GLEXT_PROTOTYPES
-
-#include <stdlib.h>
-#include <cstring>
-#include <cassert>
-#include <math.h>
-#include "tapi2.h"
-
-
-namespace GLEAN {
-
-bool
-API2Test::setup(void)
-{
- // check that we have OpenGL 2.0
- if (GLUtils::getVersion() < 2.0) {
- //env->log << "OpenGL 2.0 not supported\n";
- return false;
- }
-
- GLenum err = glGetError();
- assert(!err); // should be OK
-
- // setup vertex transform (we'll draw a quad in middle of window)
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-4.0, 4.0, -4.0, 4.0, 0.0, 1.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glDrawBuffer(GL_FRONT);
- glReadBuffer(GL_FRONT);
-
- // compute error tolerances (may need fine-tuning)
- int bufferBits[5];
- glGetIntegerv(GL_RED_BITS, &bufferBits[0]);
- glGetIntegerv(GL_GREEN_BITS, &bufferBits[1]);
- glGetIntegerv(GL_BLUE_BITS, &bufferBits[2]);
- glGetIntegerv(GL_ALPHA_BITS, &bufferBits[3]);
- glGetIntegerv(GL_DEPTH_BITS, &bufferBits[4]);
-
- tolerance[0] = 2.0 / (1 << bufferBits[0]);
- tolerance[1] = 2.0 / (1 << bufferBits[1]);
- tolerance[2] = 2.0 / (1 << bufferBits[2]);
- if (bufferBits[3])
- tolerance[3] = 2.0 / (1 << bufferBits[3]);
- else
- tolerance[3] = 1.0;
- if (bufferBits[4])
- tolerance[4] = 16.0 / (1 << bufferBits[4]);
- else
- tolerance[4] = 1.0;
-
- return true;
-}
-
-
-void
-API2Test::reportFailure(const char *msg, int line) const
-{
- env->log << "FAILURE: " << msg << " (at tapi2.cpp:" << line << ")\n";
-}
-
-
-void
-API2Test::reportFailure(const char *msg, GLenum target, int line) const
-{
- env->log << "FAILURE: " << msg;
- if (target == GL_FRAGMENT_SHADER)
- env->log << " (fragment)";
- else
- env->log << " (vertex)";
- env->log << " (at tapi2.cpp:" << line << ")\n";
-}
-
-
-
-#define REPORT_FAILURE(MSG) reportFailure(MSG, __LINE__)
-#define REPORT_FAILURE_T(MSG, TARGET) reportFailure(MSG, TARGET, __LINE__)
-
-
-// Compare actual and expected colors
-bool
-API2Test::equalColors(const GLfloat act[4], const GLfloat exp[4]) const
-{
- if ((fabsf(act[0] - exp[0]) > tolerance[0]) ||
- (fabsf(act[1] - exp[1]) > tolerance[1]) ||
- (fabsf(act[2] - exp[2]) > tolerance[2]) ||
- (fabsf(act[3] - exp[3]) > tolerance[3]))
- return false;
- else
- return true;
-}
-
-
-// Render test quad w/ current shader program, return RGBA color of quad
-void
-API2Test::renderQuad(GLfloat *pixel) const
-{
- const GLfloat r = 0.62; // XXX draw 16x16 pixel quad
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glBegin(GL_POLYGON);
- glTexCoord2f(0, 0); glVertex2f(-r, -r);
- glTexCoord2f(1, 0); glVertex2f( r, -r);
- glTexCoord2f(1, 1); glVertex2f( r, r);
- glTexCoord2f(0, 1); glVertex2f(-r, r);
- glEnd();
-
- // read a pixel from lower-left corner of rendered quad
- glReadPixels(windowSize / 2 - 2, windowSize / 2 - 2, 1, 1,
- GL_RGBA, GL_FLOAT, pixel);
-}
-
-
-// As above, but use vertex arrays
-// \param attr which vertex attribute array to put colors into
-// \param value 4-component valut to put into the attribute array
-// \param pixel returns the rendered color obtained with glReadPixels
-void
-API2Test::renderQuadWithArrays(GLint attr, const GLfloat value[4],
- GLfloat *pixel) const
-{
- const GLfloat r = 0.62; // XXX draw 16x16 pixel quad
- static const GLfloat vertcoords[4][3] = {
- { -r, -r, 0 }, { r, -r, 0 }, { r, r, 0 }, { -r, r, 0 }
- };
- GLfloat values[4][4];
- GLint i;
- for (i = 0; i < 4; i++) {
- values[i][0] = value[0];
- values[i][1] = value[1];
- values[i][2] = value[2];
- values[i][3] = value[3];
- };
-
- glVertexPointer(3, GL_FLOAT, 0, vertcoords);
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexAttribPointer(attr, 4, GL_FLOAT, GL_FALSE, 0, values);
- glEnableVertexAttribArray(attr);
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glDrawArrays(GL_POLYGON, 0, 4);
-
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableVertexAttribArray(attr);
-
- // read a pixel from lower-left corner of rendered quad
- glReadPixels(windowSize / 2 - 2, windowSize / 2 - 2, 1, 1,
- GL_RGBA, GL_FLOAT, pixel);
-}
-
-
-GLuint
-API2Test::loadAndCompileShader(GLenum target, const char *text)
-{
- GLint stat, val;
- GLuint shader = glCreateShader(target);
- if (!shader) {
- REPORT_FAILURE("glCreateShader failed (fragment)");
- return 0;
- }
- glShaderSource(shader, 1,
- (const GLchar **) &text, NULL);
- glCompileShader(shader);
- glGetShaderiv(shader, GL_COMPILE_STATUS, &stat);
- if (!stat) {
- REPORT_FAILURE_T("glShaderSource or glCompileShader failed", target);
- return 0;
- }
- if (!glIsShader(shader)) {
- REPORT_FAILURE("glIsShader failed (fragment)");
- return false;
- }
- glGetShaderiv(shader, GL_SHADER_TYPE, &val);
- if (val != (GLint) target) {
- REPORT_FAILURE_T("glGetShaderiv(GL_SHADER_TYPE) failed", target);
- return 0;
- }
- glGetShaderiv(shader, GL_COMPILE_STATUS, &val);
- if (val != GL_TRUE) {
- REPORT_FAILURE_T("glGetShaderiv(GL_COMPILE_STATUS) failed", target);
- return 0;
- }
- glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &val);
- // Note: some OpenGLs return a 1-char shorter length than strlen(text)
- if (abs(val - (int) strlen(text)) > 1) {
- REPORT_FAILURE_T("glGetShaderiv(GL_SHADER_SOURCE_LENGTH) failed", target);
- return 0;
- }
- return shader;
-}
-
-
-GLuint
-API2Test::createProgram(GLuint vertShader, GLuint fragShader)
-{
- GLuint program = glCreateProgram();
- if (vertShader)
- glAttachShader(program, vertShader);
- if (fragShader)
- glAttachShader(program, fragShader);
- glLinkProgram(program);
- return program;
-}
-
-
-bool
-API2Test::testShaderObjectFuncs(void)
-{
- static const char *vertShaderText =
- "void main() { \n"
- " gl_Position = ftransform(); \n"
- "} \n";
- static const char *fragShaderText =
- "void main() { \n"
- " gl_FragColor = vec4(1.0, 0.5, 0.25, 0.0); \n"
- "} \n";
- GLuint vertShader, fragShader, program;
- GLint stat, val, err;
-
- vertShader = loadAndCompileShader(GL_VERTEX_SHADER, vertShaderText);
- if (!vertShader)
- return false;
- fragShader = loadAndCompileShader(GL_FRAGMENT_SHADER, fragShaderText);
- if (!fragShader)
- return false;
-
-
- program = createProgram(vertShader, fragShader);
- if (!program) {
- REPORT_FAILURE("glCreateProgram failed");
- return false;
- }
- glGetProgramiv(program, GL_LINK_STATUS, &stat);
- if (!stat) {
- REPORT_FAILURE("glLinkProgram failed");
- return false;
- }
- glUseProgram(program);
-
- glGetIntegerv(GL_CURRENT_PROGRAM, &val);
- if (val != (GLint) program) {
- REPORT_FAILURE("glGetInteger(GL_CURRENT_PROGRAM) failed");
- return false;
- }
-
- err = glGetError();
- if (err) {
- REPORT_FAILURE("OpenGL error detected in testShaderFuncs");
- return false;
- }
-
- if (!glIsProgram(program)) {
- REPORT_FAILURE("glIsProgram failed");
- return false;
- }
-
- GLuint objects[2];
- GLsizei count;
- glGetProgramiv(program, GL_ATTACHED_SHADERS, &val);
- if (val != 2) {
- REPORT_FAILURE("glGetProgramiv(GL_ATTACHED_SHADERS) failed");
- return false;
- }
- glGetAttachedShaders(program, 2, &count, objects);
- if (count != 2) {
- REPORT_FAILURE("glGetAttachedShaders failed (wrong count)");
- return false;
- }
- if (objects[0] != vertShader && objects[1] != vertShader) {
- REPORT_FAILURE("glGetAttachedShaders failed (vertex shader missing)");
- return false;
- }
- if (objects[0] != fragShader && objects[1] != fragShader) {
- REPORT_FAILURE("glGetAttachedShaders failed (fragment shader missing)");
- return false;
- }
-
- glValidateProgram(program);
- glGetProgramiv(program, GL_VALIDATE_STATUS, &stat);
- if (!stat) {
- REPORT_FAILURE("glValidateProgram failed");
- return false;
- }
-
- // Delete vertex shader
- glDeleteShader(vertShader);
- if (!glIsShader(vertShader)) {
- // the shader is still attached so the handle should be valid
- REPORT_FAILURE("glIsShader(deleted shader) failed");
- return false;
- }
- glGetShaderiv(vertShader, GL_DELETE_STATUS, &stat);
- if (stat != GL_TRUE) {
- REPORT_FAILURE("Incorrect shader delete status");
- return false;
- }
-
- // Delete fragment shader
- glDeleteShader(fragShader);
-
- // Delete program object
- glDeleteProgram(program);
- if (!glIsProgram(program)) {
- // the program is still in use so the handle should be valid
- REPORT_FAILURE("glIsProgram(deleted program) failed");
- return false;
- }
- glGetProgramiv(program, GL_DELETE_STATUS, &stat);
- if (stat != GL_TRUE) {
- REPORT_FAILURE("Incorrect program delete status");
- return false;
- }
-
- // now unbind the program
- glUseProgram(0);
- stat = glIsProgram(program);
- if (stat) {
- // the program and handle should have really been deleted now
- REPORT_FAILURE("glIsProgram(deleted program) failed");
- return false;
- }
-
- glGetProgramiv(program, GL_DELETE_STATUS, &stat);
- err = glGetError();
- if (!err) {
- // the program and handle should have been deleted now
- // so glGetProgramiv() should have generated an error
- REPORT_FAILURE("glGetProgramiv(deleted program) failed");
- return false;
- }
-
- return true;
-}
-
-
-bool
-API2Test::testUniformfFuncs(void)
-{
- static const char *fragShaderText =
- "uniform float uf1; \n"
- "uniform vec2 uf2; \n"
- "uniform vec3 uf3; \n"
- "uniform vec4 uf4; \n"
- "void main() { \n"
- " gl_FragColor = vec4(uf1, uf2.y, uf3.z, uf4.w); \n"
- "} \n";
- GLuint fragShader, program;
- GLint uf1, uf2, uf3, uf4;
- GLfloat value[4];
-
- fragShader = loadAndCompileShader(GL_FRAGMENT_SHADER, fragShaderText);
- if (!fragShader) {
- return false;
- }
- program = createProgram(0, fragShader);
- if (!program) {
- REPORT_FAILURE("glCreateProgram (uniform test) failed");
- return false;
- }
- glUseProgram(program);
-
- uf1 = glGetUniformLocation(program, "uf1");
- if (uf1 < 0) {
- REPORT_FAILURE("glGetUniform \"uf1\" failed");
- return false;
- }
- uf2 = glGetUniformLocation(program, "uf2");
- if (uf2 < 0) {
- REPORT_FAILURE("glGetUniform \"uf2\" failed");
- return false;
- }
- uf3 = glGetUniformLocation(program, "uf3");
- if (uf3 < 0) {
- REPORT_FAILURE("glGetUniform \"uf3\" failed");
- return false;
- }
- uf4 = glGetUniformLocation(program, "uf4");
- if (uf4 < 0) {
- REPORT_FAILURE("glGetUniform \"uf4\" failed");
- return false;
- }
-
-
- GLfloat pixel[4], expected[4];
-
- // Test glUniform[1234]f()
- expected[0] = 0.1;
- expected[1] = 0.2;
- expected[2] = 0.3;
- expected[3] = 0.4;
- glUniform1f(uf1, expected[0]);
- glUniform2f(uf2, 0.0, expected[1]);
- glUniform3f(uf3, 0.0, 0.0, expected[2]);
- glUniform4f(uf4, 0.0, 0.0, 0.0, expected[3]);
- renderQuad(pixel);
- if (!equalColors(pixel, expected)) {
- REPORT_FAILURE("glUniform[1234]f failed");
- //printf("found: %f %f %f %f\n", pixel[0], pixel[1], pixel[2], pixel[3]);
- //printf("expected: %f %f %f %f\n", expected[0], expected[1], expected[2], expected[3]);
-
- return false;
- }
-
- // Test glUniform[1234]fv()
- GLfloat u[4];
- expected[0] = 0.9;
- expected[1] = 0.8;
- expected[2] = 0.7;
- expected[3] = 0.6;
- u[0] = expected[0];
- glUniform1fv(uf1, 1, u);
- u[0] = 0.0; u[1] = expected[1];
- glUniform2fv(uf2, 1, u);
- u[0] = 0.0; u[1] = 0.0; u[2] = expected[2];
- glUniform3fv(uf3, 1, u);
- u[0] = 0.0; u[1] = 0.0; u[2] = 0.0; u[3] = expected[3];
- glUniform4fv(uf4, 1, u);
- renderQuad(pixel);
- if (!equalColors(pixel, expected)) {
- REPORT_FAILURE("glUniform[1234]f failed");
- return false;
- }
-
- // Test glGetUniformfv
- glUniform4fv(uf4, 1, expected);
- glGetUniformfv(program, uf4, value);
- if (value[0] != expected[0] ||
- value[1] != expected[1] ||
- value[2] != expected[2] ||
- value[3] != expected[3]) {
- REPORT_FAILURE("glGetUniformfv failed");
- return false;
- }
-
- return true;
-}
-
-
-bool
-API2Test::testUniformiFuncs(void)
-{
- static const char *fragShaderText =
- "uniform int ui1; \n"
- "uniform ivec2 ui2; \n"
- "uniform ivec3 ui3; \n"
- "uniform ivec4 ui4; \n"
- "void main() { \n"
- " gl_FragColor = vec4(ui1, ui2.y, ui3.z, ui4.w) * 0.1; \n"
- "} \n";
- GLuint fragShader, program;
- GLint ui1, ui2, ui3, ui4;
-
- fragShader = loadAndCompileShader(GL_FRAGMENT_SHADER, fragShaderText);
- if (!fragShader) {
- return false;
- }
- program = createProgram(0, fragShader);
- if (!program) {
- REPORT_FAILURE("glCreateProgram (uniform test) failed");
- return false;
- }
- glUseProgram(program);
-
- ui1 = glGetUniformLocation(program, "ui1");
- if (ui1 < 0) {
- REPORT_FAILURE("glGetUniform \"ui1\" failed");
- return false;
- }
- ui2 = glGetUniformLocation(program, "ui2");
- if (ui2 < 0) {
- REPORT_FAILURE("glGetUniform \"ui2\" failed");
- return false;
- }
- ui3 = glGetUniformLocation(program, "ui3");
- if (ui3 < 0) {
- REPORT_FAILURE("glGetUniform \"ui3\" failed");
- return false;
- }
- ui4 = glGetUniformLocation(program, "ui4");
- if (ui4 < 0) {
- REPORT_FAILURE("glGetUniform \"ui4\" failed");
- return false;
- }
-
- GLfloat pixel[4], expected[4];
- GLint expectedInt[4];
-
- // Test glUniform[1234]i()
- expectedInt[0] = 1;
- expectedInt[1] = 2;
- expectedInt[2] = 3;
- expectedInt[3] = 4;
- expected[0] = 0.1;
- expected[1] = 0.2;
- expected[2] = 0.3;
- expected[3] = 0.4;
- glUniform1i(ui1, expectedInt[0]);
- glUniform2i(ui2, 0, expectedInt[1]);
- glUniform3i(ui3, 0, 0, expectedInt[2]);
- glUniform4i(ui4, 0, 0, 0, expectedInt[3]);
- renderQuad(pixel);
- if (!equalColors(pixel, expected)) {
- REPORT_FAILURE("glUniform[1234]i failed");
- //printf("%f %f %f %f\n", pixel[0], pixel[1], pixel[2], pixel[3]);
- return false;
- }
-
- // Test glUniform[1234]iv()
- GLint u[4];
- expectedInt[0] = 9;
- expectedInt[1] = 8;
- expectedInt[2] = 7;
- expectedInt[3] = 6;
- expected[0] = 0.9;
- expected[1] = 0.8;
- expected[2] = 0.7;
- expected[3] = 0.6;
- u[0] = expectedInt[0];
- glUniform1iv(ui1, 1, u);
- u[0] = 0; u[1] = expectedInt[1];
- glUniform2iv(ui2, 1, u);
- u[0] = 0; u[1] = 0; u[2] = expectedInt[2];
- glUniform3iv(ui3, 1, u);
- u[0] = 0; u[1] = 0; u[2] = 0; u[3] = expectedInt[3];
- glUniform4iv(ui4, 1, u);
- renderQuad(pixel);
- if (!equalColors(pixel, expected)) {
- REPORT_FAILURE("glUniform[1234]i failed");
-#if 0
- printf("Expected color %f %f %f %f\n",
- expected[0], expected[1], expected[2], expected[3]);
- printf("Found color %f %f %f %f\n",
- pixel[0], pixel[1], pixel[2], pixel[3]);
-#endif
- return false;
- }
-
- return true;
-}
-
-
-bool
-API2Test::testShaderAttribs(void)
-{
- static const char *vertShaderText =
- "attribute vec4 generic; \n"
- "void main() { \n"
- " gl_Position = ftransform(); \n"
- " gl_FrontColor = generic; \n"
- "} \n";
- GLuint vertShader, program;
-
- vertShader = loadAndCompileShader(GL_VERTEX_SHADER, vertShaderText);
- if (!vertShader) {
- return false;
- }
- program = createProgram(vertShader, 0);
- if (!program) {
- REPORT_FAILURE("glCreateProgram (uniform test) failed");
- return false;
- }
- glUseProgram(program);
-
- static const GLfloat testColors[3][4] = {
- { 1.0, 0.5, 0.25, 0.0 },
- { 0.0, 0.1, 0.2, 0.3 },
- { 0.5, 0.6, 0.7, 0.8 },
- };
-
- // let compiler allocate the attribute location
- const GLint attr = glGetAttribLocation(program, "generic");
- if (attr < 0) {
- REPORT_FAILURE("glGetAttribLocation failed");
- return false;
- }
- for (int i = 0; i < 3; i++) {
- GLfloat pixel[4];
- renderQuadWithArrays(attr, testColors[i], pixel);
- if (!equalColors(pixel, testColors[i])) {
-#if 0
- printf("Expected color %f %f %f\n",
- testColors[i][0],
- testColors[i][1],
- testColors[i][2]);
- printf("Found color %f %f %f\n",
- pixel[0], pixel[1], pixel[2]);
-#endif
- REPORT_FAILURE("Vertex array test failed");
- return false;
- }
- }
-
- // Test explicit attribute binding.
- const GLint bindAttr = 6; // XXX a non-colliding alias
- glBindAttribLocation(program, bindAttr, "generic");
- glLinkProgram(program);
- GLint loc = glGetAttribLocation(program, "generic");
- if (loc != bindAttr) {
- REPORT_FAILURE("glBindAttribLocation failed");
- return false;
- }
- for (int i = 0; i < 3; i++) {
- GLfloat pixel[4];
- renderQuadWithArrays(bindAttr, testColors[i], pixel);
- if (!equalColors(pixel, testColors[i])) {
- REPORT_FAILURE("Vertex array test failed (2)");
- return false;
- }
- }
-
- return true;
-}
-
-#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
-
-bool
-API2Test::testStencilFuncSeparate(void)
-{
- GLint val;
- GLint stencilBits, stencilMax;
-
- glGetIntegerv(GL_STENCIL_BITS, &stencilBits);
- stencilMax = (1 << stencilBits) - 1;
-
- glStencilFuncSeparate(GL_FRONT, GL_LEQUAL, 12, 0xf);
- glStencilFuncSeparate(GL_BACK, GL_GEQUAL, 13, 0xe);
-
- glGetIntegerv(GL_STENCIL_BACK_FUNC, &val);
- if (val != GL_GEQUAL) {
- REPORT_FAILURE("GL_STENCIL_BACK_FUNC query returned wrong value");
- return false;
- }
-
- glGetIntegerv(GL_STENCIL_FUNC, &val);
- if (val != GL_LEQUAL) {
- REPORT_FAILURE("GL_STENCIL_FUNC (front) query returned wrong value");
- return false;
- }
-
- glGetIntegerv(GL_STENCIL_BACK_REF, &val);
- if (val != CLAMP(13, 0, stencilMax)) {
- REPORT_FAILURE("GL_STENCIL_BACK_REF query returned wrong value");
- return false;
- }
-
- glGetIntegerv(GL_STENCIL_REF, &val);
- if (val != CLAMP(12, 0, stencilMax)) {
- REPORT_FAILURE("GL_STENCIL_REF (front) query returned wrong value");
- return false;
- }
-
- glGetIntegerv(GL_STENCIL_BACK_VALUE_MASK, &val);
- if (val != 0xe) {
- REPORT_FAILURE("GL_STENCIL_BACK_VALUE_MASK query returned wrong value");
- return false;
- }
-
- glGetIntegerv(GL_STENCIL_VALUE_MASK, &val);
- if (val != 0xf) {
- REPORT_FAILURE("GL_STENCIL_VALUE_MASK (front) query returned wrong value");
- return false;
- }
-
- return true;
-}
-
-
-bool
-API2Test::testStencilOpSeparate(void)
-{
- GLint val;
-
- // face, fail, zfail, zpass
- glStencilOpSeparate(GL_FRONT, GL_INVERT, GL_ZERO, GL_INCR);
- glStencilOpSeparate(GL_BACK, GL_INCR, GL_KEEP, GL_REPLACE);
-
- glGetIntegerv(GL_STENCIL_BACK_FAIL, &val);
- if (val != GL_INCR) {
- REPORT_FAILURE("GL_STENCIL_BACK_FAIL query returned wrong value");
- return false;
- }
-
- glGetIntegerv(GL_STENCIL_FAIL, &val);
- if (val != GL_INVERT) {
- REPORT_FAILURE("GL_STENCIL_FAIL (front) query returned wrong value");
- return false;
- }
-
- glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_FAIL, &val);
- if (val != GL_KEEP) {
- REPORT_FAILURE("GL_STENCIL_BACK_PASS_DEPTH_FAIL query returned wrong value");
- return false;
- }
-
- glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &val);
- if (val != GL_ZERO) {
- REPORT_FAILURE("GL_STENCIL_PASS_DEPTH_FAIL (front) query returned wrong value");
- return false;
- }
-
- glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_PASS, &val);
- if (val != GL_REPLACE) {
- REPORT_FAILURE("GL_STENCIL_BACK_PASS_DEPTH_PASS query returned wrong value");
- return false;
- }
-
- glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &val);
- if (val != GL_INCR) {
- REPORT_FAILURE("GL_STENCIL_PASS_DEPTH_PASS (front) query returned wrong value");
- return false;
- }
-
- return true;
-}
-
-
-bool
-API2Test::testStencilMaskSeparate(void)
-{
- GLint val;
-
- // face, fail, zfail, zpass
- glStencilMaskSeparate(GL_BACK, 0xa);
- glStencilMaskSeparate(GL_FRONT, 0xb);
-
- glGetIntegerv(GL_STENCIL_BACK_WRITEMASK, &val);
- if (val != 0xa) {
- REPORT_FAILURE("GL_STENCIL_BACK_WRITEMASK query returned wrong value");
- return false;
- }
-
- glGetIntegerv(GL_STENCIL_WRITEMASK, &val);
- if (val != 0xb) {
- REPORT_FAILURE("GL_STENCIL_WRITEMASK (front) query returned wrong value");
- return false;
- }
-
- return true;
-}
-
-
-bool
-API2Test::testBlendEquationSeparate(void)
-{
- GLint val;
-
- glBlendEquationSeparate(GL_MAX, GL_FUNC_SUBTRACT);
-
- glGetIntegerv(GL_BLEND_EQUATION, &val);
- if (val != GL_MAX) {
- REPORT_FAILURE("GL_BLEND_EQUATION (rgb) query returned wrong value");
- return false;
- }
-
- glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &val);
- if (val != GL_FUNC_SUBTRACT) {
- REPORT_FAILURE("GL_BLEND_EQUATION (rgb) query returned wrong value");
- return false;
- }
-
- return true;
-}
-
-
-bool
-API2Test::testDrawBuffers(void)
-{
- const int MAX = 2;
- GLint maxBuf = -1, i, n, val;
- GLenum buffers[MAX], err;
- GLint initDrawBuffer;
-
- glGetIntegerv(GL_DRAW_BUFFER, &initDrawBuffer);
-
- glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxBuf);
- if (maxBuf < 1) {
- REPORT_FAILURE("GL_MAX_DRAW_BUFFERS query failed");
- return false;
- }
-
- n = maxBuf < MAX ? maxBuf : MAX;
- assert(n > 0);
- for (i = 0; i < n; i++) {
- buffers[i] = (i & 1) ? GL_FRONT_LEFT : GL_BACK_LEFT;
- }
- glDrawBuffers(n, buffers);
-
- for (i = 0; i < n; i++) {
- glGetIntegerv(GL_DRAW_BUFFER0 + i, &val);
- if (val != (GLint) buffers[i]) {
- REPORT_FAILURE("glDrawBuffers failed");
- return false;
- }
- }
-
- // restore
- glDrawBuffer(initDrawBuffer);
-
- err = glGetError();
- if (err) {
- REPORT_FAILURE("glDrawBuffers generrated an OpenGL error");
- return false;
- }
-
- return true;
-}
-
-
-// Run all the subtests, incrementing numPassed, numFailed
-void
-API2Test::runSubTests(MultiTestResult &r)
-{
- static TestFunc funcs[] = {
- &GLEAN::API2Test::testStencilFuncSeparate,
- &GLEAN::API2Test::testStencilOpSeparate,
- &GLEAN::API2Test::testStencilMaskSeparate,
- &GLEAN::API2Test::testBlendEquationSeparate,
- &GLEAN::API2Test::testDrawBuffers,
- &GLEAN::API2Test::testShaderObjectFuncs,
- &GLEAN::API2Test::testUniformfFuncs,
- &GLEAN::API2Test::testUniformiFuncs,
- &GLEAN::API2Test::testShaderAttribs,
- NULL
- };
-
- for (int i = 0; funcs[i]; i++)
- if ((this->*funcs[i])())
- r.numPassed++;
- else
- r.numFailed++;
-}
-
-
-void
-API2Test::runOne(MultiTestResult &r, Window &w)
-{
- (void) w;
-
- if (!setup()) {
- r.pass = false;
- return;
- }
-
- runSubTests(r);
-
- r.pass = (r.numFailed == 0);
-}
-
-
-// The test object itself:
-API2Test api2Test("api2", "window, rgb, z, db",
- "", // no extension filter (we'll test for version 2.x during setup)
- "API2 test: check that OpenGL 2.x API functions work.\n"
- );
-
-
-
-} // namespace GLEAN
diff --git a/tests/glean/tapi2.h b/tests/glean/tapi2.h
deleted file mode 100644
index 36cf587..0000000
--- a/tests/glean/tapi2.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-// tapi2.h: Test OpenGL 2.x API functions/features
-// Brian Paul 9 March 2007
-
-#ifndef __tapi2_h__
-#define __tapi2_h__
-
-#include "tmultitest.h"
-
-namespace GLEAN {
-
-#define windowSize 100
-
-
-class API2Test: public MultiTest
-{
-public:
- API2Test(const char* testName, const char* filter,
- const char *extensions, const char* description):
- MultiTest(testName, filter, extensions, description),
- tolerance()
- {
- }
-
- virtual void runOne(MultiTestResult &r, Window &w);
-
-private:
- typedef bool (API2Test::*TestFunc)(void);
-
- GLfloat tolerance[5];
-
- GLuint loadAndCompileShader(GLenum target, const char *str);
- GLuint createProgram(GLuint vertShader, GLuint fragShader);
-
- void renderQuad(GLfloat *pixel) const;
- void renderQuadWithArrays(GLint attr, const GLfloat value[4],
- GLfloat *pixel) const;
-
- bool testStencilFuncSeparate(void);
- bool testStencilOpSeparate(void);
- bool testStencilMaskSeparate(void);
- bool testBlendEquationSeparate(void);
- bool testDrawBuffers(void);
- bool testShaderObjectFuncs(void);
- bool testUniformfFuncs(void);
- bool testUniformiFuncs(void);
- bool testShaderAttribs(void);
-
- void runSubTests(MultiTestResult &r);
-
- bool setup(void);
- bool equalColors(const GLfloat a[4], const GLfloat b[4]) const;
-
- void reportFailure(const char *msg, int line) const;
- void reportFailure(const char *msg, GLenum target, int line) const;
-};
-
-} // namespace GLEAN
-
-#endif // __tglsl1_h__
diff --git a/tests/glean/tbasic.cpp b/tests/glean/tbasic.cpp
deleted file mode 100644
index 1e5fe2e..0000000
--- a/tests/glean/tbasic.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999-2000 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-// tbasic.cpp: implementation of example class for basic tests
-
-#include "tbasic.h"
-
-namespace GLEAN {
-
-///////////////////////////////////////////////////////////////////////////////
-// runOne: Run a single test case
-///////////////////////////////////////////////////////////////////////////////
-void
-BasicTest::runOne(BasicResult& r, Window&) {
- r.pass = true;
-} // BasicTest::runOne
-
-///////////////////////////////////////////////////////////////////////////////
-// logOne: Log a single test case
-///////////////////////////////////////////////////////////////////////////////
-void
-BasicTest::logOne(BasicResult& r) {
- logPassFail(r);
- logConcise(r);
-} // BasicTest::logOne
-
-///////////////////////////////////////////////////////////////////////////////
-// The test object itself:
-///////////////////////////////////////////////////////////////////////////////
-BasicTest basicTest("basic", "window",
- "This trivial test simply verifies the internal support for basic\n"
- "tests. It is run on every OpenGL-capable drawing surface\n"
- "configuration that supports creation of a window.\n");
-
-} // namespace GLEAN
diff --git a/tests/glean/tbasic.h b/tests/glean/tbasic.h
deleted file mode 100644
index 2d3af68..0000000
--- a/tests/glean/tbasic.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 1999-2000 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-
-
-// tbasic.h: Example class for basic tests
-
-// This class illustrates the use of the BaseResult class and BaseTest
-// template class for constructing straightforward portable tests.
-// See the file tbase.h for a discussion of this process.
-
-// BasicTest simply runs on all drawing surface configurations that
-// permit the creation of a window, and always passes.
-
-
-#ifndef __tbasic_h__
-#define __tbasic_h__
-
-#include "tbase.h"
-
-namespace GLEAN {
-
-class BasicResult: public BaseResult {
-public:
- bool pass;
-
- void putresults(ostream& s) const {
- s << pass << '\n';
- }
-
- bool getresults(istream& s) {
- s >> pass;
- return s.good();
- }
-};
-
-class BasicTest: public BaseTest<BasicResult> {
-public:
- GLEAN_CLASS(BasicTest, BasicResult);
-};
-
-} // namespace GLEAN
-
-#endif // __tbasic_h__
diff --git a/tests/glean/tbinding.cpp b/tests/glean/tbinding.cpp
deleted file mode 100644
index 48c7668..0000000
--- a/tests/glean/tbinding.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 2000 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-// tbinding.cpp: Test functions in the window-system binding
-
-#include "tbinding.h"
-#include "image.h"
-#include "rand.h"
-#include <cmath>
-#include <algorithm> // max
-
-#if 0
-#ifdef __UNIX__
-#include <unistd.h>
-#endif
-
-#include <iostream>
-#include <fstream>
-#include <cmath>
-#include "dsconfig.h"
-#include "dsfilt.h"
-#include "dsurf.h"
-#include "winsys.h"
-#include "environ.h"
-#include "rc.h"
-#include "glutils.h"
-#include "stats.h"
-#include "tbinding.h"
-#include "misc.h"
-#endif
-
-namespace {
-
-bool
-makeCurrentOK(GLEAN::DrawingSurfaceConfig& config) {
- using namespace GLEAN;
- float expected[4];
- glClear(GL_COLOR_BUFFER_BIT);
- glGetFloatv(GL_COLOR_CLEAR_VALUE, expected);
- Image probe(1, 1, GL_RGBA, GL_FLOAT);
- probe.read(drawingSize/2, drawingSize/2);
- const float* actual = reinterpret_cast<float*>(probe.pixels());
- double maxError = ErrorBits(fabs(expected[0] - actual[0]), config.r);
- maxError = max(maxError,
- ErrorBits(fabs(expected[1] - actual[1]), config.g));
- maxError = max(maxError,
- ErrorBits(fabs(expected[2] - actual[2]), config.b));
- return maxError <= 1.0;
-} // makeCurrentOK
-
-} // anonymous namespace
-
-namespace GLEAN {
-
-///////////////////////////////////////////////////////////////////////////////
-// runOne: Run a single test case
-///////////////////////////////////////////////////////////////////////////////
-void
-MakeCurrentTest::runOne(MakeCurrentResult& r, Window& w) {
-
- DrawingSurfaceConfig& config = *(r.config);
- WindowSystem& ws = env->winSys;
-
- // The rendering contexts to be used:
- vector<RenderingContext*> rcs;
-
- RandomBitsDouble rRand(config.r, 712105);
- RandomBitsDouble gRand(config.g, 63230);
- RandomBitsDouble bRand(config.b, 912167);
-
- // Create rendering contexts to be used with the test window.
- // Note that the first context (at index 0) is always the
- // null context.
-
- rcs.push_back(0);
- r.descriptions.push_back("Null context");
- ws.makeCurrent();
- r.testSequence.push_back(static_cast<int>(rcs.size()) - 1);
-
- rcs.push_back(new RenderingContext(env->winSys, config, 0, true));
- r.descriptions.push_back("Direct-rendering context");
- ws.makeCurrent(*rcs.back(), w);
- r.testSequence.push_back(static_cast<int>(rcs.size()) - 1);
- glDisable(GL_DITHER);
- glClearColor(rRand.next(), gRand.next(), bRand.next(), 1.0);
- if (!makeCurrentOK(config))
- goto failed;
-
- rcs.push_back(new RenderingContext(env->winSys, config, 0, false));
- r.descriptions.push_back("Indirect-rendering context");
- ws.makeCurrent(*rcs.back(), w);
- r.testSequence.push_back(static_cast<int>(rcs.size()) - 1);
- glDisable(GL_DITHER);
- glClearColor(rRand.next(), gRand.next(), bRand.next(), 1.0);
- if (!makeCurrentOK(config))
- goto failed;
-
- // Now run through all the pairs of rendering contexts, making
- // them current in sequence and checking that rendering looks
- // correct. Don't worry about the redundant sequences; we want
- // to check those, too!
-
- int i;
- for (i = 0; i < static_cast<int>(rcs.size()); ++i)
- for (int j = 0; j < static_cast<int>(rcs.size()); ++j) {
- r.testSequence.push_back(i);
- if (rcs[i] == 0)
- ws.makeCurrent();
- else {
- ws.makeCurrent(*rcs[i], w);
- if (!makeCurrentOK(config))
- goto failed;
- }
- r.testSequence.push_back(j);
- if (rcs[j] == 0)
- ws.makeCurrent();
- else {
- ws.makeCurrent(*rcs[j], w);
- if (!makeCurrentOK(config))
- goto failed;
- }
- }
- r.pass = true;
- goto cleanup;
-
-failed:
- r.pass = false;
-cleanup:
- for (i = 0; i < static_cast<int>(rcs.size()); ++i)
- if (rcs[i]) {
- // We need to make sure that no GL commands are
- // pending when the window is destroyed, or we
- // risk a GLXBadCurrentWindow error at some
- // indeterminate time in the future when
- // glXMakeCurrent() is executed.
- // In theory, if glReadPixels() is the last
- // command executed by a test, then an implicit
- // flush has occurred, and the command queue is
- // empty. In practice, we have to protect
- // against the possibility that the implicit
- // flush is not enough to avoid the error.
- ws.makeCurrent(*rcs[i], w);
- glFinish();
- ws.makeCurrent();
-
- delete rcs[i];
- }
-} // MakeCurrentTest::runOne
-
-///////////////////////////////////////////////////////////////////////////////
-// logOne: Log a single test case
-///////////////////////////////////////////////////////////////////////////////
-void
-MakeCurrentTest::logOne(MakeCurrentResult& r) {
- logPassFail(r);
- logConcise(r);
- if (!r.pass) {
- env->log << "\tSequence of MakeCurrent operations was:\n";
- for (int k = 0; k < static_cast<int>(r.testSequence.size()); ++k)
- env->log << "\t\t"
- << r.descriptions[r.testSequence[k]]
- << '\n';
- }
-} // MakeCurrentTestTest::logOne
-
-///////////////////////////////////////////////////////////////////////////////
-// The test object itself:
-///////////////////////////////////////////////////////////////////////////////
-MakeCurrentTest makeCurrentTest("makeCurrent", "window, rgb",
-
- "This test sanity-checks the ability to use multiple rendering\n"
- "contexts. It creates several contexts with differing\n"
- "characteristics (e.g., some are direct-rendering and some\n"
- "are indirect-rendering, if the window system binding supports\n"
- "that distinction). Then it runs through all pairs of contexts,\n"
- "making each one \"current\" in turn and verifying that simple\n"
- "rendering succeeds.\n"
-
- );
-
-} // namespace GLEAN
diff --git a/tests/glean/tbinding.h b/tests/glean/tbinding.h
deleted file mode 100644
index 021b854..0000000
--- a/tests/glean/tbinding.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 2000 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-
-
-
-// tbinding.h: Test functions in the window-system binding
-
-#ifndef __tbinding_h__
-#define __tbinding_h__
-
-#include "tbasic.h"
-
-namespace GLEAN {
-
-class DrawingSurfaceConfig; // Forward reference.
-class Window;
-
-#define drawingSize 64
-
-class MakeCurrentResult: public BaseResult {
-public:
- bool pass;
- // Short descriptions of the rendering contexts:
- vector<const char*> descriptions;
- // Complete record of rendering contexts made "current" during
- // the test:
- vector<int> testSequence;
-
- void putresults(ostream& s) const {
- s << pass << '\n';
- }
-
- bool getresults(istream& s) {
- s >> pass;
- return s.good();
- }
-};
-
-class MakeCurrentTest: public BaseTest<MakeCurrentResult> {
-public:
- GLEAN_CLASS_WH(MakeCurrentTest, MakeCurrentResult,
- drawingSize, drawingSize);
-}; // class MakeCurrentTest
-
-} // namespace GLEAN
-
-#endif // __tbinding_h__
diff --git a/tests/glean/tfbo.cpp b/tests/glean/tfbo.cpp
deleted file mode 100644
index 288fb0e..0000000
--- a/tests/glean/tfbo.cpp
+++ /dev/null
@@ -1,1367 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyrigth (C) 2007 Intel Corporation
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-//
-// Authors:
-// Shuang He <shuang.he at intel.com>
-//
-// tfbo.cpp: Test OpenGL Extension GL_EXT_framebuffer_object
-
-
-#define GL_GLEXT_PROTOTYPES
-
-#include "tfbo.h"
-#include <cassert>
-#include <math.h>
-#include <cstring>
-#include "piglit-util-gl.h"
-
-namespace GLEAN
-{
-
-static int useFramebuffer;
-
-bool
-FBOTest::setup(void)
-{
- // setup vertex transform (we'll draw a quad in middle of window)
- glMatrixMode(GL_PROJECTION);
-
- glLoadIdentity();
- glOrtho(0, 100, 0, 100, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glDrawBuffer(GL_FRONT);
- glReadBuffer(GL_FRONT);
-
- glDisable(GL_DITHER);
-
- // compute error tolerances (may need fine-tuning)
- int bufferBits[5];
-
- glGetIntegerv(GL_RED_BITS, &bufferBits[0]);
- glGetIntegerv(GL_GREEN_BITS, &bufferBits[1]);
- glGetIntegerv(GL_BLUE_BITS, &bufferBits[2]);
- glGetIntegerv(GL_ALPHA_BITS, &bufferBits[3]);
- glGetIntegerv(GL_DEPTH_BITS, &bufferBits[4]);
-
- tolerance[0] = 3.0 / (1 << bufferBits[0]);
- tolerance[1] = 3.0 / (1 << bufferBits[1]);
- tolerance[2] = 3.0 / (1 << bufferBits[2]);
- if (bufferBits[3])
- tolerance[3] = 3.0 / (1 << bufferBits[3]);
- else
- tolerance[3] = 1.0;
- if (bufferBits[4])
- tolerance[4] = 16.0 / (1 << bufferBits[4]);
- else
- tolerance[4] = 1.0;
-
- // Check if GL_EXT_framebuffer_object is supported
- if (GLUtils::haveExtension("GL_EXT_framebuffer_object")) {
- printf("GL_EXT_framebuffer_object is supported\n");
- useFramebuffer = 1;
- }
- else {
- printf("GL_EXT_framebuffer_object is not supported\n");
- useFramebuffer = 0;
- return false;
- }
-
- haveARBfbo = GLUtils::haveExtension("GL_ARB_framebuffer_object");
- if (haveARBfbo)
- printf("GL_ARB_framebuffer_object is supported\n");
- else
- printf("GL_ARB_framebuffer_object is not supported\n");
-
- return true;
-}
-
-
-void
-FBOTest::reportFailure(const char *msg, const int line) const
-{
- env->log << "FAILURE: " << msg << " (at tfbo.cpp:" << line
- << ")\n";
-}
-
-void
-FBOTest::reportFailure(const char *msg, const GLenum target, const int line) const
-{
- env->log << "FAILURE: " << msg;
- if (target == GL_FRAGMENT_SHADER)
- env->log << " (fragment)";
- else
- env->log << " (vertex)";
- env->log << " (at tfbo.cpp:" << line << ")\n";
-}
-
-#define REPORT_FAILURE(MSG) reportFailure(MSG, __LINE__)
-#define REPORT_FAILURE_T(MSG, TARGET) reportFailure(MSG, TARGET, __LINE__)
-// Compare actual and expected colors
-bool
-FBOTest::equalColors(const GLfloat act[3], const GLfloat exp[3]) const
-{
- if ((fabsf(act[0] - exp[0]) > tolerance[0])
- || (fabsf(act[1] - exp[1]) > tolerance[1])
- || (fabsf(act[2] - exp[2]) > tolerance[2])) {
- return false;
- }
- else
- return true;
-}
-
-
-#define TEXSIZE 64
-
-/*
-|--------------------|
- |---depth---|
- |---stencil---|
-*/
-bool
-FBOTest::checkResult(const GLfloat color[4], const int depth,
- const int stencil) const
-{
- GLfloat buf[TEXSIZE * TEXSIZE * 3];
- int i, j;
- const GLfloat black[4] = { 0.0, 0.0, 0.0, 0.0 };
- const GLfloat *exp;
-
- glReadPixels(0, 0, TEXSIZE, TEXSIZE, GL_RGB, GL_FLOAT, buf);
-
- for (j = 0; j < TEXSIZE; j++) {
- for (i = 0; i < TEXSIZE; i++) {
- exp = color;
-
- if (i * 4 >= TEXSIZE && i * 8 < TEXSIZE * 5
- && depth)
- exp = black;
- if (i * 2 >= TEXSIZE && i * 8 < TEXSIZE * 7
- && stencil)
- exp = black;
-
-
- if (!equalColors(buf + (j * TEXSIZE + i) * 3, exp)) {
- printf(" depth = %d, stencil = %d\n",
- depth, stencil);
- printf(" (%d, %d) = [%f, %f, %f], is expected to be[%f, %f, %f]\n", i, j, buf[(j * TEXSIZE + i) * 3], buf[(j * TEXSIZE + i) * 3 + 1], buf[(j * TEXSIZE + i) * 3 + 2], exp[0], exp[1], exp[2]);
- return false;
- }
- }
- }
- return true;
-}
-
-
-// Check FB status, print unexpected results to stdout.
-static GLenum
-CheckFramebufferStatus(const char *func, int line)
-{
- GLenum status;
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
-
- switch(status) {
- case GL_FRAMEBUFFER_COMPLETE_EXT:
- /*printf(" (%s:%d)GL_FRAMEBUFFER_COMPLETE_EXT\n", func, line);*/
- break;
- case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
- printf(" (%s:%d)GL_FRAMEBUFFER_UNSUPPORTED_EXT\n", func, line);
- /* choose different formats */
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
- printf(" (%s:%d)GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\n", func, line);
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
- printf(" (%s:%d)GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\n", func, line);
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
- printf(" (%s:%d)GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\n", func, line);
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
- printf(" (%s:%d)GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT\n", func, line);
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
- printf(" (%s:%d)GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT\n", func, line);
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
- printf(" (%s:%d)GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT\n", func, line);
- break;
- default:
- /* programming error; will fail on all hardware */
- printf(" (%s:%d)programming error\n", func, line);
- break;
- }
- return status;
-}
-
-
-enum
-{ BLACK, RED, GREEN, BLUE, WHITE };
-
-GLfloat colors[][4] = {
- {0.0, 0.0, 0.0, 0.0},
- {1.0, 0.0, 0.0, 1.0},
- {0.0, 1.0, 0.0, 1.0},
- {0.0, 0.0, 1.0, 1.0},
- {1.0, 1.0, 1.0, 1.0}
-};
-
-
-
-bool
-FBOTest::testSanity(void)
-{
- GLuint fbs[2];
- GLuint maxColorAttachment;
- GLuint fb_binding;
-
- if (!useFramebuffer)
- return true;
-
- glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT,
- (GLint *) & maxColorAttachment);
- if (maxColorAttachment < 1) {
- REPORT_FAILURE
- ("Failed to get max color attachment points");
- return false;
- }
-
-
- glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, (GLint *) & fb_binding);
- if (fb_binding != 0) {
- printf(" fb_binding = %d\n", fb_binding);
- REPORT_FAILURE
- ("The default framebuffer binding should be 0");
- return false;
- }
-
- glGenFramebuffersEXT(1, fbs);
-
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
- glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, (GLint *) & fb_binding);
- if (fb_binding != fbs[0]) {
- printf(" fb_binding = %d\n", fb_binding);
- REPORT_FAILURE("Binding framebuffer failed");
- return false;
- }
- if (glIsFramebufferEXT(fbs[0]) != GL_TRUE)
- {
- REPORT_FAILURE("Call glIsFramebufferEXT failed");
- return false;
- }
-
- glDeleteFramebuffersEXT(1, fbs);
-
- GLint maxRenderbufferSize;
-
- glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &maxRenderbufferSize);
- if (maxRenderbufferSize < 1) {
- printf(" maxRenderbufferSize = %d\n",
- maxRenderbufferSize);
- REPORT_FAILURE("Get max Renderbuffer Size failed");
- return false;
- }
-
- return true;
-}
-
-
-void
-FBOTest::reset(void)
-{
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_STENCIL_TEST);
-}
-
-GLenum textureModes[] = { GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D,
- GL_TEXTURE_CUBE_MAP};
-
-bool
-FBOTest::testRender2SingleTexture(void)
-{
- GLint depthBuffer = 0;
- GLint stencilBuffer = 0;
- GLuint fbs[1];
- GLuint depth_rb[1];
- GLuint stencil_rb[1];
- GLuint textures[1];
- int mode;
- int maxzoffset = -1;
- GLenum status;
-
- glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &maxzoffset);
- if (maxzoffset > 16)
- maxzoffset = 16;
-
- for (depthBuffer = 0; depthBuffer < 2; depthBuffer++) {
- for (stencilBuffer = 0; stencilBuffer < 2; stencilBuffer++) {
- for (mode = 0; mode < 4; mode++) {
-
- //
- // Setup state to test
- //
- if (mode == 2 && maxzoffset <= 0)
- continue;
-
- if (useFramebuffer)
- glGenFramebuffersEXT(1, fbs);
- glGenTextures(1, textures);
-
- glBindTexture(textureModes[mode],
- textures[0]);
- glTexParameteri(textureModes[mode],
- GL_TEXTURE_MIN_FILTER,
- GL_NEAREST);
- glTexParameteri(textureModes[mode],
- GL_TEXTURE_MAG_FILTER,
- GL_NEAREST);
-
- switch (textureModes[mode]) {
- case GL_TEXTURE_1D:
- glTexImage1D(GL_TEXTURE_1D,
- 0, GL_RGB,
- TEXSIZE, 0,
- GL_RGB, GL_INT, NULL);
- break;
- case GL_TEXTURE_2D:
- glTexImage2D(GL_TEXTURE_2D,
- 0, GL_RGB,
- TEXSIZE,
- TEXSIZE, 0,
- GL_RGB, GL_INT, NULL);
- break;
- case GL_TEXTURE_3D:
- glTexImage3D(GL_TEXTURE_3D,
- 0, GL_RGB,
- TEXSIZE,
- TEXSIZE,
- maxzoffset, 0,
- GL_RGB, GL_INT, NULL);
- break;
- case GL_TEXTURE_CUBE_MAP:
- glTexImage2D
- (GL_TEXTURE_CUBE_MAP_POSITIVE_X,
- 0, GL_RGB,
- TEXSIZE, TEXSIZE,
- 0, GL_RGB, GL_INT, NULL);
- glTexImage2D
- (GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
- 0, GL_RGB,
- TEXSIZE, TEXSIZE,
- 0, GL_RGB, GL_INT, NULL);
- glTexImage2D
- (GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
- 0, GL_RGB,
- TEXSIZE, TEXSIZE,
- 0, GL_RGB, GL_INT, NULL);
- glTexImage2D
- (GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
- 0, GL_RGB,
- TEXSIZE, TEXSIZE,
- 0, GL_RGB, GL_INT, NULL);
- glTexImage2D
- (GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
- 0, GL_RGB,
- TEXSIZE, TEXSIZE,
- 0, GL_RGB, GL_INT, NULL);
- glTexImage2D
- (GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
- 0, GL_RGB,
- TEXSIZE, TEXSIZE,
- 0, GL_RGB, GL_INT, NULL);
- break;
- }
-
-
- if (useFramebuffer) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
- int height = TEXSIZE;
-
- if (textureModes[mode] == GL_TEXTURE_1D)
- height = 1;
-
- if (depthBuffer) {
- int params;
-
- glGenRenderbuffersEXT(1, depth_rb);
-
-
- glBindRenderbufferEXT
- (GL_RENDERBUFFER_EXT,
- depth_rb[0]);
- if (glIsRenderbufferEXT(depth_rb[0]) != GL_TRUE)
- {
- REPORT_FAILURE("Call glIsRenderbufferEXT failed\n");
- return false;
- }
-
- glRenderbufferStorageEXT
- (GL_RENDERBUFFER_EXT,
- GL_DEPTH_COMPONENT,
- TEXSIZE, height);
- glFramebufferRenderbufferEXT
- (GL_FRAMEBUFFER_EXT,
- GL_DEPTH_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT,
- depth_rb[0]);
- glGetRenderbufferParameterivEXT
- (GL_RENDERBUFFER_EXT,
- GL_RENDERBUFFER_WIDTH_EXT,
- ¶ms);
- if (params != TEXSIZE) {
- REPORT_FAILURE("Get Renderbuffer width failed");
- printf("glGetRenderbufferParameterivEXT: %s\n", piglit_get_gl_error_name(glGetError()));
- printf("width = %d\n", params);
- return false;
- }
- glGetRenderbufferParameterivEXT
- (GL_RENDERBUFFER_EXT,
- GL_RENDERBUFFER_HEIGHT_EXT,
- ¶ms);
- if (params != height) {
- REPORT_FAILURE("Get Renderbuffer height failed");
- printf("glGetRenderbufferParameterivEXT: %s\n", piglit_get_gl_error_name(glGetError()));
- return false;
- }
- }
-
- if (stencilBuffer) {
- int type;
-
- type = -1;
- glGenRenderbuffersEXT(1, stencil_rb);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, stencil_rb[0]);
- glRenderbufferStorageEXT
- (GL_RENDERBUFFER_EXT,
- GL_STENCIL_INDEX,
- TEXSIZE, height);
- glFramebufferRenderbufferEXT
- (GL_FRAMEBUFFER_EXT,
- GL_STENCIL_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT,
- stencil_rb[0]);
- glGetFramebufferAttachmentParameterivEXT
- (GL_FRAMEBUFFER_EXT,
- GL_STENCIL_ATTACHMENT_EXT,
- GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT,
- &type);
- if (type != GL_RENDERBUFFER_EXT) {
- REPORT_FAILURE("Get Framebuffer attached object type failed");
- printf("glGetFramebufferParameterivEXT: %s\n", piglit_get_gl_error_name(glGetError()));
- printf("type = %d\n", type);
- return false;
- }
- }
-
- switch (textureModes[mode]) {
- case GL_TEXTURE_1D:
- int name;
-
- name = -1;
- glFramebufferTexture1DEXT
- (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_1D,
- textures[0], 0);
- glGetFramebufferAttachmentParameterivEXT
- (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT,
- &name);
- if ((GLuint)name != textures[0]) {
- REPORT_FAILURE("Get Framebuffer attached texture name failed");
- printf("glGetFramebufferParameterivEXT: %s\n", piglit_get_gl_error_name(glGetError()));
- printf("name = %d\n", name);
- return false;
- }
-
- break;
- case GL_TEXTURE_2D:
- int level;
-
- level = -1;
- glFramebufferTexture2DEXT
- (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D,
- textures[0], 0);
- glGetFramebufferAttachmentParameterivEXT
- (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT,
- &level);
- if (level != 0) {
- REPORT_FAILURE("Get Framebuffer attached texture level failed");
- printf("glGetFramebufferParameterivEXT: %s\n", piglit_get_gl_error_name(glGetError()));
- printf("level = %d\n", level);
- return false;
- }
-
- break;
- case GL_TEXTURE_3D:
- int zoffset;
-
- zoffset = -1;
- glFramebufferTexture3DEXT
- (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_3D,
- textures[0],
- 0,
- maxzoffset-1);
-
- glGetFramebufferAttachmentParameterivEXT
- (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT,
- &zoffset);
-
- if (zoffset != maxzoffset-1) {
- REPORT_FAILURE("Get Framebuffer attached 3D texture z-offset failed");
- printf("glGetFramebufferParameterivEXT: %s\n", piglit_get_gl_error_name(glGetError()));
- printf("zoffset = %d\n", zoffset);
- return false;
- }
- break;
- case GL_TEXTURE_CUBE_MAP:
- int face = 0;
-
- glFramebufferTexture2DEXT
- (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
- textures[0], 0);
- glGetFramebufferAttachmentParameterivEXT
- (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT,
- &face);
- if (face !=
- GL_TEXTURE_CUBE_MAP_POSITIVE_Z)
- {
- REPORT_FAILURE("Get Framebuffer attached cube map face failed");
- printf("glGetFramebufferParameterivEXT: %s\n", piglit_get_gl_error_name(glGetError()));
- printf("face = %d\n", face);
- return false;
- }
-
- break;
- }
-
- status = CheckFramebufferStatus("FBOTest::testRender2SingleTexture", __LINE__);
- }
- else {
- status = GL_FRAMEBUFFER_COMPLETE_EXT;
- }
-
-
- if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- glDeleteTextures(1, textures);
- if (useFramebuffer)
- glDeleteFramebuffersEXT(1, fbs);
- if (depthBuffer)
- glDeleteRenderbuffersEXT(1, depth_rb);
- if (stencilBuffer)
- glDeleteRenderbuffersEXT(1, stencil_rb);
- continue;
- }
-
- //
- // Render, test the results
- //
-
- if (depthBuffer) {
- glClear(GL_DEPTH_BUFFER_BIT);
- // Init depth buffer
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_ALWAYS);
- glBegin(GL_POLYGON);
- glVertex3f(TEXSIZE / 4, 0, 0.3);
- glVertex3f(TEXSIZE * 5 / 8, 0, 0.3);
- glVertex3f(TEXSIZE * 5 / 8, TEXSIZE, 0.3);
- glVertex3f(TEXSIZE / 4, TEXSIZE, 0.3);
- glEnd();
- glDepthFunc(GL_LESS);
- }
-
- if (stencilBuffer) {
- glClear(GL_STENCIL_BUFFER_BIT);
- // Init stencil buffer
- glEnable(GL_STENCIL_TEST);
- glStencilFunc(GL_ALWAYS, 0x1, 0x1);
- glStencilOp(GL_KEEP,
- GL_KEEP, GL_REPLACE);
- glBegin(GL_POLYGON);
- glVertex3f(TEXSIZE / 2, 0, 0.3);
- glVertex3f(TEXSIZE * 7 / 8, 0, 0.3);
- glVertex3f(TEXSIZE * 7 / 8, TEXSIZE, 0.3);
- glVertex3f(TEXSIZE / 2, TEXSIZE, 0.3);
- glEnd();
- glStencilFunc(GL_NOTEQUAL, 0x1, 0x1);
- }
-
- // Render to the texture
- glBindTexture(textureModes[mode], 0);
- glDisable(textureModes[mode]);
- glColor4fv(colors[RED]);
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- glBegin(GL_POLYGON);
- glVertex3f(0, 0, 0.2);
- glVertex3f(TEXSIZE, 0, 0.2);
- glVertex3f(TEXSIZE, TEXSIZE, 0.2);
- glVertex3f(0, TEXSIZE, 0.2);
- glEnd();
-
- // Render to the window
- glEnable(textureModes[mode]);
- glBindTexture(textureModes[mode],
- textures[0]);
- if (useFramebuffer) {
- glBindFramebufferEXT
- (GL_FRAMEBUFFER_EXT, 0);
- glBindTexture(textureModes
- [mode], textures[0]);
- }
- else {
- switch (textureModes[mode]) {
- case GL_TEXTURE_1D:
- glCopyTexImage1D
- (GL_TEXTURE_1D,
- 0, GL_RGB,
- 0, 0, TEXSIZE, 0);
- break;
- case GL_TEXTURE_2D:
- glCopyTexImage2D
- (GL_TEXTURE_2D,
- 0, GL_RGB,
- 0, 0,
- TEXSIZE,
- TEXSIZE, 0);
- break;
- case GL_TEXTURE_3D:
- glCopyTexSubImage3D
- (GL_TEXTURE_3D,
- 0, 0, 0,
- 0, 0, 0,
- TEXSIZE, TEXSIZE);
- break;
- case GL_TEXTURE_CUBE_MAP:
- glCopyTexImage2D
- (GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
- 0, GL_RGB,
- 0, 0,
- TEXSIZE,
- TEXSIZE, 0);
- default:
- break;
- }
- }
- if (depthBuffer)
- glDisable(GL_DEPTH_TEST);
- if (stencilBuffer)
- glDisable(GL_STENCIL_TEST);
-
- glEnable(textureModes[mode]);
- glColor4fv(colors[WHITE]);
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- glTexParameteri (textureModes[mode], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri (textureModes[mode], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri (textureModes[mode], GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
-
- if (textureModes[mode] !=
- GL_TEXTURE_CUBE_MAP) {
- GLfloat depth = 0.99+0.01;
- glBegin(GL_POLYGON);
- glTexCoord3f(0.0, 0.0, depth);
- glVertex2f(0, 0);
- glTexCoord3f(1.0, 0.0, depth);
- glVertex2f(TEXSIZE, 0);
- glTexCoord3f(1.0, 1.0, depth);
- glVertex2f(TEXSIZE, TEXSIZE);
- glTexCoord3f(0.0, 1.0, depth);
- glVertex2f(0, TEXSIZE);
- glEnd();
- }
- else {
- glBegin(GL_POLYGON);
- glTexCoord3f(-1.0, 1.0, 1.0);
- glVertex2f(0, 0);
- glTexCoord3f(1.0, 1.0, 1.0);
- glVertex2f(TEXSIZE, 0);
- glTexCoord3f(1.0, -1.0, 1.0);
- glVertex2f(TEXSIZE, TEXSIZE);
- glTexCoord3f(-1.0, -1.0, 1.0);
- glVertex2f(0, TEXSIZE);
- glEnd();
- }
-
- glDeleteTextures(1, textures);
- if (useFramebuffer)
- glDeleteFramebuffersEXT(1, fbs);
- if (depthBuffer)
- glDeleteRenderbuffersEXT(1, depth_rb);
- if (stencilBuffer)
- glDeleteRenderbuffersEXT(1, stencil_rb);
-
-// getchar();
- if (checkResult(colors[RED], depthBuffer, stencilBuffer) == false) {
- REPORT_FAILURE("Render to single texture failed");
- printf(" mode = %d\n", mode);
- return false;
- }
- }
- }
- }
-
- return true;
-}
-
-
-bool
-FBOTest::testRender2MultiTexture(void)
-{
- int i;
- GLuint fbs[8];
- GLuint textures[8];
- GLint maxColorAttachment = 8;
-
-
- enum { MULTI_FBO, SINGLE_COLOR_ATTACH, MULTI_COLOR_ATTACH };
- int numRender;
- int numFBO;
- int numColorAttach;
- int mode;
-
- reset();
- for (mode = MULTI_FBO; mode < MULTI_COLOR_ATTACH + 1; mode++) {
- if (useFramebuffer) {
- glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT,
- &maxColorAttachment);
- if (maxColorAttachment < 1) {
- REPORT_FAILURE("Failed to get max color attachment points");
- return false;
- }
- }
-
- numRender = maxColorAttachment;
- numColorAttach = maxColorAttachment;
- if (mode == MULTI_FBO)
- numFBO = maxColorAttachment;
- else
- numFBO = 1;
-
- if (useFramebuffer)
- glGenFramebuffersEXT(numFBO, fbs);
-
- GLint maxTexUnits;
-
- glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTexUnits);
- glGenTextures(maxTexUnits, textures);
-
-
- for (i = 0; i < numColorAttach; i++) {
- int idx;
-
- if (i > maxTexUnits - 1)
- idx = maxTexUnits - 1;
- else
- idx = i;
-
- glActiveTexture(GL_TEXTURE0 + idx);
- glBindTexture(GL_TEXTURE_2D, textures[idx]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
- TEXSIZE, TEXSIZE, 0, GL_RGB,
- GL_INT, NULL);
-
- if (useFramebuffer) {
- if (mode == MULTI_FBO)
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[i]);
- else
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
-
- if (mode != SINGLE_COLOR_ATTACH)
- glFramebufferTexture2DEXT
- (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT + i,
- GL_TEXTURE_2D,
- textures[idx], 0);
- else
- glFramebufferTexture2DEXT
- (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D,
- textures[idx], 0);
- if (mode != SINGLE_COLOR_ATTACH) {
- glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + i);
- glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + i);
- }
- else {
- glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
- glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
- }
- CheckFramebufferStatus("FBOTest::testRender2MultiTexture", __LINE__);
- }
- }
-
-
-
- for (i = 0; i < numRender; i++) {
- int idx;
-
- if (i > maxTexUnits - 1)
- idx = maxTexUnits - 1;
- else
- idx = i;
-
-
- if (useFramebuffer) {
- if (mode == MULTI_FBO)
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[i]);
- else
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
-
- if (mode == MULTI_COLOR_ATTACH) {
- glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + idx);
- glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + idx);
- }
-
- CheckFramebufferStatus("FBOTest::testRender2MultiTexture", __LINE__);
- if (mode == SINGLE_COLOR_ATTACH) {
- glFramebufferTexture2DEXT
- (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D,
- textures[idx], 0);
- }
- }
-
- glDisable(GL_TEXTURE_2D);
-
- // Render to the texture
- glColor4fv(colors[RED + i % (WHITE - RED)]);
-
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- glBegin(GL_POLYGON);
- glVertex3f(0, 0, 1);
- glVertex3f(TEXSIZE, 0, 1);
- glVertex3f(TEXSIZE, TEXSIZE, 1);
- glVertex3f(0, TEXSIZE, 1);
- glEnd();
-
-
- glEnable(GL_TEXTURE_2D);
- if (useFramebuffer) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glBindTexture(GL_TEXTURE_2D, textures[idx]);
- }
- else {
- glBindTexture(GL_TEXTURE_2D, textures[idx]);
- glCopyTexImage2D(GL_TEXTURE_2D, 0,
- GL_RGB, 0, 0,
- TEXSIZE, TEXSIZE, 0);
- }
-
- }
- // Clean up
- if (useFramebuffer)
- glDeleteFramebuffersEXT(numFBO, fbs);
-
-
- // Render to the window
- for (i = 0; i < numRender; i++) {
- int idx;
-
- if (i > maxTexUnits - 1)
- idx = maxTexUnits - 1;
- else
- idx = i;
-
- glActiveTexture(GL_TEXTURE0 + idx);
- glEnable(GL_TEXTURE_2D);
- glTexParameteri(GL_TEXTURE_2D,
- GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D,
- GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- glColor4fv(colors[WHITE]);
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glBegin(GL_POLYGON);
- glMultiTexCoord2f(GL_TEXTURE0 + idx, 0, 0);
- glVertex3f(0, 0, 1);
- glMultiTexCoord2f(GL_TEXTURE0 + idx, 1, 0);
- glVertex3f(TEXSIZE, 0, 1);
- glMultiTexCoord2f(GL_TEXTURE0 + idx, 1, 1);
- glVertex3f(TEXSIZE, TEXSIZE, 1);
- glMultiTexCoord2f(GL_TEXTURE0 + idx, 0, 1);
- glVertex3f(0, TEXSIZE, 1);
- glEnd();
-
- //Check result
- int exp = (i >= maxTexUnits - 1) ? maxColorAttachment - 1 : i;
-
- if (checkResult(colors[RED + (exp % (WHITE - RED))], 0, 0) == false) {
- glDeleteTextures(maxTexUnits, textures);
-
- REPORT_FAILURE("Render to multi texture failed");
- return false;
- }
-
- glDisable(GL_TEXTURE_2D);
- glActiveTexture(GL_TEXTURE0);
- }
-
- glDeleteTextures(maxTexUnits, textures);
- }
-
- return true;
-}
-
-
-bool
-FBOTest::testRender2depthTexture(void)
-{
- GLuint fbs[2];
- GLuint textures[8];
-
- reset();
- if (useFramebuffer)
- glGenFramebuffersEXT(1, fbs);
-
- glGenTextures(1, textures);
- glBindTexture(GL_TEXTURE_2D, textures[0]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, TEXSIZE,
- TEXSIZE, 0, GL_DEPTH_COMPONENT, GL_INT, NULL);
-
- if (useFramebuffer) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_DEPTH_ATTACHMENT_EXT,
- GL_TEXTURE_2D, textures[0], 0);
- glDrawBuffer(GL_NONE);
- glReadBuffer(GL_NONE);
-
- CheckFramebufferStatus("FBOTest::testRender2depthTexture", __LINE__);
- }
- glClear(GL_DEPTH_BUFFER_BIT);
- glEnable(GL_DEPTH_TEST);
-
- glDisable(GL_TEXTURE_2D);
-
- // Render to the texture
- glColor4fv(colors[RED]);
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glBegin(GL_POLYGON);
- glVertex3f(TEXSIZE / 4, 0, 0.5);
- glVertex3f(TEXSIZE * 5 / 8, 0, 0.5);
- glVertex3f(TEXSIZE * 5 / 8, TEXSIZE, 0.5);
- glVertex3f(TEXSIZE / 4, TEXSIZE, 0.5);
- glEnd();
-
- if (useFramebuffer) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glBindTexture(GL_TEXTURE_2D, textures[0]);
- }
- else {
- glBindTexture(GL_TEXTURE_2D, textures[0]);
- glCopyTexImage2D(GL_TEXTURE_2D, 0,
- GL_DEPTH_COMPONENT, 0, 0, TEXSIZE,
- TEXSIZE, 0);
- }
-
- glClear(GL_DEPTH_BUFFER_BIT);
-
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE,
- GL_COMPARE_R_TO_TEXTURE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LESS);
- glTexParameterf(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE,
- GL_LUMINANCE);
- glEnable(GL_TEXTURE_2D);
- glDisable(GL_DEPTH_TEST);
-
- // Render to the window
- glColor4fv(colors[GREEN]);
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glBegin(GL_POLYGON);
- glTexCoord3f(0, 0, 0.75);
- glVertex2f(0, 0);
- glTexCoord3f(1, 0, 0.75);
- glVertex2f(TEXSIZE, 0);
- glTexCoord3f(1, 1, 0.75);
- glVertex2f(TEXSIZE, TEXSIZE);
- glTexCoord3f(0, 1, 0.75);
- glVertex2f(0, TEXSIZE);
- glEnd();
- glFlush();
-
- // Clean up
- if (useFramebuffer)
- glDeleteFramebuffersEXT(1, fbs);
- glDeleteTextures(1, textures);
-
- // Check result
- if (checkResult(colors[WHITE], 1, 0) == false) {
- REPORT_FAILURE("Render to depth texture failed");
- return false;
- }
-
-
-
- return true;
-}
-
-
-bool
-FBOTest::testRender2MipmapTexture(void)
-{
- int i;
- GLuint fbs[1];
- GLuint textures[1];
-
- reset();
- if (useFramebuffer)
- glGenFramebuffersEXT(1, fbs);
-
- glGenTextures(1, textures);
- glBindTexture(GL_TEXTURE_2D, textures[0]);
-
- if (useFramebuffer)
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
-
- glDisable(GL_TEXTURE_2D);
-
- GLint level = 0;
-
- for (i = TEXSIZE; i > 0; i /= 2, level++) {
- if (useFramebuffer) {
- glTexImage2D(GL_TEXTURE_2D, level, GL_RGB,
- i, i, 0, GL_RGB, GL_INT, NULL);
- glFramebufferTexture2DEXT
- (GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, textures[0], level);
- CheckFramebufferStatus("FBOTest::testRender2MipmapTexture", __LINE__);
-
- glColor4fv(colors[RED + (level % (WHITE - RED))]);
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- glBegin(GL_POLYGON);
- glVertex3f(0, 0, 1);
- glVertex3f(TEXSIZE, 0, 1);
- glVertex3f(TEXSIZE, TEXSIZE, 1);
- glVertex3f(0, TEXSIZE, 1);
- glEnd();
- }
- else {
- glColor4fv(colors[RED + (level % (WHITE - RED))]);
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- glBegin(GL_POLYGON);
- glVertex3f(0, 0, 1);
- glVertex3f(TEXSIZE, 0, 1);
- glVertex3f(TEXSIZE, TEXSIZE, 1);
- glVertex3f(0, TEXSIZE, 1);
- glEnd();
-
-
- glTexImage2D(GL_TEXTURE_2D, level, GL_RGB,
- i, i, 0, GL_RGB, GL_INT, NULL);
- glCopyTexImage2D(GL_TEXTURE_2D, level,
- GL_RGB, 0, 0, i, i, 0);
- }
- }
-
- if (useFramebuffer) {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glBindTexture(GL_TEXTURE_2D, textures[0]);
- }
- glEnable(GL_TEXTURE_2D);
-
- // Render to the window
- glColor4fv(colors[GREEN]);
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- GL_NEAREST_MIPMAP_NEAREST);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- for (i = TEXSIZE; i > 0; i /= 2) {
- glBegin(GL_POLYGON);
- glTexCoord2f(0, 0);
- glVertex3f(windowSize / 2 - i / 2,
- windowSize / 2 - i / 2, 1);
- glTexCoord2f(1, 0);
- glVertex3f(windowSize / 2 + i / 2,
- windowSize / 2 - i / 2, 1);
- glTexCoord2f(1, 1);
- glVertex3f(windowSize / 2 + i / 2,
- windowSize / 2 + i / 2, 1);
- glTexCoord2f(0, 1);
- glVertex3f(windowSize / 2 - i / 2,
- windowSize / 2 + i / 2, 1);
- glEnd();
- }
- glFlush();
-
- // Clean up
- if (useFramebuffer)
- glDeleteFramebuffersEXT(1, fbs);
- glDeleteTextures(1, textures);
-
- // Check result
- level = 0;
- for (i = TEXSIZE; i > 1; i /= 2, level++) {
- GLfloat pixel[3];
-
- glReadPixels(windowSize / 2 - i / 2,
- windowSize / 2 - i / 2, 1, 1, GL_RGB,
- GL_FLOAT, pixel);
- if (!equalColors
- (pixel, colors[RED + (level % (WHITE - RED))])) {
- REPORT_FAILURE("Render to mipmap texture failed");
- printf(" level = %d\n", level);
- return false;
- }
- }
-
-
- return true;
-}
-
-
-bool
-FBOTest::testErrorHandling(void)
-{
- GLuint fbs[1];
- GLuint textures[2];
- GLuint renderbuffer;
- GLenum status;
- bool have_ARB_ES2 = GLUtils::haveExtension("GL_ARB_ES2_compatibility");
-
- if (useFramebuffer) {
- GLuint maxColorAttachment;
-
- glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, (GLint *) & maxColorAttachment);
- if (maxColorAttachment < 1) {
- REPORT_FAILURE("Failed to get max color attachment points");
- return false;
- }
-
-
- // At least one image attached to the framebuffer
- glGenFramebuffersEXT(1, fbs);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
- glDrawBuffer(GL_NONE);
- glReadBuffer(GL_NONE);
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glDeleteFramebuffersEXT(1, fbs);
- if (status !=
- GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT) {
- REPORT_FAILURE
- ("If no image is attached to framebuffer, status should be GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT");
- return false;
- }
-
- // All attached images have the same width and height,
- // unless GL_ARB_framebuffer object is supported.
- glGenFramebuffersEXT(1, fbs);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
- glGenTextures(2, textures);
- glBindTexture(GL_TEXTURE_2D, textures[0]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, TEXSIZE,
- TEXSIZE, 0, GL_RGB, GL_INT, NULL);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, textures[0], 0);
- glBindTexture(GL_TEXTURE_2D, textures[1]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, TEXSIZE / 2,
- TEXSIZE / 2, 0, GL_RGB, GL_INT, NULL);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT
- + maxColorAttachment - 1,
- GL_TEXTURE_2D, textures[1], 0);
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glDeleteFramebuffersEXT(1, fbs);
- glDeleteTextures(2, textures);
- if (!haveARBfbo &&
- status != GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT) {
- REPORT_FAILURE
- ("If renderbuffer sizes don't all match, status should be GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT");
- return false;
- }
-
- // All images attached to the attachment points
- // COLOR_ATTACHMENT0_EXT through COLOR_ATTACHMENTn_EXT must
- // have the same internal format, unless ARB_fbo is supported.
- glGenFramebuffersEXT(1, fbs);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
- glGenTextures(2, textures);
- glBindTexture(GL_TEXTURE_2D, textures[0]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, TEXSIZE,
- TEXSIZE, 0, GL_RGB, GL_INT, NULL);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, textures[0], 0);
- glBindTexture(GL_TEXTURE_2D, textures[1]);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXSIZE,
- TEXSIZE, 0, GL_RGBA, GL_INT, NULL);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT
- + maxColorAttachment - 1,
- GL_TEXTURE_2D, textures[1], 0);
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glDeleteFramebuffersEXT(1, fbs);
- glDeleteTextures(2, textures);
- if (!haveARBfbo &&
- status != GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT) {
- REPORT_FAILURE
- ("All color renderbuffers must be of same format, status should be GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT");
- return false;
- }
-
-
- // The value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT must not
- // be NONE for any color attachment point(s) named by
- // DRAW_BUFFERi.
- // [Note: to avoid being caught by the no-attachments
- // case above, we attach a depth renderbuffer.]
- glGenFramebuffersEXT(1, fbs);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
- glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT +
- maxColorAttachment - 1);
- glGenRenderbuffers(1, &renderbuffer);
- glBindRenderbuffer(GL_RENDERBUFFER_EXT, renderbuffer);
- glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24,
- TEXSIZE, TEXSIZE);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT,
- GL_DEPTH_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT,
- renderbuffer);
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glDeleteFramebuffersEXT(1, fbs);
- glDeleteTextures(1, textures);
- glDeleteRenderbuffers(1, &renderbuffer);
- if (status != GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT &&
- !have_ARB_ES2) {
- REPORT_FAILURE
- ("All any buffer named by glDrawBuffers is missing, status should be GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT");
- return false;
- }
-
- // If READ_BUFFER is not NONE, then the value of
- // FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT must not be NONE for
- // the color attachment point named by READ_BUFFER.
- // [Note: to avoid being caught by the no-attachments
- // case above, we attach a depth renderbuffer.]
- glGenFramebuffersEXT(1, fbs);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbs[0]);
- glDrawBuffer(GL_NONE);
- glReadBuffer(GL_COLOR_ATTACHMENT0_EXT +
- maxColorAttachment - 1);
- glGenRenderbuffers(1, &renderbuffer);
- glBindRenderbuffer(GL_RENDERBUFFER_EXT, renderbuffer);
- glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24,
- TEXSIZE, TEXSIZE);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT,
- GL_DEPTH_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT,
- renderbuffer);
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- glDeleteFramebuffersEXT(1, fbs);
- glDeleteRenderbuffers(1, &renderbuffer);
- if (status != GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT &&
- !have_ARB_ES2) {
- REPORT_FAILURE
- ("If buffer named by glReadBuffers is missing, status should be GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT");
- return false;
- }
- }
- return true;
-}
-
-void
-FBOTest::runOne(MultiTestResult & r, Window & w)
-{
- (void) w;
-
- if (!setup()) {
- r.pass = false;
- return;
- }
-
- static SubTestFunc funcs[] = {
- &GLEAN::FBOTest::testSanity,
- &GLEAN::FBOTest::testRender2SingleTexture,
- &GLEAN::FBOTest::testRender2MultiTexture,
- &GLEAN::FBOTest::testRender2depthTexture,
- &GLEAN::FBOTest::testRender2MipmapTexture,
- &GLEAN::FBOTest::testErrorHandling,
- NULL
- };
-
- for (int i = 0; funcs[i]; i++)
- if ((this->*funcs[i]) ())
- r.numPassed++;
- else
- r.numFailed++;
-
- r.pass = (r.numFailed == 0);
-}
-
-
-// The test object itself:
-FBOTest fboTest("fbo", "window, rgb, z", "", // no extension filter
- "fbo test: Test OpenGL Extension GL_EXT_framebuffer_object\n");
-
-
-
-} // namespace GLEAN
diff --git a/tests/glean/tfbo.h b/tests/glean/tfbo.h
deleted file mode 100644
index 5f8b719..0000000
--- a/tests/glean/tfbo.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyrigth (C) 2007 Intel Corporation
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-//
-// Authors:
-// Shuang He <shuang.he at intel.com>
-//
-// tfbo.h: Test OpenGL Extension GL_EXT_framebuffer_objec
-
-#ifndef __tfbo_h__
-#define __tfbo_h__
-
-#include "tmultitest.h"
-
-namespace GLEAN {
-
-#define windowSize 100
-
-
-class FBOTest: public MultiTest
-{
-public:
- FBOTest(const char* testName, const char* filter,
- const char *extensions, const char* description):
- MultiTest(testName, filter, extensions, description),
- haveARBfbo(false),
- tolerance()
- {
- }
-
- virtual void runOne(MultiTestResult &r, Window &w);
-
-private:
- typedef bool (FBOTest::*TestFunc)(MultiTestResult &r);
- typedef bool (FBOTest::*SubTestFunc)(void);
-
- GLboolean haveARBfbo; // GL_ARB_framebuffer_object supported?
- GLfloat tolerance[5];
- void reset(void);
- bool testSanity(void);
- bool testRender2SingleTexture(void);
- bool testRender2MultiTexture(void);
- bool testRender2depthTexture(void);
- bool testRender2MipmapTexture(void);
- bool testErrorHandling(void);
-
-
- bool setup(void);
- bool checkResult(const GLfloat exp[4], const int depth, const int stencil) const;
- bool equalColors(const GLfloat a[4], const GLfloat b[4]) const;
-
- void reportFailure(const char *msg, int line) const;
- void reportFailure(const char *msg, GLenum target, int line) const;
-};
-
-} // namespace GLEAN
-
-#endif // __tfbo_h__
diff --git a/tests/glean/tfragprog1.cpp b/tests/glean/tfragprog1.cpp
deleted file mode 100644
index 837382c..0000000
--- a/tests/glean/tfragprog1.cpp
+++ /dev/null
@@ -1,1125 +0,0 @@
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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.
-// Brian Paul 22 October 2005
-//
-// This is pretty simple. Specific fragment programs are run, we read back
-// the framebuffer color and compare the color to the expected result.
-// Pretty much any fragment program can be tested in the manner.
-// Ideally, an additional fragment program test should be developed which
-// exhaustively tests instruction combinations with all the various swizzle
-// and masking options, etc.
-// But this test is good for regression testing to be sure that particular or
-// unique programs work correctly.
-
-#include <cstdlib>
-#include <cstring>
-#include <cassert>
-#include <cmath>
-#include <math.h>
-#include "tfragprog1.h"
-
-
-namespace GLEAN {
-
-// Clamp X to [0, 1]
-#define CLAMP01( X ) ( (X)<(0.0) ? (0.0) : ((X)>(1.0) ? (1.0) : (X)) )
-// Absolute value
-#define ABS(X) ( (X) < 0.0 ? -(X) : (X) )
-// Max
-#define MAX( A, B ) ( (A) > (B) ? (A) : (B) )
-// Min
-#define MIN( A, B ) ( (A) < (B) ? (A) : (B) )
-// Duplicate value four times
-#define SMEAR(X) (X), (X), (X), (X)
-
-#define DONT_CARE_Z -1.0
-#define DONT_CARE_COLOR -1.0
-
-#define FRAGCOLOR { 0.25, 0.75, 0.5, 0.25 }
-#define PARAM0 { 0.0, 0.0, 0.0, 0.0 }
-#define PARAM1 { 0.5, 0.25, 1.0, 0.5 }
-#define PARAM2 { -1.0, 0.0, 0.25, -0.5 }
-static const GLfloat FragColor[4] = FRAGCOLOR;
-static const GLfloat Param0[4] = PARAM0;
-static const GLfloat Param1[4] = PARAM1;
-static const GLfloat Param2[4] = PARAM2;
-static GLfloat InfNan[4];
-static GLfloat FogColor[4] = {1.0, 1.0, 0.0, 0.0};
-static GLfloat FogStart = 10.0;
-static GLfloat FogEnd = 100.0;
-static GLfloat FogDensity = 0.03;
-static GLfloat FogCoord = 50.0; /* Between FogStart and FogEnd */
-
-
-// These are the specific fragment programs which we'll test
-// Alphabetical order, please
-static const FragmentProgram Programs[] = {
- {
- "ABS test",
- "!!ARBfp1.0\n"
- "PARAM p = program.local[2]; \n"
- "ABS result.color, p; \n"
- "END \n",
- { ABS(Param2[0]),
- ABS(Param2[1]),
- ABS(Param2[2]),
- ABS(Param2[3])
- },
- DONT_CARE_Z,
- },
- {
- "ADD test",
- "!!ARBfp1.0\n"
- "PARAM p = program.local[1]; \n"
- "ADD result.color, fragment.color, p; \n"
- "END \n",
- { CLAMP01(FragColor[0] + Param1[0]),
- CLAMP01(FragColor[1] + Param1[1]),
- CLAMP01(FragColor[2] + Param1[2]),
- CLAMP01(FragColor[3] + Param1[3])
- },
- DONT_CARE_Z
- },
- {
- "ADD with saturation",
- "!!ARBfp1.0\n"
- "PARAM p = program.local[1]; \n"
- "TEMP t; \n"
- "ADD t, p, p; \n"
- "ADD_SAT result.color, t, p; \n"
- "END \n",
- { CLAMP01(Param1[0] + Param1[0] + Param1[0]),
- CLAMP01(Param1[1] + Param1[1] + Param1[1]),
- CLAMP01(Param1[2] + Param1[2] + Param1[2]),
- CLAMP01(Param1[3] + Param1[3] + Param1[3]),
- },
- DONT_CARE_Z
- },
-
- {
- "ADD an immediate",
- "!!ARBfp1.0\n"
- "PARAM p = program.local[1]; \n"
- "ADD result.color, p, {0.25, 0.0, 0.5, 0.25}; \n"
- "END \n",
- { CLAMP01(Param1[0] + 0.25),
- CLAMP01(Param1[1] + 0.0),
- CLAMP01(Param1[2] + 0.5),
- CLAMP01(Param1[3] + 0.25),
- },
- DONT_CARE_Z
- },
-
- {
- "ADD negative immediate",
- "!!ARBfp1.0\n"
- "PARAM p = program.local[1]; \n"
- "ADD result.color, p, {-0.25, -0.2, 0.0, -0.25}; \n"
- "END \n",
- { CLAMP01(Param1[0] - 0.25),
- CLAMP01(Param1[1] - 0.2),
- CLAMP01(Param1[2] - 0.0),
- CLAMP01(Param1[3] - 0.25),
- },
- DONT_CARE_Z
- },
-
- {
- "ADD negative immediate (2)",
- "!!ARBfp1.0\n"
- "PARAM p = program.local[1]; \n"
- "TEMP t; \n"
- "MOV t, p; \n"
- "MUL t.xyz, t, 2.0; \n"
- "ADD t.xyz, t, -1.0; \n"
- "MOV result.color, t; \n"
- "END \n",
- { CLAMP01(Param1[0] * 2.0 - 1.0),
- CLAMP01(Param1[1] * 2.0 - 1.0),
- CLAMP01(Param1[2] * 2.0 - 1.0),
- CLAMP01(Param1[3] ),
- },
- DONT_CARE_Z
- },
-
- {
- "CMP test",
- "!!ARBfp1.0\n"
- "PARAM zero = program.local[0]; \n"
- "PARAM p1 = program.local[1]; \n"
- "PARAM p2 = program.local[2]; \n"
- "CMP result.color, p2, zero, p1; \n"
- "END \n",
- { Param0[0], Param1[1], Param1[2], Param0[3] },
- DONT_CARE_Z
- },
- {
- "COS test",
- "!!ARBfp1.0\n"
- "PARAM values = { 0.0, 3.14159, 0.5, 1.0 }; \n"
- "COS result.color.x, values.x; \n"
- "COS result.color.y, values.y; \n"
- "COS result.color.z, values.z; \n"
- "COS result.color.w, values.w; \n"
- "END \n",
- { CLAMP01(1.0),
- CLAMP01(-1.0),
- CLAMP01(0.8775),
- CLAMP01(0.5403)
- },
- DONT_CARE_Z
- },
- {
- "COS test 2",
- "!!ARBfp1.0\n"
- "PARAM values = { 6.78318, 7.28318, 6.28318, -5.78318 }; \n"
- "COS result.color.x, values.x; \n"
- "COS result.color.y, values.y; \n"
- "COS result.color.z, values.z; \n"
- "COS result.color.w, values.w; \n"
- "END \n",
- { CLAMP01(0.8775),
- CLAMP01(0.5403),
- CLAMP01(1.0),
- CLAMP01(0.8775)
- },
- DONT_CARE_Z
- },
- {
- "DP3 test",
- "!!ARBfp1.0\n"
- "PARAM p1 = program.local[1]; \n"
- "DP3 result.color, p1, fragment.color; \n"
- "END \n",
- { SMEAR(CLAMP01(Param1[0] * FragColor[0] +
- Param1[1] * FragColor[1] +
- Param1[2] * FragColor[2]))
- },
- DONT_CARE_Z
- },
- {
- "DP3 test (2)",
- "!!ARBfp1.0\n"
- "PARAM p1 = program.local[1]; \n"
- "TEMP t, r; \n"
- "MOV t, p1; \n"
- "DP3 r.x, t, t; \n"
- "MUL result.color, r.xxxx, 0.5; \n"
- "END \n",
- { SMEAR(CLAMP01((Param1[0] * Param1[0] +
- Param1[1] * Param1[1] +
- Param1[2] * Param1[2]) * 0.5))
- },
- DONT_CARE_Z
- },
- {
- "DP4 test",
- "!!ARBfp1.0\n"
- "PARAM p1 = program.local[1]; \n"
- "DP4 result.color, p1, fragment.color; \n"
- "END \n",
- { SMEAR(CLAMP01(Param1[0] * FragColor[0] +
- Param1[1] * FragColor[1] +
- Param1[2] * FragColor[2] +
- Param1[3] * FragColor[3]))
- },
- DONT_CARE_Z
- },
- {
- "DPH test",
- "!!ARBfp1.0\n"
- "PARAM p1 = program.local[1]; \n"
- "PARAM scale = {0.1, 0.1, 0.1, 0.1}; \n"
- "TEMP t; \n"
- "DPH t, p1, fragment.color; \n"
- "MUL result.color, t, scale; \n"
- "END \n",
- { SMEAR(CLAMP01((Param1[0] * FragColor[0] +
- Param1[1] * FragColor[1] +
- Param1[2] * FragColor[2] +
- FragColor[3]) * 0.1))
- },
- DONT_CARE_Z
- },
- {
- "DST test",
- "!!ARBfp1.0\n"
- "# let d = 0.4 \n"
- "PARAM v1 = {9.9, 0.16, 0.16, 9.9}; \n"
- "PARAM v2 = {9.9, 2.5, 9.9, 2.5}; \n"
- "DST result.color, v1, v2; \n"
- "END \n",
- { 1.0,
- 0.4, // v1.y * v2.y
- 0.16, // v1.z
- CLAMP01(2.5) // v2.w
- },
- DONT_CARE_Z
- },
- {
- "EX2 test",
- "!!ARBfp1.0\n"
- "PARAM scale = {0.01, 0.01, 0.01, 0.01}; \n"
- "PARAM values = {0.0, 1.0, 4.0, -2.0 }; \n"
- "TEMP t; \n"
- "EX2 t.x, values.x; \n"
- "EX2 t.y, values.y; \n"
- "EX2 t.z, values.z; \n"
- "EX2 t.w, values.w; \n"
- "MUL result.color, t, scale; \n"
- "END \n",
- { 1.0 * 0.01,
- 2.0 * 0.01,
- 16.0 * 0.01,
- 0.25 * 0.01 },
- DONT_CARE_Z
- },
- {
- "FLR test",
- "!!ARBfp1.0\n"
- "PARAM values = {4.8, 0.3, -0.2, 1.2}; \n"
- "PARAM scale = {0.1, 0.1, 0.1, 0.1}; \n"
- "TEMP t; \n"
- "FLR t, values; \n"
- "MUL result.color, t, scale; \n"
- "END \n",
- { 0.4,
- 0.0,
- CLAMP01(-0.1),
- 0.1
- },
- DONT_CARE_Z
- },
- {
- "FRC test",
- "!!ARBfp1.0\n"
- "PARAM values = {-1.1, 0.1, -2.2, 2.4 }; \n"
- "FRC result.color, values; \n"
- "END \n",
- { 0.9, 0.1, 0.8, 0.4 },
- DONT_CARE_Z
- },
- {
- "LG2 test",
- "!!ARBfp1.0\n"
- "PARAM values = {64.0, 1, 30, 4}; \n"
- "PARAM scale = {0.1, 0.1, 0.1, 0.1}; \n"
- "TEMP t; \n"
- "LG2 t.x, values.x; \n"
- "LG2 t.y, values.y; \n"
- "LG2 t.z, values.z; \n"
- "LG2 t.w, values.w; \n"
- "MUL result.color, t, scale; \n"
- "END \n",
- { 0.6,
- 0.0,
- 0.49,
- 0.2
- },
- DONT_CARE_Z
- },
- {
- "LIT test 1",
- "!!ARBfp1.0\n"
- "PARAM values = {0.65, 0.9, 0.0, 8.0}; \n"
- "LIT result.color, values; \n"
- "END \n",
- { 1.0,
- 0.65, // values.x
- 0.433, // roughly Pow(values.y, values.w)
- 1.0
- },
- DONT_CARE_Z
- },
- {
- "LIT test 2 (degenerate case: 0 ^ 0 -> 1)",
- "!!ARBfp1.0\n"
- "PARAM values = {0.65, 0.0, 0.0, 0.0}; \n"
- "LIT result.color, values; \n"
- "END \n",
- { 1.0,
- 0.65, // values.x
- 1.0, // 0^0
- 1.0
- },
- DONT_CARE_Z
- },
- {
- "LIT test 3 (case x < 0)",
- "!!ARBfp1.0\n"
- "PARAM values = {-0.5, 0.0, 0.0, 0.0}; \n"
- "LIT result.color, values; \n"
- "END \n",
- { 1.0,
- CLAMP01(-0.5), // values.x
- 0.0,
- 1.0
- },
- DONT_CARE_Z
- },
- {
- "LRP test",
- "!!ARBfp1.0\n"
- "PARAM p1 = program.local[1]; \n"
- "PARAM t = {0.2, 0.5, 1.0, 0.0}; \n"
- "LRP result.color, t, fragment.color, p1; \n"
- "END \n",
- { 0.2 * FragColor[0] + (1.0 - 0.2) * Param1[0],
- 0.5 * FragColor[1] + (1.0 - 0.5) * Param1[1],
- 1.0 * FragColor[2] + (1.0 - 1.0) * Param1[2],
- 0.0 * FragColor[3] + (1.0 - 0.0) * Param1[3]
- },
- DONT_CARE_Z
- },
- {
- "MAD test",
- "!!ARBfp1.0\n"
- "PARAM p1 = program.local[1]; \n"
- "PARAM p2 = program.local[2]; \n"
- "MAD result.color, fragment.color, p1, p2; \n"
- "END \n",
- { CLAMP01(FragColor[0] * Param1[0] + Param2[0]),
- CLAMP01(FragColor[1] * Param1[1] + Param2[1]),
- CLAMP01(FragColor[2] * Param1[2] + Param2[2]),
- CLAMP01(FragColor[3] * Param1[3] + Param2[3])
- },
- DONT_CARE_Z
- },
- {
- "MAX test",
- "!!ARBfp1.0\n"
- "PARAM p1 = program.local[1]; \n"
- "PARAM p2 = program.local[2]; \n"
- "MAX result.color, p1, p2; \n"
- "END \n",
- { MAX(Param1[0], Param2[0]),
- MAX(Param1[1], Param2[1]),
- MAX(Param1[2], Param2[2]),
- MAX(Param1[3], Param2[3]),
- },
- DONT_CARE_Z
- },
- {
- "MIN test",
- "!!ARBfp1.0\n"
- "PARAM p1 = program.local[1]; \n"
- "MIN result.color, p1, fragment.color; \n"
- "END \n",
- { MIN(Param1[0], FragColor[0]),
- MIN(Param1[1], FragColor[1]),
- MIN(Param1[2], FragColor[2]),
- MIN(Param1[3], FragColor[3]),
- },
- DONT_CARE_Z
- },
- {
- "MOV test",
- "!!ARBfp1.0\n"
- "MOV result.color, fragment.color; \n"
- "END \n",
- FRAGCOLOR,
- DONT_CARE_Z,
- },
- {
- "MUL test",
- "!!ARBfp1.0\n"
- "PARAM p = program.local[1]; \n"
- "MUL result.color, fragment.color, p; \n"
- "END \n",
- { CLAMP01(FragColor[0] * Param1[0]),
- CLAMP01(FragColor[1] * Param1[1]),
- CLAMP01(FragColor[2] * Param1[2]),
- CLAMP01(FragColor[3] * Param1[3])
- },
- DONT_CARE_Z
- },
- {
- "masked MUL test",
- "!!ARBfp1.0\n"
- "PARAM zero = program.local[0]; \n"
- "PARAM p = program.local[1]; \n"
- "MOV result.color, zero; \n"
- "MUL result.color.xy, fragment.color, p; \n"
- "END \n",
- { CLAMP01(FragColor[0] * Param1[0]),
- CLAMP01(FragColor[1] * Param1[1]),
- 0.0,
- 0.0
- },
- DONT_CARE_Z
- },
- {
- "POW test (exponentiation)",
- "!!ARBfp1.0\n"
- "PARAM values = {0.5, 2, 3, 4}; \n"
- "POW result.color.x, values.x, values.y; \n"
- "POW result.color.y, values.x, values.z; \n"
- "POW result.color.z, values.x, values.w; \n"
- "POW result.color.w, values.w, values.x; \n"
- "END \n",
- { 0.5 * 0.5,
- 0.5 * 0.5 * 0.5,
- 0.5 * 0.5 * 0.5 * 0.5,
- CLAMP01(2.0) },
- DONT_CARE_Z
- },
- {
- "RCP test (reciprocal)",
- "!!ARBfp1.0\n"
- "PARAM values = {8, -10, 1, 12 }; \n"
- "RCP result.color.x, values.x; \n"
- "RCP result.color.y, values.y; \n"
- "RCP result.color.z, values.z; \n"
- "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
- },
- {
- /* check that RCP result is replicated across XYZW */
- "RCP test 2 (reciprocal)",
- "!!ARBfp1.0\n"
- "PARAM values = {8, -10, 1, 12 }; \n"
- "MOV result.color, values; \n"
- "RCP result.color, values.x; \n"
- "END \n",
- { 1.0 / 8.0, 1.0 / 8.0, 1.0 / 8.0, 1.0 / 8.0 },
- DONT_CARE_Z
- },
- {
- "RSQ test 1 (reciprocal square root)",
- "!!ARBfp1.0\n"
- "PARAM values = {1, 4, 9, 100 }; \n"
- "RSQ result.color.x, values.x; \n"
- "RSQ result.color.y, values.y; \n"
- "RSQ result.color.z, values.z; \n"
- "RSQ result.color.w, values.w; \n"
- "END \n",
- { 1.0, 0.5, 0.3333, 0.1 },
- DONT_CARE_Z
- },
- {
- "RSQ test 2 (reciprocal square root of negative value)",
- "!!ARBfp1.0\n"
- "PARAM values = {0, -100, -5, -1}; \n"
- "RSQ result.color.x, values.x; \n"
- "RSQ result.color.y, values.y; \n"
- "RSQ result.color.z, values.z; \n"
- "RSQ result.color.w, values.w; \n"
- "END \n",
- { DONT_CARE_COLOR,
- 0.1,
- 0.447,
- 1.0,
- },
- DONT_CARE_Z
- },
- {
- "SCS test",
- "!!ARBfp1.0\n"
- "PARAM values = { 0.5, 0.5, 0.0, 0.0 }; \n"
- "SCS result.color.x, values.x; \n"
- "SCS result.color.y, values.y; \n"
- "END \n",
- { CLAMP01(0.8775),
- CLAMP01(0.4794),
- DONT_CARE_COLOR,
- DONT_CARE_COLOR,
- },
- DONT_CARE_Z
- },
- {
- "SGE test",
- "!!ARBfp1.0\n"
- "PARAM p0 = program.local[0]; \n"
- "PARAM p2 = program.local[2]; \n"
- "SGE result.color, p2, p0; \n"
- "END \n",
- { Param2[0] >= Param0[0] ? 1.0 : 0.0,
- Param2[1] >= Param0[1] ? 1.0 : 0.0,
- Param2[2] >= Param0[2] ? 1.0 : 0.0,
- Param2[3] >= Param0[3] ? 1.0 : 0.0,
- },
- DONT_CARE_Z
- },
- {
- "SIN test",
- "!!ARBfp1.0\n"
- "PARAM values = { 1.57079, -1.57079, 0.5, 1.0 }; \n"
- "SIN result.color.x, values.x; \n"
- "SIN result.color.y, values.y; \n"
- "SIN result.color.z, values.z; \n"
- "SIN result.color.w, values.w; \n"
- "END \n",
- { CLAMP01(1.0),
- CLAMP01(-1.0),
- CLAMP01(0.4794),
- CLAMP01(0.8414)
- },
- DONT_CARE_Z
- },
- {
- "SIN test 2",
- "!!ARBfp1.0\n"
- "PARAM values = { 3.14159, -3.14159, 6.78319, -5.78319 }; \n"
- "SIN result.color.x, values.x; \n"
- "SIN result.color.y, values.y; \n"
- "SIN result.color.z, values.z; \n"
- "SIN result.color.w, values.w; \n"
- "END \n",
- { CLAMP01(0.0),
- CLAMP01(0.0),
- CLAMP01(0.4794),
- CLAMP01(0.4794)
- },
- DONT_CARE_Z
- },
- {
- "SLT test",
- "!!ARBfp1.0\n"
- "PARAM p1 = program.local[1]; \n"
- "SLT result.color, fragment.color, p1; \n"
- "END \n",
- { FragColor[0] < Param1[0] ? 1.0 : 0.0,
- FragColor[1] < Param1[1] ? 1.0 : 0.0,
- FragColor[2] < Param1[2] ? 1.0 : 0.0,
- FragColor[3] < Param1[3] ? 1.0 : 0.0,
- },
- DONT_CARE_Z
- },
- {
- "SUB test (with swizzle)",
- "!!ARBfp1.0\n"
- "PARAM p1 = program.local[1]; \n"
- "SUB result.color, p1.yxwz, fragment.color.yxwz; \n"
- "END \n",
- { CLAMP01(Param1[1] - FragColor[1]),
- CLAMP01(Param1[0] - FragColor[0]),
- CLAMP01(Param1[3] - FragColor[3]),
- CLAMP01(Param1[2] - FragColor[2])
- },
- DONT_CARE_Z
- },
- {
- "SUB with saturation",
- "!!ARBfp1.0\n"
- "PARAM p1 = program.local[1]; \n"
- "PARAM bias = {0.1, 0.1, 0.1, 0.1}; \n"
- "TEMP t; \n"
- "SUB_SAT t, fragment.color, p1; \n"
- "ADD result.color, t, bias; \n"
- "END \n",
- { CLAMP01(FragColor[0] - Param1[1]) + 0.1,
- CLAMP01(FragColor[1] - Param1[1]) + 0.1,
- CLAMP01(FragColor[2] - Param1[2]) + 0.1,
- CLAMP01(FragColor[3] - Param1[3]) + 0.1
- },
- DONT_CARE_Z
- },
- {
- "SWZ test",
- "!!ARBfp1.0\n"
- "PARAM p = program.local[1]; \n"
- "SWZ result.color, p, -1,-y,z,0; \n"
- "END \n",
- { CLAMP01(-1.0),
- CLAMP01(-Param1[1]),
- CLAMP01(Param1[2]),
- CLAMP01(0.0)
- },
- DONT_CARE_Z
- },
- {
- // this test checks that SOA execution is handled correctly
- "swizzled move test",
- "!!ARBfp1.0\n"
- "TEMP t; \n"
- "PARAM p = program.local[1]; \n"
- "MOV t, p; \n"
- "MOV t, t.yxwz; \n" // "in-place" swizzle
- "MOV result.color, t; \n"
- "END \n",
- { Param1[1], Param1[0], Param1[3], Param1[2] },
- DONT_CARE_Z
- },
- {
- // this test checks that SOA execution is handled correctly
- "swizzled add test",
- "!!ARBfp1.0\n"
- "TEMP t; \n"
- "PARAM p = program.local[1]; \n"
- "MOV t, p; \n"
- "ADD t, t, t.yxwz; \n" // "in-place" swizzled add
- "MOV result.color, t; \n"
- "END \n",
- { CLAMP01(Param1[0] + Param1[1]),
- CLAMP01(Param1[1] + Param1[0]),
- CLAMP01(Param1[2] + Param1[3]),
- CLAMP01(Param1[3] + Param1[2]) },
- DONT_CARE_Z
- },
- {
- "XPD test 1",
- "!!ARBfp1.0\n"
- "PARAM p1 = program.local[1]; \n"
- "PARAM p2 = program.local[2]; \n"
- "XPD result.color, p1, p2; \n"
- "END \n",
- { CLAMP01(Param1[1] * Param2[2] - Param1[2] * Param2[1]),
- CLAMP01(Param1[2] * Param2[0] - Param1[0] * Param2[2]),
- CLAMP01(Param1[0] * Param2[1] - Param1[1] * Param2[0]),
- DONT_CARE_COLOR
- },
- DONT_CARE_Z
- },
- {
- "Z-write test",
- "!!ARBfp1.0\n"
- "PARAM p = program.local[1]; \n"
- "MOV result.color, p; \n"
- "MOV result.depth.z, p.y; \n"
- "END \n",
- { Param1[0],
- Param1[1],
- Param1[2],
- Param1[3]
- },
- Param1[1]
- },
-
- // ============= Numeric stress tests =================================
- // Basically just check that we don't crash when we do divides by
- // zero, etc.
- {
- "Divide by zero test",
- "!!ARBfp1.0\n"
- "PARAM zero = program.local[0]; \n"
- "RCP result.color.x, zero.x; \n"
- "RCP result.color.y, zero.y; \n"
- "RCP result.color.z, zero.z; \n"
- "RCP result.color.w, zero.w; \n"
- "END \n",
- { DONT_CARE_COLOR,
- DONT_CARE_COLOR,
- DONT_CARE_COLOR,
- DONT_CARE_COLOR
- },
- DONT_CARE_Z
- },
- {
- "Infinity and nan test",
- "!!ARBfp1.0\n"
- "PARAM zero = program.local[0]; \n"
- "PARAM infNan = program.local[9]; \n"
- "ADD result.color, infNan, zero; \n"
- "END \n",
- { DONT_CARE_COLOR,
- DONT_CARE_COLOR,
- DONT_CARE_COLOR,
- DONT_CARE_COLOR
- },
- DONT_CARE_Z
- },
-
- // ============= Fog tests ============================================
- // Linear fog
-#define FOG_FACT ((FogEnd - FogCoord) / (FogEnd - FogStart))
- {
- "ARB_fog_linear test",
- "!!ARBfp1.0\n"
- "OPTION ARB_fog_linear; \n"
- "MOV result.color, fragment.color; \n"
- "END \n",
- { FragColor[0] * FOG_FACT + FogColor[0] * (1.0 - FOG_FACT),
- FragColor[1] * FOG_FACT + FogColor[1] * (1.0 - FOG_FACT),
- FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
- FragColor[3]
- },
- DONT_CARE_Z
- },
- {
- "Computed fog linear test",
- "!!ARBfp1.0\n"
- "# fogParams.x = density \n"
- "# fogParams.y = start \n"
- "# fogParams.z = end \n"
- "# fogParams.w = 1/(end-start) \n"
- "PARAM fogParams = state.fog.params; \n"
- "ATTRIB fogCoord = fragment.fogcoord; \n"
- "PARAM fogColor = state.fog.color; \n"
- "TEMP numerator, f; \n"
- "# f = (end - coord) / (end - start) \n"
- "SUB numerator, fogParams.z, fogCoord.x; \n"
- "MUL_SAT f, numerator, fogParams.w; \n"
- "LRP result.color.rgb, f, fragment.color, fogColor; \n"
- "MOV result.color.a, fragment.color.a; \n"
- "END \n",
- { FragColor[0] * FOG_FACT + FogColor[0] * (1.0 - FOG_FACT),
- FragColor[1] * FOG_FACT + FogColor[1] * (1.0 - FOG_FACT),
- FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
- FragColor[3]
- },
- DONT_CARE_Z
- },
-#undef FOG_FACT
-
- // Exp fog
-#define FOG_FACT 0.2231 // = exp(-Density * Coord)
- {
- "ARB_fog_exp test",
- "!!ARBfp1.0\n"
- "OPTION ARB_fog_exp; \n"
- "MOV result.color, fragment.color; \n"
- "END \n",
- { FragColor[0] * FOG_FACT + FogColor[0] * (1.0 - FOG_FACT),
- FragColor[1] * FOG_FACT + FogColor[1] * (1.0 - FOG_FACT),
- FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
- FragColor[3]
- },
- DONT_CARE_Z
- },
-#undef FOG_FACT
-#define FOG_FACT 0.3535 // = ex2(-Density * Coord)
- {
- // NOTE: we could also do this with the POW instruction
- "Computed fog exp test",
- "!!ARBfp1.0\n"
- "# fogParams.x = density \n"
- "# fogParams.y = start \n"
- "# fogParams.z = end \n"
- "# fogParams.w = 1/(end-start) \n"
- "PARAM fogParams = state.fog.params; \n"
- "ATTRIB fogCoord = fragment.fogcoord; \n"
- "PARAM fogColor = state.fog.color; \n"
- "TEMP f, dc; \n"
- "# f = exp(-density * coord) \n"
- "MUL dc.x, fogParams.x, fogCoord.x; \n"
- "EX2_SAT f, -dc.x; \n"
- "LRP result.color.rgb, f, fragment.color, fogColor; \n"
- "MOV result.color.a, fragment.color.a; \n"
- "END \n",
- { FragColor[0] * FOG_FACT + FogColor[0] * (1.0 - FOG_FACT),
- FragColor[1] * FOG_FACT + FogColor[1] * (1.0 - FOG_FACT),
- FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
- FragColor[3]
- },
- DONT_CARE_Z
- },
-#undef FOG_FACT
-
- // Exp2 fog
-#define FOG_FACT 0.1054 // = exp(-(Density * Coord)^2)
- {
- "ARB_fog_exp2 test",
- "!!ARBfp1.0\n"
- "OPTION ARB_fog_exp2; \n"
- "MOV result.color, fragment.color; \n"
- "END \n",
- { FragColor[0] * FOG_FACT + FogColor[0] * (1.0 - FOG_FACT),
- FragColor[1] * FOG_FACT + FogColor[1] * (1.0 - FOG_FACT),
- FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
- FragColor[3]
- },
- DONT_CARE_Z
- },
-#undef FOG_FACT
-#define FOG_FACT 0.2102 // = ex2(-(Density * Coord)^2)
- {
- // NOTE: we could also do this with the POW instruction
- "Computed fog exp2 test",
- "!!ARBfp1.0\n"
- "# fogParams.x = density \n"
- "# fogParams.y = start \n"
- "# fogParams.z = end \n"
- "# fogParams.w = 1/(end-start) \n"
- "PARAM fogParams = state.fog.params; \n"
- "ATTRIB fogCoord = fragment.fogcoord; \n"
- "PARAM fogColor = state.fog.color; \n"
- "TEMP f, dc; \n"
- "# f = exp(-(density * coord)^2) \n"
- "MUL dc.x, fogParams.x, fogCoord.x; \n"
- "MUL dc.x, dc.x, dc.x; \n"
- "EX2_SAT f, -dc.x; \n"
- "LRP result.color.rgb, f, fragment.color, fogColor; \n"
- "MOV result.color.a, fragment.color.a; \n"
- "END \n",
- { FragColor[0] * FOG_FACT + FogColor[0] * (1.0 - FOG_FACT),
- FragColor[1] * FOG_FACT + FogColor[1] * (1.0 - FOG_FACT),
- FragColor[2] * FOG_FACT + FogColor[2] * (1.0 - FOG_FACT),
- FragColor[3]
- },
- DONT_CARE_Z
- },
-#undef FOG_FACT
-
- // XXX add lots more tests here!
- { NULL, NULL, {0,0,0,0}, 0 } // end of list sentinal
-};
-
-
-
-void
-FragmentProgramTest::setup(void)
-{
- // setup Infinity, Nan values
- int nan;
- float *nanPtr;
-
- nan = (0xff << 23) | (1 << 0);
- nanPtr = (float *) &nan;
- InfNan[0] = HUGE_VAL;
- InfNan[1] = -HUGE_VAL;
- InfNan[2] = (float) (*nanPtr);
- InfNan[3] = 1.0 / HUGE_VAL;
-
- // get function pointers
-
- GLuint progID;
- glGenProgramsARB(1, &progID);
- glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, progID);
- glEnable(GL_FRAGMENT_PROGRAM_ARB);
-
- // load program inputs
- glColor4fv(FragColor);
- glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 0, Param0);
- glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 1, Param1);
- glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 2, Param2);
- glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 9, InfNan);
-
- GLenum err = glGetError();
- assert(!err); // should be OK
-
- // setup vertex transform (we'll draw a quad in middle of window)
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-#if DEVEL_MODE
- glOrtho(-1.0, 1.0, -1.0, 1.0, 0.0, 1.0);
-#else
- glOrtho(-4.0, 4.0, -4.0, 4.0, 0.0, 1.0);
-#endif
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glDrawBuffer(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(FogCoord);
-
- // compute error tolerances (may need fine-tuning)
- int bufferBits[5];
- glGetIntegerv(GL_RED_BITS, &bufferBits[0]);
- glGetIntegerv(GL_GREEN_BITS, &bufferBits[1]);
- glGetIntegerv(GL_BLUE_BITS, &bufferBits[2]);
- glGetIntegerv(GL_ALPHA_BITS, &bufferBits[3]);
- glGetIntegerv(GL_DEPTH_BITS, &bufferBits[4]);
-
- tolerance[0] = 2.0 / (1 << bufferBits[0]);
- tolerance[1] = 2.0 / (1 << bufferBits[1]);
- tolerance[2] = 2.0 / (1 << bufferBits[2]);
- if (bufferBits[3])
- tolerance[3] = 2.0 / (1 << bufferBits[3]);
- else
- tolerance[3] = 1.0;
- if (bufferBits[4])
- tolerance[4] = 16.0 / (1 << bufferBits[4]);
- else
- tolerance[4] = 1.0;
-}
-
-
-void
-FragmentProgramTest::reportFailure(const char *programName,
- const GLfloat expectedColor[4],
- const GLfloat actualColor[4] ) const
-{
- env->log << "FAILURE:\n";
- env->log << " Program: " << programName << "\n";
- env->log << " Expected color: ";
- env->log << expectedColor[0] << ", ";
- env->log << expectedColor[1] << ", ";
- env->log << expectedColor[2] << ", ";
- env->log << expectedColor[3] << "\n";
- env->log << " Observed color: ";
- env->log << actualColor[0] << ", ";
- env->log << actualColor[1] << ", ";
- env->log << actualColor[2] << ", ";
- env->log << actualColor[3] << "\n";
-}
-
-
-void
-FragmentProgramTest::reportZFailure(const char *programName,
- GLfloat expectedZ, GLfloat actualZ) const
-{
- env->log << "FAILURE:\n";
- env->log << " Program: " << programName << "\n";
- env->log << " Expected Z: " << expectedZ << "\n";
- env->log << " Observed Z: " << actualZ << "\n";
-}
-
-
-// Compare actual and expected colors
-bool
-FragmentProgramTest::equalColors(const GLfloat act[4], const GLfloat exp[4]) const
-{
- if (fabsf(act[0] - exp[0]) > tolerance[0] && exp[0] != DONT_CARE_COLOR)
- return false;
- if (fabsf(act[1] - exp[1]) > tolerance[1] && exp[1] != DONT_CARE_COLOR)
- return false;
- if (fabsf(act[2] - exp[2]) > tolerance[2] && exp[2] != DONT_CARE_COLOR)
- return false;
- if (fabsf(act[3] - exp[3]) > tolerance[3] && exp[3] != DONT_CARE_COLOR)
- return false;
- return true;
-}
-
-
-bool
-FragmentProgramTest::equalDepth(GLfloat z0, GLfloat z1) const
-{
- if (fabsf(z0 - z1) > tolerance[4])
- return false;
- else
- return true;
-}
-
-
-bool
-FragmentProgramTest::testProgram(const FragmentProgram &p)
-{
- glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB,
- GL_PROGRAM_FORMAT_ASCII_ARB,
- strlen(p.progString),
- (const GLubyte *) p.progString);
-
- GLenum err = glGetError();
- if (err) {
- env->log << "OpenGL error " << (int) err << "\n";
- env->log << "Invalid Fragment Program:\n";
- env->log << p.progString;
- env->log << glGetString(GL_PROGRAM_ERROR_STRING_ARB) << "\n";
- return false;
- }
-
- // to avoid potential issue with undefined result.depth.z
- if (p.expectedZ == DONT_CARE_Z)
- glDisable(GL_DEPTH_TEST);
- else
- glEnable(GL_DEPTH_TEST);
-
-#if !DEVEL_MODE
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-#endif
- glBegin(GL_POLYGON);
- glVertex2f(-1, -1);
- glVertex2f( 1, -1);
- glVertex2f( 1, 1);
- glVertex2f(-1, 1);
- glEnd();
-
-#if !DEVEL_MODE
- GLfloat pixel[4];
- glReadPixels(windowWidth / 2, windowHeight / 2, 1, 1,
- GL_RGBA, GL_FLOAT, pixel);
-
- if (0) // debug
- 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],
- pixel[0], pixel[1], pixel[2], pixel[3]);
-
- if (!equalColors(pixel, p.expectedColor)) {
- reportFailure(p.name, p.expectedColor, pixel);
- return false;
- }
-
- if (p.expectedZ != DONT_CARE_Z) {
- GLfloat z;
- glReadPixels(windowWidth / 2, windowHeight / 2, 1, 1,
- GL_DEPTH_COMPONENT, GL_FLOAT, &z);
- if (!equalDepth(z, p.expectedZ)) {
- reportZFailure(p.name, p.expectedZ, z);
- return false;
- }
- }
-#endif
- return true;
-}
-
-void
-FragmentProgramTest::runOne(MultiTestResult &r, Window &w)
-{
- // to test a single sub-test, set the name here:
- const char *single = getenv("PIGLIT_TEST");
-
- (void) w;
- setup();
-
-#if DEVEL_MODE
- 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 DEVEL_MODE
- glViewport(0, i * 20, windowWidth, 20);
-#endif
- if (!testProgram(Programs[i])) {
- r.numFailed++;
- }
- else {
- r.numPassed++;
- }
- }
- }
-
-#if DEVEL_MODE
- glFinish();
- sleep(100);
-#endif
- r.pass = (r.numFailed == 0);
-}
-
-
-// The test object itself:
-FragmentProgramTest fragmentProgramTest("fragProg1", "window, rgb, z",
- "GL_ARB_fragment_program",
- "Fragment Program test 1: test a specific set of fragment programs.\n");
-
-
-
-} // namespace GLEAN
diff --git a/tests/glean/tfragprog1.h b/tests/glean/tfragprog1.h
deleted file mode 100644
index 2e795eb..0000000
--- a/tests/glean/tfragprog1.h
+++ /dev/null
@@ -1,92 +0,0 @@
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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.
-// Brian Paul 22 October 2005
-
-#ifndef __tfragprog_h__
-#define __tfragprog_h__
-
-// If DEVEL_MODE==1 we generate a tall window of color swatches, one per
-// fragment program, which can be eyeballed against a reference image.
-// Use this if glReadPixels functionality is not working yet.
-#undef windowWidth
-#undef windowHeight
-#define DEVEL_MODE 0
-#if DEVEL_MODE
-#define windowWidth 200
-#define windowHeight 850
-#else
-#define windowWidth 100
-#define windowHeight 100
-#endif
-
-
-#include "tmultitest.h"
-
-namespace GLEAN {
-
-
-class FragmentProgram
-{
-public:
- const char *name;
- const char *progString;
- GLfloat expectedColor[4];
- GLfloat expectedZ;
-};
-
-
-class FragmentProgramTest: public MultiTest
-{
-public:
- FragmentProgramTest(const char* testName, const char* filter,
- const char *extensions, const char* description):
- MultiTest(testName, filter, extensions, description),
- tolerance()
- {
- }
-
- virtual void runOne(MultiTestResult &r, Window &w);
-
-private:
- GLfloat tolerance[5];
- void setup(void);
- bool equalColors(const GLfloat a[4], const GLfloat b[4]) const;
- bool equalDepth(GLfloat z0, GLfloat z1) const;
- bool testProgram(const FragmentProgram &p);
- void reportFailure(const char *programName,
- const GLfloat expectedColor[4],
- const GLfloat actualColor[4] ) const;
- void reportZFailure(const char *programName,
- GLfloat expectedZ, GLfloat actualZ) const;
-};
-
-} // namespace GLEAN
-
-#endif // __tfragprog_h__
diff --git a/tests/glean/tpixelformats.cpp b/tests/glean/tpixelformats.cpp
deleted file mode 100644
index d9818dc..0000000
--- a/tests/glean/tpixelformats.cpp
+++ /dev/null
@@ -1,1675 +0,0 @@
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-
-#include <stdlib.h>
-#include <cassert>
-#include <cmath>
-#include "tpixelformats.h"
-#include "../util/rgb9e5.h"
-#include "piglit-util-gl.h"
-
-
-// Set to 1 to help debug test failures:
-// Also, when a test failure is found, rearrange the order of the
-// formats, types, internformats below so the failure case comes first.
-#define DEBUG 0
-
-
-// just for extra debugging
-// Maybe add fragment program path as a 3rd envMode (below) someday.
-#define USE_FRAG_PROG 0
-
-#define abort() do { printf("%s:%i\n", __FUNCTION__, __LINE__); abort(); } while (0)
-
-namespace GLEAN {
-
-
-struct NameTokenComps {
- const char *Name;
- GLenum Token;
- GLuint Components;
-};
-
-
-static const NameTokenComps Types[] =
-{
- { "GL_UNSIGNED_BYTE", GL_UNSIGNED_BYTE, 0 },
- { "GL_BYTE", GL_BYTE, 0 },
- { "GL_UNSIGNED_INT", GL_UNSIGNED_INT, 0 },
- { "GL_SHORT", GL_SHORT, 0 },
- { "GL_UNSIGNED_SHORT", GL_UNSIGNED_SHORT, 0 },
- { "GL_INT", GL_INT, 0 },
- { "GL_FLOAT", GL_FLOAT, 0 },
- { "GL_HALF_FLOAT_ARB", GL_HALF_FLOAT_ARB, 0 },
-
- { "GL_UNSIGNED_INT_8_8_8_8", GL_UNSIGNED_INT_8_8_8_8, 4 },
- { "GL_UNSIGNED_INT_8_8_8_8_REV", GL_UNSIGNED_INT_8_8_8_8_REV, 4 },
- { "GL_UNSIGNED_INT_10_10_10_2", GL_UNSIGNED_INT_10_10_10_2, 4 },
- { "GL_UNSIGNED_INT_2_10_10_10_REV", GL_UNSIGNED_INT_2_10_10_10_REV, 4 },
- { "GL_UNSIGNED_SHORT_5_5_5_1", GL_UNSIGNED_SHORT_5_5_5_1, 4 },
- { "GL_UNSIGNED_SHORT_1_5_5_5_REV", GL_UNSIGNED_SHORT_1_5_5_5_REV, 4 },
- { "GL_UNSIGNED_SHORT_4_4_4_4", GL_UNSIGNED_SHORT_4_4_4_4, 4 },
- { "GL_UNSIGNED_SHORT_4_4_4_4_REV", GL_UNSIGNED_SHORT_4_4_4_4_REV, 4 },
- { "GL_UNSIGNED_SHORT_5_6_5", GL_UNSIGNED_SHORT_5_6_5, 3 },
- { "GL_UNSIGNED_SHORT_5_6_5_REV", GL_UNSIGNED_SHORT_5_6_5_REV, 3 },
- { "GL_UNSIGNED_BYTE_3_3_2", GL_UNSIGNED_BYTE_3_3_2, 3 },
- { "GL_UNSIGNED_BYTE_2_3_3_REV", GL_UNSIGNED_BYTE_2_3_3_REV, 3 },
-
- { "GL_UNSIGNED_INT_5_9_9_9_REV", GL_UNSIGNED_INT_5_9_9_9_REV, 3 }
-};
-
-#define NUM_TYPES (sizeof(Types) / sizeof(Types[0]))
-
-
-static const NameTokenComps Formats[] =
-{
- { "GL_RGBA", GL_RGBA, 4 },
- { "GL_BGRA", GL_BGRA, 4 },
- { "GL_RGB", GL_RGB, 3 },
- { "GL_BGR", GL_BGR, 3 },
- { "GL_RED", GL_RED, 1 },
- { "GL_GREEN", GL_GREEN, 1 },
- { "GL_BLUE", GL_BLUE, 1 },
- { "GL_ALPHA", GL_ALPHA, 1 },
- { "GL_LUMINANCE", GL_LUMINANCE, 1 },
- { "GL_LUMINANCE_ALPHA", GL_LUMINANCE_ALPHA, 2 },
- { "GL_ABGR_EXT", GL_ABGR_EXT, 4 },
- { "GL_RG", GL_RG, 2 }
-};
-
-#define NUM_FORMATS (sizeof(Formats) / sizeof(Formats[0]))
-
-
-static const NameTokenComps InternalFormats[] =
-{
- { "glDrawPixels", 0, 4 }, // special case for glDrawPixels
-
- { "4", 4, 4 },
- { "GL_RGBA", GL_RGBA, 4 },
- { "GL_RGBA2", GL_RGBA2, 4 },
- { "GL_RGBA4", GL_RGBA4, 4 },
- { "GL_RGB5_A1", GL_RGB5_A1, 4 },
- { "GL_RGBA8", GL_RGBA8, 4 },
- { "GL_RGB10_A2", GL_RGB10_A2, 4 },
- { "GL_RGBA12", GL_RGBA12, 4 },
- { "GL_RGBA16", GL_RGBA16, 4 },
- { "GL_SRGB_ALPHA_EXT", GL_SRGB_ALPHA_EXT, 4 },
- { "GL_SRGB8_ALPHA8_EXT", GL_SRGB8_ALPHA8_EXT, 4 },
-
- { "3", 3, 3 },
- { "GL_RGB", GL_RGB, 3 },
- { "GL_R3_G3_B2", GL_R3_G3_B2, 3 },
- { "GL_RGB4", GL_RGB4, 3 },
- { "GL_RGB5", GL_RGB5, 3 },
- { "GL_RGB8", GL_RGB8, 3 },
- { "GL_RGB10", GL_RGB10, 3 },
- { "GL_RGB12", GL_RGB12, 3 },
- { "GL_RGB16", GL_RGB16, 3 },
- { "GL_SRGB_EXT", GL_SRGB_EXT, 3 },
- { "GL_SRGB8_EXT", GL_SRGB8_EXT, 3 },
-
- { "2", 2, 2 },
- { "GL_LUMINANCE_ALPHA", GL_LUMINANCE_ALPHA, 2 },
- { "GL_LUMINANCE4_ALPHA4", GL_LUMINANCE4_ALPHA4, 1 },
- { "GL_LUMINANCE6_ALPHA2", GL_LUMINANCE6_ALPHA2, 1 },
- { "GL_LUMINANCE8_ALPHA8", GL_LUMINANCE8_ALPHA8, 1 },
- { "GL_LUMINANCE12_ALPHA4", GL_LUMINANCE12_ALPHA4, 1 },
- { "GL_LUMINANCE12_ALPHA12", GL_LUMINANCE12_ALPHA12, 1 },
- { "GL_LUMINANCE16_ALPHA16", GL_LUMINANCE16_ALPHA16, 1 },
- { "GL_SLUMINANCE_ALPHA_EXT", GL_SLUMINANCE_ALPHA_EXT, 3 },
- { "GL_SLUMINANCE8_ALPHA8_EXT", GL_SLUMINANCE8_ALPHA8_EXT, 3 },
-
- { "1", 1, 1 },
- { "GL_LUMINANCE", GL_LUMINANCE, 1 },
- { "GL_LUMINANCE4", GL_LUMINANCE4, 1 },
- { "GL_LUMINANCE8", GL_LUMINANCE8, 1 },
- { "GL_LUMINANCE12", GL_LUMINANCE12, 1 },
- { "GL_LUMINANCE16", GL_LUMINANCE16, 1 },
- { "GL_SLUMINANCE_EXT", GL_SLUMINANCE_EXT, 3 },
- { "GL_SLUMINANCE8_EXT", GL_SLUMINANCE8_EXT, 3 },
-
- { "GL_ALPHA", GL_ALPHA, 1 },
- { "GL_ALPHA4", GL_ALPHA4, 1 },
- { "GL_ALPHA8", GL_ALPHA8, 1 },
- { "GL_ALPHA12", GL_ALPHA12, 1 },
- { "GL_ALPHA16", GL_ALPHA16, 1 },
-
- { "GL_INTENSITY", GL_INTENSITY, 1 },
- { "GL_INTENSITY4", GL_INTENSITY4, 1 },
- { "GL_INTENSITY8", GL_INTENSITY8, 1 },
- { "GL_INTENSITY12", GL_INTENSITY12, 1 },
- { "GL_INTENSITY16", GL_INTENSITY16, 1 },
-
- { "GL_RED", GL_RED, 1 },
- { "GL_RG", GL_RG, 2 },
- { "GL_R8", GL_R8, 1 },
- { "GL_RG8", GL_RG8, 2 },
- { "GL_R16", GL_R16, 1},
- { "GL_RG16", GL_RG16, 2 },
- { "GL_R16F", GL_R16F, 1 },
- { "GL_RG16F", GL_RG16F, 2 },
- { "GL_R32F", GL_R32F, 1},
- { "GL_RG32F", GL_RG32F, 2 },
-
- { "GL_RED_SNORM", GL_RED_SNORM, 1 },
- { "GL_RG_SNORM", GL_RG_SNORM, 2 },
- { "GL_RGB_SNORM", GL_RGB_SNORM, 3 },
- { "GL_RGBA_SNORM", GL_RGBA_SNORM, 4 },
- { "GL_ALPHA_SNORM", GL_ALPHA_SNORM, 1 },
- { "GL_LUMINANCE_SNORM", GL_LUMINANCE_SNORM, 1 },
- { "GL_LUMINANCE_ALPHA_SNORM", GL_LUMINANCE_ALPHA_SNORM, 2 },
- { "GL_INTENSITY_SNORM", GL_INTENSITY_SNORM, 1 },
-
- { "GL_R8_SNORM", GL_R8_SNORM, 1 },
- { "GL_RG8_SNORM", GL_RG8_SNORM, 2 },
- { "GL_RGB8_SNORM", GL_RGB8_SNORM, 3 },
- { "GL_RGBA8_SNORM", GL_RGBA8_SNORM, 4 },
- { "GL_ALPHA8_SNORM", GL_ALPHA8_SNORM, 1 },
- { "GL_LUMINANCE8_SNORM", GL_LUMINANCE8_SNORM, 1 },
- { "GL_LUMINANCE8_ALPHA8_SNORM", GL_LUMINANCE8_ALPHA8_SNORM, 2 },
- { "GL_INTENSITY8_SNORM", GL_INTENSITY8_SNORM, 1 },
-
- { "GL_R16_SNORM", GL_R16_SNORM, 1 },
- { "GL_RG16_SNORM", GL_RG16_SNORM, 2 },
- { "GL_RGB16_SNORM", GL_RGB16_SNORM, 3 },
- { "GL_RGBA16_SNORM", GL_RGBA16_SNORM, 4 },
- { "GL_ALPHA16_SNORM", GL_ALPHA16_SNORM, 1 },
- { "GL_LUMINANCE16_SNORM", GL_LUMINANCE16_SNORM, 1 },
- { "GL_LUMINANCE16_ALPHA16_SNORM", GL_LUMINANCE16_ALPHA16_SNORM, 2 },
- { "GL_INTENSITY16_SNORM", GL_INTENSITY16_SNORM, 1 },
-
- { "GL_RGB9_E5", GL_RGB9_E5, 3 }
-
- // XXX maybe add compressed formats too...
-};
-
-#define NUM_INT_FORMATS (sizeof(InternalFormats) / sizeof(InternalFormats[0]))
-
-
-static const char *EnvModes[] = {
- "GL_REPLACE",
- "GL_COMBINE_ARB"
-};
-
-
-// Return four bitmasks indicating which bits correspond to the
-// 1st, 2nd, 3rd and 4th components in a packed datatype.
-// Set all masks to zero for non-packed types.
-static void
-ComponentMasks(GLenum datatype, GLuint masks[4])
-{
- switch (datatype) {
- case GL_UNSIGNED_BYTE:
- case GL_BYTE:
- case GL_UNSIGNED_SHORT:
- case GL_SHORT:
- case GL_UNSIGNED_INT:
- case GL_INT:
- case GL_FLOAT:
- case GL_HALF_FLOAT_ARB:
- case GL_UNSIGNED_INT_5_9_9_9_REV: /* special case, handled separately */
- masks[0] =
- masks[1] =
- masks[2] =
- masks[3] = 0x0;
- break;
- case GL_UNSIGNED_INT_8_8_8_8:
- masks[0] = 0xff000000;
- masks[1] = 0x00ff0000;
- masks[2] = 0x0000ff00;
- masks[3] = 0x000000ff;
- break;
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- masks[0] = 0x000000ff;
- masks[1] = 0x0000ff00;
- masks[2] = 0x00ff0000;
- masks[3] = 0xff000000;
- break;
- case GL_UNSIGNED_INT_10_10_10_2:
- masks[0] = 0xffc00000;
- masks[1] = 0x003ff000;
- masks[2] = 0x00000ffc;
- masks[3] = 0x00000003;
- break;
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- masks[0] = 0x000003ff;
- masks[1] = 0x000ffc00;
- masks[2] = 0x3ff00000;
- masks[3] = 0xc0000000;
- break;
- case GL_UNSIGNED_SHORT_5_5_5_1:
- masks[0] = 0xf800;
- masks[1] = 0x07c0;
- masks[2] = 0x003e;
- masks[3] = 0x0001;
- break;
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- masks[0] = 0x001f;
- masks[1] = 0x03e0;
- masks[2] = 0x7c00;
- masks[3] = 0x8000;
- break;
- case GL_UNSIGNED_SHORT_4_4_4_4:
- masks[0] = 0xf000;
- masks[1] = 0x0f00;
- masks[2] = 0x00f0;
- masks[3] = 0x000f;
- break;
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- masks[0] = 0x000f;
- masks[1] = 0x00f0;
- masks[2] = 0x0f00;
- masks[3] = 0xf000;
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- masks[0] = 0xf800;
- masks[1] = 0x07e0;
- masks[2] = 0x001f;
- masks[3] = 0;
- break;
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- masks[0] = 0x001f;
- masks[1] = 0x07e0;
- masks[2] = 0xf800;
- masks[3] = 0;
- break;
- case GL_UNSIGNED_BYTE_3_3_2:
- masks[0] = 0xe0;
- masks[1] = 0x1c;
- masks[2] = 0x03;
- masks[3] = 0;
- break;
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- masks[0] = 0x07;
- masks[1] = 0x38;
- masks[2] = 0xc0;
- masks[3] = 0;
- break;
- default:
- abort();
- }
-}
-
-
-// Return four values indicating the ordering of the Red, Green, Blue and
-// Alpha components for the given image format.
-// For example: GL_BGRA = {2, 1, 0, 3}.
-static void
-ComponentPositions(GLenum format, GLint pos[4])
-{
- switch (format) {
- case GL_RGBA:
- pos[0] = 0;
- pos[1] = 1;
- pos[2] = 2;
- pos[3] = 3;
- break;
- case GL_BGRA:
- pos[0] = 2;
- pos[1] = 1;
- pos[2] = 0;
- pos[3] = 3;
- break;
- case GL_RGB:
- pos[0] = 0;
- pos[1] = 1;
- pos[2] = 2;
- pos[3] = -1;
- break;
- case GL_BGR:
- pos[0] = 2;
- pos[1] = 1;
- pos[2] = 0;
- pos[3] = -1;
- break;
- case GL_LUMINANCE:
- pos[0] = 0;
- pos[1] = -1;
- pos[2] = -1;
- pos[3] = -1;
- break;
- case GL_LUMINANCE_ALPHA:
- pos[0] = 0;
- pos[1] = -1;
- pos[2] = -1;
- pos[3] = 1;
- break;
- case GL_RED:
- pos[0] = 0;
- pos[1] = -1;
- pos[2] = -1;
- pos[3] = -1;
- break;
- case GL_GREEN:
- pos[0] = -1;
- pos[1] = 0;
- pos[2] = -1;
- pos[3] = -1;
- break;
- case GL_BLUE:
- pos[0] = -1;
- pos[1] = -1;
- pos[2] = 0;
- pos[3] = -1;
- break;
- case GL_ALPHA:
- pos[0] = -1;
- pos[1] = -1;
- pos[2] = -1;
- pos[3] = 0;
- break;
- case GL_ABGR_EXT:
- pos[0] = 3;
- pos[1] = 2;
- pos[2] = 1;
- pos[3] = 0;
- break;
- case GL_RG:
- pos[0] = 0;
- pos[1] = 1;
- pos[2] = -1;
- pos[3] = -1;
- break;
- default:
- abort();
- }
-}
-
-
-// Given a texture internal format, return the corresponding base format.
-static GLenum
-BaseTextureFormat(GLint intFormat)
-{
- switch (intFormat) {
- case 0:
- return 0; // for glDrawPixels
- case GL_ALPHA:
- case GL_ALPHA4:
- case GL_ALPHA8:
- case GL_ALPHA12:
- case GL_ALPHA16:
- case GL_ALPHA_SNORM:
- case GL_ALPHA8_SNORM:
- case GL_ALPHA16_SNORM:
- return GL_ALPHA;
- case 1:
- case GL_LUMINANCE:
- case GL_LUMINANCE4:
- case GL_LUMINANCE8:
- case GL_LUMINANCE12:
- case GL_LUMINANCE16:
- case GL_LUMINANCE_SNORM:
- case GL_LUMINANCE8_SNORM:
- case GL_LUMINANCE16_SNORM:
- return GL_LUMINANCE;
- case 2:
- case GL_LUMINANCE_ALPHA:
- case GL_LUMINANCE4_ALPHA4:
- case GL_LUMINANCE6_ALPHA2:
- case GL_LUMINANCE8_ALPHA8:
- case GL_LUMINANCE12_ALPHA4:
- case GL_LUMINANCE12_ALPHA12:
- case GL_LUMINANCE16_ALPHA16:
- case GL_LUMINANCE_ALPHA_SNORM:
- case GL_LUMINANCE8_ALPHA8_SNORM:
- case GL_LUMINANCE16_ALPHA16_SNORM:
- return GL_LUMINANCE_ALPHA;
- case GL_INTENSITY:
- case GL_INTENSITY4:
- case GL_INTENSITY8:
- case GL_INTENSITY12:
- case GL_INTENSITY16:
- case GL_INTENSITY_SNORM:
- case GL_INTENSITY8_SNORM:
- case GL_INTENSITY16_SNORM:
- return GL_INTENSITY;
-
- case GL_RED:
- case GL_R8:
- case GL_R16:
- case GL_R16F:
- case GL_R32F:
- case GL_RED_SNORM:
- case GL_R8_SNORM:
- case GL_R16_SNORM:
- return GL_RED;
-
- case GL_RG:
- case GL_RG8:
- case GL_RG16:
- case GL_RG16F:
- case GL_RG32F:
- case GL_RG_SNORM:
- case GL_RG8_SNORM:
- case GL_RG16_SNORM:
- return GL_RG;
-
- case 3:
- case GL_RGB:
- case GL_R3_G3_B2:
- case GL_RGB4:
- case GL_RGB5:
- case GL_RGB8:
- case GL_RGB10:
- case GL_RGB12:
- case GL_RGB16:
- case GL_RGB_SNORM:
- case GL_RGB8_SNORM:
- case GL_RGB16_SNORM:
- case GL_RGB9_E5:
- return GL_RGB;
- case 4:
- case GL_RGBA:
- case GL_RGBA2:
- case GL_RGBA4:
- case GL_RGB5_A1:
- case GL_RGBA8:
- case GL_RGB10_A2:
- case GL_RGBA12:
- case GL_RGBA16:
- case GL_RGBA_SNORM:
- case GL_RGBA8_SNORM:
- case GL_RGBA16_SNORM:
- return GL_RGBA;
-
- case GL_SRGB_EXT:
- case GL_SRGB8_EXT:
- case GL_COMPRESSED_SRGB_EXT:
- case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
- return GL_RGB;
- case GL_SRGB_ALPHA_EXT:
- case GL_SRGB8_ALPHA8_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
- return GL_RGBA;
- case GL_SLUMINANCE_ALPHA_EXT:
- case GL_SLUMINANCE8_ALPHA8_EXT:
- case GL_COMPRESSED_SLUMINANCE_EXT:
- case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
- return GL_LUMINANCE_ALPHA;
- case GL_SLUMINANCE_EXT:
- case GL_SLUMINANCE8_EXT:
- return GL_LUMINANCE;
- default:
- abort();
- }
-}
-
-
-
-
-// Return number components in the given datatype. This is 3 or 4 for
-// packed types and zero for non-packed types
-// Ex: GL_UNSIGNED_SHORT_5_5_5_1 = 4
-// Ex: GL_INT = 0
-static int
-NumberOfComponentsInPackedType(GLenum datatype)
-{
- for (unsigned i = 0; i < NUM_TYPES; i++) {
- if (Types[i].Token == datatype)
- return Types[i].Components;
- }
- abort();
-}
-
-
-static int
-IsPackedType(GLenum datatype)
-{
- return NumberOfComponentsInPackedType(datatype) > 0;
-}
-
-
-// Return number components in the given image format.
-// Ex: GL_BGR = 3
-static int
-NumberOfComponentsInFormat(GLenum format)
-{
- for (unsigned i = 0; i < NUM_FORMATS; i++) {
- if (Formats[i].Token == format)
- return Formats[i].Components;
- }
- abort();
-}
-
-
-// Return size, in bytes, of given datatype.
-static int
-SizeofType(GLenum datatype)
-{
- switch (datatype) {
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_5_9_9_9_REV:
- case GL_UNSIGNED_INT:
- case GL_INT:
- case GL_FLOAT:
- return 4;
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- case GL_UNSIGNED_SHORT:
- case GL_SHORT:
- case GL_HALF_FLOAT_ARB:
- return 2;
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- case GL_UNSIGNED_BYTE:
- case GL_BYTE:
- return 1;
- default:
- abort();
- }
-}
-
-
-// Check if the given image format and datatype are compatible.
-// Also check for types/formats defined by GL extensions here.
-bool
-PixelFormatsTest::CompatibleFormatAndType(GLenum format, GLenum datatype) const
-{
- // Special case: GL_BGR can't be used with packed types!
- // This has to do with putting the most color bits in red and green,
- // not blue.
- if (format == GL_BGR && IsPackedType(datatype))
- return false;
-
- if (datatype == GL_HALF_FLOAT_ARB && !haveHalfFloat)
- return false;
-
- if (format == GL_ABGR_EXT && !haveABGR)
- return false;
-
- // Special case: GL_ABGR_EXT can't be used with packed types
- // because the packed formats specs (which were all written after the
- // GL_EXT_abgr) explicitly say that the packed formats can only be used
- // with GL_RGB, GL_BGR, GL_RGBA, or GL_BGRA and do not mention
- // GL_ABGR_EXT.
- if (format == GL_ABGR_EXT && IsPackedType(datatype))
- return false;
-
- if (format == GL_RG && !haveRG)
- return false;
-
- if (datatype == GL_UNSIGNED_INT_5_9_9_9_REV && !haveTexSharedExp)
- return false;
-
- const int formatComps = NumberOfComponentsInFormat(format);
- const int typeComps = NumberOfComponentsInPackedType(datatype);
- return formatComps == typeComps || typeComps == 0;
-}
-
-
-bool
-PixelFormatsTest::SupportedIntFormat(GLint intFormat) const
-{
- switch (intFormat) {
- case GL_SRGB_ALPHA_EXT:
- case GL_SRGB8_ALPHA8_EXT:
- case GL_SRGB_EXT:
- case GL_SRGB8_EXT:
- case GL_SLUMINANCE_ALPHA_EXT:
- case GL_SLUMINANCE8_ALPHA8_EXT:
- case GL_SLUMINANCE_EXT:
- case GL_SLUMINANCE8_EXT:
- return haveSRGB;
- case GL_RED:
- case GL_RG:
- case GL_R8:
- case GL_RG8:
- case GL_R16:
- case GL_RG16:
- return haveRG;
- case GL_R16F:
- case GL_RG16F:
- case GL_R32F:
- case GL_RG32F:
- return haveRG && haveFloat;
- case GL_RED_SNORM:
- case GL_R8_SNORM:
- case GL_R16_SNORM:
- case GL_RG_SNORM:
- case GL_RG8_SNORM:
- case GL_RG16_SNORM:
- case GL_RGB_SNORM:
- case GL_RGB8_SNORM:
- case GL_RGB16_SNORM:
- case GL_RGBA_SNORM:
- case GL_RGBA8_SNORM:
- case GL_RGBA16_SNORM:
- case GL_ALPHA_SNORM:
- case GL_ALPHA8_SNORM:
- case GL_ALPHA16_SNORM:
- case GL_LUMINANCE_SNORM:
- case GL_LUMINANCE8_SNORM:
- case GL_LUMINANCE16_SNORM:
- case GL_LUMINANCE_ALPHA_SNORM:
- case GL_LUMINANCE8_ALPHA8_SNORM:
- case GL_LUMINANCE16_ALPHA16_SNORM:
- case GL_INTENSITY_SNORM:
- case GL_INTENSITY8_SNORM:
- case GL_INTENSITY16_SNORM:
- return haveSnorm;
- case GL_RGB9_E5:
- return haveTexSharedExp;
- default:
-
- return true;
- }
-}
-
-
-// Determine if the ith pixel is in the upper-right quadrant of the
-// rectangle of size 'width' x 'height'.
-static bool
-IsUpperRight(int i, int width, int height)
-{
- const int y = i / width, x = i % width;
- return (x >= width / 2 && y >= height / 2);
-}
-
-
-
-// Create an image buffer and fill it so that a single image channel is
-// the max value (1.0) while the other channels are zero. For example,
-// if fillComponent==2 and we're filling a four-component image, the
-// pixels will be (0, 0, max, 0).
-//
-// We always leave the upper-right quadrant black/zero. This is to help
-// detect any image conversion issues related to stride, packing, etc.
-static GLubyte *
-MakeImage(int width, int height, GLenum format, GLenum type,
- int fillComponent)
-{
- assert(fillComponent < 4);
-
- if (type == GL_UNSIGNED_INT_5_9_9_9_REV) {
- GLubyte *image = new GLubyte [width * height * 4];
- int i;
-
- assert(format == GL_RGB);
-
- GLuint *ui = (GLuint *) image;
- for (i = 0; i < width * height; i++) {
- float p[3] = {0, 0, 0};
-
- if (!IsUpperRight(i, width, height))
- p[fillComponent] = 1;
-
- ui[i] = float3_to_rgb9e5(p);
- }
-
- return image;
- }
- else if (IsPackedType(type)) {
- const int bpp = SizeofType(type);
- GLubyte *image = new GLubyte [width * height * bpp];
- GLuint masks[4];
- int pos[4];
- int i;
-
- ComponentMasks(type, masks);
- ComponentPositions(format, pos);
-
- const GLuint value = masks[fillComponent];
-
- switch (bpp) {
- case 1:
- for (i = 0; i < width * height; i++) {
- if (IsUpperRight(i, width, height))
- image[i] = 0;
- else
- image[i] = (GLubyte) value;
- }
- break;
- case 2:
- {
- GLushort *image16 = (GLushort *) image;
- for (i = 0; i < width * height; i++) {
- if (IsUpperRight(i, width, height))
- image16[i] = 0;
- else
- image16[i] = (GLushort) value;
- }
- }
- break;
- case 4:
- {
- GLuint *image32 = (GLuint *) image;
- for (i = 0; i < width * height; i++) {
- if (IsUpperRight(i, width, height))
- image32[i] = 0;
- else
- image32[i] = (GLuint) value;
- }
- }
- break;
- default:
- abort();
- }
-
- return image;
- }
- else {
- const int comps = NumberOfComponentsInFormat(format);
- const int bpp = comps * SizeofType(type);
- assert(bpp > 0);
- GLubyte *image = new GLubyte [width * height * bpp];
- int i;
-
- switch (type) {
- case GL_UNSIGNED_BYTE:
- for (i = 0; i < width * height * comps; i++) {
- if (i % comps == fillComponent && !IsUpperRight(i/comps, width, height))
- image[i] = 0xff;
- else
- image[i] = 0x0;
- }
- break;
- case GL_BYTE:
- {
- GLbyte *b = (GLbyte *) image;
- for (i = 0; i < width * height * comps; i++) {
- if (i % comps == fillComponent && !IsUpperRight(i/comps, width, height))
- b[i] = 0x7f;
- else
- b[i] = 0x0;
- }
- }
- break;
- case GL_UNSIGNED_SHORT:
- {
- GLushort *us = (GLushort *) image;
- for (i = 0; i < width * height * comps; i++) {
- if (i % comps == fillComponent && !IsUpperRight(i/comps, width, height))
- us[i] = 0xffff;
- else
- us[i] = 0x0;
- }
- }
- break;
- case GL_SHORT:
- {
- GLshort *s = (GLshort *) image;
- for (i = 0; i < width * height * comps; i++) {
- if (i % comps == fillComponent && !IsUpperRight(i/comps, width, height))
- s[i] = 0x7fff;
- else
- s[i] = 0x0;
- }
- }
- break;
- case GL_UNSIGNED_INT:
- {
- GLuint *ui = (GLuint *) image;
- for (i = 0; i < width * height * comps; i++) {
- if (i % comps == fillComponent && !IsUpperRight(i/comps, width, height))
- ui[i] = 0xffffffff;
- else
- ui[i] = 0x0;
- }
- }
- break;
- case GL_INT:
- {
- GLint *in = (GLint *) image;
- for (i = 0; i < width * height * comps; i++) {
- if (i % comps == fillComponent && !IsUpperRight(i/comps, width, height))
- in[i] = 0x7fffffff;
- else
- in[i] = 0x0;
- }
- }
- break;
- case GL_FLOAT:
- {
- GLfloat *f = (GLfloat *) image;
- for (i = 0; i < width * height * comps; i++) {
- if (i % comps == fillComponent && !IsUpperRight(i/comps, width, height))
- f[i] = 1.0;
- else
- f[i] = 0.0;
- }
- }
- break;
- case GL_HALF_FLOAT_ARB:
- {
- GLhalfARB *f = (GLhalfARB *) image;
- for (i = 0; i < width * height * comps; i++) {
- if (i % comps == fillComponent && !IsUpperRight(i/comps, width, height))
- f[i] = 0x3c00; /* == 1.0 */
- else
- f[i] = 0;
- }
- }
- break;
- default:
- abort();
- }
- return image;
- }
-}
-
-
-bool
-PixelFormatsTest::CheckError(const char *where) const
-{
- GLint err = glGetError();
- if (err) {
- char msg[1000];
- sprintf(msg, "GL Error: %s (0x%x) in %s\n",
- piglit_get_gl_error_name(err), err, where);
- env->log << msg;
- return true;
- }
- return false;
-}
-
-
-// Draw the given image, either as a texture quad or glDrawPixels.
-// Return true for success, false if GL error detected.
-bool
-PixelFormatsTest::DrawImage(int width, int height,
- GLenum format, GLenum type, GLint intFormat,
- const GLubyte *image) const
-{
- if (intFormat) {
- glEnable(GL_TEXTURE_2D);
- glViewport(0, 0, width, height);
- glTexImage2D(GL_TEXTURE_2D, 0, intFormat, width, height, 0,
- format, type, image);
- if (CheckError("glTexImage2D"))
- return false;
-#if USE_FRAG_PROG
- glEnable(GL_FRAGMENT_PROGRAM_ARB);
-#endif
- glBegin(GL_POLYGON);
- glTexCoord2f(0, 0); glVertex2f(-1, -1);
- glTexCoord2f(1, 0); glVertex2f(1, -1);
- glTexCoord2f(1, 1); glVertex2f(1, 1);
- glTexCoord2f(0, 1); glVertex2f(-1, 1);
- glEnd();
- glDisable(GL_TEXTURE_2D);
-#if USE_FRAG_PROG
- glDisable(GL_FRAGMENT_PROGRAM_ARB);
-#endif
- }
- else {
- // glDrawPixels
- glDrawPixels(width, height, format, type, image);
- if (CheckError("glDrawPixels"))
- return false;
- }
- return true;
-}
-
-
-static bool
-ColorsEqual(const GLubyte img[4], const GLubyte expected[4])
-{
- const int tolerance = 1;
- if ((abs(img[0] - expected[0]) > tolerance) ||
- (abs(img[1] - expected[1]) > tolerance) ||
- (abs(img[2] - expected[2]) > tolerance) ||
- (abs(img[3] - expected[3]) > tolerance)) {
- return false;
- }
- else {
- return true;
- }
-}
-
-
-// Compute the expected RGBA color we're expecting to find with glReadPixels
-// if the texture was defined with the given image format and texture
-// internal format. 'testChan' indicates which of the srcFormat's image
-// channels was set (to 1.0) when the image was filled.
-void
-PixelFormatsTest::ComputeExpected(GLenum srcFormat, int testChan,
- GLint intFormat, GLubyte exp[4]) const
-{
- const GLenum baseIntFormat = BaseTextureFormat(intFormat);
-
- switch (srcFormat) {
-
- case GL_RGBA:
- case GL_BGRA:
- case GL_ABGR_EXT:
- assert(testChan < 4);
- switch (baseIntFormat) {
- case 0: // == glReadPixels
- // fallthrough
- case GL_RGBA:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = 0;
- exp[testChan] = 255;
- break;
- case GL_RGB:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[testChan] = 255;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_RG:
- exp[0] = 0;
- exp[1] = 0;
- exp[testChan] = 255;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_RED:
- exp[0] = testChan == 0 ? 255 : 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_ALPHA:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = testChan == 3 ? 255 : 0;
- break;
- case GL_LUMINANCE:
- exp[0] =
- exp[1] =
- exp[2] = testChan == 0 ? 255 : 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_LUMINANCE_ALPHA:
- exp[0] =
- exp[1] =
- exp[2] = testChan == 0 ? 255 : 0;
- exp[3] = testChan == 3 ? 255 : 0;
- break;
- case GL_INTENSITY:
- exp[0] =
- exp[1] =
- exp[2] =
- exp[3] = testChan == 0 ? 255 : 0;
- break;
- default:
- abort();
- }
- break;
-
- case GL_RGB:
- case GL_BGR:
- assert(testChan < 3);
- switch (baseIntFormat) {
- case 0:
- case GL_RGBA:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[testChan] = 255;
- exp[3] = 255; // texture's alpha
- break;
- case GL_RGB:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[testChan] = 255;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_RG:
- exp[0] = 0;
- exp[1] = 0;
- exp[testChan] = 255;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_RED:
- exp[0] = testChan == 0 ? 255 : 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_ALPHA:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_LUMINANCE:
- exp[0] =
- exp[1] =
- exp[2] = testChan == 0 ? 255 : 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_LUMINANCE_ALPHA:
- exp[0] =
- exp[1] =
- exp[2] = testChan == 0 ? 255 : 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_INTENSITY:
- exp[0] =
- exp[1] =
- exp[2] =
- exp[3] = testChan == 0 ? 255 : 0;
- break;
- default:
- abort();
- }
- break;
-
- case GL_RG:
- assert(testChan < 2);
- switch (baseIntFormat) {
- case 0:
- case GL_RGBA:
- exp[0] = 0;
- exp[1] = 0;
- exp[testChan] = 255;
- exp[2] = 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_RGB:
- exp[0] = 0;
- exp[1] = 0;
- exp[testChan] = 255;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_RG:
- exp[0] = 0;
- exp[1] = 0;
- exp[testChan] = 255;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_RED:
- exp[0] = testChan == 0 ? 255 : 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_ALPHA:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_LUMINANCE:
- exp[0] =
- exp[1] =
- exp[2] = testChan == 0 ? 255 : 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_LUMINANCE_ALPHA:
- exp[0] =
- exp[1] =
- exp[2] = testChan == 0 ? 255 : 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_INTENSITY:
- exp[0] =
- exp[1] =
- exp[2] =
- exp[3] = testChan == 0 ? 255 : 0;
- break;
- default:
- abort();
- }
- break;
-
- case GL_RED:
- assert(testChan == 0);
- switch (baseIntFormat) {
- case 0:
- case GL_RGBA:
- exp[0] = 255;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_RGB:
- exp[0] = 255;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_RG:
- exp[0] = 255;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_RED:
- exp[0] = 255;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_ALPHA:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_LUMINANCE:
- exp[0] =
- exp[1] =
- exp[2] = 255;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_LUMINANCE_ALPHA:
- exp[0] =
- exp[1] =
- exp[2] = 255;
- exp[3] = 255; // texture's alpha
- break;
- case GL_INTENSITY:
- exp[0] =
- exp[1] =
- exp[2] = 255;
- exp[3] = 255; // texture's alpha
- break;
- default:
- abort();
- }
- break;
-
- case GL_GREEN:
- case GL_BLUE:
- assert(testChan == 0);
- switch (baseIntFormat) {
- case 0:
- case GL_RGBA:
- exp[0] = 0;
- exp[1] = 255;
- exp[2] = 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_RGB:
- exp[0] = 0;
- exp[1] = 255;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_ALPHA:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_LUMINANCE:
- exp[0] =
- exp[1] =
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_LUMINANCE_ALPHA:
- exp[0] =
- exp[1] =
- exp[2] = 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_INTENSITY:
- exp[0] =
- exp[1] =
- exp[2] = 0;
- exp[3] = 0; // texture's alpha
- break;
- default:
- abort();
- }
- break;
-
- case GL_ALPHA:
- assert(testChan == 0);
- switch (baseIntFormat) {
- case 0:
- case GL_RGBA:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_RGB:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_ALPHA:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_LUMINANCE:
- exp[0] =
- exp[1] =
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_LUMINANCE_ALPHA:
- exp[0] =
- exp[1] =
- exp[2] = 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_INTENSITY:
- exp[0] =
- exp[1] =
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- default:
- abort();
- }
- break;
-
- case GL_LUMINANCE:
- assert(testChan == 0);
- switch (baseIntFormat) {
- case 0:
- case GL_RGBA:
- exp[0] = 255;
- exp[1] = 255;
- exp[2] = 255;
- exp[3] = 255; // texture's alpha
- break;
- case GL_RGB:
- exp[0] = 255;
- exp[1] = 255;
- exp[2] = 255;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_RG:
- exp[0] = 255;
- exp[1] = 255;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_RED:
- exp[0] = 255;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_ALPHA:
- exp[0] = 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = 255; // texture's alpha
- break;
- case GL_LUMINANCE:
- exp[0] = 255;
- exp[1] = 255;
- exp[2] = 255;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_LUMINANCE_ALPHA:
- exp[0] = 255;
- exp[1] = 255;
- exp[2] = 255;
- exp[3] = 255; // texture's alpha
- break;
- case GL_INTENSITY:
- exp[0] = 255;
- exp[1] = 255;
- exp[2] = 255;
- exp[3] = 255; // texture's alpha
- break;
- default:
- abort();
- }
- break;
-
- case GL_LUMINANCE_ALPHA:
- assert(testChan < 2);
- switch (baseIntFormat) {
- case 0:
- case GL_RGBA:
- exp[0] =
- exp[1] =
- exp[2] = testChan == 0 ? 255 : 0;
- exp[3] = testChan == 1 ? 255 : 0;
- break;
- case GL_RGB:
- exp[0] =
- exp[1] =
- exp[2] = testChan == 0 ? 255 : 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_RG:
- exp[0] =
- exp[1] = testChan == 0 ? 255 : 0;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_RED:
- exp[0] = testChan == 0 ? 255 : 0;
- exp[1] = 0;
- exp[2] = 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_ALPHA:
- exp[0] =
- exp[1] =
- exp[2] = 0; // fragment color
- exp[3] = testChan == 1 ? 255 : 0;
- break;
- case GL_LUMINANCE:
- exp[0] =
- exp[1] =
- exp[2] = testChan == 0 ? 255 : 0;
- exp[3] = defaultAlpha; // fragment alpha or texture alpha
- break;
- case GL_LUMINANCE_ALPHA:
- exp[0] = testChan == 0 ? 255 : 0;
- exp[1] = testChan == 0 ? 255 : 0;
- exp[2] = testChan == 0 ? 255 : 0;
- exp[3] = testChan == 1 ? 255 : 0;
- break;
- case GL_INTENSITY:
- exp[0] =
- exp[1] =
- exp[2] =
- exp[3] = testChan == 0 ? 255 : 0;
- break;
- default:
- abort();
- }
- break;
-
- default:
- abort();
- }
-}
-
-
-// Read framebuffer and check that region [width x height] is the expected
-// solid color, except the upper-right quadrant will always be black/zero.
-// comp: which color channel in src image was set (0 = red, 1 = green,
-// 2 = blue, 3 = alpha), other channels are zero.
-// format is the color format we're testing.
-bool
-PixelFormatsTest::CheckRendering(int width, int height, int comp,
- GLenum format, GLint intFormat) const
-{
- const int checkAlpha = alphaBits > 0;
- GLubyte *image = new GLubyte [width * height * 4];
- GLboolean ok = 1;
- GLubyte expected[4];
- int i;
-
- assert(comp >= 0 && comp < 4);
-
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, image);
- for (i = 0; i < width * height; i += 4) {
-
- ComputeExpected(format, comp, intFormat, expected);
- if (IsUpperRight(i/4, width, height)) {
- expected[0] =
- expected[1] =
- expected[2] =
- expected[3] = 0;
- }
-
- if (!checkAlpha) {
- expected[3] = 0xff;
- }
-
- // do the color check
- if (!ColorsEqual(image+i, expected)) {
- // report failure info
- char msg[1000];
- env->log << name;
- sprintf(msg, " failed at pixel (%d,%d), color channel %d:\n",
- i/width, i%width, comp);
- env->log << msg;
- sprintf(msg, " Expected: 0x%02x 0x%02x 0x%02x 0x%02x\n",
- expected[0], expected[1], expected[2], expected[3]);
- env->log << msg;
- sprintf(msg, " Found: 0x%02x 0x%02x 0x%02x 0x%02x\n",
- image[i + 0], image[i + 1], image[i + 2], image[i + 3]);
- env->log << msg;
- ok = false;
- break;
- }
- }
- delete [] image;
- return ok;
-}
-
-
-
-// Exercise a particular combination of image format, type and internal
-// texture format.
-// Return true for success, false for failure.
-bool
-PixelFormatsTest::TestCombination(GLenum format, GLenum type, GLint intFormat)
-{
- const int numComps = NumberOfComponentsInFormat(format);
- const int width = 16;
- const int height = 16;
- int colorPos[4];
- ComponentPositions(format, colorPos);
-
- for (int comp = 0; comp < numComps; comp++) {
- if (colorPos[comp] >= 0) {
- // make original/incoming image
- const int comp2 = colorPos[comp];
- GLubyte *image = MakeImage(width, height, format, type, comp2);
-
- // render with image (texture / glDrawPixels)
- bool ok = DrawImage(width, height, format, type, intFormat, image);
-
- if (ok) {
- // check rendering
- ok = CheckRendering(width, height, comp, format, intFormat);
- }
-
- delete [] image;
-
- if (!ok) {
- return false;
- }
- }
- }
-
- return true;
-}
-
-
-// Per visual setup.
-void
-PixelFormatsTest::setup(void)
-{
- haveHalfFloat = GLUtils::haveExtensions("GL_ARB_half_float_pixel");
- haveABGR = GLUtils::haveExtensions("GL_EXT_abgr");
- haveSRGB = GLUtils::haveExtensions("GL_EXT_texture_sRGB");
- haveCombine = GLUtils::haveExtensions("GL_ARB_texture_env_combine");
- haveRG = GLUtils::haveExtensions("GL_ARB_texture_rg");
- haveFloat = GLUtils::haveExtensions("GL_ARB_texture_float");
- haveSnorm = GLUtils::haveExtensions("GL_EXT_texture_snorm");
- haveTexSharedExp = GLUtils::haveExtensions("GL_EXT_texture_shared_exponent");
-
- glGetIntegerv(GL_ALPHA_BITS, &alphaBits);
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-
- glDrawBuffer(GL_FRONT);
- glReadBuffer(GL_FRONT);
-
- glColor4f(0, 0, 0, 0);
-
-#if USE_FRAG_PROG
- {
- PFNGLPROGRAMSTRINGARBPROC glProgramStringARB_func;
- PFNGLBINDPROGRAMARBPROC glBindProgramARB_func;
- static const char *progText =
- "!!ARBfp1.0\n"
- "TEX result.color, fragment.texcoord[0], texture[0], 2D; \n"
- "END \n"
- ;
- glProgramStringARB_func = (PFNGLPROGRAMSTRINGARBPROC)
- GLUtils::getProcAddress("glProgramStringARB");
- assert(glProgramStringARB_func);
- glBindProgramARB_func = (PFNGLBINDPROGRAMARBPROC)
- GLUtils::getProcAddress("glBindProgramARB");
- assert(glBindProgramARB_func);
- glBindProgramARB_func(GL_FRAGMENT_PROGRAM_ARB, 1);
- glProgramStringARB_func(GL_FRAGMENT_PROGRAM_ARB,
- GL_PROGRAM_FORMAT_ASCII_ARB,
- strlen(progText), (const GLubyte *) progText);
- if (glGetError()) {
- fprintf(stderr, "Bad fragment program, error: %s\n",
- (const char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
- exit(0);
- }
- }
-#endif
-}
-
-
-
-// Test all possible image formats, types and internal texture formats.
-// Result will indicate number of passes and failures.
-void
-PixelFormatsTest::runOne(MultiTestResult &r, Window &w)
-{
- int testNum = 0, testStride;
- (void) w; // silence warning
-
- setup();
-
- if (env->options.quick)
- testStride = 13; // a prime number
- else
- testStride = 1;
-
- const unsigned numEnvModes = haveCombine ? 2 : 1;
-
- for (unsigned envMode = 0; envMode < numEnvModes; envMode++) {
- if (envMode == 0) {
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- // When the texture internal format is GL_LUMINANCE or GL_RGB,
- // GL_REPLACE takes alpha from the fragment, which we set to zero
- // with glColor4f(0,0,0,0).
-#if USE_FRAG_PROG
- defaultAlpha = 255;
-#else
- defaultAlpha = 0;
-#endif
- }
- else {
- assert(haveCombine);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
- glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
- glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
- glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
- glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
- // For this GL_COMBINE mode, when sampling a texture that does
- // not have an alpha channel, alpha is effectively 1.0.
- defaultAlpha = 255;
- }
-
- for (unsigned formatIndex = 0; formatIndex < NUM_FORMATS; formatIndex++) {
- for (unsigned typeIndex = 0; typeIndex < NUM_TYPES; typeIndex++) {
-
- if (CompatibleFormatAndType(Formats[formatIndex].Token,
- Types[typeIndex].Token)) {
-
- for (unsigned intFormat = 0; intFormat < NUM_INT_FORMATS; intFormat++) {
-
- if (!SupportedIntFormat(InternalFormats[intFormat].Token))
- continue;
-
-#if DEBUG
- env->log << "testing "
- << testNum
- << ":\n";
- env->log << " Format: " << Formats[formatIndex].Name << "\n";
- env->log << " Type: " << Types[typeIndex].Name << "\n";
- env->log << " IntFormat: " << InternalFormats[intFormat].Name << "\n";
-
-#endif
- bool ok;
-
- if (testNum % testStride == 0) {
- ok = TestCombination(Formats[formatIndex].Token,
- Types[typeIndex].Token,
- InternalFormats[intFormat].Token);
- }
- else {
- // skip
- ok = true;
- }
-
- if (!ok) {
- // error was reported to log, add format info here:
- env->log << " Format: " << Formats[formatIndex].Name << "\n";
- env->log << " Type: " << Types[typeIndex].Name << "\n";
- env->log << " Internal Format: " << InternalFormats[intFormat].Name << "\n";
- env->log << " EnvMode: " << EnvModes[envMode] << "\n";
- r.numFailed++;
- }
- else {
- r.numPassed++;
- }
- testNum++;
- }
- }
- }
- }
- }
-
- r.pass = (r.numFailed == 0);
-}
-
-
-// The test object itself:
-PixelFormatsTest pixelFormatsTest("pixelFormats", "window, rgb",
- "",
- "Test that all the various pixel formats/types (like\n"
- "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4_REV) operate correctly.\n"
- "Test both glTexImage and glDrawPixels.\n"
- "For textures, also test all the various internal texture formats.\n"
- "Thousands of combinations are possible!\n"
- );
-
-
-} // namespace GLEAN
diff --git a/tests/glean/tpixelformats.h b/tests/glean/tpixelformats.h
deleted file mode 100644
index d0edb94..0000000
--- a/tests/glean/tpixelformats.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-// Brian Paul September 2006
-
-#ifndef __tpixelformats_h__
-#define __tpixelformats_h__
-
-#include "tmultitest.h"
-
-namespace GLEAN {
-
-#define windowSize 100
-
-
-class PixelFormatsTest: public MultiTest
-{
-public:
- PixelFormatsTest(const char* testName, const char* filter,
- const char *extensions, const char* description):
- MultiTest(testName, filter, extensions, description),
- alphaBits(0),
- defaultAlpha(0),
- haveHalfFloat(false),
- haveABGR(false),
- haveSRGB(false),
- haveCombine(false),
- haveRG(false),
- haveSnorm(false),
- haveTexSharedExp(false)
- {
- }
-
- virtual void runOne(MultiTestResult &r, Window &w);
-
-private:
- int alphaBits;
- int defaultAlpha; // depends on texture env mode
- // extensions
- bool haveHalfFloat;
- bool haveABGR;
- bool haveSRGB;
- bool haveCombine;
- bool haveRG;
- bool haveFloat;
- bool haveSnorm;
- bool haveTexSharedExp;
-
- bool CheckError(const char *where) const;
-
- bool CompatibleFormatAndType(GLenum format, GLenum datatype) const;
-
- bool SupportedIntFormat(GLint intFormat) const;
-
- bool DrawImage(int width, int height,
- GLenum format, GLenum type, GLint intFormat,
- const GLubyte *image) const;
-
- void ComputeExpected(GLenum srcFormat, int testChan,
- GLint intFormat, GLubyte exp[4]) const;
-
- bool CheckRendering(int width, int height, int color,
- GLenum format, GLint intFormat) const;
-
- bool TestCombination(GLenum format, GLenum type, GLint intFormat);
-
- void setup(void);
-};
-
-} // namespace GLEAN
-
-#endif // __tpixelformats_h__
-
diff --git a/tests/glean/tshaderapi.cpp b/tests/glean/tshaderapi.cpp
deleted file mode 100644
index cad46af..0000000
--- a/tests/glean/tshaderapi.cpp
+++ /dev/null
@@ -1,470 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 2009 VMware, Inc. 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL VMWARE BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-
-// Test GLSL-related API functions for correct behaviour
-// Based on the "shader_api.c" test from Mesa, written by Bruce Merry.
-
-
-#include <cstring>
-#include "tshaderapi.h"
-#include "rand.h"
-#include "image.h"
-#include "piglit-util-gl.h"
-
-
-namespace GLEAN {
-
-ShaderAPIResult::ShaderAPIResult()
-{
- pass = false;
-}
-
-void
-ShaderAPITest::assert_test(const char *file, int line, int cond, const char *msg)
-{
- if (!cond) {
- error = true;
- fprintf(stderr, "%s:%d assertion \"%s\" failed\n", file, line, msg);
- }
-}
-
-#undef assert
-#define assert(x) assert_test(__FILE__, __LINE__, (x), #x)
-
-
-void
-ShaderAPITest::assert_no_error_test(const char *file, int line)
-{
- GLenum err;
-
- err = glGetError();
- if (err != GL_NO_ERROR) {
- error = true;
- fprintf(stderr, "%s:%d received error %s\n",
- file, line, piglit_get_gl_error_name(err));
- }
-}
-
-#define assert_no_error() assert_no_error_test(__FILE__, __LINE__)
-
-
-void
-ShaderAPITest::assert_error_test(const char *file, int line, GLenum expect)
-{
- GLenum err;
-
- err = glGetError();
- if (err != expect) {
- fprintf(stderr, "%s:%d expected %s but received %s\n",
- file, line, piglit_get_gl_error_name(expect), piglit_get_gl_error_name(err));
- error = true;
- }
-
- while (glGetError())
- ; /* consume any following errors */
-}
-
-#define assert_error(err) assert_error_test(__FILE__, __LINE__, (err))
-
-
-void
-ShaderAPITest::check_status(GLuint id, GLenum pname,
- void (APIENTRY *query)(GLuint, GLenum, GLint *),
- void (APIENTRY *get_log)(GLuint, GLsizei, GLsizei *, GLchar *))
-{
- GLint status;
-
- query(id, pname, &status);
- if (!status) {
- char info[65536];
-
- fprintf(stderr, "Compilation/link failure:\n");
- get_log(id, sizeof(info), NULL, info);
- fprintf(stderr, "%s\n", info);
-
- error = true;
- }
-}
-
-
-void
-ShaderAPITest::check_compile_status(GLuint id)
-{
- check_status(id, GL_COMPILE_STATUS, glGetShaderiv,
- glGetShaderInfoLog);
-}
-
-
-void
-ShaderAPITest::check_link_status(GLuint id)
-{
- check_status(id, GL_LINK_STATUS, glGetProgramiv,
- glGetProgramInfoLog);
-}
-
-
-GLuint
-ShaderAPITest::make_shader(GLenum type, const char *src)
-{
- GLuint id;
-
- assert_no_error();
- id = glCreateShader(type);
- glShaderSource(id, 1, &src, NULL);
- glCompileShader(id);
- check_compile_status(id);
- assert_no_error();
- return id;
-}
-
-
-GLuint
-ShaderAPITest::make_program(const char *vs_src, const char *fs_src)
-{
- GLuint id, vs, fs;
-
- assert_no_error();
- id = glCreateProgram();
- if (vs_src) {
- vs = make_shader(GL_VERTEX_SHADER, vs_src);
- glAttachShader(id, vs);
- glDeleteShader(vs);
- }
- if (fs_src) {
- fs = make_shader(GL_FRAGMENT_SHADER, fs_src);
- glAttachShader(id, fs);
- glDeleteShader(fs);
- }
- glLinkProgram(id);
- check_link_status(id);
- glUseProgram(id);
- glDeleteProgram(id);
- assert_no_error();
- return id;
-}
-
-
-void
-ShaderAPITest::test_uniform_size_type1(const char *glslType, GLenum glType, const char *el)
-{
- char buffer[1024];
- GLuint program;
- GLint active, i;
-
- //printf(" Running subtest %s\n", glslType);
- //fflush(stdout);
- sprintf(buffer, "#version 120\nuniform %s m[60];\nvoid main() { gl_Position[0] = m[59]%s; }\n",
- glslType, el);
-
- program = make_program(buffer, NULL);
- glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &active);
- assert_no_error();
- for (i = 0; i < active; i++) {
- GLint size = -1;
- GLenum type = 0;
- glGetActiveUniform(program, i, sizeof(buffer), NULL,
- &size, &type, buffer);
- assert_no_error();
- assert(type == glType);
- assert(size == 60);
- if (strncmp(buffer, "m", 1) == 0)
- break;
- }
-}
-
-
-void
-ShaderAPITest::test_uniform_size_type(void)
-{
- test_uniform_size_type1("float", GL_FLOAT, "");
- test_uniform_size_type1("vec2", GL_FLOAT_VEC2, "[0]");
- test_uniform_size_type1("vec3", GL_FLOAT_VEC3, "[0]");
- test_uniform_size_type1("vec4", GL_FLOAT_VEC4, "[0]");
-
- test_uniform_size_type1("bool", GL_BOOL, " ? 1.0 : 0.0");
- test_uniform_size_type1("bvec2", GL_BOOL_VEC2, "[0] ? 1.0 : 0.0");
- test_uniform_size_type1("bvec3", GL_BOOL_VEC3, "[0] ? 1.0 : 0.0");
- test_uniform_size_type1("bvec4", GL_BOOL_VEC4, "[0] ? 1.0 : 0.0");
-
- test_uniform_size_type1("int", GL_INT, "");
- test_uniform_size_type1("ivec2", GL_INT_VEC2, "[0]");
- test_uniform_size_type1("ivec3", GL_INT_VEC3, "[0]");
- test_uniform_size_type1("ivec4", GL_INT_VEC4, "[0]");
-
- test_uniform_size_type1("mat2", GL_FLOAT_MAT2, "[0][0]");
- test_uniform_size_type1("mat3", GL_FLOAT_MAT3, "[0][0]");
- test_uniform_size_type1("mat4", GL_FLOAT_MAT4, "[0][0]");
- test_uniform_size_type1("mat2x3", GL_FLOAT_MAT2x3, "[0][0]");
- test_uniform_size_type1("mat2x4", GL_FLOAT_MAT2x4, "[0][0]");
- test_uniform_size_type1("mat3x2", GL_FLOAT_MAT3x2, "[0][0]");
- test_uniform_size_type1("mat3x4", GL_FLOAT_MAT3x4, "[0][0]");
- test_uniform_size_type1("mat4x2", GL_FLOAT_MAT4x2, "[0][0]");
- test_uniform_size_type1("mat4x3", GL_FLOAT_MAT4x3, "[0][0]");
-}
-
-
-void
-ShaderAPITest::test_attrib_size_type1(const char *glslType, GLenum glType, const char *el)
-{
- char buffer[1024];
- GLuint program;
- GLint active, i;
-
- //printf(" Running subtest %s\n", glslType);
- //fflush(stdout);
- sprintf(buffer, "#version 120\nattribute %s m;\nvoid main() { gl_Position[0] = m%s; }\n",
- glslType, el);
-
- program = make_program(buffer, NULL);
- glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &active);
- assert_no_error();
- for (i = 0; i < active; i++) {
- GLint size = -1;
- GLenum type = 0;
- glGetActiveAttrib(program, i, sizeof(buffer), NULL,
- &size, &type, buffer);
- assert_no_error();
- assert(type == glType);
- assert(size == 1);
- if (strncmp(buffer, "m", 1) == 0)
- break;
- }
- assert(i < active); /* Otherwise the compiler optimised it out */
-}
-
-
-void
-ShaderAPITest::test_attrib_size_type(void)
-{
- test_attrib_size_type1("float", GL_FLOAT, "");
- test_attrib_size_type1("vec2", GL_FLOAT_VEC2, "[0]");
- test_attrib_size_type1("vec3", GL_FLOAT_VEC3, "[0]");
- test_attrib_size_type1("vec4", GL_FLOAT_VEC4, "[0]");
- test_attrib_size_type1("mat2", GL_FLOAT_MAT2, "[0][0]");
- test_attrib_size_type1("mat3", GL_FLOAT_MAT3, "[0][0]");
- test_attrib_size_type1("mat4", GL_FLOAT_MAT4, "[0][0]");
- test_attrib_size_type1("mat2x3", GL_FLOAT_MAT2x3, "[0][0]");
- test_attrib_size_type1("mat2x4", GL_FLOAT_MAT2x4, "[0][0]");
- test_attrib_size_type1("mat3x2", GL_FLOAT_MAT3x2, "[0][0]");
- test_attrib_size_type1("mat3x4", GL_FLOAT_MAT3x4, "[0][0]");
- test_attrib_size_type1("mat4x2", GL_FLOAT_MAT4x2, "[0][0]");
- test_attrib_size_type1("mat4x3", GL_FLOAT_MAT4x3, "[0][0]");
-}
-
-
-void
-ShaderAPITest::test_uniform_array_overflow(void)
-{
- GLuint program;
- GLint location;
- GLfloat data[128];
-
- program = make_program("#version 120\nuniform vec2 x[10];\nvoid main() { gl_Position.xy = x[9]; }\n", NULL);
- location = glGetUniformLocation(program, "x");
- assert_no_error();
- glUniform2fv(location, 64, data);
- assert_no_error();
-}
-
-
-void
-ShaderAPITest::test_uniform_scalar_count(void)
-{
- GLuint program;
- GLint location;
- GLfloat data[128];
-
- program = make_program("#version 110\nuniform vec2 x;\nvoid main() { gl_Position.xy = x; }\n", NULL);
- location = glGetUniformLocation(program, "x");
- assert_no_error();
- glUniform2fv(location, 64, data);
- assert_error(GL_INVALID_OPERATION);
-}
-
-
-void
-ShaderAPITest::test_uniform_query_matrix(void)
-{
- GLuint program;
- GLfloat data[18];
- GLint i, r, c;
- GLint location;
-
- program = make_program("#version 110\nuniform mat3 m[2];\nvoid main() { gl_Position.xyz = m[1][2]; }\n", NULL);
- location = glGetUniformLocation(program, "m");
- for (i = 0; i < 9; i++)
- data[i] = i;
- for (i = 9; i < 18; i++)
- data[i] = 321.0;
- glUniformMatrix3fv(location, 1, GL_TRUE, data);
-
- for (i = 0; i < 18; i++)
- data[i] = 123.0;
- glGetUniformfv(program, location, data);
- for (c = 0; c < 3; c++)
- for (r = 0; r < 3; r++)
- assert(data[c * 3 + r] == r * 3 + c);
- for (i = 9; i < 18; i++)
- assert(data[i] == 123.0);
-}
-
-
-void
-ShaderAPITest::test_uniform_neg_location(void)
-{
- GLuint program;
- GLfloat data[4];
-
- program = make_program("#version 110\nvoid main() { gl_Position = vec4(1.0, 1.0, 1.0, 1.0); }\n", NULL);
- (void) program;
- assert_no_error();
- glUniform1i(-1, 1);
- assert_no_error();
- glUniform1i(-200, 1);
- assert_error(GL_INVALID_OPERATION);
- glUniformMatrix2fv(-1, 1, GL_FALSE, data);
- assert_no_error();
- glUniformMatrix2fv(-200, 1, GL_FALSE, data);
- assert_error(GL_INVALID_OPERATION);
-}
-
-
-void
-ShaderAPITest::test_uniform_bool_conversion(void)
-{
- GLuint program;
- GLint location;
- GLint value[16]; /* in case glGetUniformiv goes nuts on the stack */
-
- assert_no_error();
- program = make_program("uniform bool b;\nvoid main() { gl_Position.x = b ? 1.5 : 0.5; }\n", NULL);
- location = glGetUniformLocation(program, "b");
- assert(location != -1);
- assert_no_error();
- glUniform1i(location, 5);
- assert_no_error();
- glGetUniformiv(program, location, &value[0]);
- assert_no_error();
- assert(value[0] == 1);
-}
-
-
-void
-ShaderAPITest::run_tests(void)
-{
- test_uniform_size_type();
- test_attrib_size_type();
- test_uniform_array_overflow();
- test_uniform_scalar_count();
- test_uniform_query_matrix();
- test_uniform_neg_location();
- test_uniform_bool_conversion();
-}
-
-
-void
-ShaderAPITest::runOne(ShaderAPIResult &r, Window &w)
-{
- (void) w; // silence warning
-
- // error will be set to true if any of the assert functions below fail.
- error = false;
-
- run_tests();
-
- r.pass = !error;
-}
-
-
-void
-ShaderAPITest::logOne(ShaderAPIResult &r)
-{
- if (r.pass) {
- logPassFail(r);
- logConcise(r);
- }
- else {
- env->log << name << "FAIL\n";
- }
-}
-
-
-void
-ShaderAPIResult::putresults(ostream &s) const
-{
- if (pass) {
- s << "PASS\n";
- }
- else {
- s << "FAIL\n";
- }
-}
-
-
-bool
-ShaderAPIResult::getresults(istream &s)
-{
- char result[1000];
- s >> result;
-
- if (strcmp(result, "FAIL") == 0) {
- pass = false;
- }
- else {
- pass = true;
- }
- return s.good();
-}
-
-
-// We need OpenGL 2.0, 2.1 or 3.0
-bool
-ShaderAPITest::isApplicable() const
-{
- if (GLUtils::getVersion() >= 2.0) {
- return true;
- }
- else {
- env->log << name
- << ": skipped. Requires GL >= 2.0.\n";
- return false;
- }
-}
-
-
-// The test object itself:
-ShaderAPITest shaderAPITest("shaderAPI", "window, rgb",
- "", // no extensions, but see isApplicable()
- "Test GLSL shader-related API features.\n");
-
-
-
-} // namespace GLEAN
-
-
diff --git a/tests/glean/tshaderapi.h b/tests/glean/tshaderapi.h
deleted file mode 100644
index 876876a..0000000
--- a/tests/glean/tshaderapi.h
+++ /dev/null
@@ -1,98 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 2009 VMware, Inc. 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL VMWARE BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-
-#ifndef __tshaderapi_h__
-#define __tshaderapi_h__
-
-#include "tbase.h"
-
-#ifndef APIENTRY
-#define APIENTRY
-#endif
-
-namespace GLEAN {
-
-#define windowSize 100
-
-
-class ShaderAPIResult: public BaseResult
-{
-public:
- bool pass;
-
- ShaderAPIResult();
-
- virtual void putresults(ostream& s) const;
- virtual bool getresults(istream& s);
-};
-
-
-class ShaderAPITest: public BaseTest<ShaderAPIResult>
-{
-public:
- // "WHO" = width, height and one config flag
- GLEAN_CLASS_WHO(ShaderAPITest, ShaderAPIResult,
- windowSize, windowSize, true);
-
- virtual bool isApplicable() const;
-
-private:
- bool error;
-
- void assert_test(const char *file, int line, int cond, const char *msg);
- void assert_no_error_test(const char *file, int line);
- void assert_error_test(const char *file, int line, GLenum expect);
-
- void check_status(GLuint id, GLenum pname,
- void (APIENTRY *query)(GLuint, GLenum, GLint *),
- void (APIENTRY *get_log)(GLuint, GLsizei, GLsizei *, GLchar *));
- void check_compile_status(GLuint id);
- void check_link_status(GLuint id);
-
- GLuint make_shader(GLenum type, const char *src);
- GLuint make_program(const char *vs_src, const char *fs_src);
-
- void test_uniform_size_type1(const char *glslType, GLenum glType, const char *el);
- void test_attrib_size_type1(const char *glslType, GLenum glType, const char *el);
-
- void test_uniform_size_type(void);
- void test_attrib_size_type(void);
- void test_uniform_array_overflow(void);
- void test_uniform_scalar_count(void);
- void test_uniform_query_matrix(void);
- void test_uniform_neg_location(void);
- void test_uniform_bool_conversion(void);
- void test_uniform_multiple_samplers(void);
- void run_tests(void);
-};
-
-} // namespace GLEAN
-
-#endif // __tshaderapi_h__
-
diff --git a/tests/glean/ttexcube.cpp b/tests/glean/ttexcube.cpp
deleted file mode 100644
index 1d8ac29..0000000
--- a/tests/glean/ttexcube.cpp
+++ /dev/null
@@ -1,426 +0,0 @@
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-
-// ttexcube.cpp: Test the GL_ARB_texture_cube_map extension
-// Author: Brian Paul (brianp at valinux.com) March 2001
-//
-// Test procedure:
-// We build a 6-sided texture cube map in which each side is a simple 2x2
-// checkboard pattern with known colors. Then we do three sets of tests.
-// Each test draws a single quadrilateral. The tests are:
-//
-// 1. Directly specify texture coordinates. By changing the texture coords
-// we can sample specific regions of the cube map. Check the rendered
-// quad colors for correctness.
-// 2. Use GL_NORMAL_MAP_ARB texgen mode with specific normal vectors to
-// sample specific regions of the cube map. Check for correctness.
-// 3. Test GL_REFLECTION_MAP_ARB texgen mode by specifying a quad with
-// fixed vertices and normals but rotating the texture coordinate
-// matrix to select each side of the cube map. Check that the rendered
-// quad's four colors match the cube face.
-//
-
-#include "ttexcube.h"
-#include <stdio.h>
-#include <cmath>
-
-namespace GLEAN {
-
-
-#define VP_SIZE 20
-
-static const char *faceName[6] = {
- "POSITIVE_X",
- "NEGATIVE_X",
- "POSITIVE_Y",
- "NEGATIVE_Y",
- "POSITIVE_Z",
- "NEGATIVE_Z"
-};
-
-
-//
-// Test if two colors are close enough to be considered the same
-//
-bool
-TexCubeTest::TestColor(const GLfloat c1[3], const GLfloat c2[3]) {
- if (fabs(c1[0] - c2[0]) <= mTolerance[0] &&
- fabs(c1[1] - c2[1]) <= mTolerance[1] &&
- fabs(c1[2] - c2[2]) <= mTolerance[2])
- return true;
- else
- return false;
-}
-
-
-//
-// Define a 2x2 checkerboard texture image using the given four colors.
-//
-void
-TexCubeTest::BuildTexImage(GLenum target, const GLfloat color[4][3]) {
- const GLint w = 8, h = 8;
- GLfloat texImage[8][8][4];
- for (int i = 0; i < h; i++) {
- const int ibit = (i >= (h / 2));
- for (int j = 0; j < w; j++) {
- const int jbit = (j >= (w / 2));
- const int c = ibit * 2 + jbit;
- texImage[i][j][0] = color[c][0];
- texImage[i][j][1] = color[c][1];
- texImage[i][j][2] = color[c][2];
- texImage[i][j][3] = 1.0;
- }
- }
- glTexImage2D(target, 0, GL_RGB, w, h, 0, GL_RGBA, GL_FLOAT, texImage);
-}
-
-
-//
-// Draw a polygon either with texcoords or normal vectors and check that
-// we hit the correct quadrant of each of the six cube faces.
-// Return: true = pass, false = fail
-//
-bool
-TexCubeTest::TestNormalMap(bool texCoordMode, const char *modeName) {
-
- // We use the coordinates both directly as texture coordinates
- // and as normal vectors for testing NORMAL_MAP_ARB texgen mode).
- static const GLfloat coords[6][4][3] = {
- // +X
- {
- { 1.0, 0.5, 0.5 },
- { 1.0, 0.5, -0.5 },
- { 1.0, -0.5, 0.5 },
- { 1.0, -0.5, -0.5 },
- },
- // -X
- {
- { -1.0, 0.5, -0.5 },
- { -1.0, 0.5, 0.5 },
- { -1.0, -0.5, -0.5 },
- { -1.0, -0.5, 0.5 },
- },
- // +Y
- {
- { -0.5, 1.0, -0.5 },
- { 0.5, 1.0, -0.5 },
- { -0.5, 1.0, 0.5 },
- { 0.5, 1.0, 0.5 },
- },
- // -Y
- {
- { -0.5, -1.0, 0.5 },
- { 0.5, -1.0, 0.5 },
- { -0.5, -1.0, -0.5 },
- { 0.5, -1.0, -0.5 },
- },
- // +Z
- {
- { -0.5, 0.5, 1.0 },
- { 0.5, 0.5, 1.0 },
- { -0.5, -0.5, 1.0 },
- { 0.5, -0.5, 1.0 },
- },
- // -Z
- {
- { 0.5, 0.5, -1.0 },
- { -0.5, 0.5, -1.0 },
- { 0.5, -0.5, -1.0 },
- { -0.5, -0.5, -1.0 },
- }
- };
-
- // normal vectors to hit the four colors of each cube face when
-
- for (int face = 0; face < 6; face++) {
- for (int quadrant = 0; quadrant < 4; quadrant++) {
-
- // draw the test quad
- if (texCoordMode)
- glTexCoord3fv(coords[face][quadrant]);
- else
- glNormal3fv(coords[face][quadrant]);
- glColor3f(0, 1, 0);
- glBegin(GL_POLYGON);
- glVertex2f(-1, -1);
- glVertex2f( 1, -1);
- glVertex2f( 1, 1);
- glVertex2f(-1, 1);
- glEnd();
-
- // check the color
- GLfloat result[3];
- glReadPixels(1, 1, 1, 1, GL_RGB, GL_FLOAT, result);
-
- if (!TestColor(mColors[face][quadrant], result)) {
- env->log << name
- << ": FAIL: mode='"
- << modeName
- << "' face="
- << faceName[face]
- << " quadrant="
- << quadrant
- << " expected=("
- << mColors[face][quadrant][0] << ", "
- << mColors[face][quadrant][1] << ", "
- << mColors[face][quadrant][2]
- << ") measured=("
- << result[0] << ", "
- << result[1] << ", "
- << result[2]
- << ")\n";
- return false;
- }
- }
- }
- return true;
-}
-
-
-//
-// Test GL_REFLECTION_MAP_ARB texgen mode.
-// Return: true = pass, false = fail
-//
-bool
-TexCubeTest::TestReflectionMap(const char *modeName) {
-
-// These are the glReadPixels coords we'll use for pixel testing
-#define X0 ((int) (VP_SIZE * 0.25))
-#define X1 ((int) (VP_SIZE * 0.75))
-#define Y0 ((int) (VP_SIZE * 0.25))
-#define Y1 ((int) (VP_SIZE * 0.75))
-
- // We'll rotate the texture coordinates to map each cube face
- // onto a screen-aligned quad.
- static const GLfloat rotation[6][4] = {
- { -90, 0, 1, 0 }, // +X
- { 90, 0, 1, 0 }, // -X
- { 90, 1, 0, 0 }, // +Y
- { -90, 1, 0, 0 }, // -Y
- { 180, 1, 0, 0 }, // -Z
- { 0, 1, 0, 0 } // +Z
- };
-
- // For each face we'll test the four quadrants to be sure test
- // if the expected color is where it should be.
- // These are the glReadPixels coordinates at which we should
- // find the colors in the mColors[6][4] array.
- static const GLint readPos[6][4][2] = {
- // +X
- {
- { X1, Y1 }, { X0, Y1 }, { X1, Y0 }, { X0, Y0 }
- },
- // -X
- {
- { X1, Y1 }, { X0, Y1 }, { X1, Y0 }, { X0, Y0 }
- },
- // +Y
- {
- { X0, Y0 }, { X1, Y0 }, { X0, Y1 }, { X1, Y1 }
- },
- // -Y
- {
- { X0, Y0 }, { X1, Y0 }, { X0, Y1 }, { X1, Y1 }
- },
- // +Z
- {
- { X0, Y0 }, { X1, Y0 }, { X0, Y1 }, { X1, Y1 }
- },
- // -Z
- {
- { X1, Y1 }, { X0, Y1 }, { X1, Y0 }, { X0, Y0 }
- }
- };
-
- for (int face = 0; face < 6; face++) {
-
- // Draw the test quad.
- // It'll be textured with one face of the cube map texture.
- glMatrixMode(GL_TEXTURE);
- glPushMatrix();
- glRotatef(rotation[face][0], rotation[face][1],
- rotation[face][2], rotation[face][3]);
- glNormal3f(0, 0, 1);
- glColor3f(0, 1, 0);
- glBegin(GL_POLYGON);
- glVertex3f(-1, -1, 1);
- glVertex3f( 1, -1, 1);
- glVertex3f( 1, 1, 1);
- glVertex3f(-1, 1, 1);
- glEnd();
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
-
- // Verify the colors
- for (int quadrant = 0; quadrant < 4; quadrant++) {
-
- GLfloat result[3];
- glReadPixels(readPos[face][quadrant][0],
- readPos[face][quadrant][1],
- 1, 1, GL_RGB, GL_FLOAT, result);
-
- if (!TestColor(mColors[face][quadrant], result)) {
- env->log << name
- << ": FAIL: mode='"
- << modeName
- << "' face="
- << faceName[face]
- << " quadrant="
- << quadrant
- << " expected=("
- << mColors[face][quadrant][0] << ", "
- << mColors[face][quadrant][1] << ", "
- << mColors[face][quadrant][2]
- << ") measured=("
- << result[0] << ", "
- << result[1] << ", "
- << result[2]
- << ")\n";
- return false;
- }
- }
- }
- return true;
-}
-
-
-void
-TexCubeTest::runOne(BasicResult& r, Window& w) {
-
- (void) w;
-
- // each of six faces needs four test colors
- for (int i = 0; i < 6 * 4; i++) {
- GLint r = i % 3;
- GLint g = (i / 3) % 3;
- GLint b = (i / 9) % 3;
- mColors[i / 4][i % 4][0] = r * 0.5;
- mColors[i / 4][i % 4][1] = g * 0.5;
- mColors[i / 4][i % 4][2] = b * 0.5;
- //printf("mColors[%d][%d] = %g %g %g\n", i/4, i%4,
- // mColors[i/4][i%4][0],
- // mColors[i/4][i%4][1],
- // mColors[i/4][i%4][2]);
- }
-
- glDrawBuffer(GL_FRONT);
- glReadBuffer(GL_FRONT);
-
- BuildTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, mColors[0]);
- BuildTexImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, mColors[1]);
- BuildTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, mColors[2]);
- BuildTexImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, mColors[3]);
- BuildTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, mColors[4]);
- BuildTexImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, mColors[5]);
-
- glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER,
- GL_NEAREST);
- glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER,
- GL_NEAREST);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glEnable(GL_TEXTURE_CUBE_MAP_ARB);
-
- // compute RGB error tolerance
- {
- GLint rBits, gBits, bBits;
- GLint rTexBits, gTexBits, bTexBits;
- glGetIntegerv(GL_RED_BITS, &rBits);
- glGetIntegerv(GL_GREEN_BITS, &gBits);
- glGetIntegerv(GL_BLUE_BITS, &bBits);
- glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
- 0, GL_TEXTURE_RED_SIZE, &rTexBits);
- glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
- 0, GL_TEXTURE_GREEN_SIZE, &gTexBits);
- glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
- 0, GL_TEXTURE_BLUE_SIZE, &bTexBits);
- // find smaller of frame buffer and texture bits
- rBits = (rBits < rTexBits) ? rBits : rTexBits;
- gBits = (gBits < gTexBits) ? gBits : gTexBits;
- bBits = (bBits < bTexBits) ? bBits : bTexBits;
- mTolerance[0] = 2.0 / (1 << rBits);
- mTolerance[1] = 2.0 / (1 << gBits);
- mTolerance[2] = 2.0 / (1 << bBits);
- }
-
- glViewport(0, 0, VP_SIZE, VP_SIZE);
-
- bool passed = true;
-
- if (passed) {
- // Test directly specifying texture coords
- glDisable(GL_TEXTURE_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
- glDisable(GL_TEXTURE_GEN_R);
- passed = TestNormalMap(true,
- "Direct specification of texture coordinates");
- }
-
- if (passed) {
- // Test GL_NORMAL_MAP_ARB mode
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
- glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
- glEnable(GL_TEXTURE_GEN_S);
- glEnable(GL_TEXTURE_GEN_T);
- glEnable(GL_TEXTURE_GEN_R);
- passed = TestNormalMap(false, "GL_NORMAL_MAP_ARB texgen");
- }
-
- if (passed) {
- // Test GL_REFLECTION_MAP_ARB mode
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
- glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
- glEnable(GL_TEXTURE_GEN_S);
- glEnable(GL_TEXTURE_GEN_T);
- glEnable(GL_TEXTURE_GEN_R);
- glEnable(GL_NORMALIZE);
- passed = TestReflectionMap("GL_REFLECTION_MAP_ARB texgen");
- }
-
- r.pass = passed;
-} // TexCubeTest::runOne
-
-
-void
-TexCubeTest::logOne(BasicResult& r) {
- logPassFail(r);
- logConcise(r);
-} // TexCubeTest::logOne
-
-
-///////////////////////////////////////////////////////////////////////////////
-// The test object itself:
-///////////////////////////////////////////////////////////////////////////////
-TexCubeTest texCubeTest("texCube", "window, rgb",
-
- "GL_ARB_texture_cube_map verification test.\n");
-
-
-} // namespace GLEAN
diff --git a/tests/glean/ttexcube.h b/tests/glean/ttexcube.h
deleted file mode 100644
index 7494022..0000000
--- a/tests/glean/ttexcube.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-
-// ttexcube.h: Test the GL_ARB_texture_cube_map extension
-// Author: Brian Paul (brianp at valinux.com) March 2001
-
-
-#ifndef __ttexcube_h__
-#define __ttexcube_h__
-
-#include "tbasic.h"
-
-namespace GLEAN {
-
-class TexCubeTest: public BasicTest {
- public:
- TexCubeTest(const char* testName, const char* filter,
- const char* description):
- BasicTest(testName, filter, "GL_ARB_texture_cube_map",
- description),
- mTolerance() {
- }
-
- virtual void runOne(BasicResult& r, Window& w);
- virtual void logOne(BasicResult& r);
-
- private:
- bool TestColor(const GLfloat c1[3], const GLfloat c2[3]);
- void BuildTexImage(GLenum target, const GLfloat color[4][3]);
- bool TestNormalMap(bool testTexCoords, const char *modeName);
- bool TestReflectionMap(const char *modeName);
-
- GLfloat mColors[6][4][3];
- GLfloat mTolerance[3];
-
-}; // class TexCubeTest
-
-} // namespace GLEAN
-
-#endif // __ttexcube_h__
diff --git a/tests/glean/ttexture_srgb.cpp b/tests/glean/ttexture_srgb.cpp
deleted file mode 100644
index 524685f..0000000
--- a/tests/glean/ttexture_srgb.cpp
+++ /dev/null
@@ -1,356 +0,0 @@
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-// ttexture_srgb.h: Test GL_EXT_texture_sRGB extension.
-// Brian Paul August 2006
-
-
-#include <cassert>
-#include <cstring>
-#include <cmath>
-#include "ttexture_srgb.h"
-#include "rand.h"
-#include "piglit-util-gl.h"
-
-
-namespace GLEAN {
-
-
-static const struct {
- GLenum sFormat;
- GLenum baseFormat;
- GLint components;
-} Formats[] = {
- { GL_SRGB_EXT, GL_RGB, 3 },
- { GL_SRGB8_EXT, GL_RGB, 3 },
- { GL_SRGB_ALPHA_EXT, GL_RGBA, 4 },
- { GL_SRGB8_ALPHA8_EXT, GL_RGBA, 4 },
- { GL_SLUMINANCE_ALPHA_EXT, GL_LUMINANCE_ALPHA, 2 },
- { GL_SLUMINANCE8_ALPHA8_EXT, GL_LUMINANCE_ALPHA, 2 },
- { GL_SLUMINANCE_EXT, GL_LUMINANCE, 1 },
- { GL_SLUMINANCE8_EXT, GL_LUMINANCE, 1 },
- { 0, 0, 0 }
-};
-
-
-
-
-// Convert an 8-bit sRGB value from non-linear space to a
-// linear RGB value in [0, 1].
-// Implemented with a 256-entry lookup table.
-static float
-nonlinear_to_linear(GLubyte cs8)
-{
- static GLfloat table[256];
- static GLboolean tableReady = GL_FALSE;
- if (!tableReady) {
- // compute lookup table now
- GLuint i;
- for (i = 0; i < 256; i++) {
- const GLfloat cs = i / 255.0;
- if (cs <= 0.04045) {
- table[i] = cs / 12.92;
- }
- else {
- table[i] = pow((cs + 0.055) / 1.055, 2.4);
- }
- }
- tableReady = GL_TRUE;
- }
- return table[cs8];
-}
-
-
-// allocate and fill an array with random values
-static GLubyte *
-randomArray(int bytes, int seed)
-{
- GLEAN::RandomBits r(8, seed);
- GLubyte *img = new GLubyte [bytes];
-
- for (int i = 0; i < bytes; i++)
- img[i] = r.next();
-
- return img;
-}
-
-
-// Test glTexImage and glGetTexImage functionality
-bool
-TextureSRGBTest::testImageTransfer(void)
-{
- const GLubyte *image = randomArray(128 * 128 * 4, 0);
- GLubyte image2[128 * 128 * 4];
- int i, j;
-
- for (i = 0; Formats[i].sFormat; i++) {
- // upload tex image
- glTexImage2D(GL_TEXTURE_2D, 0, Formats[i].sFormat, 128, 128, 0,
- Formats[i].baseFormat, GL_UNSIGNED_BYTE, image);
-
- // retrieve tex image
- glGetTexImage(GL_TEXTURE_2D, 0,
- Formats[i].baseFormat, GL_UNSIGNED_BYTE, image2);
-
- // compare original and returned images
- const int comps = Formats[i].components;
- for (j = 0; j < 128 * 128 * comps; j++) {
- if (image[j] != image2[j]) {
- env->log << '\n'
- << name
- << " glGetTexImage failed for internalFormat "
- << Formats[i].sFormat
- << "\n";
- env->log << "Expected value at ["
- << j
- << "] should be "
- << (int) image[j]
- << " found "
- << (int) image2[j]
- << "\n";
- delete [] image;
- return false;
- }
- image2[j] = 0; // reset for next GetTexImage
- }
- }
-
- delete [] image;
- return true;
-}
-
-
-bool
-TextureSRGBTest::testTextureFormat(GLenum intFormat, GLint components,
- GLEAN::Environment &env)
-{
- const GLubyte *image = randomArray(128 * 128 * 4, intFormat);
- GLfloat readback[128 * 128 * 4];
- int i;
- GLint redBits, alphaBits;
-
- glGetIntegerv(GL_RED_BITS, &redBits);
- glGetIntegerv(GL_ALPHA_BITS, &alphaBits);
- const float tolerance = 1.0 / ((1 << (redBits - 1)) - 1);
-
- // setup matrices
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glViewport(0, 0, windowSize, windowSize);
-
- // setup texture
- glTexImage2D(GL_TEXTURE_2D, 0, intFormat, 128, 128, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, image);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glEnable(GL_TEXTURE_2D);
-
- glDisable(GL_DITHER);
-
- glDrawBuffer(GL_FRONT);
- glReadBuffer(GL_FRONT);
-
- // draw test polygon
- glBegin(GL_POLYGON);
- glTexCoord2f(0, 0); glVertex2f(-1, -1);
- glTexCoord2f(1, 0); glVertex2f( 1, -1);
- glTexCoord2f(1, 1); glVertex2f( 1, 1);
- glTexCoord2f(0, 1); glVertex2f(-1, 1);
- glEnd();
-
- glReadPixels(0, 0, windowSize, windowSize,
- GL_RGBA, GL_FLOAT, readback);
-
- // compare rendered results to expected values
- for (i = 0; i < 128 * 128; i++) {
- const GLfloat *actual = readback + i * 4;
- GLfloat expected[4];
-
- expected[0] = nonlinear_to_linear(image[i * 4 + 0]);
- expected[1] = nonlinear_to_linear(image[i * 4 + 1]);
- expected[2] = nonlinear_to_linear(image[i * 4 + 2]);
- expected[3] = image[i * 4 + 3] / 255.0;
-
- if (components <= 2) {
- if (fabs(actual[0] - expected[0]) > tolerance) {
- env.log << '\n'
- << name
- << " failed for internalFormat "
- << intFormat
- << "\n";
- env.log << "Expected luminance "
- << expected[0]
- << " found "
- << actual[0]
- << "\n";
- delete [] image;
- return GL_FALSE;
- }
-
- }
- else {
- assert(components == 3 || components == 4);
- if (fabs(actual[0] - expected[0]) > tolerance ||
- fabs(actual[1] - expected[1]) > tolerance ||
- fabs(actual[2] - expected[2]) > tolerance) {
- env.log << '\n'
- << name
- << " failed for internalFormat "
- << intFormat
- << "\n";
- env.log << "Expected color "
- << expected[0]
- << ", "
- << expected[1]
- << ", "
- << expected[2]
- << " found "
- << actual[0]
- << ", "
- << actual[1]
- << ", "
- << actual[2]
- << "\n";
- delete [] image;
- return GL_FALSE;
- }
- }
-
- if (alphaBits >= redBits
- && components == 4
- && fabs(actual[3] - expected[3]) > tolerance) {
- env.log << '\n'
- << name
- << " failed for internalFormat "
- << intFormat
- << "\n";
- env.log << "Expected alpha "
- << expected[3]
- << " found "
- << actual[3]
- << "\n";
- delete [] image;
- return GL_FALSE;
- }
- }
-
- delete [] image;
- return GL_TRUE;
-}
-
-
-// Test actual texture mapping using each of the sRGB formats
-// Return GL_TRUE if all format tests pass, GL_FALSE if any fail.
-bool
-TextureSRGBTest::testTexturing(void)
-{
- for (int i = 0; Formats[i].sFormat; i++) {
- if (!testTextureFormat(Formats[i].sFormat,
- Formats[i].components, *env))
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-
-void
-TextureSRGBTest::runOne(TextureSRGBResult &r, Window &w)
-{
- (void) w; // silence warning
- r.pass = true;
- errorCode = 0;
- errorPos = NULL;
- errorMsg[0] = 0;
-
- if (r.pass)
- r.pass = testImageTransfer();
- if (r.pass)
- r.pass = testTexturing();
-}
-
-
-void
-TextureSRGBTest::logOne(TextureSRGBResult &r)
-{
- if (r.pass) {
- logPassFail(r);
- logConcise(r);
- }
- else {
- env->log << name << " FAIL\n";
- if (errorCode) {
- env->log << "\tOpenGL Error " << piglit_get_gl_error_name(errorCode)
- << " at " << errorPos << "\n";
- }
- else if (errorMsg[0]) {
- env->log << "\t" << errorMsg << "\n";
- }
- }
-}
-
-
-void
-TextureSRGBResult::putresults(ostream &s) const
-{
- if (pass) {
- s << "PASS\n";
- }
- else {
- s << "FAIL\n";
- }
-}
-
-
-bool
-TextureSRGBResult::getresults(istream &s)
-{
- char result[1000];
- s >> result;
-
- if (strcmp(result, "FAIL") == 0) {
- pass = false;
- }
- else {
- pass = true;
- }
- return s.good();
-}
-
-
-// The test object itself:
-TextureSRGBTest srgbTest("texture_srgb", "window, rgb",
- "GL_EXT_texture_sRGB",
- "Test the GL_EXT_texture_sRGB extension.\n");
-
-
-
-} // namespace GLEAN
diff --git a/tests/glean/ttexture_srgb.h b/tests/glean/ttexture_srgb.h
deleted file mode 100644
index 8875b2d..0000000
--- a/tests/glean/ttexture_srgb.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-// ttexture_srgb.h: Test GL_EXT_texture_sRGB extension.
-// Brian Paul August 2006
-
-#ifndef __ttexture_srgb_h__
-#define __ttexture_srgb_h__
-
-#include "tbase.h"
-
-namespace GLEAN {
-
-#define windowSize 128
-
-class TextureSRGBResult: public BaseResult
-{
-public:
- bool pass;
-
- virtual void putresults(ostream& s) const;
- virtual bool getresults(istream& s);
-};
-
-
-class TextureSRGBTest: public BaseTest<TextureSRGBResult>
-{
-public:
- GLEAN_CLASS_WH(TextureSRGBTest, TextureSRGBResult,
- windowSize, windowSize);
-
-private:
- GLenum errorCode;
- const char *errorPos;
- char errorMsg[1000];
-
- bool testImageTransfer(void);
- bool testTextureFormat(GLenum intFormat, GLint components,
- GLEAN::Environment &env);
- bool testTexturing(void);
-};
-
-} // namespace GLEAN
-
-#endif // __ttexture_srgb_h__
-
diff --git a/tests/glean/tvertarraybgra.cpp b/tests/glean/tvertarraybgra.cpp
deleted file mode 100644
index ff8ac31..0000000
--- a/tests/glean/tvertarraybgra.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 2009 VMware, Inc. 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL VMWARE BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-
-// Render some geometry with random GLubyte/RGBA vertex colors.
-// Then re-render same thing with GLubyte/BGRA vertex colors.
-// Brian Paul
-// 23 Jan 2009
-
-
-#define GL_GLEXT_PROTOTYPES
-
-#include <cassert>
-#include <cmath>
-#include <cstring>
-#include "tvertarraybgra.h"
-#include "rand.h"
-#include "image.h"
-
-
-namespace GLEAN {
-
-
-VertArrayBGRAResult::VertArrayBGRAResult()
-{
- pass = true;
-}
-
-
-void
-VertArrayBGRATest::reportError(const char *msg)
-{
- env->log << name << ": Error: " << msg << "\n";
-}
-
-
-void
-VertArrayBGRATest::setupPoints()
-{
- RandomDouble r(10);
- int i;
- for (i = 0; i < NUM_POINTS; i++) {
- mPos[i][0] = r.next() * WINDOW_SIZE;
- mPos[i][1] = r.next() * WINDOW_SIZE;
- mRGBA[i][0] = int(r.next() * 255);
- mRGBA[i][1] = int(r.next() * 255);
- mRGBA[i][2] = int(r.next() * 255);
- mRGBA[i][3] = int(r.next() * 255);
- mBGRA[i][0] = mRGBA[i][2]; // blue
- mBGRA[i][1] = mRGBA[i][1]; // green
- mBGRA[i][2] = mRGBA[i][0]; // red
- mBGRA[i][3] = mRGBA[i][3]; // alpha
- }
-}
-
-
-void
-VertArrayBGRATest::renderPoints(bool useBGRA)
-{
- glVertexPointer(2, GL_FLOAT, 0, mPos);
- glEnableClientState(GL_VERTEX_ARRAY);
-
- if (useBGRA)
- glColorPointer(GL_BGRA, GL_UNSIGNED_BYTE, 0, mBGRA);
- else
- glColorPointer(4, GL_UNSIGNED_BYTE, 0, mRGBA);
- glEnableClientState(GL_COLOR_ARRAY);
-
- glDrawArrays(GL_POINTS, 0, NUM_POINTS);
-
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_COLOR_ARRAY);
-}
-
-
-void
-VertArrayBGRATest::runOne(VertArrayBGRAResult &r, Window &w)
-{
- (void) w; // silence warning
- Image rgbaImage(WINDOW_SIZE, WINDOW_SIZE, GL_RGBA, GL_UNSIGNED_BYTE);
- Image bgraImage(WINDOW_SIZE, WINDOW_SIZE, GL_RGBA, GL_UNSIGNED_BYTE);
-
- setupPoints();
-#if 0 // test lighting path too (debug only)
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glEnable(GL_COLOR_MATERIAL);
-#endif
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, WINDOW_SIZE, 0, WINDOW_SIZE, -1.0, 1.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- // render with RGBA colors and save image
- glClear(GL_COLOR_BUFFER_BIT);
- renderPoints(false);
- rgbaImage.read(0, 0); // pos=(0,0)
- w.swap();
-
- // render with BGRA colors and save image
- glClear(GL_COLOR_BUFFER_BIT);
- renderPoints(true);
- bgraImage.read(0, 0); // pos=(0,0)
- w.swap();
-
- // images should be identical
- r.pass = (rgbaImage == bgraImage);
- if (!r.pass) {
- reportError("BGRA colors did not match RGBA colors.");
- }
-}
-
-
-void
-VertArrayBGRATest::logOne(VertArrayBGRAResult &r)
-{
- logPassFail(r);
- logConcise(r);
-}
-
-
-void
-VertArrayBGRAResult::putresults(ostream &s) const
-{
- if (pass) {
- s << "PASS\n";
- }
- else {
- s << "FAIL\n";
- }
-}
-
-
-bool
-VertArrayBGRAResult::getresults(istream &s)
-{
- char result[1000];
- s >> result;
-
- if (strcmp(result, "FAIL") == 0) {
- pass = false;
- }
- else {
- pass = true;
- }
- return s.good();
-}
-
-
-// The test object itself:
-VertArrayBGRATest vertArrayBGRATest("vertArrayBGRA", "window, rgb",
- "GL_EXT_vertex_array_bgra",
- "Test the GL_EXT_vertex_array_bgra extension.\n");
-
-
-
-} // namespace GLEAN
-
-
diff --git a/tests/glean/tvertarraybgra.h b/tests/glean/tvertarraybgra.h
deleted file mode 100644
index 2b3a118..0000000
--- a/tests/glean/tvertarraybgra.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// BEGIN_COPYRIGHT -*- glean -*-
-//
-// Copyright (C) 2009 VMware, Inc. 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL VMWARE BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-// tvertarraybgra.h: Test GL_EXT_vertex_array bgra
-
-#ifndef __tvertarraybgra_h__
-#define __tvertarraybgra_h__
-
-#include "tbase.h"
-
-
-namespace GLEAN {
-
-#define NUM_POINTS 1000
-#define WINDOW_SIZE 100
-
-class VertArrayBGRAResult: public BaseResult
-{
-public:
- VertArrayBGRAResult();
-
- virtual void putresults(ostream& s) const;
- virtual bool getresults(istream& s);
-
- bool pass;
-};
-
-
-class VertArrayBGRATest: public BaseTest<VertArrayBGRAResult>
-{
-public:
- GLEAN_CLASS_WH(VertArrayBGRATest, VertArrayBGRAResult,
- WINDOW_SIZE, WINDOW_SIZE);
-
-private:
- float mPos[NUM_POINTS][2];
- GLubyte mRGBA[NUM_POINTS][4];
- GLubyte mBGRA[NUM_POINTS][4];
-
- void reportError(const char *msg);
- bool testAPI(void);
- void setupPoints(void);
- void renderPoints(bool useBGRA);
-};
-
-} // namespace GLEAN
-
-#endif // __tvertarraybgra_h__
-
diff --git a/tests/glean/tvertattrib.cpp b/tests/glean/tvertattrib.cpp
deleted file mode 100644
index e18077a..0000000
--- a/tests/glean/tvertattrib.cpp
+++ /dev/null
@@ -1,1398 +0,0 @@
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-
-// tvertattrib.cpp: Test vertex attribute functions.
-//
-// Indexed vertex attributes may either alias with conventional attributes
-// or name a separate set of generic attributes. The following extensions/
-// versions are tested (and whether aliasing is allowed):
-// GL_NV_vertex_program (aliasing required)
-// GL_ARB_vertex_program (aliasing optional)
-// GL_ARB_vertex_shader (aliasing disallowed)
-// OpenGL 2.0 (aliasing disallowed)
-//
-// If either GL_ARB_vertex_shader or OpenGL 2.0 is supported, that means
-// aliasing is required for GL_ARB_vertex_program too.
-//
-// We test both immediate mode and display list mode.
-//
-// Author: Brian Paul (brian.paul a t tungstengraphics.com) October 2004
-
-
-#include <stdlib.h>
-#include <cassert>
-#include <math.h>
-#include "tvertattrib.h"
-#include "glutils.h"
-
-namespace GLEAN {
-
-#define COPY1(DST, SRC) DST[0] = SRC[0]; DST[1] = 0.0F; DST[2] = 0.0F; DST[3] = 1.0F
-
-#define COPY2(DST, SRC) DST[0] = SRC[0]; DST[1] = SRC[1]; DST[2] = 0.0F; DST[3] = 1.0F
-
-#define COPY3(DST, SRC) DST[0] = SRC[0]; DST[1] = SRC[1]; DST[2] = SRC[2]; DST[3] = 1.0F
-
-#define COPY4(DST, SRC) DST[0] = SRC[0]; DST[1] = SRC[1]; DST[2] = SRC[2]; DST[3] = SRC[3]
-
-#define FLOAT_TO_BYTE(X) ( (((GLint) (255.0F * (X))) - 1) / 2 )
-
-#define FLOAT_TO_UBYTE(X) ((GLubyte) (GLint) ((X) * 255.0F))
-
-#define FLOAT_TO_SHORT(X) ( (((GLint) (65535.0F * (X))) - 1) / 2 )
-
-#define FLOAT_TO_USHORT(X) ((GLushort) (GLint) ((X) * 65535.0F))
-
-#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) )
-
-#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0))
-
-
-#define NUM_NV_ATTRIB_FUNCS 26
-#define NUM_ARB_ATTRIB_FUNCS 36
-#define NUM_2_0_ATTRIB_FUNCS 36
-
-static const char *
-AttribFuncNames[] = {
- "glVertexAttrib1fNV",
- "glVertexAttrib2fNV",
- "glVertexAttrib3fNV",
- "glVertexAttrib4fNV",
- "glVertexAttrib1fvNV",
- "glVertexAttrib2fvNV",
- "glVertexAttrib3fvNV",
- "glVertexAttrib4fvNV",
- "glVertexAttrib1dNV",
- "glVertexAttrib2dNV",
- "glVertexAttrib3dNV",
- "glVertexAttrib4dNV",
- "glVertexAttrib1dvNV",
- "glVertexAttrib2dvNV",
- "glVertexAttrib3dvNV",
- "glVertexAttrib4dvNV",
- "glVertexAttrib1sNV",
- "glVertexAttrib2sNV",
- "glVertexAttrib3sNV",
- "glVertexAttrib4sNV",
- "glVertexAttrib1svNV",
- "glVertexAttrib2svNV",
- "glVertexAttrib3svNV",
- "glVertexAttrib4svNV",
- "glVertexAttrib4ubNV",
- "glVertexAttrib4ubvNV",
-
- "glVertexAttrib1fARB",
- "glVertexAttrib2fARB",
- "glVertexAttrib3fARB",
- "glVertexAttrib4fARB",
- "glVertexAttrib1fvARB",
- "glVertexAttrib2fvARB",
- "glVertexAttrib3fvARB",
- "glVertexAttrib4fvARB",
- "glVertexAttrib1dARB",
- "glVertexAttrib2dARB",
- "glVertexAttrib3dARB",
- "glVertexAttrib4dARB",
- "glVertexAttrib1dvARB",
- "glVertexAttrib2dvARB",
- "glVertexAttrib3dvARB",
- "glVertexAttrib4dvARB",
- "glVertexAttrib1sARB",
- "glVertexAttrib2sARB",
- "glVertexAttrib3sARB",
- "glVertexAttrib4sARB",
- "glVertexAttrib1svARB",
- "glVertexAttrib2svARB",
- "glVertexAttrib3svARB",
- "glVertexAttrib4svARB",
- "glVertexAttrib4NsvARB",
- "glVertexAttrib4NubARB",
- "glVertexAttrib4NubvARB",
- "glVertexAttrib4ubvARB",
- "glVertexAttrib4NbvARB",
- "glVertexAttrib4bvARB",
- "glVertexAttrib4NivARB",
- "glVertexAttrib4ivARB",
- "glVertexAttrib4NuivARB",
- "glVertexAttrib4uivARB",
- "glVertexAttrib4NusvARB",
- "glVertexAttrib4usvARB",
-
- "glVertexAttrib1f",
- "glVertexAttrib2f",
- "glVertexAttrib3f",
- "glVertexAttrib4f",
- "glVertexAttrib1fv",
- "glVertexAttrib2fv",
- "glVertexAttrib3fv",
- "glVertexAttrib4fv",
- "glVertexAttrib1d",
- "glVertexAttrib2d",
- "glVertexAttrib3d",
- "glVertexAttrib4d",
- "glVertexAttrib1dv",
- "glVertexAttrib2dv",
- "glVertexAttrib3dv",
- "glVertexAttrib4dv",
- "glVertexAttrib1s",
- "glVertexAttrib2s",
- "glVertexAttrib3s",
- "glVertexAttrib4s",
- "glVertexAttrib1sv",
- "glVertexAttrib2sv",
- "glVertexAttrib3sv",
- "glVertexAttrib4sv",
- "glVertexAttrib4Nsv",
- "glVertexAttrib4Nub",
- "glVertexAttrib4Nubv",
- "glVertexAttrib4ubv",
- "glVertexAttrib4Nbv",
- "glVertexAttrib4bv",
- "glVertexAttrib4Niv",
- "glVertexAttrib4iv",
- "glVertexAttrib4Nuiv",
- "glVertexAttrib4uiv",
- "glVertexAttrib4Nusv",
- "glVertexAttrib4usv"
-};
-
-
-// Set a vertex attribute with one of the many glVertexAttrib* functions.
-// index = the vertex attribute
-// v = the 4-element attribute value
-// funcIndex = indicates which glVertexAttrib* function to use
-// refOut = returns the value which should now be in the attribute register
-//
-static void
-SetAttrib(GLuint index, const GLfloat v[4], GLuint funcIndex, GLfloat refOut[4])
-{
- switch (funcIndex) {
- // ** GLfloat-valued functions
-#if defined(GL_NV_vertex_program)
- case 0:
- {
- glVertexAttrib1fNV(index, v[0]);
- COPY1(refOut, v);
- }
- break;
- case 1:
- {
- glVertexAttrib2fNV(index, v[0], v[1]);
- COPY2(refOut, v);
- }
- break;
- case 2:
- {
- glVertexAttrib3fNV(index, v[0], v[1], v[2]);
- COPY3(refOut, v);
- }
- break;
- case 3:
- {
- glVertexAttrib4fNV(index, v[0], v[1], v[2], v[3]);
- COPY4(refOut, v);
- }
- break;
- case 4:
- {
- glVertexAttrib1fvNV(index, v);
- COPY1(refOut, v);
- }
- break;
- case 5:
- {
- glVertexAttrib2fvNV(index, v);
- COPY2(refOut, v);
- }
- break;
- case 6:
- {
- glVertexAttrib3fvNV(index, v);
- COPY3(refOut, v);
- }
- break;
- case 7:
- {
- glVertexAttrib4fvNV(index, v);
- COPY4(refOut, v);
- }
- break;
- // ** GLdouble-valued functions
- case 8:
- {
- glVertexAttrib1dNV(index, v[0]);
- COPY1(refOut, v);
- }
- break;
- case 9:
- {
- glVertexAttrib2dNV(index, v[0], v[1]);
- COPY2(refOut, v);
- }
- break;
- case 10:
- {
- glVertexAttrib3dNV(index, v[0], v[1], v[2]);
- COPY3(refOut, v);
- }
- break;
- case 11:
- {
- glVertexAttrib4dNV(index, v[0], v[1], v[2], v[3]);
- COPY4(refOut, v);
- }
- break;
- case 12:
- {
- GLdouble d[1];
- d[0] = v[0];
- glVertexAttrib1dvNV(index, d);
- COPY1(refOut, v);
- }
- break;
- case 13:
- {
- GLdouble d[2];
- d[0] = v[0];
- d[1] = v[1];
- glVertexAttrib2dvNV(index, d);
- COPY2(refOut, v);
- }
- break;
- case 14:
- {
- GLdouble d[3];
- d[0] = v[0];
- d[1] = v[1];
- d[2] = v[2];
- glVertexAttrib3dvNV(index, d);
- COPY3(refOut, v);
- }
- break;
- case 15:
- {
- GLdouble d[4];
- d[0] = v[0];
- d[1] = v[1];
- d[2] = v[2];
- d[3] = v[3];
- glVertexAttrib4dvNV(index, d);
- COPY4(refOut, v);
- }
- break;
- // ** GLshort-valued functions
- case 16:
- {
- glVertexAttrib1sNV(index, (GLshort) v[0]);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = 0.0F;
- refOut[2] = 0.0F;
- refOut[3] = 1.0F;
- }
- break;
- case 17:
- {
- glVertexAttrib2sNV(index, (GLshort) v[0], (GLshort) v[1]);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = 0.0F;
- refOut[3] = 1.0F;
- }
- break;
- case 18:
- {
- glVertexAttrib3sNV(index, (GLshort) v[0], (GLshort) v[1], (GLshort) v[2]);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = (GLfloat) (GLshort) v[2];
- refOut[3] = 1.0F;
- }
- break;
- case 19:
- {
- glVertexAttrib4sNV(index, (GLshort) v[0], (GLshort) v[1], (GLshort) v[2], (GLshort) v[3]);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = (GLfloat) (GLshort) v[2];
- refOut[3] = (GLfloat) (GLshort) v[3];
- }
- break;
- case 20:
- {
- GLshort s[1];
- s[0] = (GLshort) v[0];
- glVertexAttrib1svNV(index, s);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = 0.0F;
- refOut[2] = 0.0F;
- refOut[3] = 1.0F;
- }
- break;
- case 21:
- {
- GLshort s[2];
- s[0] = (GLshort) v[0];
- s[1] = (GLshort) v[1];
- glVertexAttrib2svNV(index, s);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = 0.0F;
- refOut[3] = 1.0F;
- }
- break;
- case 22:
- {
- GLshort s[3];
- s[0] = (GLshort) v[0];
- s[1] = (GLshort) v[1];
- s[2] = (GLshort) v[2];
- glVertexAttrib3svNV(index, s);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = (GLfloat) (GLshort) v[2];
- refOut[3] = 1.0F;
- }
- break;
- case 23:
- {
- GLshort s[4];
- s[0] = (GLshort) v[0];
- s[1] = (GLshort) v[1];
- s[2] = (GLshort) v[2];
- s[3] = (GLshort) v[3];
- glVertexAttrib4svNV(index, s);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = (GLfloat) (GLshort) v[2];
- refOut[3] = (GLfloat) (GLshort) v[3];
- }
- break;
- // ** GLubyte-valued functions
- case 24:
- {
- glVertexAttrib4ubNV(index, FLOAT_TO_UBYTE(v[0]), FLOAT_TO_UBYTE(v[1]), FLOAT_TO_UBYTE(v[2]), FLOAT_TO_UBYTE(v[3]));
- refOut[0] = v[0];
- refOut[1] = v[1];
- refOut[2] = v[2];
- refOut[3] = v[3];
- }
- break;
- case 25:
- {
- GLubyte ub[4];
- for (int i = 0; i < 4; i++ )
- ub[i] = FLOAT_TO_UBYTE(v[i]);
- glVertexAttrib4ubvNV(index, ub);
- refOut[0] = v[0];
- refOut[1] = v[1];
- refOut[2] = v[2];
- refOut[3] = v[3];
- }
- break;
- /* XXX Also test glVertexAttribs* functions? */
-#endif
-
-#if defined(GL_ARB_vertex_program) || defined (GL_ARB_vertex_shader)
- // ** GLfloat-valued functions
- case 26:
- {
- glVertexAttrib1fARB(index, v[0]);
- COPY1(refOut, v);
- }
- break;
- case 27:
- {
- glVertexAttrib2fARB(index, v[0], v[1]);
- COPY2(refOut, v);
- }
- break;
- case 28:
- {
- glVertexAttrib3fARB(index, v[0], v[1], v[2]);
- COPY3(refOut, v);
- }
- break;
- case 29:
- {
- glVertexAttrib4fARB(index, v[0], v[1], v[2], v[3]);
- COPY4(refOut, v);
- }
- break;
- case 30:
- {
- glVertexAttrib1fvARB(index, v);
- COPY1(refOut, v);
- }
- break;
- case 31:
- {
- glVertexAttrib2fvARB(index, v);
- COPY2(refOut, v);
- }
- break;
- case 32:
- {
- glVertexAttrib3fvARB(index, v);
- COPY3(refOut, v);
- }
- break;
- case 33:
- {
- glVertexAttrib4fvARB(index, v);
- COPY4(refOut, v);
- }
- break;
- // ** GLdouble-valued functions
- case 34:
- {
- glVertexAttrib1dARB(index, v[0]);
- COPY1(refOut, v);
- }
- break;
- case 35:
- {
- glVertexAttrib2dARB(index, v[0], v[1]);
- COPY2(refOut, v);
- }
- break;
- case 36:
- {
- glVertexAttrib3dARB(index, v[0], v[1], v[2]);
- COPY3(refOut, v);
- }
- break;
- case 37:
- {
- glVertexAttrib4dARB(index, v[0], v[1], v[2], v[3]);
- COPY4(refOut, v);
- }
- break;
- case 38:
- {
- GLdouble d[1];
- d[0] = v[0];
- glVertexAttrib1dvARB(index, d);
- COPY1(refOut, v);
- }
- break;
- case 39:
- {
- GLdouble d[2];
- d[0] = v[0];
- d[1] = v[1];
- glVertexAttrib2dvARB(index, d);
- COPY2(refOut, v);
- }
- break;
- case 40:
- {
- GLdouble d[3];
- d[0] = v[0];
- d[1] = v[1];
- d[2] = v[2];
- glVertexAttrib3dvARB(index, d);
- COPY3(refOut, v);
- }
- break;
- case 41:
- {
- GLdouble d[4];
- d[0] = v[0];
- d[1] = v[1];
- d[2] = v[2];
- d[3] = v[3];
- glVertexAttrib4dvARB(index, d);
- COPY4(refOut, v);
- }
- break;
- // ** GLshort-valued functions
- case 42:
- {
- glVertexAttrib1sARB(index, (GLshort) v[0]);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = 0.0F;
- refOut[2] = 0.0F;
- refOut[3] = 1.0F;
- }
- break;
- case 43:
- {
- glVertexAttrib2sARB(index, (GLshort) v[0], (GLshort) v[1]);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = 0.0F;
- refOut[3] = 1.0F;
- }
- break;
- case 44:
- {
- glVertexAttrib3sARB(index, (GLshort) v[0], (GLshort) v[1], (GLshort) v[2]);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = (GLfloat) (GLshort) v[2];
- refOut[3] = 1.0F;
- }
- break;
- case 45:
- {
- glVertexAttrib4sARB(index, (GLshort) v[0], (GLshort) v[1], (GLshort) v[2], (GLshort) v[3]);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = (GLfloat) (GLshort) v[2];
- refOut[3] = (GLfloat) (GLshort) v[3];
- }
- break;
- case 46:
- {
- GLshort s[1];
- s[0] = (GLshort) v[0];
- glVertexAttrib1svARB(index, s);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = 0.0F;
- refOut[2] = 0.0F;
- refOut[3] = 1.0F;
- }
- break;
- case 47:
- {
- GLshort s[2];
- s[0] = (GLshort) v[0];
- s[1] = (GLshort) v[1];
- glVertexAttrib2svARB(index, s);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = 0.0F;
- refOut[3] = 1.0F;
- }
- break;
- case 48:
- {
- GLshort s[3];
- s[0] = (GLshort) v[0];
- s[1] = (GLshort) v[1];
- s[2] = (GLshort) v[2];
- glVertexAttrib3svARB(index, s);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = (GLfloat) (GLshort) v[2];
- refOut[3] = 1.0F;
- }
- break;
- case 49:
- {
- GLshort s[4];
- s[0] = (GLshort) v[0];
- s[1] = (GLshort) v[1];
- s[2] = (GLshort) v[2];
- s[3] = (GLshort) v[3];
- glVertexAttrib4svARB(index, s);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = (GLfloat) (GLshort) v[2];
- refOut[3] = (GLfloat) (GLshort) v[3];
- }
- break;
- case 50:
- {
- GLshort s[4];
- for (int i = 0; i < 4; i++)
- s[i] = FLOAT_TO_SHORT(v[i]);
- glVertexAttrib4NsvARB(index, s);
- COPY4(refOut, v);
- }
- break;
- // ** GLubyte-valued functions
- case 51:
- {
- glVertexAttrib4NubARB(index, FLOAT_TO_UBYTE(v[0]), FLOAT_TO_UBYTE(v[1]), FLOAT_TO_UBYTE(v[2]), FLOAT_TO_UBYTE(v[3]));
- COPY4(refOut, v);
- }
- break;
- case 52:
- {
- GLubyte ub[4];
- for (int i = 0; i < 4; i++ )
- ub[i] = FLOAT_TO_UBYTE(v[i]);
- glVertexAttrib4NubvARB(index, ub);
- COPY4(refOut, v);
- }
- break;
- case 53:
- {
- GLubyte ub[4];
- for (int i = 0; i < 4; i++ )
- ub[i] = (GLubyte) v[i];
- glVertexAttrib4ubvARB(index, ub);
- refOut[0] = (GLfloat) (GLubyte) v[0];
- refOut[1] = (GLfloat) (GLubyte) v[1];
- refOut[2] = (GLfloat) (GLubyte) v[2];
- refOut[3] = (GLfloat) (GLubyte) v[3];
- }
- break;
- // ** GLbyte-valued functions
- case 54:
- {
- GLbyte b[4];
- for (int i = 0; i < 4; i++ )
- b[i] = FLOAT_TO_BYTE(v[i]);
- glVertexAttrib4NbvARB(index, b);
- COPY4(refOut, v);
- }
- break;
- case 55:
- {
- GLbyte b[4];
- for (int i = 0; i < 4; i++ )
- b[i] = (GLbyte) v[i];
- glVertexAttrib4bvARB(index, b);
- refOut[0] = (GLfloat) (GLbyte) v[0];
- refOut[1] = (GLfloat) (GLbyte) v[1];
- refOut[2] = (GLfloat) (GLbyte) v[2];
- refOut[3] = (GLfloat) (GLbyte) v[3];
- }
- break;
- // ** GLint-valued functions
- case 56:
- {
- GLint iv[4];
- for (int i = 0; i < 4; i++ )
- iv[i] = FLOAT_TO_INT(v[i]);
- glVertexAttrib4NivARB(index, iv);
- COPY4(refOut, v);
- }
- break;
- case 57:
- {
- GLint iv[4];
- for (int i = 0; i < 4; i++ )
- iv[i] = (GLint) v[i];
- glVertexAttrib4ivARB(index, iv);
- refOut[0] = (GLfloat) (GLint) v[0];
- refOut[1] = (GLfloat) (GLint) v[1];
- refOut[2] = (GLfloat) (GLint) v[2];
- refOut[3] = (GLfloat) (GLint) v[3];
- }
- break;
- // ** GLuint-valued functions
- case 58:
- {
- GLuint ui[4];
- for (int i = 0; i < 4; i++ )
- ui[i] = FLOAT_TO_UINT(v[i]);
- glVertexAttrib4NuivARB(index, ui);
- COPY4(refOut, v);
- }
- break;
- case 59:
- {
- GLuint ui[4];
- for (int i = 0; i < 4; i++ )
- ui[i] = (GLint) v[i];
- glVertexAttrib4uivARB(index, ui);
- refOut[0] = (GLfloat) (GLint) v[0];
- refOut[1] = (GLfloat) (GLint) v[1];
- refOut[2] = (GLfloat) (GLint) v[2];
- refOut[3] = (GLfloat) (GLint) v[3];
- }
- break;
- // ** GLushort-valued functions
- case 60:
- {
- GLushort us[4];
- for (int i = 0; i < 4; i++ )
- us[i] = FLOAT_TO_USHORT(v[i]);
- glVertexAttrib4NusvARB(index, us);
- COPY4(refOut, v);
- }
- break;
- case 61:
- {
- GLushort us[4];
- for (int i = 0; i < 4; i++ )
- us[i] = (GLint) v[i];
- glVertexAttrib4usvARB(index, us);
- refOut[0] = (GLfloat) (GLint) v[0];
- refOut[1] = (GLfloat) (GLint) v[1];
- refOut[2] = (GLfloat) (GLint) v[2];
- refOut[3] = (GLfloat) (GLint) v[3];
- }
- break;
-#endif
-
-#if defined(GL_VERSION_2_0)
- case 62:
- {
- glVertexAttrib1f(index, v[0]);
- COPY1(refOut, v);
- }
- break;
- case 63:
- {
- glVertexAttrib2f(index, v[0], v[1]);
- COPY2(refOut, v);
- }
- break;
- case 64:
- {
- glVertexAttrib3f(index, v[0], v[1], v[2]);
- COPY3(refOut, v);
- }
- break;
- case 65:
- {
- glVertexAttrib4f(index, v[0], v[1], v[2], v[3]);
- COPY4(refOut, v);
- }
- break;
- case 66:
- {
- glVertexAttrib1fv(index, v);
- COPY1(refOut, v);
- }
- break;
- case 67:
- {
- glVertexAttrib2fv(index, v);
- COPY2(refOut, v);
- }
- break;
- case 68:
- {
- glVertexAttrib3fv(index, v);
- COPY3(refOut, v);
- }
- break;
- case 69:
- {
- glVertexAttrib4fv(index, v);
- COPY4(refOut, v);
- }
- break;
- // ** GLdouble-valued functions
- case 70:
- {
- glVertexAttrib1d(index, v[0]);
- COPY1(refOut, v);
- }
- break;
- case 71:
- {
- glVertexAttrib2d(index, v[0], v[1]);
- COPY2(refOut, v);
- }
- break;
- case 72:
- {
- glVertexAttrib3d(index, v[0], v[1], v[2]);
- COPY3(refOut, v);
- }
- break;
- case 73:
- {
- glVertexAttrib4d(index, v[0], v[1], v[2], v[3]);
- COPY4(refOut, v);
- }
- break;
- case 74:
- {
- GLdouble d[1];
- d[0] = v[0];
- glVertexAttrib1dv(index, d);
- COPY1(refOut, v);
- }
- break;
- case 75:
- {
- GLdouble d[2];
- d[0] = v[0];
- d[1] = v[1];
- glVertexAttrib2dv(index, d);
- COPY2(refOut, v);
- }
- break;
- case 76:
- {
- GLdouble d[3];
- d[0] = v[0];
- d[1] = v[1];
- d[2] = v[2];
- glVertexAttrib3dv(index, d);
- COPY3(refOut, v);
- }
- break;
- case 77:
- {
- GLdouble d[4];
- d[0] = v[0];
- d[1] = v[1];
- d[2] = v[2];
- d[3] = v[3];
- glVertexAttrib4dv(index, d);
- COPY4(refOut, v);
- }
- break;
- // ** GLshort-valued functions
- case 78:
- {
- glVertexAttrib1s(index, (GLshort) v[0]);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = 0.0F;
- refOut[2] = 0.0F;
- refOut[3] = 1.0F;
- }
- break;
- case 79:
- {
- glVertexAttrib2s(index, (GLshort) v[0], (GLshort) v[1]);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = 0.0F;
- refOut[3] = 1.0F;
- }
- break;
- case 80:
- {
- glVertexAttrib3s(index, (GLshort) v[0], (GLshort) v[1], (GLshort) v[2]);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = (GLfloat) (GLshort) v[2];
- refOut[3] = 1.0F;
- }
- break;
- case 81:
- {
- glVertexAttrib4s(index, (GLshort) v[0], (GLshort) v[1], (GLshort) v[2], (GLshort) v[3]);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = (GLfloat) (GLshort) v[2];
- refOut[3] = (GLfloat) (GLshort) v[3];
- }
- break;
- case 82:
- {
- GLshort s[1];
- s[0] = (GLshort) v[0];
- glVertexAttrib1sv(index, s);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = 0.0F;
- refOut[2] = 0.0F;
- refOut[3] = 1.0F;
- }
- break;
- case 83:
- {
- GLshort s[2];
- s[0] = (GLshort) v[0];
- s[1] = (GLshort) v[1];
- glVertexAttrib2sv(index, s);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = 0.0F;
- refOut[3] = 1.0F;
- }
- break;
- case 84:
- {
- GLshort s[3];
- s[0] = (GLshort) v[0];
- s[1] = (GLshort) v[1];
- s[2] = (GLshort) v[2];
- glVertexAttrib3sv(index, s);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = (GLfloat) (GLshort) v[2];
- refOut[3] = 1.0F;
- }
- break;
- case 85:
- {
- GLshort s[4];
- s[0] = (GLshort) v[0];
- s[1] = (GLshort) v[1];
- s[2] = (GLshort) v[2];
- s[3] = (GLshort) v[3];
- glVertexAttrib4sv(index, s);
- refOut[0] = (GLfloat) (GLshort) v[0];
- refOut[1] = (GLfloat) (GLshort) v[1];
- refOut[2] = (GLfloat) (GLshort) v[2];
- refOut[3] = (GLfloat) (GLshort) v[3];
- }
- break;
- case 86:
- {
- GLshort s[4];
- for (int i = 0; i < 4; i++)
- s[i] = FLOAT_TO_SHORT(v[i]);
- glVertexAttrib4Nsv(index, s);
- COPY4(refOut, v);
- }
- break;
- // ** GLubyte-valued functions
- case 87:
- {
- glVertexAttrib4Nub(index, FLOAT_TO_UBYTE(v[0]), FLOAT_TO_UBYTE(v[1]), FLOAT_TO_UBYTE(v[2]), FLOAT_TO_UBYTE(v[3]));
- COPY4(refOut, v);
- }
- break;
- case 88:
- {
- GLubyte ub[4];
- for (int i = 0; i < 4; i++ )
- ub[i] = FLOAT_TO_UBYTE(v[i]);
- glVertexAttrib4Nubv(index, ub);
- COPY4(refOut, v);
- }
- break;
- case 89:
- {
- GLubyte ub[4];
- for (int i = 0; i < 4; i++ )
- ub[i] = (GLubyte) v[i];
- glVertexAttrib4ubv(index, ub);
- refOut[0] = (GLfloat) (GLubyte) v[0];
- refOut[1] = (GLfloat) (GLubyte) v[1];
- refOut[2] = (GLfloat) (GLubyte) v[2];
- refOut[3] = (GLfloat) (GLubyte) v[3];
- }
- break;
- // ** GLbyte-valued functions
- case 90:
- {
- GLbyte b[4];
- for (int i = 0; i < 4; i++ )
- b[i] = FLOAT_TO_BYTE(v[i]);
- glVertexAttrib4Nbv(index, b);
- COPY4(refOut, v);
- }
- break;
- case 91:
- {
- GLbyte b[4];
- for (int i = 0; i < 4; i++ )
- b[i] = (GLbyte) v[i];
- glVertexAttrib4bv(index, b);
- refOut[0] = (GLfloat) (GLbyte) v[0];
- refOut[1] = (GLfloat) (GLbyte) v[1];
- refOut[2] = (GLfloat) (GLbyte) v[2];
- refOut[3] = (GLfloat) (GLbyte) v[3];
- }
- break;
- // ** GLint-valued functions
- case 92:
- {
- GLint iv[4];
- for (int i = 0; i < 4; i++ )
- iv[i] = FLOAT_TO_INT(v[i]);
- glVertexAttrib4Niv(index, iv);
- COPY4(refOut, v);
- }
- break;
- case 93:
- {
- GLint iv[4];
- for (int i = 0; i < 4; i++ )
- iv[i] = (GLint) v[i];
- glVertexAttrib4iv(index, iv);
- refOut[0] = (GLfloat) (GLint) v[0];
- refOut[1] = (GLfloat) (GLint) v[1];
- refOut[2] = (GLfloat) (GLint) v[2];
- refOut[3] = (GLfloat) (GLint) v[3];
- }
- break;
- // ** GLuint-valued functions
- case 94:
- {
- GLuint ui[4];
- for (int i = 0; i < 4; i++ )
- ui[i] = FLOAT_TO_UINT(v[i]);
- glVertexAttrib4Nuiv(index, ui);
- COPY4(refOut, v);
- }
- break;
- case 95:
- {
- GLuint ui[4];
- for (int i = 0; i < 4; i++ )
- ui[i] = (GLint) v[i];
- glVertexAttrib4uiv(index, ui);
- refOut[0] = (GLfloat) (GLint) v[0];
- refOut[1] = (GLfloat) (GLint) v[1];
- refOut[2] = (GLfloat) (GLint) v[2];
- refOut[3] = (GLfloat) (GLint) v[3];
- }
- break;
- // ** GLushort-valued functions
- case 96:
- {
- GLushort us[4];
- for (int i = 0; i < 4; i++ )
- us[i] = FLOAT_TO_USHORT(v[i]);
- glVertexAttrib4Nusv(index, us);
- COPY4(refOut, v);
- }
- break;
- case 97:
- {
- GLushort us[4];
- for (int i = 0; i < 4; i++ )
- us[i] = (GLint) v[i];
- glVertexAttrib4usv(index, us);
- refOut[0] = (GLfloat) (GLint) v[0];
- refOut[1] = (GLfloat) (GLint) v[1];
- refOut[2] = (GLfloat) (GLint) v[2];
- refOut[3] = (GLfloat) (GLint) v[3];
- }
- break;
-#endif
-
- default:
- // never get here!
- abort();
- }
-
- assert(98 == NUM_NV_ATTRIB_FUNCS + NUM_ARB_ATTRIB_FUNCS + NUM_2_0_ATTRIB_FUNCS);
-}
-
-
-// Test if 'a and 'b' are within an epsilon of each other
-static bool
-NearlyEqual(const GLfloat a[4], const GLfloat b[4])
-{
- const GLfloat epsilon = 0.05;
- if (fabsf(a[0] - b[0]) > epsilon ||
- fabsf(a[1] - b[1]) > epsilon ||
- fabsf(a[2] - b[2]) > epsilon ||
- fabsf(a[3] - b[3]) > epsilon)
- return 0;
- else
- return 1;
-}
-
-
-void VertAttribTest::FailMessage(VertAttribResult &r, const char *msg,
- const char *func, int dlistMode) const
-{
- // record the failure
- r.pass = false;
-
- // print the message
- env->log << name << ": FAIL "
- << r.config->conciseDescription() << '\n';
- env->log << "\t" << msg << " (Testing " << func << " in ";
-
- if (dlistMode)
- env->log << "display list mode)\n";
- else
- env->log << "immediate mode)\n";
-}
-
-
-
-// Test setting/getting a set of vertex attribute values
-// Return true if pass, false if fail
-bool
-VertAttribTest::TestAttribs(VertAttribResult &r,
- int attribFunc,
- Aliasing aliasing,
- int numAttribs)
-{
- static const GLfloat refValues[7] = { 1.0F, 0.8F, 0.6F, 0.5F, 0.4F, 0.2F, 0.0F };
- GLfloat refValue[32][4];
- GLfloat refOut[32][4];
- bool result = true;
-
- assert(numAttribs <= 32);
-
- // Initialize the refValue array
- int refIndex = 0;
- for (int i = 1; i < numAttribs; i++) {
- refValue[i][0] = refValues[refIndex++ % 7];
- refValue[i][1] = refValues[refIndex++ % 7];
- refValue[i][2] = refValues[refIndex++ % 7];
- refValue[i][3] = refValues[refIndex++ % 7];
- }
-
- for (int dlist = 0; dlist < 2; dlist++) {
-
- // set a couple conventional attribs for later aliasing tests
- glNormal3f(-1.0F, -2.0F, -3.0F);
- glTexCoord4f(-1.0F, -2.0F, -3.0F, -4.0F);
-
- if (dlist == 1) {
- glNewList(42, GL_COMPILE);
- }
-
- // Set all the vertex attributes
- for (int i = 1; i < numAttribs; i++) {
- SetAttrib(i, refValue[i], attribFunc, refOut[i]);
- }
-
- if (dlist == 1) {
- glEndList();
- glCallList(42);
- }
-
- // Test all the vertex attributes
- for (int i = 1; i < numAttribs; i++) {
- const GLfloat *expected = refOut[i];
- GLfloat v[4];
- glGetVertexAttribfvNV(i, GL_CURRENT_VERTEX_ATTRIB_ARB, v);
- if (!NearlyEqual(v, expected)) {
- char msg[1000];
- sprintf(msg, "Vertex Attribute %d is (%g, %g, %g, %g) but expected (%g, %g, %g, %g)",
- i, v[0], v[1], v[2], v[3],
- expected[0], expected[1], expected[2], expected[3]);
- FailMessage(r, msg, AttribFuncNames[attribFunc], dlist);
- result = false;
- }
- }
-
- if (aliasing == REQUIRED) {
- // spot check a few aliased attribs
- GLfloat v[4];
- glGetFloatv(GL_CURRENT_NORMAL, v);
- v[3] = refOut[2][3];
- if (!NearlyEqual(v, refOut[2])) {
- FailMessage(r, "Setting attribute 2 did not update GL_CURRENT_NORMAL", AttribFuncNames[attribFunc], dlist);
- result = false;
- }
-
- glGetFloatv(GL_CURRENT_TEXTURE_COORDS, v);
- if (!NearlyEqual(v, refOut[8])) {
- FailMessage(r, "Setting attribute 8 did not update GL_CURRENT_TEXTURE_COORDS", AttribFuncNames[attribFunc], dlist);
- result = false;
- }
- }
- else if (aliasing == DISALLOWED) {
- // spot check a few non-aliased attribs
- GLfloat v[4];
- glGetFloatv(GL_CURRENT_NORMAL, v);
- if (v[0] != -1.0F ||
- v[1] != -2.0F ||
- v[2] != -3.0F) {
- FailMessage(r, "GL_CURRENT_NORMAL was erroneously set by a glVertexAttrib call", AttribFuncNames[attribFunc], dlist);
- result = false;
- }
- glGetFloatv(GL_CURRENT_TEXTURE_COORDS, v);
- if (v[0] != -1.0F ||
- v[1] != -2.0F ||
- v[2] != -3.0F ||
- v[3] != -4.0F) {
- FailMessage(r, "GL_CURRENT_TEXTURE_COORDS was erroneously set by a glVertexAttrib call", AttribFuncNames[attribFunc], dlist);
- result = false;
- }
- }
-
- } // dlist loop
-
- return result;
-}
-
-
-// Test the GL_NV_vertex_program functions
-// Return true if pass, false if fail
-bool
-VertAttribTest::TestNVfuncs(VertAttribResult &r)
-{
- bool result = true;
-#ifdef GL_NV_vertex_program
- const GLint numAttribs = 16;
- const Aliasing aliasing = REQUIRED;
-
- r.numNVtested = 0;
-
- for (int attribFunc = 0; attribFunc < NUM_NV_ATTRIB_FUNCS; attribFunc++) {
- bool b;
- b = TestAttribs(r, attribFunc, aliasing, numAttribs);
- if (!b)
- result = false;
- r.numNVtested++;
- }
-#else
- (void) r;
-#endif
- return result;
-}
-
-
-// Test the GL_ARB_vertex_program/shader functions
-// Return true if pass, false if fail
-bool
-VertAttribTest::TestARBfuncs(VertAttribResult &r, bool shader)
-{
- bool result = true;
-#if defined(GL_ARB_vertex_program) || defined(GL_ARB_vertex_shader)
- GLint numAttribs;
-
- glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &numAttribs);
- assert(numAttribs > 0);
-
- r.numARBtested = 0;
-
- if (shader) {
- // test GL_ARB_vertex_shader (aliasing is disallowed)
- const Aliasing aliasing = DISALLOWED;
- for (int i = 0; i < NUM_ARB_ATTRIB_FUNCS; i++) {
- int attribFunc = NUM_NV_ATTRIB_FUNCS + i;
- bool b;
- b = TestAttribs(r, attribFunc, aliasing, numAttribs);
- if (!b)
- result = false;
- r.numARBtested++;
- }
- }
- else {
- // test GL_ARB_vertex_program:
- // Determine if attribute aliasing is allowed
- Aliasing aliasing;
- if (GLUtils::haveExtension("GL_ARB_vertex_shader")) {
- aliasing = DISALLOWED;
- }
- else {
- // check for OpenGL 2.x support
- char *vers = (char *) glGetString(GL_VERSION);
- if (vers[0] == '2' && vers[1] == '.') {
- aliasing = DISALLOWED;
- }
- else {
- assert(vers[0] == '1'); /* revisit when we have OpenGL 3.x */
- aliasing = OPTIONAL;
- }
- }
- for (int i = 0; i < NUM_ARB_ATTRIB_FUNCS; i++) {
- int attribFunc = NUM_NV_ATTRIB_FUNCS + i;
- bool b;
- b = TestAttribs(r, attribFunc, aliasing, numAttribs);
- if (!b)
- result = false;
- r.numARBtested++;
- }
- }
-#else
- (void) r;
-#endif
- return result;
-}
-
-
-// Test the OpenGL 2.x glVertexAttrib functions
-// Return true if pass, false if fail
-bool
-VertAttribTest::Test20funcs(VertAttribResult &r)
-{
- bool result = true;
-#ifdef GL_VERSION_2_0
- GLint numAttribs;
- const Aliasing aliasing = DISALLOWED;
-
- glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numAttribs);
- assert(numAttribs > 0);
-
- r.num20tested = 0;
-
- for (int i = 0; i < NUM_2_0_ATTRIB_FUNCS; i++) {
- int attribFunc = NUM_NV_ATTRIB_FUNCS + NUM_ARB_ATTRIB_FUNCS+ i;
- bool b;
- b = TestAttribs(r, attribFunc, aliasing, numAttribs);
- if (!b)
- result = false;
- r.num20tested++;
- }
-#else
- (void) r;
-#endif
- return result;
-}
-
-
-void
-VertAttribTest::runOne(VertAttribResult& r, Window&)
-{
-
- assert(sizeof(AttribFuncNames) / sizeof(AttribFuncNames[0]) ==
- NUM_NV_ATTRIB_FUNCS + NUM_ARB_ATTRIB_FUNCS + NUM_2_0_ATTRIB_FUNCS);
-
- r.pass = true;
-#ifdef GL_NV_vertex_program
- if (GLUtils::haveExtension("GL_NV_vertex_program")) {
- bool p = TestNVfuncs(r);
- if (!p)
- r.pass = false;
- }
-#endif
-#ifdef GL_ARB_vertex_program
- if (GLUtils::haveExtension("GL_ARB_vertex_program")) {
- bool p = TestARBfuncs(r, false);
- if (!p)
- r.pass = false;
- }
-#endif
-#ifdef GL_ARB_vertex_shader
- if (GLUtils::haveExtension("GL_ARB_vertex_shader")) {
- bool p = TestARBfuncs(r, true);
- if (!p)
- r.pass = false;
- }
-#endif
-#ifdef GL_VERSION_2_0
- const char *vers = (const char *) glGetString(GL_VERSION);
- if (vers[0] == '2' && vers[1] == '.') {
- bool p = Test20funcs(r);
- if (!p)
- r.pass = false;
- }
-#endif
-}
-
-
-void
-VertAttribTest::logOne(VertAttribResult& r)
-{
- logPassFail(r);
- logConcise(r);
- logStats(r);
-}
-
-
-void
-VertAttribTest::logStats(VertAttribResult& r)
-{
- env->log << "\t" << r.numNVtested << " GL_NV_vertex_program functions tested\n";
- env->log << "\t" << r.numARBtested << " GL_ARB_vertex_program/shader functions tested\n";
- env->log << "\t" << r.num20tested << " OpenGL 2.0 functions tested\n";
-}
-
-
-// Instantiate this test object
-VertAttribTest vertAttribTest("vertattrib", "window, rgb",
- "Verify that the glVertexAttribNV, glVertexAttribARB, and glVertexAttrib\n"
- "functions all work correctly.\n");
-
-
-} // namespace GLEAN
diff --git a/tests/glean/tvertattrib.h b/tests/glean/tvertattrib.h
deleted file mode 100644
index ba69640..0000000
--- a/tests/glean/tvertattrib.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or
-// 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
-// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ALLEN AKIN BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-// 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
-
-
-#ifndef __tvertattrib_h__
-#define __tvertattrib_h__
-
-#include "tbase.h"
-
-// Avoid name collision on Windows
-#undef OPTIONAL
-
-namespace GLEAN {
-
-
-class VertAttribResult: public BaseResult
-{
-public:
- bool pass;
- int numNVtested, numARBtested, num20tested;
-
- VertAttribResult()
- {
- numNVtested = numARBtested = num20tested = 0;
- }
-
- virtual void putresults(ostream& s) const
- {
- s << pass
- << ' ' << numNVtested
- << ' ' << numARBtested
- << ' ' << num20tested
- << '\n';
- }
-
- virtual bool getresults(istream& s)
- {
- s >> pass >> numNVtested >> numARBtested >> num20tested;
- return s.good();
- }
-};
-
-
-class VertAttribTest: public BaseTest<VertAttribResult>
-{
-public:
- GLEAN_CLASS(VertAttribTest, VertAttribResult);
- virtual void logStats(VertAttribResult& r);
-
-private:
- enum Aliasing {
- REQUIRED,
- DISALLOWED,
- OPTIONAL
- };
-
- void FailMessage(VertAttribResult &r, const char *msg,
- const char *ext, int dlistMode) const;
- bool TestAttribs(VertAttribResult &r,
- int attribFunc,
- Aliasing aliasing,
- int numAttribs);
- bool TestNVfuncs(VertAttribResult &r);
- bool TestARBfuncs(VertAttribResult &r, bool shader);
- bool Test20funcs(VertAttribResult &r);
-};
-
-} // namespace GLEAN
-
-#endif // __tvertattrib_h__
diff --git a/tests/no_error.py b/tests/no_error.py
index e63d393..3e06313 100644
--- a/tests/no_error.py
+++ b/tests/no_error.py
@@ -21,8 +21,7 @@ profile.test_list = TestDict()
# Add a modified version of each PiglitGLTest as a khr_no_error variant.
# Shader runner doesn't explitly test for expected errors so we add shader
-# tests as is. We actively filter GleanTest instances as well as GLSL parser
-# and any other type of tests.
+# tests as is. We actively filter GLSL parser and any other type of tests.
for name, test in six.iteritems(old_test_list):
if isinstance(test, (PiglitGLTest, ShaderTest, MultiShaderTest)):
profile.test_list['{} khr_no_error'.format(name)] = test
diff --git a/tests/quick.py b/tests/quick.py
index 5107d9f..1a7d674 100644
--- a/tests/quick.py
+++ b/tests/quick.py
@@ -16,7 +16,7 @@ from __future__ import (
import random
from framework import grouptools
-from framework.test import (GleanTest, PiglitGLTest)
+from framework.test import PiglitGLTest
from tests.all import profile as _profile
__all__ = ['profile']
@@ -41,8 +41,6 @@ class FilterVsIn(object):
profile = _profile.copy() # pylint: disable=invalid-name
-GleanTest.GLOBAL_PARAMS += ["--quick"]
-
# Set the --quick flag on a few image_load_store_tests
with profile.test_list.group_manager(
PiglitGLTest,
--
2.7.4
More information about the Piglit
mailing list