Convert/Export dmabuf to shader buffer object

2022-05-27 Thread Zong, Wei
Hello,

I'm using GLES shader to do post-processing on GPU decoded video frame. I found 
sample code to demonstrate buffer sharing between decoder and rendering, the 
method is to create EGLImage texture targets from dma_buf file descriptor by 
using extension "EGL_EXT_image_dma_buf_import" & "GL_OES_EGL_image_external"

I cannot use EGLImage texture directly, I tried to bind texture objects to 
GL_SHADER_STORAGE_BUFFER target, but failed to when access the shader buffer, 
the GL error shows " GL_INVALID_OPERATION in glMapBufferRange(buffer does not 
allow read access)"

Could you kindly give some help:

1. If Mesa provide API to create GL sharder storage buffer from dma_buf file 
descriptor?
2. If EGL can covert EGL texture object to shader storage buffer object?

Thanks,
Zong Wei




Re: [Mesa-dev] bad performance issue in GPU & CPU data sharing

2021-06-07 Thread Zong, Wei



> -Original Message-
> From: Palli, Tapani 
> Sent: Thursday, June 3, 2021 1:23 PM
> To: Zong, Wei ; mesa-dev@lists.freedesktop.org
> Subject: Re: [Mesa-dev] bad performance issue in GPU & CPU data sharing
> 
> Hi;
> 
> On 5/31/21 12:33 PM, Zong, Wei wrote:
> > Hello,
> >
> > I'm using GLES shader to run algorithms on image frames, I got very
> > bad performance issue in GPU & CPU data sharing, especially retrieve
> > data from GPU to CPU.
> >
> > Basically, I use
> > */glGenBuffers/*/*/glBindBuffer/*/*/glBufferData(target, size, data,
> > usage) /*to create GPU buffer object and initialize GPU data store
> > with CPU data pointer. After GLES shader finished the processing, I
> > use /*glMapBufferRange*///to retrieve processed image data back to
> > CPU, and for some reason I have to do an extra data copy from the gl
> > map pointer to another CPU buffer, this is super slow.
> >
> > Here's the code snippet
> > https://github.com/intel/libxcam/blob/master/modules/gles/gl_buffer.cp
> > p#L94
> > <https://github.com/intel/libxcam/blob/master/modules/gles/gl_buffer.c
> > pp#L94>
> >
> > https://github.com/intel/libxcam/blob/master/modules/gles/gl_buffer.cp
> > p#L127
> > <https://github.com/intel/libxcam/blob/master/modules/gles/gl_buffer.c
> > pp#L127>
> >
> > I wonder If there has other efficient way to sharing data between CPU
> > & GPU GLES shader?
> >
> > Thanks,
> >
> > Zong Wei
> >
> 
> Could you break down the use-case here a bit, why do you need CPU access to
> the image? If I understand correctly, is it so that camera pipeline renders 
> to a
> dmabuf and then this is imported to GLES for processing and then you map it to
> CPU for ... something?
> 
> Thanks;
> 
> // Tapani

Hi Tapani,
I got multiple input video frames from decoder, copied these frames to egl 
buffers, used GLES shader to stitch these frames into one high resolution frame 
(8K), then I mapped the stitched frame to CPU, encoded the frame into h246 
stream. I don't have GPU encoder to handle 8K frame.

I noticed glMapBufferRange Api description from 
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glMapBufferRange.xhtml
"Mappings to the data stores of buffer objects may have nonstandard performance 
characteristics. For example, such mappings may be marked as uncacheable 
regions of memory, and in such cases reading from them may be very slow. To 
ensure optimal performance, the client should use the mapping in a fashion 
consistent with the values of GL_BUFFER_USAGE for the buffer object and of 
access. Using a mapping in a fashion inconsistent with these values is liable 
to be multiple orders of magnitude slower than using normal memory."

Seems I should find a way to map the buffer as cacheable memory. How to map a 
cacheable memory? And how to use DMA buffering?

Thanks,
Zong Wei



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] bad performance issue in GPU & CPU data sharing

2021-05-31 Thread Zong, Wei
Hello,



I'm using GLES shader to run algorithms on image frames, I got very bad 
performance issue in GPU & CPU data sharing, especially retrieve data from GPU 
to CPU.



Basically, I use glGenBuffers/glBindBuffer/glBufferData(target, size, data, 
usage) to create GPU buffer object and initialize GPU data store with CPU data 
pointer. After GLES shader finished the processing, I use glMapBufferRange to 
retrieve processed image data back to CPU, and for some reason I have to do an 
extra data copy from the gl map pointer to another CPU buffer, this is super 
slow.



Here's the code snippet 
https://github.com/intel/libxcam/blob/master/modules/gles/gl_buffer.cpp#L94

https://github.com/intel/libxcam/blob/master/modules/gles/gl_buffer.cpp#L127



I wonder If there has other efficient way to sharing data between CPU & GPU 
GLES shader?



Thanks,

