Commit ad03bd4d authored by Nicolai Hähnle's avatar Nicolai Hähnle

Various fixes by Brian Paul.

Quote from his description:
In fp-fragment-position.c the 4th fragment program uses
fragment.position to index a 2D texture.  Since all the fragment
positions are integers > 1 the default GL_REPEAT texture wrap mode
converts all the texcoords to zero.  Actually, though, that's not true.
  Because of the way texcoords are processed, the fractional part of the
coords is not always zero but some epsilon value.  That caused us to
sample with different texcoords than the test expects.

I think it's more useful to scale the fragment position to put it into
the nominal [0,1] range to get a color that varies per pixel.

My patch does that, and adds some assorted comments to the code.

---

In fp-list-mask.c and texrect-many.c and texdepth.c I added GLUT_ALPHA
to glutInitDisplayMode().  We had failures because GLUT was sometimes
choosing visuals without an alpha channel.

---
<
The logic in vp-bad-program.c was incorrect.  When glProgramString() is
called with an invalid program, we raise an error, but the previous
program (if any) stays in effect.  So the subsequent glBegin() would
never raise an error.  The proper way to check for glBegin raising an
error with an invalid program is to simply bind a non-existant program.

I made the same fix in glean a while ago.

There's still some other failures I need to look into (and I'm not sure
where the faults are) but I need to move onto some other things now.
parent 46c346ff
......@@ -43,11 +43,13 @@ static void CheckFail(const char* cond);
static GLuint FragProg[NUM_PROGRAMS];
static const char* const ProgramText[NUM_PROGRAMS] = {
/* Color = fragment pos * scale factor */
"!!ARBfp1.0\n"
"PARAM factor = { 0.01, 0.01, 1.0, 0.2 };\n"
"MUL result.color, fragment.position, factor;\n"
"END",
/* Color = dependent 2D texture read */
"!!ARBfp1.0\n"
"TEMP r0;\n"
"ALIAS scaled = r0;\n"
......@@ -55,12 +57,17 @@ static const char* const ProgramText[NUM_PROGRAMS] = {
"TEX result.color, scaled, texture[1], 2D;\n"
"END",
/* Color = RECT texture color at fragment pos */
"!!ARBfp1.0\n"
"TEX result.color, fragment.position, texture[0], RECT;\n"
"END",
/* Color = 2D texture color at fragment pos */
"!!ARBfp1.0\n"
"TEX result.color, fragment.position, texture[1], 2D;\n"
"PARAM scale = { 0.01, 0.01, 1.0, 1.0 };\n"
"TEMP tc;\n"
"MUL tc, fragment.position, scale;\n"
"TEX result.color, tc, texture[1], 2D;\n"
"MOV result.color.w, 0.5;\n"
"END",
};
......@@ -79,6 +86,19 @@ static PFNGLISPROGRAMARBPROC pglIsProgramARB;
static PFNGLDELETEPROGRAMSARBPROC pglDeleteProgramsARB;
/**
* Draw four quadrilaterals, one for each fragment program:
* +--------+--------+
* | | |
* | Prog 1 | Prog 3 |
* | | |
* +--------+--------+
* | | |
* | Prog 0 | Prog 2 |
* | | |
* +--------+--------+
* Each quad is about 100x100 pixels in size.
*/
static void DoFrame(void)
{
int mask;
......@@ -208,22 +228,22 @@ static const struct {
{
"tex2d unscaled #1",
1.2, 1.2,
{ 1.0, 0.5, 0.5, 0.5 }
{ 0.8, 0.2, 0.2, 0.5 }
},
{
"tex2d unscaled #2",
1.8, 1.2,
{ 1.0, 0.5, 0.5, 0.5 }
{ 0.2, 0.2, 0.8, 0.5 }
},
{
"tex2d unscaled #3",
1.8, 1.8,
{ 1.0, 0.5, 0.5, 0.5 }
{ 0.2, 0.8, 0.8, 0.5 }
},
{
"tex2d unscaled #4",
1.2, 1.8,
{ 1.0, 0.5, 0.5, 0.5 }
{ 0.8, 0.8, 0.2, 0.5 }
},
// Sentinel!
......@@ -248,6 +268,12 @@ static int DoTest( void )
GLfloat delta[4];
int i;
/*
printf("ReadPixels at %d, %d\n",
(int)(Probes[idx].x*Width/2),
(int)(Probes[idx].y*Height/2));
*/
glReadPixels((int)(Probes[idx].x*Width/2),
(int)(Probes[idx].y*Height/2),
1, 1,
......@@ -410,7 +436,7 @@ static void Init(void)
}
/*
* Textures
* Texture unit 0: 200x200 RECTANGLE texture
*/
for(y = 0; y < 200; ++y) {
for(x = 0; x < 200; ++x) {
......@@ -426,6 +452,9 @@ static void Init(void)
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 200, 200, 0,
GL_RGBA, GL_UNSIGNED_BYTE, rectangle);
/*
* Texture unit 1: 256x256 2D texture
*/
for(y = 0; y < 256; ++y) {
for(x = 0; x < 256; ++x) {
tex[256*y+x][0] = 255-x;
......
......@@ -258,7 +258,7 @@ int main(int argc, char *argv[])
Automatic = 1;
glutInitWindowPosition(0, 0);
glutInitWindowSize(Width, Height);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitDisplayMode(GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
......
......@@ -51,6 +51,7 @@ static int automatic = 0;
#define WIN_HEIGHT 128
static PFNGLPROGRAMSTRINGARBPROC pglProgramStringARB;
static PFNGLBINDPROGRAMARBPROC pglBindProgramARB;
static void
display(void)
......@@ -86,8 +87,11 @@ display(void)
}
/* Check that we correctly produce GL_INVALID_OPERATION when rendering
* with the bad program string.
* with an invalid/non-existant program.
*/
pglBindProgramARB(GL_VERTEX_PROGRAM_ARB, 99);
glEnable(GL_VERTEX_PROGRAM_ARB);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_POLYGON);
glTexCoord2f(0, 0); glVertex2f(-0.25, -0.25);
......@@ -108,7 +112,7 @@ display(void)
}
/* Check that we correctly produce GL_INVALID_OPERATION when doing
* glDrawArrays with the bad program string.
* glDrawArrays with an invalid/non-existant program.
*/
glVertexPointer(3, GL_FLOAT, 0, vertcoords);
......@@ -154,6 +158,9 @@ main(int argc, char**argv)
pglProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) glutGetProcAddress("glProgramStringARB");
assert(pglProgramStringARB);
pglBindProgramARB = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress("glBindProgramARB");
assert(pglBindProgramARB);
glutMainLoop();
return 0;
}
......@@ -65,6 +65,7 @@ static void CreateRenderedTexture()
static int probe_cell_depth_mode(int cellx, int celly, int depth_texture_mode, float value)
{
float expected[4] = { 1.0, 1.0, 1.0, 1.0 };
int res;
switch(depth_texture_mode) {
case GL_INTENSITY:
......@@ -83,9 +84,13 @@ static int probe_cell_depth_mode(int cellx, int celly, int depth_texture_mode, f
break;
}
return piglit_probe_pixel_rgba(
res = piglit_probe_pixel_rgba(
cellx*CellWidth + (CellWidth/2), celly*CellHeight + (CellHeight/2),
expected);
printf("%s(%d, %d, 0x%x, %f) = %d\n",
__FUNCTION__, cellx, celly, depth_texture_mode, value, res);
return res;
}
......@@ -408,7 +413,7 @@ int main(int argc, char**argv)
glutInit(&argc, argv);
if (argc == 2 && !strcmp(argv[1], "-auto"))
Automatic = 1;
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA | GLUT_DEPTH);
glutInitWindowSize(Width, Height);
glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
......
......@@ -196,7 +196,7 @@ int main(int argc, char**argv)
glutInit(&argc, argv);
if (argc == 2 && !strcmp(argv[1], "-auto"))
Automatic = 1;
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA);
glutInitWindowSize(Width, Height);
glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
......
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