Commit 2bac11f2 authored by Kenneth Graunke's avatar Kenneth Graunke

Add a test for EXT_texture_swizzle and DEPTH_TEXTURE_MODE together.

This tests every possible DEPTH_TEXTURE_MODE with a random smattering of
EXT_texture_swizzle modes.  While it could be more exhaustive (or use a
more logically ordered layout), it does catch the bugs I wanted to
detect.

v2: Fix probing bug, minor cleanups based on Brian's feedback.
Signed-off-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>
parent 16358d4e
......@@ -1641,6 +1641,7 @@ for stage in ['vs', 'fs']:
for sampler in textureSize_samplers_atcma:
spec['ARB_texture_cube_map_array/textureSize/' + stage + '-textureSize-' + sampler] = concurrent_test('textureSize ' + stage + ' ' + sampler)
profile.test_list['spec/EXT_texture_swizzle/depth_texture_mode_and_swizzle'] = concurrent_test('depth_texture_mode_and_swizzle')
ext_texture_compression_latc = Group()
spec['EXT_texture_compression_latc'] = ext_texture_compression_latc
......
......@@ -28,6 +28,7 @@ add_subdirectory (ext_fog_coord)
add_subdirectory (ext_framebuffer_multisample)
add_subdirectory (ext_packed_depth_stencil)
add_subdirectory (ext_packed_float)
add_subdirectory (ext_texture_swizzle)
add_subdirectory (ext_timer_query)
add_subdirectory (ext_transform_feedback)
add_subdirectory (nv_conditional_render)
......
include_directories(
${GLEXT_INCLUDE_DIR}
${OPENGL_INCLUDE_PATH}
)
link_libraries (
piglitutil_${piglit_target_api}
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
)
piglit_add_executable (depth_texture_mode_and_swizzle depth_texture_mode_and_swizzle.c)
# vim: ft=cmake:
/*
* Copyright © 2012 Intel Corporation
*
* 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 (including the next
* paragraph) 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
* THE AUTHORS OR COPYRIGHT HOLDERS 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.
*/
/**
* \file depth_texture_mode_and_swizzle.c
*
* Tests the interactions between EXT_texture_swizzle and DEPTH_TEXTURE_MODE.
*
* From the EXT_texture_swizzle specfication:
* "4) How does this interact with depth component textures?
*
* RESOLVED: The swizzle is applied after the DEPTH_TEXTURE_MODE. This
* naturally falls out of specifying the swizzle in terms of Table 3.20."
*
* It would be very easy to write an implementation that respects one or the
* other (but not both), or applies them in the wrong order. This test guards
* against those pitfalls.
*/
#include "piglit-util-gl-common.h"
PIGLIT_GL_TEST_MAIN(170, 30, GLUT_RGBA | GLUT_DOUBLE)
enum piglit_result
piglit_display()
{
bool pass = true;
int i = 0;
static const struct {
GLenum depth_mode;
int swizzles[4];
float expected[4];
} tests[] = {
{
GL_INTENSITY,
{ GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
{ .5, .5, .5, .5 }
},
{
GL_INTENSITY,
{ GL_ONE, GL_GREEN, GL_BLUE, GL_ALPHA },
{ 1, .5, .5, .5 }
},
{
GL_LUMINANCE,
{ GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
{ .5, .5, .5, 1 }
},
{
GL_LUMINANCE,
{ GL_RED, GL_ALPHA, GL_ALPHA, GL_ONE },
{ .5, 1, 1, 1 }
},
{
GL_RED,
{ GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
{ .5, 0, 0, 1 }
},
{
GL_RED,
{ GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA },
{ 0, 0, .5, 1 }
},
{
GL_ALPHA,
{ GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA },
{ 0, 0, 0, 0.5 }
},
{
GL_ALPHA,
{ GL_ONE, GL_GREEN, GL_ALPHA, GL_ZERO },
{ 1, 0, .5, 0 }
},
};
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
glClearColor(0.15, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
for (i = 0; i < ARRAY_SIZE(tests); i++) {
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE,
tests[i].depth_mode);
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA,
tests[i].swizzles);
piglit_draw_rect(10 + 20 * i, 10, 10, 10);
pass = piglit_probe_rect_rgba(10 + 20 * i, 10, 10, 10,
tests[i].expected) && pass;
}
piglit_present_results();
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
/**
* Create texel data: a 1x1 depth texture containing 0.5.
*/
void
setup_texture()
{
GLuint tex;
const float contents = 0.5;
glGenTextures(1, &tex);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
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);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1, 1, 0,
GL_DEPTH_COMPONENT, GL_FLOAT, &contents);
/* Omit the complexity of depth comparisons; just use the raw data. */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
}
/**
* Generate, compile, link, and use the GLSL shaders.
*/
void
setup_shaders()
{
GLuint vs, fs, prog, tex_location;
static const char *vs_code =
"#version 120\n"
"void main()\n"
"{\n"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
"}\n";
static const char *fs_code =
"#version 120\n"
"uniform sampler2D tex;\n"
"void main()\n"
"{\n"
" gl_FragColor = texture2D(tex, vec2(0.5, 0.5));\n"
"}\n";
vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_code);
if (!vs) {
printf("VS code:\n%s", vs_code);
piglit_report_result(PIGLIT_FAIL);
}
fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_code);
if (!fs) {
printf("FS code:\n%s", fs_code);
piglit_report_result(PIGLIT_FAIL);
}
prog = piglit_link_simple_program(vs, fs);
if (!piglit_link_check_status(prog))
piglit_report_result(PIGLIT_FAIL);
piglit_UseProgram(prog);
tex_location = piglit_GetUniformLocation(prog, "tex");
piglit_Uniform1i(tex_location, 0);
}
void
piglit_init(int argc, char **argv)
{
piglit_require_extension("GL_EXT_texture_swizzle");
piglit_require_extension("GL_ARB_texture_rg");
setup_shaders();
setup_texture();
}
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