[Piglit] [PATCH] glsl-deriv-varyings: Fixes compilation warnings and adds extra regular subtest

Andres Gomez agomez at igalia.com
Fri Dec 19 17:43:16 PST 2014


A new subtest has been introduced for testing the regular expected
values when using dFdx/dFdy in combination with the negative and abs
register modifiers.
---
 tests/shaders/glsl-deriv-varyings.c | 62 ++++++++++++++++++++++++++++++-------
 1 file changed, 50 insertions(+), 12 deletions(-)

diff --git a/tests/shaders/glsl-deriv-varyings.c b/tests/shaders/glsl-deriv-varyings.c
index fa72eec..c3492df 100644
--- a/tests/shaders/glsl-deriv-varyings.c
+++ b/tests/shaders/glsl-deriv-varyings.c
@@ -55,6 +55,8 @@ static GLint prog4;
 static GLint fs4;
 static GLint prog5;
 static GLint fs5;
+static GLint prog6;
+static GLint fs6;
 
 
 static GLfloat verts[12] = {175.0, 125.0, 0.0,
@@ -86,7 +88,6 @@ static const char *fragShaderText =
 	"} \n";
 
 static const char *fragShaderText2 =
-	"uniform sampler2D tex2d;\n"
 	"varying vec2 texCoords;\n"
 	"void main()\n"
 	"{ \n"
@@ -96,7 +97,6 @@ static const char *fragShaderText2 =
 	"} \n";
 
 static const char *fragShaderText3 =
-	"uniform sampler2D tex2d;\n"
 	"varying vec2 texCoords;\n"
 	"void main()\n"
 	"{ \n"
@@ -106,7 +106,6 @@ static const char *fragShaderText3 =
 	"} \n";
 
 static const char *fragShaderText4 =
-	"uniform sampler2D tex2d;\n"
 	"varying vec2 texCoords;\n"
 	"void main()\n"
 	"{ \n"
@@ -116,12 +115,20 @@ static const char *fragShaderText4 =
 	"} \n";
 
 static const char *fragShaderText5 =
-	"uniform sampler2D tex2d;\n"
 	"varying vec2 texCoords;\n"
 	"void main()\n"
 	"{ \n"
 	"	gl_FragColor = vec4(dFdx(-abs(texCoords.x)) * -40.0,\n"
-	"			    dFdy(-abs(texCoords.y) * -40.0,\n"
+	"			    dFdy(-abs(texCoords.y)) * -40.0,\n"
+	"			    0.0, 1.0);\n"
+	"} \n";
+
+static const char *fragShaderText6 =
+	"varying vec2 texCoords;\n"
+	"void main()\n"
+	"{ \n"
+	"	gl_FragColor = vec4(dFdx(abs(texCoords.x)) * 40.0,\n"
+	"			    dFdy(abs(texCoords.y)) * 40.0,\n"
 	"			    0.0, 1.0);\n"
 	"} \n";
 
@@ -158,12 +165,15 @@ compileLinkProg(void)
 
 	fs5 = glCreateShader(GL_FRAGMENT_SHADER);
 
+	fs6 = glCreateShader(GL_FRAGMENT_SHADER);
+
 	glShaderSource(vs1, 1, (const GLchar **) &vertShaderText, NULL);
 	glShaderSource(fs1, 1, (const GLchar **) &fragShaderText, NULL);
 	glShaderSource(fs2, 1, (const GLchar **) &fragShaderText2, NULL);
 	glShaderSource(fs3, 1, (const GLchar **) &fragShaderText3, NULL);
-	glShaderSource(fs4, 1, (const GLchar **) &fragShaderText3, NULL);
-	glShaderSource(fs5, 1, (const GLchar **) &fragShaderText3, NULL);
+	glShaderSource(fs4, 1, (const GLchar **) &fragShaderText4, NULL);
+	glShaderSource(fs5, 1, (const GLchar **) &fragShaderText5, NULL);
+	glShaderSource(fs6, 1, (const GLchar **) &fragShaderText6, NULL);
 
 	glCompileShader(vs1);
 	glGetShaderiv(vs1, GL_COMPILE_STATUS, &stat);
@@ -207,6 +217,13 @@ compileLinkProg(void)
 		exit(1);
 	}
 
+	glCompileShader(fs6);
+	glGetShaderiv(fs6, GL_COMPILE_STATUS, &stat);
+	if (!stat) {
+		printf("error compiling fragment shader6!\n");
+		exit(1);
+	}
+
 
 	prog1 = glCreateProgram();
 	glAttachShader(prog1, vs1);
@@ -281,6 +298,21 @@ compileLinkProg(void)
 				texCoords);
 	glEnableVertexAttribArray(0);
 	glEnableVertexAttribArray(1);
+
+
+	prog6 = glCreateProgram();
+	glAttachShader(prog6, vs1);
+	glAttachShader(prog6, fs6);
+	glBindAttribLocation(prog6, 1, "textureCoords");
+	glLinkProgram(prog6);
+	glUseProgram(prog6);
+
+	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3*sizeof(GLfloat),
+                               verts);
+	glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 2*sizeof(GLfloat),
+				texCoords);
+	glEnableVertexAttribArray(0);
+	glEnableVertexAttribArray(1);
 }
 
 static void
@@ -359,13 +391,19 @@ piglit_display(void)
 	glUseProgram(prog5);
 	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
+	glTranslatef(75.0, 0.0, 0.0);
+
+	glUseProgram(prog6);
+	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
 	glPopMatrix();
 
-	pass = pass && piglit_probe_pixel_rgb(132, 125, green);
-	pass = pass && piglit_probe_pixel_rgb(205, 125, deriv);
-	pass = pass && piglit_probe_pixel_rgb(280, 125, deriv);
-	pass = pass && piglit_probe_pixel_rgb(355, 125, deriv);
-	pass = pass && piglit_probe_pixel_rgb(430, 125, deriv);
+	pass = pass && piglit_probe_pixel_rgb(132, 130, green);
+	pass = pass && piglit_probe_pixel_rgb(205, 130, deriv);
+	pass = pass && piglit_probe_pixel_rgb(280, 130, deriv);
+	pass = pass && piglit_probe_pixel_rgb(355, 130, deriv);
+	pass = pass && piglit_probe_pixel_rgb(430, 130, deriv);
+	pass = pass && piglit_probe_pixel_rgb(505, 130, deriv);
 
 	glFinish();
 	piglit_present_results();
-- 
1.9.1



More information about the Piglit mailing list