[Piglit] [PATCH 6/8] sample_common: Separate drawing from destroying an image.

Eric Anholt eric at anholt.net
Tue Jul 26 00:43:42 UTC 2016


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.
---
 .../spec/ext_image_dma_buf_import/sample_common.c  | 30 ++++++++++++----------
 .../spec/ext_image_dma_buf_import/sample_common.h  |  3 +++
 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 9864ad038644..276d8a116a24 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 75a5c59bdbc1..6964dc12f6e9 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 */
-- 
2.8.1



More information about the Piglit mailing list