[Piglit] [PATCH] arb_shader_image_load_store: Test format incompatible texture buffer
Danylo Piliaiev
danylo.piliaiev at gmail.com
Tue Jul 17 15:35:55 UTC 2018
Test for the regression which happened when GL_TEXTURE_BUFFER was
allowed to have incompatible format.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106465
Signed-off-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
---
.../arb_shader_image_load_store/invalid.c | 54 +++++++++++++++++--
1 file changed, 49 insertions(+), 5 deletions(-)
diff --git a/tests/spec/arb_shader_image_load_store/invalid.c b/tests/spec/arb_shader_image_load_store/invalid.c
index ed4b6c064..adab56ffc 100644
--- a/tests/spec/arb_shader_image_load_store/invalid.c
+++ b/tests/spec/arb_shader_image_load_store/invalid.c
@@ -172,12 +172,45 @@ init_level(const struct image_info img, unsigned level,
GLenum format, unsigned w, unsigned h)
{
uint32_t pixels[4 * N];
-
init_pixels(img, pixels, 1, 1, 1, 1);
- glBindTexture(GL_TEXTURE_2D, get_texture(0));
- glTexImage2D(GL_TEXTURE_2D, level, format,
- w, h, 0, img.format->pixel_format,
- image_base_type(img.format), pixels);
+
+ glBindTexture(img.target->target, get_texture(0));
+
+ switch (img.target->target) {
+ case GL_TEXTURE_2D: {
+ glTexImage2D(GL_TEXTURE_2D, level, format,
+ w, h, 0, img.format->pixel_format,
+ image_base_type(img.format), pixels);
+ break;
+ }
+ case GL_TEXTURE_BUFFER: {
+ const struct image_extent grid = image_optimal_extent(img.size);
+ GLuint packed_tex;
+
+ assert(level == 0);
+
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, get_buffer(0));
+ glBufferData(GL_PIXEL_PACK_BUFFER,
+ img.size.x * image_pixel_size(img.format) / 8,
+ NULL, GL_STATIC_DRAW);
+
+ glGenTextures(1, &packed_tex);
+ glBindTexture(GL_TEXTURE_2D, packed_tex);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, format,
+ grid.x, grid.y, 0, img.format->pixel_format,
+ image_base_type(img.format), pixels);
+ glGetTexImage(GL_TEXTURE_2D, 0, img.format->pixel_format,
+ img.format->pixel_type, NULL);
+ glDeleteTextures(1, &packed_tex);
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+
+ glTexBuffer(GL_TEXTURE_BUFFER, format, get_buffer(0));
+ break;
+ }
+ default:
+ abort();
+ }
return piglit_check_gl_error(GL_NO_ERROR);
}
@@ -346,6 +379,8 @@ piglit_init(int argc, char **argv)
for (op = image_ops; op->name; ++op) {
const struct image_info def_img = image_info(
GL_TEXTURE_2D, op->formats[0].format, W, H);
+ const struct image_info def_img_buffer = image_info(
+ GL_TEXTURE_BUFFER, op->formats[0].format, W, H);
/*
* According to the spec, an access is considered
@@ -399,6 +434,15 @@ piglit_init(int argc, char **argv)
invalidate_incompatible_format, false),
"%s/incompatible format test", op->name);
+ /* Test for the regression which happened when
+ * GL_TEXTURE_BUFFER was allowed to have incompatible format.
+ */
+ subtest(&status, true,
+ run_test(op, def_img_buffer, def_img_buffer,
+ invalidate_incompatible_format, false),
+ "%s/incompatible format test/image%s",
+ op->name, def_img_buffer.target->name);
+
/*
* " * the texture bound to the image unit has layers,
* and the selected layer or cube map face doesn't
--
2.17.1
More information about the Piglit
mailing list