summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-08-25 12:07:49 -0700
committerEric Anholt <eric@anholt.net>2010-08-25 12:30:44 -0700
commit4016a33491ee6ba37e1dc39f6057d2603a065398 (patch)
treea44cde33a86d4f95f1d8bc33f72e1c81e611e288
parent23d9c250e60c4931a24d83fcd525cfe165f325dd (diff)
glsl-fs-sampler-numbering-[23]: More thorough tests of sampler numbering.
-rw-r--r--tests/all.tests2
-rw-r--r--tests/shaders/glsl-fs-sampler-numbering-2.shader_test51
-rw-r--r--tests/shaders/glsl-fs-sampler-numbering-3.shader_test50
-rw-r--r--tests/shaders/shader_runner.c15
4 files changed, 117 insertions, 1 deletions
diff --git a/tests/all.tests b/tests/all.tests
index a1a83a46e..b87c4e66f 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -294,6 +294,8 @@ add_plain_test(shaders, 'glsl-fs-pointcoord')
add_plain_test(shaders, 'glsl-fs-raytrace-bug27060')
add_shader_generic(shaders, 'glsl-fs-reflect')
add_plain_test(shaders, 'glsl-fs-sampler-numbering')
+add_shader_generic(shaders, 'glsl-fs-sampler-numbering-2')
+add_shader_generic(shaders, 'glsl-fs-sampler-numbering-3')
add_plain_test(shaders, 'glsl-fs-sqrt-branch')
add_plain_test(shaders, 'glsl-fs-sqrt-zero')
add_shader_generic(shaders, 'glsl-fs-sign')
diff --git a/tests/shaders/glsl-fs-sampler-numbering-2.shader_test b/tests/shaders/glsl-fs-sampler-numbering-2.shader_test
new file mode 100644
index 000000000..6ae0f87a3
--- /dev/null
+++ b/tests/shaders/glsl-fs-sampler-numbering-2.shader_test
@@ -0,0 +1,51 @@
+[require]
+GL >= 2.0
+GLSL >= 1.10
+
+[vertex shader]
+varying vec2 texcoords;
+uniform float yoffset;
+
+void main()
+{
+ gl_Position = gl_Vertex;
+ texcoords = gl_Vertex.xy + vec2(0.0, yoffset);
+}
+
+[fragment shader]
+varying vec2 texcoords;
+uniform sampler2D left;
+uniform sampler2D right;
+
+void main()
+{
+ if (texcoords.x < 0.0) {
+ gl_FragColor = texture2D(left, texcoords.xy + vec2(1.0, 0.0));
+ } else {
+ gl_FragColor = texture2D(right, texcoords.xy);
+ }
+}
+
+[test]
+texture checkerboard 0 0 (8, 8) (0.0, 0.0, 0.0, 0.0) (0.0, 1.0, 0.0, 0.0)
+texture checkerboard 1 0 (8, 8) (0.0, 0.0, 0.0, 0.0) (1.0, 0.0, 0.0, 0.0)
+
+uniform int left 0
+uniform int right 1
+uniform float yoffset 1.0
+draw rect -1 -1 2 1
+
+uniform int left 1
+uniform int right 0
+uniform float yoffset 0.0
+draw rect -1 0 2 1
+
+relative probe rgb (0.375, 0.125) (0.0, 1.0, 0.0)
+relative probe rgb (0.125, 0.375) (0.0, 1.0, 0.0)
+relative probe rgb (0.875, 0.625) (0.0, 1.0, 0.0)
+relative probe rgb (0.675, 0.875) (0.0, 1.0, 0.0)
+
+relative probe rgb (0.875, 0.125) (1.0, 0.0, 0.0)
+relative probe rgb (0.625, 0.375) (1.0, 0.0, 0.0)
+relative probe rgb (0.375, 0.625) (1.0, 0.0, 0.0)
+relative probe rgb (0.125, 0.875) (1.0, 0.0, 0.0)
diff --git a/tests/shaders/glsl-fs-sampler-numbering-3.shader_test b/tests/shaders/glsl-fs-sampler-numbering-3.shader_test
new file mode 100644
index 000000000..35090ab1d
--- /dev/null
+++ b/tests/shaders/glsl-fs-sampler-numbering-3.shader_test
@@ -0,0 +1,50 @@
+[require]
+GL >= 2.0
+GLSL >= 1.10
+
+[vertex shader]
+varying vec2 texcoords;
+uniform float yoffset;
+
+void main()
+{
+ gl_Position = gl_Vertex;
+ texcoords = gl_Vertex.xy + vec2(0.0, yoffset);
+}
+
+[fragment shader]
+varying vec2 texcoords;
+uniform sampler2D tex[2];
+
+void main()
+{
+ if (texcoords.x < 0.0) {
+ gl_FragColor = texture2D(tex[0], texcoords.xy + vec2(1.0, 0.0));
+ } else {
+ gl_FragColor = texture2D(tex[1], texcoords.xy);
+ }
+}
+
+[test]
+texture checkerboard 0 0 (8, 8) (0.0, 0.0, 0.0, 0.0) (0.0, 1.0, 0.0, 0.0)
+texture checkerboard 1 0 (8, 8) (0.0, 0.0, 0.0, 0.0) (1.0, 0.0, 0.0, 0.0)
+
+uniform int tex[0] 0
+uniform int tex[1] 1
+uniform float yoffset 1.0
+draw rect -1 -1 2 1
+
+uniform int tex[0] 1
+uniform int tex[1] 0
+uniform float yoffset 0.0
+draw rect -1 0 2 1
+
+relative probe rgb (0.375, 0.125) (0.0, 1.0, 0.0)
+relative probe rgb (0.125, 0.375) (0.0, 1.0, 0.0)
+relative probe rgb (0.875, 0.625) (0.0, 1.0, 0.0)
+relative probe rgb (0.675, 0.875) (0.0, 1.0, 0.0)
+
+relative probe rgb (0.875, 0.125) (1.0, 0.0, 0.0)
+relative probe rgb (0.625, 0.375) (1.0, 0.0, 0.0)
+relative probe rgb (0.375, 0.625) (1.0, 0.0, 0.0)
+relative probe rgb (0.125, 0.875) (1.0, 0.0, 0.0)
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index fe8515714..bb9637947 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -658,7 +658,7 @@ piglit_display(void)
line = test_start;
while (line[0] != '\0') {
float c[32];
- int x, y, w, h, tex;
+ int x, y, w, h, tex, level;
line = eat_whitespace(line);
@@ -740,6 +740,19 @@ piglit_display(void)
glActiveTexture(GL_TEXTURE0 + tex);
piglit_rgbw_texture(GL_RGBA, w, h, GL_FALSE);
glEnable(GL_TEXTURE_2D);
+ } else if (sscanf(line,
+ "texture checkerboard %d %d ( %d , %d ) "
+ "( %f , %f , %f , %f ) "
+ "( %f , %f , %f , %f )",
+ &tex, &level, &w, &h,
+ c + 0, c + 1, c + 2, c + 3,
+ c + 4, c + 5, c + 6, c + 7) == 12) {
+ glActiveTexture(GL_TEXTURE0 + tex);
+ piglit_checkerboard_texture(0, level,
+ w, h,
+ w / 2, h / 2,
+ c + 0, c + 4);
+ glEnable(GL_TEXTURE_2D);
} else if (string_match("uniform", line)) {
set_uniform(line + 7);
} else if ((line[0] != '\n') && (line[0] != '\0')