Commit 693b0f62 authored by chadversary's avatar chadversary

hiz: Add tests for depth reads with various framebuffer configurations

Add the following tests:
    hiz-depth-read-fbo-d24-s0
    hiz-depth-read-fbo-d24-s8
    hiz-depth-read-fbo-d24s8
    hiz-depth-read-window-stencil0
    hiz-depth-read-window-stencil1
Signed-off-by: chadversary's avatarChad Versace <chad@chad-versace.us>
parent 6930fc79
......@@ -1054,6 +1054,11 @@ add_plain_test(hiz, 'hiz-depth-stencil-test-fbo-d0-s8')
add_plain_test(hiz, 'hiz-depth-stencil-test-fbo-d24-s0')
add_plain_test(hiz, 'hiz-depth-stencil-test-fbo-d24-s8')
add_plain_test(hiz, 'hiz-depth-stencil-test-fbo-d24s8')
add_plain_test(hiz, 'hiz-depth-read-fbo-d24-s0')
add_plain_test(hiz, 'hiz-depth-read-fbo-d24-s8')
add_plain_test(hiz, 'hiz-depth-read-fbo-d24s8')
add_plain_test(hiz, 'hiz-depth-read-window-stencil0')
add_plain_test(hiz, 'hiz-depth-read-window-stencil1')
add_plain_test(hiz, 'hiz-depth-test-fbo-d24')
add_plain_test(hiz, 'hiz-depth-test-fbo-d24-s8')
add_plain_test(hiz, 'hiz-depth-test-fbo-d24s8')
......
......@@ -28,6 +28,11 @@ add_executable(hiz-depth-stencil-test-fbo-d0-s8 hiz-depth-stencil-test-fbo-d0-s8
add_executable(hiz-depth-stencil-test-fbo-d24-s0 hiz-depth-stencil-test-fbo-d24-s0.c)
add_executable(hiz-depth-stencil-test-fbo-d24-s8 hiz-depth-stencil-test-fbo-d24-s8.c)
add_executable(hiz-depth-stencil-test-fbo-d24s8 hiz-depth-stencil-test-fbo-d24s8.c)
add_executable(hiz-depth-read-fbo-d24-s0 hiz-depth-read-fbo-d24-s0.c)
add_executable(hiz-depth-read-fbo-d24-s8 hiz-depth-read-fbo-d24-s8.c)
add_executable(hiz-depth-read-fbo-d24s8 hiz-depth-read-fbo-d24s8.c)
add_executable(hiz-depth-read-window-stencil0 hiz-depth-read-window-stencil0.c)
add_executable(hiz-depth-read-window-stencil1 hiz-depth-read-window-stencil1.c)
add_executable(hiz-depth-test-fbo-d24 hiz-depth-test-fbo-d24.c)
add_executable(hiz-depth-test-fbo-d24-s8 hiz-depth-test-fbo-d24-s8.c)
add_executable(hiz-depth-test-fbo-d24s8 hiz-depth-test-fbo-d24s8.c)
......
/*
* Copyright © 2011 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 hiz-depth-read-fbo-d24-s0.c
*
* Checks that depth reads work correctly when rendering to a window FBO with
* the following attachments:
* - GL_COLOR_ATTACHMENT0: GL_RGBA
* - GL_DEPTH_ATTACHMENT: GL_DEPTH_COMPONENT24
*/
#include "piglit-util.h"
#include "hiz/hiz-util.h"
int piglit_width = 400;
int piglit_height = 400;
int piglit_window_mode = GLUT_RGB;
struct hiz_fbo_options fbo_options = {
GL_RGBA,
GL_DEPTH_COMPONENT24,
0,
0,
};
void
piglit_init(int argc, char **argv)
{
/* empty */
}
enum piglit_result
piglit_display()
{
if (hiz_run_test_depth_read_fbo(&fbo_options))
return PIGLIT_PASS;
else
return PIGLIT_FAIL;
}
/*
* Copyright © 2011 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 hiz-depth-read-fbo-d24-s8.c
*
* Checks that depth reads work correctly when rendering to a window FBO with
* the following attachments:
* - GL_COLOR_ATTACHMENT0: GL_RGBA
* - GL_DEPTH_ATTACHMENT: GL_DEPTH_COMPONENT24
* - GL_STENCIL_ATTACHMENT: GL_STENCIL_INDEX8
*/
#include "piglit-util.h"
#include "hiz/hiz-util.h"
int piglit_width = 400;
int piglit_height = 400;
int piglit_window_mode = GLUT_RGB;
struct hiz_fbo_options fbo_options = {
GL_RGBA,
GL_DEPTH_COMPONENT24,
GL_STENCIL_INDEX8,
0,
};
void
piglit_init(int argc, char **argv)
{
/* empty */
}
enum piglit_result
piglit_display()
{
if (hiz_run_test_depth_read_fbo(&fbo_options))
return PIGLIT_PASS;
else
return PIGLIT_FAIL;
}
/*
* Copyright © 2011 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 hiz-depth-read-fbo-d24s8.c
*
* Checks that depth reads work correctly when rendering to a window FBO with
* the following attachments:
* - GL_COLOR_ATTACHMENT0: GL_RGBA
* - GL_DEPTH_STENCIL_ATTACHMENT: GL_DEPTH24_STENCIL8
*/
#include "piglit-util.h"
#include "hiz/hiz-util.h"
int piglit_width = 400;
int piglit_height = 400;
int piglit_window_mode = GLUT_RGB;
struct hiz_fbo_options fbo_options = {
GL_RGBA,
0,
0,
GL_DEPTH24_STENCIL8,
};
void
piglit_init(int argc, char **argv)
{
/* empty */
}
enum piglit_result
piglit_display()
{
if (hiz_run_test_depth_read_fbo(&fbo_options))
return PIGLIT_PASS;
else
return PIGLIT_FAIL;
}
/*
* Copyright © 2011 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 hiz-depth-read-window-stencil0.c
*
* Checks that depth reads work correctly when rendering to a window
* framebuffer for which no stencil buffer was requested.
*/
#include "piglit-util.h"
#include "hiz/hiz-util.h"
int piglit_width = 400;
int piglit_height = 400;
int piglit_window_mode = GLUT_RGB | GLUT_ALPHA | GLUT_DEPTH;
void
piglit_init(int argc, char **argv)
{
/* empty */
}
enum piglit_result
piglit_display()
{
if (hiz_run_test_depth_read_window())
return PIGLIT_PASS;
else
return PIGLIT_FAIL;
}
/*
* Copyright © 2011 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 hiz-depth-read-window-stencil1.c
*
* Checks that depth reads work correctly when rendering to a window
* framebuffer for which a stencil buffer was requested.
*/
#include "piglit-util.h"
#include "hiz/hiz-util.h"
int piglit_width = 400;
int piglit_height = 400;
int piglit_window_mode = GLUT_RGB | GLUT_ALPHA | GLUT_DEPTH | GLUT_STENCIL;
void
piglit_init(int argc, char **argv)
{
/* empty */
}
enum piglit_result
piglit_display()
{
if (hiz_run_test_depth_read_window())
return PIGLIT_PASS;
else
return PIGLIT_FAIL;
}
......@@ -283,6 +283,126 @@ hiz_run_test_depth_test_window()
/* ------------------------------------------------------------------------ */
/**
* \name hiz_run_depth_read utilties
*
* Utilities for testing depth reads.
*
* \{
*/
/**
* Common functionality needed by hiz_run_test_depth_read_fbo() and
* hiz_run_test_depth_read_window().
*/
static bool
hiz_run_test_depth_read_common()
{
static const float *expect_color[9] = {
hiz_green,
hiz_green,
hiz_grey,
hiz_green,
hiz_green,
hiz_blue,
hiz_grey,
hiz_blue,
hiz_blue
};
static const float expect_depth[9] = {
hiz_green_z,
hiz_green_z,
hiz_clear_z,
hiz_green_z,
hiz_green_z,
hiz_blue_z,
hiz_clear_z,
hiz_blue_z,
hiz_blue_z
};
const float width_3 = piglit_width / 3.0;
const float height_3 = piglit_height / 3.0;
glDisable(GL_STENCIL_TEST);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glClearDepth(hiz_clear_z);
glClearColor(hiz_grey[0], hiz_grey[1], hiz_grey[2], hiz_grey[3]);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, piglit_width, piglit_height);
piglit_ortho_projection(piglit_width, piglit_height, false);
glColor4fv(hiz_green);
glDepthRange(hiz_green_z, hiz_green_z);
piglit_draw_rect(0 * width_3, 0 * width_3, /* x, y */
2 * width_3, 2 * height_3); /* width, height */
glColor4fv(hiz_blue);
glDepthRange(hiz_blue_z, hiz_blue_z);
piglit_draw_rect(1 * width_3, 1 * height_3, /* x, y */
2 * width_3, 2 * height_3); /* width, height */
glClearDepth(1.0);
glDepthRange(0, 1);
if (!hiz_probe_color_buffer(expect_color))
return false;
return hiz_probe_depth_buffer(expect_depth);
}
bool
hiz_run_test_depth_read_fbo(const struct hiz_fbo_options *fbo_options)
{
bool pass = true;
GLuint fbo = 0;
piglit_require_extension("GL_ARB_framebuffer_object");
/* Create and bind FBO. */
fbo = hiz_make_fbo(fbo_options);
assert(fbo != 0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
pass = hiz_run_test_depth_read_common();
if (!piglit_automatic) {
/* Blit the FBO to the window FB so we can see the results. */
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBlitFramebuffer(0, 0, piglit_width, piglit_height,
0, 0, piglit_width, piglit_height,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
glutSwapBuffers();
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
}
hiz_delete_fbo(fbo);
return pass;
}
bool
hiz_run_test_depth_read_window()
{
bool pass = hiz_run_test_depth_read_common();
if (!piglit_automatic)
glutSwapBuffers();
return pass;
}
/** \} */
/* ------------------------------------------------------------------------ */
/**
* \name hiz_run_stencil_test utilties
*
......
......@@ -108,6 +108,34 @@ bool hiz_run_test_depth_test_fbo(const struct hiz_fbo_options *options);
*/
bool hiz_run_test_depth_test_window();
/**
* \brief Check that depth reads work correctly when rendering to an FBO.
*
* First, probe the color buffer to check that depth testing worked as
* expected. If it did not, then immediately report test failure and do not
* probe the depth buffer. If depth testing misbehaved, we cannot expect
* the depth buffer to hold the expected values.
*
* For this test, depth test is enabled and stencil test disabled.
*
* \param options Perform the test with an FBO with the given formats.
* \return True if test passed.
*
* \see hiz_run_test_depth_read_window()
*/
bool hiz_run_test_depth_read_fbo(const struct hiz_fbo_options *options);
/**
* \brief Check that depth reads work correctly when rendering to the window
* framebuffer.
*
* \param options Perform the test with an FBO with the given formats.
* \return True if test passed.
*
* \see hiz_run_test_depth_read_fbo()
*/
bool hiz_run_test_depth_read_window();
/**
* \brief Check that stencil testing works correctly when rendering to an FBO.
*
......
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