summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2016-07-25 15:01:42 -0700
committerEric Anholt <eric@anholt.net>2016-08-18 16:21:57 -0700
commit4d4f03ca0d33d39ff53dc137fa8561322d11e8a0 (patch)
tree0a9298b097ed003a8e630d11cab51e60b6d7fa8e
parentceb77daebe8aa66c2aeaafdc8d265f6cc19d9ec9 (diff)
sample_common: Separate drawing from destroying an image.
It's a weird pair of things to do in one helper function, and I need to be able to do them separately for the refcount test. Reviewed-by: Rob Clark <robdclark@gmail.com>
-rw-r--r--tests/spec/ext_image_dma_buf_import/sample_common.c30
-rw-r--r--tests/spec/ext_image_dma_buf_import/sample_common.h3
2 files changed, 19 insertions, 14 deletions
diff --git a/tests/spec/ext_image_dma_buf_import/sample_common.c b/tests/spec/ext_image_dma_buf_import/sample_common.c
index 9864ad038..276d8a116 100644
--- a/tests/spec/ext_image_dma_buf_import/sample_common.c
+++ b/tests/spec/ext_image_dma_buf_import/sample_common.c
@@ -84,20 +84,16 @@ texture_for_egl_image(EGLImageKHR img, GLuint *out_tex)
return PIGLIT_PASS;
}
-static enum piglit_result
-sample_and_destroy_img(unsigned w, unsigned h, EGLImageKHR img)
+void
+sample_tex(GLuint tex, unsigned w, unsigned h)
{
- GLuint prog, tex;
- enum piglit_result res;
-
- res = texture_for_egl_image(img, &tex);
- if (res != PIGLIT_PASS)
- return res;
+ GLuint prog;
prog = piglit_build_simple_program(vs_src, fs_src);
glUseProgram(prog);
+ glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
glUniform1i(glGetUniformLocation(prog, "sampler"), 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -108,11 +104,6 @@ sample_and_destroy_img(unsigned w, unsigned h, EGLImageKHR img)
glDeleteProgram(prog);
glUseProgram(0);
-
- glDeleteTextures(1, &tex);
- eglDestroyImageKHR(eglGetCurrentDisplay(), img);
-
- return PIGLIT_PASS;
}
enum piglit_result
@@ -207,6 +198,7 @@ sample_buffer(void *buf, int fd, int fourcc, unsigned w, unsigned h,
{
enum piglit_result res;
EGLImageKHR img;
+ GLuint tex;
res = egl_image_for_dma_buf_fd(fd, fourcc, w, h, stride, offset, &img);
@@ -221,7 +213,17 @@ sample_buffer(void *buf, int fd, int fourcc, unsigned w, unsigned h,
if (res != PIGLIT_PASS)
return res;
- return sample_and_destroy_img(w, h, img);
+ res = texture_for_egl_image(img, &tex);
+ if (res != PIGLIT_PASS)
+ goto destroy;
+
+ sample_tex(tex, w, h);
+
+destroy:
+ glDeleteTextures(1, &tex);
+ eglDestroyImageKHR(eglGetCurrentDisplay(), img);
+
+ return res;
}
enum piglit_result
diff --git a/tests/spec/ext_image_dma_buf_import/sample_common.h b/tests/spec/ext_image_dma_buf_import/sample_common.h
index 75a5c59bd..6964dc12f 100644
--- a/tests/spec/ext_image_dma_buf_import/sample_common.h
+++ b/tests/spec/ext_image_dma_buf_import/sample_common.h
@@ -42,4 +42,7 @@ egl_image_for_dma_buf_fd(int fd, int fourcc, int w, int h,
enum piglit_result
texture_for_egl_image(EGLImageKHR img, GLuint *out_tex);
+void
+sample_tex(GLuint tex, unsigned w, unsigned h);
+
#endif /* SAMPLE_COMMON_H */