Zong Wei

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] unlock android graphic buffer spend too much time

2018-04-23 Thread Zong, Wei
Hi Dear Mesa experts,



I'm reading android graphic buffer by calling “GraphicBuffer::lock” with 
parameter "GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_NEVER", I 
copied the buffer into a CPU allocated memory only cost less than 1 
millisecond. the resolution of this graphic buffer is 1280×800, and the image 
format is “V4L2_PIX_FMT_NV12”



After finishing memory copy, I called “GraphicBuffer::unlock”, this operation 
spent more than 3 milliseconds, I guess this unlock operation would not do much 
work, I'm wondering if this 3ms can be saved? Or this 3ms is sure necessary for 
such operation?



The hardware I’m using is Broxton, and graphic driver is Mesa 18.1.0-devel.



Thanks,

Zong Wei


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Query GL extensions (“GL_OES_EGL_image_external” ) RE: Create texture2D from NV12

2018-04-17 Thread Zong, Wei
Marek & Palli, I parsed the returned GL extensions string, it sure contains " 
GL_OES_EGL_image_external ". I made a mistake by looking up log manually 
before, the string must be truncated by log length limitation.

Thank you very much!

Zong Wei

-Original Message-
From: Palli, Tapani 
Sent: Tuesday, April 17, 2018 11:55 PM
To: Zong, Wei <wei.z...@intel.com>; 'Marek Ol?ák' <mar...@gmail.com>; 
mesa-dev@lists.freedesktop.org
Subject: Re: [Mesa-dev] Query GL extensions (“GL_OES_EGL_image_external” ) RE: 
Create texture2D from NV12

Hi;

On 17.04.2018 13:30, Zong, Wei wrote:
> Hi Marek,
> 
> Thanks for your help. Now I can use GL 
> extension“*GL_OES_EGL_image_external*” to load and render NV12 image, 
> it works well on my platform (Broxton).
> 
> To ensure using this extension correctly on any platform, I checked 
> for supported OpenGL extensions by glGetString() function, and printed 
> out the list of supported extensions. Unfortunately, I did not find 
> “*GL_OES_EGL_image_external*” in the list.
> 
> GL EXTENSIONS:
> 
> GL_EXT_debug_marker GL_ANDROID_extension_pack_es31a
> GL_ANGLE_texture_compression_dxt3 GL_ANGLE_texture_compression_dxt5 
> GL_APPLE_texture_max_level GL_EXT_blend_func_extended 
> GL_EXT_blend_minmax GL_EXT_buffer_storage GL_EXT_clip_cull_distance 
> GL_EXT_color_buffer_float GL_EXT_compressed_ETC1_RGB8_sub_texture
> GL_EXT_copy_image GL_EXT_discard_framebuffer 
> GL_EXT_disjoint_timer_query GL_EXT_draw_buffers 
> GL_EXT_draw_buffers_indexed GL_EXT_draw_elements_base_vertex 
> GL_EXT_frag_depth GL_EXT_geometry_point_size GL_EXT_geometry_shader 
> GL_EXT_gpu_shader5 GL_EXT_map_buffer_range GL_EXT_multi_draw_arrays 
> GL_EXT_occlusion_query_boolean GL_EXT_polygon_offset_clamp 
> GL_EXT_primitive_bounding_box GL_EXT_read_format_bgra 
> GL_EXT_robustness GL_EXT_separate_shader_objects 
> GL_EXT_shader_framebuffer_fetch 
> GL_EXT_shader_framebuffer_fetch_non_coherent GL_EXT_shader_integer_mix 
> GL_EXT_shader_io_blocks GL_EXT_shader_ samples_identical 
> GL_EXT_tessellation_point_size GL_EXT_tessellation_shader 
> GL_EXT_texture_border_clamp
> 
> I also printed out the GL information of my platform I’m using:
> 
> GL_VENDOR: Intel Open Source Technology Center
> 
> GL_RENDERER: Mesa DRI Intel(R) HD Graphics 505 (Broxton)
> 
> GL_VERSION: OpenGL ES 3.2 Mesa 18.1.0-devel (git-d63719023b)
> 
> GL_SHADING_LANGUAGE_VERSION: OpenGL ES GLSL ES 3.20
> 
> Could you please give me a hint if I made something wrong to query the 
> extension name string “*GL_OES_EGL_image_external*” from GL?

Are you somehow parsing the returned string? Maybe there is some issue with 
that part of the app code, try to just print string as it is or use strstr on 
that string directly. On my Kabylake I get a list of 111 supported extensions 
with ES 3.2 and the list contains GL_OES_EGL_image_external as well as 
GL_OES_EGL_image_external_essl3.


> Thanks,
> 
> Zong Wei
> 
> *From:*Marek Olšák [mailto:mar...@gmail.com]
> *Sent:* Tuesday, March 20, 2018 9:42 AM
> *To:* Zong, Wei <wei.z...@intel.com>
> *Cc:* mesa-dev@lists.freedesktop.org
> *Subject:* Re: [Mesa-dev] Create texture2D from NV12
> 
> The only way is to use GL_OES_EGL_image_external to load an NV12 image. 
> kmscube does that.
> 
> Marek
> 
> On Fri, Mar 16, 2018 at 4:10 AM, Zong, Wei <wei.z...@intel.com 
> <mailto:wei.z...@intel.com>> wrote:
> 
> Hello,
> 
> May I ask a question? I got a NV12 image buffer and I want to render
> it with OpenGL. I know a method to do this is to bind Y/UV planes as
> two separate textures, then perform YUV to RGB conversion in
> fragment shader.
> 
> But I want to know if Mesa provide APIs to create and bind a texture
> 2D image with NV12 format directly?
> 
> Thanks,
> 
> Zong Wei
> 
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org <mailto:mesa-dev@lists.freedesktop.org>
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 
> 
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] Query GL extensions (“GL_OES_EGL_image_external” ) RE: Create texture2D from NV12

2018-04-17 Thread Zong, Wei
Hi Marek,

Thanks for your help. Now I can use GL extension “GL_OES_EGL_image_external” to 
load and render NV12 image, it works well on my platform (Broxton).

To ensure using this extension correctly on any platform, I checked for 
supported OpenGL extensions by glGetString() function, and printed out the list 
of supported extensions. Unfortunately, I did not find 
“GL_OES_EGL_image_external” in the list.

GL EXTENSIONS:
GL_EXT_debug_marker GL_ANDROID_extension_pack_es31a 
GL_ANGLE_texture_compression_dxt3 GL_ANGLE_texture_compression_dxt5 
GL_APPLE_texture_max_level GL_EXT_blend_func_extended GL_EXT_blend_minmax 
GL_EXT_buffer_storage GL_EXT_clip_cull_distance GL_EXT_color_buffer_float 
GL_EXT_compressed_ETC1_RGB8_sub_texture GL_EXT_copy_image 
GL_EXT_discard_framebuffer GL_EXT_disjoint_timer_query GL_EXT_draw_buffers 
GL_EXT_draw_buffers_indexed GL_EXT_draw_elements_base_vertex GL_EXT_frag_depth 
GL_EXT_geometry_point_size GL_EXT_geometry_shader GL_EXT_gpu_shader5 
GL_EXT_map_buffer_range GL_EXT_multi_draw_arrays GL_EXT_occlusion_query_boolean 
GL_EXT_polygon_offset_clamp GL_EXT_primitive_bounding_box 
GL_EXT_read_format_bgra GL_EXT_robustness  GL_EXT_separate_shader_objects 
GL_EXT_shader_framebuffer_fetch GL_EXT_shader_framebuffer_fetch_non_coherent 
GL_EXT_shader_integer_mix GL_EXT_shader_io_blocks GL_EXT_shader_ 
samples_identical GL_EXT_tessellation_point_size GL_EXT_tessellation_shader 
GL_EXT_texture_border_clamp

I also printed out the GL information of my platform I’m using:
GL_VENDOR: Intel Open Source Technology Center
GL_RENDERER: Mesa DRI Intel(R) HD Graphics 505 (Broxton)
GL_VERSION: OpenGL ES 3.2 Mesa 18.1.0-devel (git-d63719023b)
GL_SHADING_LANGUAGE_VERSION: OpenGL ES GLSL ES 3.20

Could you please give me a hint if I made something wrong to query the 
extension name string “GL_OES_EGL_image_external” from GL?


Thanks,
Zong Wei

From: Marek Olšák [mailto:mar...@gmail.com]
Sent: Tuesday, March 20, 2018 9:42 AM
To: Zong, Wei <wei.z...@intel.com>
Cc: mesa-dev@lists.freedesktop.org
Subject: Re: [Mesa-dev] Create texture2D from NV12

The only way is to use GL_OES_EGL_image_external to load an NV12 image. kmscube 
does that.
Marek

On Fri, Mar 16, 2018 at 4:10 AM, Zong, Wei 
<wei.z...@intel.com<mailto:wei.z...@intel.com>> wrote:
Hello,

May I ask a question? I got a NV12 image buffer and I want to render it with 
OpenGL. I know a method to do this is to bind Y/UV planes as two separate 
textures, then perform YUV to RGB conversion in fragment shader.

But I want to know if Mesa provide APIs to create and bind a texture 2D image 
with NV12 format directly?

Thanks,
Zong Wei



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org<mailto:mesa-dev@lists.freedesktop.org>
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] Create texture2D from NV12

2018-03-16 Thread Zong, Wei
Hello,

May I ask a question? I got a NV12 image buffer and I want to render it with 
OpenGL. I know a method to do this is to bind Y/UV planes as two separate 
textures, then perform YUV to RGB conversion in fragment shader.

But I want to know if Mesa provide APIs to create and bind a texture 2D image 
with NV12 format directly?

Thanks,
Zong Wei


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev