Commit 45e22984 authored by Chad Versace's avatar Chad Versace
Browse files

hiz: Eliminate hiz_draw_rects()



This function will soon cease to be useful, since more complex hiz tests
will each have their own drawing routine.

The function body has been copied into hiz_run_test_depth_test_common(),
which contains the common functionality needed by
hiz_run_test_depth_test_{fbo,window}().
Signed-off-by: default avatarChad Versace <chad.versace@intel.com>
parent 53facdcc
......@@ -34,35 +34,6 @@
#include "piglit-util.h"
#include "hiz/hiz-util.h"
void
hiz_draw_rects()
{
const float width_3 = piglit_width / 3.0;
const float height_3 = piglit_height / 3.0;
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);
}
bool
hiz_probe_rects()
{
......@@ -238,6 +209,51 @@ hiz_delete_fbo(GLuint fbo)
assert(!glGetError());
}
/* ------------------------------------------------------------------------ */
/**
* \name hiz_run_depth_test utilties
*
* Utilities for testing depth testing.
*
* \{
*/
/**
* Common functionality needed by hiz_run_test_depth_test_fbo() and
* hiz_run_test_depth_test_window().
*/
static bool
hiz_run_test_depth_test_common()
{
const float width_3 = piglit_width / 3.0;
const float height_3 = piglit_height / 3.0;
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);
return hiz_probe_rects();
}
bool
hiz_run_test_depth_test_fbo(const struct hiz_fbo_options *fbo_options)
{
......@@ -252,8 +268,7 @@ hiz_run_test_depth_test_fbo(const struct hiz_fbo_options *fbo_options)
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
hiz_draw_rects();
pass = hiz_probe_rects();
pass = hiz_run_test_depth_test_common();
if (!piglit_automatic) {
/* Blit the FBO to the window FB so we can see the results. */
......@@ -272,10 +287,10 @@ hiz_run_test_depth_test_fbo(const struct hiz_fbo_options *fbo_options)
bool
hiz_run_test_depth_test_window() {
bool pass = true;
hiz_draw_rects();
pass = hiz_probe_rects();
bool pass = hiz_run_test_depth_test_common();
if (!piglit_automatic)
glutSwapBuffers();
return pass;
}
/** \} */
......@@ -49,29 +49,6 @@ static const GLfloat hiz_green_z = 0.25;
static const GLfloat hiz_blue_z = 0.50;
static const GLfloat hiz_clear_z = 0.875;
/**
* \brief Draw two overlapping rectangles.
*
* Draw a green rectangle, then a blue one behind it.
* This draw function should be sufficient for all HiZ tests.
*
* Let (w, h) be the window's dimensions. Then the scene is as follows:
* - glClearDepth: hiz_clear_z
* - glClearColor: hiz_grey
* - glDepthFunc: GL_LESS
* - rectangle 1
* - color: hiz_green
* - x range: [0, 2/3 * w]
* - y range: [0, 2/3 * h]
* - z: hiz_green_z
* - rectangle 2
* - color: hiz_blue
* - x range: [1/3 * w, w]
* - y range: [1/3 * h, h]
* - z: hiz_blue_z
*/
void hiz_draw_rects();
/**
* \brief Probe the scene drawn by hiz_draw_rects().
* \return True if all probes passed.
......
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