[Mesa-dev] [PATCH 05/14] meta: Use GL_STREAM_READ for pbo created with GL_PIXEL_PACK_BUFFER

Anuj Phogat anuj.phogat at gmail.com
Mon Feb 23 14:36:42 PST 2015


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 at gmail.com>
---
 src/mesa/drivers/common/meta_tex_subimage.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c
index cd87a72..efcbce6 100644
--- a/src/mesa/drivers/common/meta_tex_subimage.c
+++ b/src/mesa/drivers/common/meta_tex_subimage.c
@@ -81,6 +81,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);
 
@@ -90,7 +91,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;
-- 
1.9.3



More information about the mesa-dev mailing list