Commit 332727dd authored by Emma Anholt's avatar Emma Anholt
Browse files

Merge branch 'glean-master'

Conflicts:

	tests/glean/tfragprog1.cpp
parents 118d2f0a a2c35c6f
......@@ -18,6 +18,7 @@ glean['api2'] = GleanTest('api2')
glean['makeCurrent'] = GleanTest('makeCurrent')
glean['blendFunc'] = GleanTest('blendFunc')
glean['depthStencil'] = GleanTest('depthStencil')
glean['fbo'] = GleanTest('fbo')
glean['fpexceptions'] = GleanTest('fpexceptions')
glean['fragProg1'] = GleanTest('fragProg1')
glean['getString'] = GleanTest('getString')
......
......@@ -24,6 +24,7 @@ add_executable (glean
tchgperf.cpp
tdepthstencil.cpp
test.cpp
tfbo.cpp
tfpexceptions.cpp
tfragprog1.cpp
tgetstr.cpp
......
......@@ -573,7 +573,9 @@ API2Test::testUniformfFuncs(void)
renderQuad(pixel);
if (!equalColors(pixel, expected)) {
REPORT_FAILURE("glUniform[1234]f failed");
printf("%f %f %f %f\n", pixel[0], pixel[1], pixel[2], pixel[3]);
//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;
}
......@@ -661,7 +663,7 @@ API2Test::testUniformiFuncs(void)
GLfloat pixel[4], expected[4];
GLint expectedInt[4];
// Test glUniform[1234]f()
// Test glUniform[1234]i()
expectedInt[0] = 1;
expectedInt[1] = 2;
expectedInt[2] = 3;
......@@ -677,11 +679,11 @@ API2Test::testUniformiFuncs(void)
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]);
//printf("%f %f %f %f\n", pixel[0], pixel[1], pixel[2], pixel[3]);
return false;
}
// Test glUniform[1234]fv()
// Test glUniform[1234]iv()
GLint u[4];
expectedInt[0] = 9;
expectedInt[1] = 8;
......@@ -702,7 +704,7 @@ API2Test::testUniformiFuncs(void)
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]);
//printf("%f %f %f %f\n", pixel[0], pixel[1], pixel[2], pixel[3]);
return false;
}
......
This diff is collapsed.
// 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@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)
{
}
virtual void runOne(MultiTestResult &r, Window &w);
private:
typedef bool (FBOTest::*TestFunc)(MultiTestResult &r);
typedef bool (FBOTest::*SubTestFunc)(void);
GLfloat tolerance[5];
void reset(void);
bool testFunctionality(MultiTestResult &r);
bool testPerformance(MultiTestResult &r);
bool testSanity(void);
bool testRender2SingleTexture(void);
bool testRender2MultiTexture(void);
bool testRender2depthTexture(void);
bool testRender2MipmapTexture(void);
bool testErrorHandling(void);
void runSubTests(MultiTestResult &r);
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__
......@@ -1034,6 +1034,9 @@ FragmentProgramTest::testProgram(const FragmentProgram &p)
void
FragmentProgramTest::runOne(MultiTestResult &r, Window &w)
{
// to test a single sub-test, set the name here:
const char *single = NULL;
(void) w;
setup();
......@@ -1041,18 +1044,22 @@ FragmentProgramTest::runOne(MultiTestResult &r, Window &w)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
#endif
for (int i = 0; Programs[i].name; i++) {
if (Programs[i].flags && FragmentProgram::NeedsFogCoord) {
if (!glFogCoordf_func)
continue;
}
if (!single || strcmp(single, Programs[i].name) == 0) {
if (Programs[i].flags &&
FragmentProgram::NeedsFogCoord) {
if (!glFogCoordf_func)
continue;
}
#if DEVEL_MODE
glViewport(0, i * 20, windowWidth, 20);
glViewport(0, i * 20, windowWidth, 20);
#endif
if (!testProgram(Programs[i])) {
r.numFailed++;
}
else {
r.numPassed++;
if (!testProgram(Programs[i])) {
r.numFailed++;
}
else {
r.numPassed++;
}
}
}
......
......@@ -35,7 +35,7 @@
#include <cassert>
#include <cstring>
#include <cmath>
#include <cstdlib>
namespace GLEAN {
......@@ -914,7 +914,7 @@ static const ShaderProgram Programs[] = {
NO_VERTEX_SHADER,
"void main() { \n"
" float x = 1.0; \n"
" if (x) { \n"
" if (x != 0.0) { \n"
" gl_FragColor = vec4(0.5, 0.0, 0.5, 0.0); \n"
" } \n"
"} \n",
......@@ -994,7 +994,7 @@ static const ShaderProgram Programs[] = {
" sum += 0.1; \n"
" if (sum >= 0.499999) \n"
" break; \n"
" } while (1); \n"
" } while (true); \n"
" gl_FragColor = vec4(sum); \n"
"} \n",
{ 0.5, 0.5, 0.5, 0.5 },
......@@ -1012,7 +1012,7 @@ static const ShaderProgram Programs[] = {
" if (sum < 0.499999) \n"
" continue; \n"
" break; \n"
" } while (1); \n"
" } while (true); \n"
" gl_FragColor = vec4(sum); \n"
"} \n",
{ 0.5, 0.5, 0.5, 0.5 },
......@@ -1089,6 +1089,22 @@ static const ShaderProgram Programs[] = {
FLAG_NONE
},
#if 0 // XXX enable someday
{
"vector subscript *=",
NO_VERTEX_SHADER,
"void main() { \n"
" vec4 c = vec4(0.25, 0.5, 0.1, 0.1); \n"
" c[0] *= 4.0; \n"
" c[1] *= 2.0; \n"
" gl_FragColor = c; \n"
"} \n",
{ 1.0, 1.0, 0.1, 0.1 },
DONT_CARE_Z,
FLAG_NONE
},
#endif
// Equality/inequality tests==========================================
{
"equality (float, pass)",
......@@ -1351,7 +1367,7 @@ static const ShaderProgram Programs[] = {
"void main() { \n"
" float x = 0.75; \n"
" // this should always be false \n"
" if (x <= 0.5 && ++x) { \n"
" if (x <= 0.5 && ++x > 0.0) { \n"
" x += 0.1; \n"
" } \n"
" gl_FragColor = vec4(x); \n"
......@@ -1396,7 +1412,7 @@ static const ShaderProgram Programs[] = {
"void main() { \n"
" float x = 0.75; \n"
" // this should always be true \n"
" if (x >= 0.5 || ++x) { \n"
" if (x >= 0.5 || ++x >= 0.0) { \n"
" x += 0.1; \n"
" } \n"
" gl_FragColor = vec4(x); \n"
......@@ -2173,10 +2189,10 @@ static const ShaderProgram Programs[] = {
" vec2 c = vec2( 3.0, 2.0); \n"
" bvec2 b1 = equal(a, b); \n"
" bvec2 b2 = notEqual(b, c); \n"
" gl_FragColor.x = b1.x; \n"
" gl_FragColor.y = b1.y; \n"
" gl_FragColor.z = b2.x; \n"
" gl_FragColor.w = b2.y; \n"
" gl_FragColor.x = float(b1.x); \n"
" gl_FragColor.y = float(b1.y); \n"
" gl_FragColor.z = float(b2.x); \n"
" gl_FragColor.w = float(b2.y); \n"
"} \n",
{ 1.0, 0.0, 1.0, 0.0 },
DONT_CARE_Z,
......@@ -3371,7 +3387,7 @@ GLSLTest::runOne(MultiTestResult &r, Window &w)
}
// If you just want to run a single sub-test, assign the name to singleTest.
const char *singleTest = NULL;
const char *singleTest = getenv("GLSL_TEST");
if (singleTest) {
for (int i = 0; Programs[i].name; i++) {
if (strcmp(Programs[i].name, singleTest) == 0) {
......
......@@ -1013,20 +1013,118 @@ VertexProgramTest::testProgram(const VertexProgram &p)
return true;
}
void
VertexProgramTest::testBadProgram(MultiTestResult &result)
{
const GLfloat r = 0.25;
GLenum err;
{
static const char *badprog =
"!!ARBvp1.0\n"
"NOTANOPCODE;\n"
"MOV result.position, vertex.position;\n";
glProgramStringARB_func(GL_VERTEX_PROGRAM_ARB,
GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(badprog),
(const GLubyte *) badprog);
/* Test that an invalid program raises an error */
err = glGetError();
if (err != GL_INVALID_OPERATION) {
env->log << "Unexpected OpenGL error state " << (int) err <<
" with bad vertex program.\n";
env->log << "Expected: " << GL_INVALID_OPERATION << "\n";
result.numFailed++;
while (err != 0)
err = glGetError();
} else {
result.numPassed++;
}
}
/* Check that we correctly produce GL_INVALID_OPERATION when rendering
* with an invalid (non-existant in this case) program.
*/
{
glBindProgramARB_func(GL_VERTEX_PROGRAM_ARB, 99);
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();
err = glGetError();
if (err != GL_INVALID_OPERATION) {
env->log << "Unexpected OpenGL error state " << (int) err <<
" in glBegin() with bad vertex program.\n";
env->log << "Expected: " << GL_INVALID_OPERATION << "\n";
result.numFailed++;
while (err != 0)
err = glGetError();
} else {
result.numPassed++;
}
}
/* Similarly, test that glDrawArrays raises GL_INVALID_OPERATION
*/
{
static const GLfloat vertcoords[4][3] = {
{ -r, -r, 0 }, { r, -r, 0 }, { r, r, 0 }, { -r, r, 0 }
};
glVertexPointer(3, GL_FLOAT, 0, vertcoords);
glEnable(GL_VERTEX_ARRAY);
glDrawArrays(GL_POLYGON, 0, 4);
err = glGetError();
glDisable(GL_VERTEX_ARRAY);
if (err != GL_INVALID_OPERATION) {
env->log << "Unexpected OpenGL error state " << (int) err <<
" in glDrawArrays() with bad vertex program.\n";
env->log << "Expected: " << GL_INVALID_OPERATION << "\n";
result.numFailed++;
while (err != 0)
glGetError();
} else {
result.numPassed++;
}
}
}
void
VertexProgramTest::runOne(MultiTestResult &r, Window &w)
{
// to test a single sub-test, set the name here:
const char *single = NULL;
(void) w;
setup();
for (int i = 0; Programs[i].name; i++) {
if (!testProgram(Programs[i])) {
r.numFailed++;
}
else {
r.numPassed++;
if (!single || strcmp(single, Programs[i].name) == 0) {
if (!testProgram(Programs[i])) {
r.numFailed++;
}
else {
r.numPassed++;
}
}
}
testBadProgram(r);
r.pass = (r.numFailed == 0);
}
......
......@@ -72,6 +72,7 @@ private:
bool equalColors(const GLfloat a[4], const GLfloat b[4], int flags) const;
bool equalDepth(GLfloat z0, GLfloat z1) const;
bool testProgram(const VertexProgram &p);
void testBadProgram(MultiTestResult &result);
void reportFailure(const char *programName,
const GLfloat expectedColor[4],
const GLfloat actualColor[4] ) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment