summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTopi Pohjolainen <topi.pohjolainen@intel.com>2014-02-24 17:54:45 +0200
committerTopi Pohjolainen <topi.pohjolainen@intel.com>2016-05-19 23:35:59 +0300
commitca6be3d3cf91e9b150df4c4cfa73a18074615204 (patch)
treed58ef26c34790cc353fcf2cc55b58dc5aaeacb9e
parent7aaba896658b369a7680e7ef04637bdc88ce05c7 (diff)
util: Add stencil support to piglit_depth_texture()
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
-rw-r--r--tests/fbo/fbo-generatemipmap-formats.c2
-rw-r--r--tests/shaders/shader_runner.c10
-rw-r--r--tests/util/piglit-util-gl.c32
-rw-r--r--tests/util/piglit-util-gl.h3
4 files changed, 34 insertions, 13 deletions
diff --git a/tests/fbo/fbo-generatemipmap-formats.c b/tests/fbo/fbo-generatemipmap-formats.c
index a1b39aa26..af6585762 100644
--- a/tests/fbo/fbo-generatemipmap-formats.c
+++ b/tests/fbo/fbo-generatemipmap-formats.c
@@ -82,7 +82,7 @@ create_tex(GLenum internalformat, GLenum baseformat, GLenum basetype)
if ((baseformat == GL_DEPTH_COMPONENT) || (baseformat == GL_DEPTH_STENCIL)) {
tex = piglit_depth_texture(GL_TEXTURE_2D, internalformat,
tex_width, tex_height, 1, GL_FALSE,
- DEPTH_GRAD_X);
+ DEPTH_GRAD_X, DEPTH_CONST_ZERO);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
if (internalformat == GL_DEPTH32F_STENCIL8) {
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 1332b7567..130b0696a 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -3150,7 +3150,7 @@ piglit_display(void)
glActiveTexture(GL_TEXTURE0 + tex);
piglit_depth_texture(GL_TEXTURE_2D, GL_DEPTH_COMPONENT,
w, h, 1, GL_FALSE,
- DEPTH_GRAD_X);
+ DEPTH_GRAD_X, DEPTH_CONST_ZERO);
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_COMPARE_MODE,
GL_COMPARE_R_TO_TEXTURE);
@@ -3166,7 +3166,7 @@ piglit_display(void)
glActiveTexture(GL_TEXTURE0 + tex);
piglit_depth_texture(GL_TEXTURE_RECTANGLE, GL_DEPTH_COMPONENT,
w, h, 1, GL_FALSE,
- DEPTH_GRAD_X);
+ DEPTH_GRAD_X, DEPTH_CONST_ZERO);
glTexParameteri(GL_TEXTURE_RECTANGLE,
GL_TEXTURE_COMPARE_MODE,
GL_COMPARE_R_TO_TEXTURE);
@@ -3179,7 +3179,7 @@ piglit_display(void)
glActiveTexture(GL_TEXTURE0 + tex);
piglit_depth_texture(GL_TEXTURE_1D, GL_DEPTH_COMPONENT,
w, 1, 1, GL_FALSE,
- DEPTH_GRAD_X);
+ DEPTH_GRAD_X, DEPTH_CONST_ZERO);
glTexParameteri(GL_TEXTURE_1D,
GL_TEXTURE_COMPARE_MODE,
GL_COMPARE_R_TO_TEXTURE);
@@ -3192,7 +3192,7 @@ piglit_display(void)
glActiveTexture(GL_TEXTURE0 + tex);
piglit_depth_texture(GL_TEXTURE_1D_ARRAY, GL_DEPTH_COMPONENT,
w, l, 1, GL_FALSE,
- DEPTH_GRAD_X);
+ DEPTH_GRAD_X, DEPTH_CONST_ZERO);
glTexParameteri(GL_TEXTURE_1D_ARRAY,
GL_TEXTURE_COMPARE_MODE,
GL_COMPARE_R_TO_TEXTURE);
@@ -3205,7 +3205,7 @@ piglit_display(void)
glActiveTexture(GL_TEXTURE0 + tex);
piglit_depth_texture(GL_TEXTURE_2D_ARRAY, GL_DEPTH_COMPONENT,
w, h, l, GL_FALSE,
- DEPTH_GRAD_X);
+ DEPTH_GRAD_X, DEPTH_CONST_ZERO);
glTexParameteri(GL_TEXTURE_2D_ARRAY,
GL_TEXTURE_COMPARE_MODE,
GL_COMPARE_R_TO_TEXTURE);
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 28eb8e06a..7e9a4a3ea 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -2644,6 +2644,7 @@ GLuint piglit_integer_texture(GLenum internalFormat, int w, int h, int b, int a)
static void
generate_depth_layer(GLenum internalformat, int w, int h,
enum depth_value_base depth_base,
+ enum depth_value_base stencil_base,
int layer, void *data)
{
int x, y;
@@ -2653,6 +2654,9 @@ generate_depth_layer(GLenum internalformat, int w, int h,
if (depth_base == DEPTH_GRAD_EVEN_LAYER_X_ODD_Y)
depth_base = layer % 2 ? DEPTH_GRAD_Y : DEPTH_GRAD_X;
+ if (stencil_base == DEPTH_GRAD_EVEN_LAYER_X_ODD_Y)
+ stencil_base = layer % 2 ? DEPTH_GRAD_Y : DEPTH_GRAD_X;
+
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
float val;
@@ -2675,6 +2679,21 @@ generate_depth_layer(GLenum internalformat, int w, int h,
if (internalformat == GL_DEPTH_STENCIL_EXT ||
internalformat == GL_DEPTH24_STENCIL8_EXT) {
i[y * w + x] = 0xffffff00 * val;
+ i[y * w + x] &= 0xffffff00;
+
+ switch (stencil_base) {
+ case DEPTH_CONST_ZERO:
+ break;
+ case DEPTH_GRAD_X:
+ i[y * w + x] += ((x * 255) / w);
+ break;
+ case DEPTH_GRAD_Y:
+ i[y * w + x] += ((y * 255) / h);
+ break;
+ case DEPTH_GRAD_EVEN_LAYER_X_ODD_Y:
+ assert(!"should be X or Y");
+ break;
+ }
} else if (internalformat == GL_DEPTH32F_STENCIL8) {
f2[(y * w + x)*2] = val;
} else {
@@ -2688,7 +2707,7 @@ static void
setup_depth_level(GLenum target, GLenum internalformat, GLenum format,
GLenum type, int w, int h, int d,
enum depth_value_base depth_base,
- int level)
+ enum depth_value_base stencil_base, int level)
{
int layer;
void *data = malloc(w * h * 4 * sizeof(GLfloat));
@@ -2696,7 +2715,7 @@ setup_depth_level(GLenum target, GLenum internalformat, GLenum format,
switch (target) {
case GL_TEXTURE_1D:
generate_depth_layer(internalformat, w, h,
- depth_base, 0, data);
+ depth_base, stencil_base, 0, data);
glTexImage1D(target, level,
internalformat,
w, 0,
@@ -2707,7 +2726,7 @@ setup_depth_level(GLenum target, GLenum internalformat, GLenum format,
case GL_TEXTURE_2D:
case GL_TEXTURE_RECTANGLE:
generate_depth_layer(internalformat, w, h,
- depth_base, 0, data);
+ depth_base, stencil_base, 0, data);
glTexImage2D(target, level,
internalformat,
w, h, 0,
@@ -2721,7 +2740,7 @@ setup_depth_level(GLenum target, GLenum internalformat, GLenum format,
format, type, NULL);
for (layer = 0; layer < d; layer++) {
generate_depth_layer(internalformat, w, h,
- depth_base, layer,
+ depth_base, stencil_base, layer,
data);
glTexSubImage3D(target, level,
0, 0, layer, w, h, 1,
@@ -2751,7 +2770,8 @@ setup_depth_level(GLenum target, GLenum internalformat, GLenum format,
*/
GLuint
piglit_depth_texture(GLenum target, GLenum internalformat, int w, int h, int d,
- GLboolean mip, enum depth_value_base depth_base)
+ GLboolean mip, enum depth_value_base depth_base,
+ enum depth_value_base stencil_base)
{
int size, level;
GLuint tex;
@@ -2787,7 +2807,7 @@ piglit_depth_texture(GLenum target, GLenum internalformat, int w, int h, int d,
for (level = 0, size = w > h ? w : h; size > 0; level++, size >>= 1) {
setup_depth_level(target, internalformat, format, type,
- w, h, d, depth_base, level);
+ w, h, d, depth_base, stencil_base, level);
if (!mip)
break;
diff --git a/tests/util/piglit-util-gl.h b/tests/util/piglit-util-gl.h
index 8a5761079..318e1d1d1 100644
--- a/tests/util/piglit-util-gl.h
+++ b/tests/util/piglit-util-gl.h
@@ -278,7 +278,8 @@ GLuint piglit_rgbw_texture(GLenum internalFormat, int w, int h, GLboolean mip,
GLboolean alpha, GLenum basetype);
GLuint piglit_integer_texture(GLenum internalFormat, int w, int h, int b, int a);
GLuint piglit_depth_texture(GLenum target, GLenum format, int w, int h, int d,
- GLboolean mip, enum depth_value_base depth);
+ GLboolean mip, enum depth_value_base depth,
+ enum depth_value_base stencil);
GLuint piglit_array_texture(GLenum target, GLenum format, int w, int h, int d, GLboolean mip);
GLuint piglit_multisample_texture(GLenum target, GLenum tex,
GLenum internalFormat,