diff options
author | Brian Paul <brianp@vmware.com> | 2015-07-24 14:57:14 -0600 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2015-07-28 12:24:51 -0600 |
commit | d1ff49bb153e04df076829d8004fa79d2d37dce0 (patch) | |
tree | aba3b0b156a77d985f160f36f173b4a5bf5f52cf | |
parent | a71ce73d23447662bac95ac76b5983cb3bb41e1f (diff) |
arb_get_texture_sub_image-errors: test getting zero-sized images
An additional set of checks for:
Getting 0x0 image from a 8x8 source.
Getting 0x0 image from a 0x0 source.
Getting offset+width > texwidth when width==0.
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
-rw-r--r-- | tests/spec/arb_get_texture_sub_image/errors.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/spec/arb_get_texture_sub_image/errors.c b/tests/spec/arb_get_texture_sub_image/errors.c index 5a702c2ac..8eb005e61 100644 --- a/tests/spec/arb_get_texture_sub_image/errors.c +++ b/tests/spec/arb_get_texture_sub_image/errors.c @@ -276,6 +276,65 @@ test_cubemap_faces(void) } +static bool +test_zero_size_image(void) +{ + GLubyte image[8*8*4]; + GLuint tex; + bool pass = true; + + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, tex); + + glTexImage2D(GL_TEXTURE_2D, + 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); + + /* getting 0x0 image from 8x8 source should work */ + glGetTextureSubImage(tex, 0, + 0, 0, 0, + 0, 0, 0, + GL_RGBA, GL_UNSIGNED_BYTE, + sizeof(image), image); + if (!piglit_check_gl_error(GL_NO_ERROR)) + pass = false; + + /* replace image with 0x0 image (deallocates old one) */ + glTexImage2D(GL_TEXTURE_2D, + 0, GL_RGBA, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); + + /* getting 0x0 image from 0x0 source should work */ + glGetTextureSubImage(tex, 0, + 0, 0, 0, + 0, 0, 0, + GL_RGBA, GL_UNSIGNED_BYTE, + sizeof(image), image); + if (!piglit_check_gl_error(GL_NO_ERROR)) + pass = false; + + /* getting 0x0 image at an offset from 0x0 source should error */ + glGetTextureSubImage(tex, 0, + 1, 2, 0, /* offset */ + 0, 0, 0, + GL_RGBA, GL_UNSIGNED_BYTE, + sizeof(image), image); + if (!piglit_check_gl_error(GL_INVALID_VALUE)) + pass = false; + + /* getting 2x2 image from 0x0 source should generate error */ + glGetTextureSubImage(tex, 0, + 0, 0, 0, + 2, 2, 1, + GL_RGBA, GL_UNSIGNED_BYTE, + sizeof(image), image); + if (!piglit_check_gl_error(GL_INVALID_VALUE)) + pass = false; + + glDeleteTextures(1, &tex); + + return pass; +} + + void piglit_init(int argc, char **argv) { @@ -288,6 +347,7 @@ piglit_init(int argc, char **argv) pass = test_buffer_size() && pass; pass = test_invalid_values() && pass; pass = test_cubemap_faces() && pass; + pass = test_zero_size_image() && pass; piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); } |