meta: Use GL_STREAM_READ for pbo created with GL_PIXEL_PACK_BUFFER
authorAnuj Phogat <anuj.phogat@gmail.com>
Wed, 4 Feb 2015 00:50:57 +0000 (16:50 -0800)
committerAnuj Phogat <anuj.phogat@gmail.com>
Wed, 25 Feb 2015 22:11:14 +0000 (14:11 -0800)
create_texture_for_pbo() is used by both _mesa_meta_pbo_GetTexSubImage()
and _mesa_meta_pbo_TexSubImage() functions with different PBO targets.
Use GL_STREAM_READ with GL_PIXEL_PACK_BUFFER and GL_STREAM_DRAW with
GL_PIXEL_UNPACK_BUFFER.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
src/mesa/drivers/common/meta_tex_subimage.c

index ffbbacd8fd892ffcf99f1991838cd58373bdb4c8..ca6fb6a5f21b4ca71720704a82546510e515c4ea 100644 (file)
@@ -79,6 +79,7 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,
       buffer_obj = packing->BufferObj;
    } else {
       assert(create_pbo);
+      bool is_pixel_pack = pbo_target == GL_PIXEL_PACK_BUFFER;
 
       _mesa_GenBuffers(1, tmp_pbo);
 
@@ -88,7 +89,12 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,
        */
       _mesa_BindBuffer(pbo_target, *tmp_pbo);
 
-      _mesa_BufferData(pbo_target, row_stride * height, pixels, GL_STREAM_DRAW);
+      if (is_pixel_pack)
+         _mesa_BufferData(pbo_target, row_stride * height, pixels,
+                          GL_STREAM_READ);
+      else
+         _mesa_BufferData(pbo_target, row_stride * height, pixels,
+                          GL_STREAM_DRAW);
 
       buffer_obj = ctx->Unpack.BufferObj;
       pixels = NULL;