OpenGL SSBO and UBO in G3D

31 views
Skip to first unread message

DayC Feng

unread,
Mar 13, 2024, 1:26:56 PM3/13/24
to G3D Users
Hi everyone! Is there a way of using a Uniform Buffer Object or a Shader Storage Buffer Object in G3D? Thanks!

Morgan McGuire

unread,
Mar 13, 2024, 1:39:52 PM3/13/24
to g3d-...@googlegroups.com
Pixel Buffer Object is abstracted by G3D::GLPixelTransferBuffer, which makes it easy to move data between Array, uint8*, Texture, Framebuffer, and Image objects for between-shader or CPU-GPU transfers of bulk data.

Vertex Buffer Object is abstracted by G3D::VertexBuffer, which provides similar functionality for arrays of structs of Vector/Color/Point types as well as flat arrays.

G3D::BufferTexture is convenient for working with "1D textures", which really means arbitrary byte arrays to pass to a shader.

I tend to use G3D::GLPixelTransferBuffer for SSBO needs (I think the underlying OpenGL objects are actually the same between PBO and SSBO). G3D-app.lib/include/DDGIVolume.h, its corresponding .cpp, and the shaders in G3D10/data-files/shader/DDGIVolume/ can show you how to use these effectively for efficient arbitrary data.

G3D does not have an abstraction of Uniform Buffer Object, which fills the role of G3D::UniformArgs but does so more efficiently. You can make OpenGL calls directly on your G3D shaders to work around the current limitation; so far I haven't found a case where it was really critical to use UBO instead of SSBO and G3D::Args, although I agree it is annoying.

The reason we haven't abstracted UBO yet is that the intention is to move all G3D::Args to UBO and never use individual uniforms any more in the implementation. We've been balancing the project to implement this against the project to just move the entire backend to Vulkan, which will have the same effect. The challenge with this change it that UBO has a different syntax in the GLSL shaders, so every shader has to be rewritten when we move to UBO/Vulkan, and that's a big rewrite that will be disruptive.

-m


On Wed, Mar 13, 2024 at 10:26 AM DayC Feng <feng...@gmail.com> wrote:
Hi everyone! Is there a way of using a Uniform Buffer Object or a Shader Storage Buffer Object in G3D? Thanks!

--
You received this message because you are subscribed to the Google Groups "G3D Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to g3d-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/g3d-users/2f584b6f-f87f-4668-854e-1967ca300a7an%40googlegroups.com.

DayC Feng

unread,
Mar 15, 2024, 3:41:36 AM3/15/24
to G3D Users
Ok, it seems that PixelTransferBuffer does the same thing as SSBO and meets my needs, I'll use it instead.
Thanks for your help!
Reply all
Reply to author
Forward
0 new messages