On Wed, Dec 1, 2010 at 2:26 PM, Robert Osfield <[email protected]>wrote:

> Hi Tim,
>
> One approach I've been wondering about is whether we could have users
> provide a C struct definition for the object they want to pass to the
> GPU, then have a template class that binds this user C struct to a
> BufferData object.  This approach could allow users to user the same
> variable naming, types and structure in C++ as they do down on the
> GPU, and avoid the convoluted mappings of osg::Array's required right
> now.
>
> Thoughts?
>
It's an interesting idea. I see some difficulties getting the correct
alignment in the structure. This would only work with the std140 layout,
because the alignments in the other layouts are implementation-specific.
However, the std140 alignment rules are a lot stricter than normal C/C++, so
the user would have to be aware of this and insert padding where necessary.
She might end up with a structure that doesn't much resemble the declaration
in the shader code and / or encounter weird bugs. I'm hoping soon to write
the code that gets the uniform variable offsets back from OpenGL, which
should be useful with all three layouts; that will reduce some of the magic
constants that are in the example.

An import use case for uniform buffer objects is to allocate a large array
and use that to pass values for instanced drawing. You can create a much
larger array in a ubo than in a uniform variable. So users will be dealing
with the messy array stuff anyway.

Tim

Robert.
> _______________________________________________
> osg-submissions mailing list
> [email protected]
>
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to