<div dir="ltr">On Wed, Mar 26, 2014 at 3:43 AM, Jon Ashburn <span dir="ltr"><<a href="mailto:jon@lunarg.com" target="_blank">jon@lunarg.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
tests/texturing/getteximage-targets.c | 46 ++++++++++++++++++++++++++++++-----<br>
1 file changed, 40 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/tests/texturing/getteximage-targets.c b/tests/texturing/getteximage-targets.c<br>
index df8a726..3017226 100644<br>
--- a/tests/texturing/getteximage-targets.c<br>
+++ b/tests/texturing/getteximage-targets.c<br>
@@ -103,13 +103,14 @@ max(int x, int y)<br>
}<br>
<br>
static bool<br>
-getTexImage(GLenum target, GLubyte data[][IMAGE_SIZE],<br>
+getTexImage(bool doPBO, GLenum target, GLubyte data[][IMAGE_SIZE],<br>
GLenum internalformat, int tolerance)<br>
{<br>
int i;<br>
int num_layers=1, num_faces=1, layer_size;<br>
GLubyte data2[18][IMAGE_SIZE];<br>
GLubyte *dataGet;<br>
+ GLuint packPBO;<br>
bool pass = true;<br>
<br>
switch (target) {<br>
@@ -179,21 +180,50 @@ getTexImage(GLenum target, GLubyte data[][IMAGE_SIZE],<br>
<br>
}<br>
<br>
- memset(data2, 123, sizeof(data2));<br>
+ /* Setup the PBO or data array to read into from glGetTexImage */<br>
+ if (doPBO) {<br>
+ glGenBuffers(1, &packPBO);<br>
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, packPBO);<br>
+ } else {<br>
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);<br>
+ memset(data2, 123, sizeof(data2));<br>
+ }<br>
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
assert(num_layers * num_faces * layer_size <= sizeof(data2));<br>
<br>
for (i = 0; i < num_faces; i++) {<br>
- glGetTexImage(target + i, 0, GL_RGBA, GL_UNSIGNED_BYTE, data2[i]);<br>
+ if (doPBO) {<br>
+ glBufferData(GL_PIXEL_PACK_BUFFER,<br>
+ layer_size * max(num_faces,num_layers),<br>
+ NULL, GL_STREAM_READ);<br></blockquote><div>glBufferData should not be called from within the loop.<br><br>You should not need this if-condition if dataGet is set up already (point to NULL for the pbo case). And I am not a fan of the max() calls as indicated in my review for the first patch. But these are minor.<br>
<br></div><div>With the glBufferData call fixed, the patch is<br><br>Reviewed-by: Chia-I Wu <<a href="mailto:olv@lunarg.com">olv@lunarg.com</a>><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ glGetTexImage(target + i, 0, GL_RGBA, GL_UNSIGNED_BYTE,<br>
+ (GLvoid *) (long) (i * layer_size));<br>
+ } else {<br>
+ glGetTexImage(target + i, 0, GL_RGBA, GL_UNSIGNED_BYTE,<br>
+ data2[i]);<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ }<br>
pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
<br>
}<br>
- dataGet = data2[0];<br>
+ if (doPBO)<br>
+ dataGet = (GLubyte *) glMapBufferRange(<br>
+ GL_PIXEL_PACK_BUFFER, 0,<br>
+ layer_size *<br>
+ max(num_faces,num_layers),<br>
+ GL_MAP_READ_BIT);<br>
+ else<br>
+ dataGet = data2[0];<br>
+<br>
for (i = 0; i < max(num_faces,num_layers); i++) {<br>
pass = compare_layer(i, layer_size, tolerance, dataGet,<br>
data[i]) && pass;<br>
dataGet += layer_size;<br>
}<br>
<br>
+ if (doPBO) {<br>
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER);<br>
+ glDeleteBuffers(1, &packPBO);<br>
+ }<br>
return pass;<br>
}<br>
<br>
@@ -245,8 +275,12 @@ piglit_init(int argc, char **argv)<br>
<br>
init_layer_data(data[0], 18);<br>
<br>
- printf("Testing %s\n", piglit_get_gl_enum_name(target));<br>
- pass = getTexImage(target, data, internalformat, tolerance) &&<br>
+ printf("Testing %s into PBO\n", piglit_get_gl_enum_name(target));<br>
+ pass = getTexImage(true, target, data, internalformat, tolerance) &&<br>
+ pass;<br>
+<br>
+ printf("Testing %s into client array\n", piglit_get_gl_enum_name(target));<br>
+ pass = getTexImage(false, target, data, internalformat, tolerance) &&<br>
pass;<br>
<br>
pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
<span class=""><font color="#888888">--<br>
1.8.1.2<br>
<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>olv@LunarG.com
</div></div>