pushConstants binding other data #843
Replies: 3 comments 2 replies
-
When you set up your graphics pipelines you'll need to specify the vsg::PushConstantRanges in the Pipeline setup, and then use assign the vsg::PushConstants to either a StateGroup above the subgaph you want to influence or added before the draw calls if you have a sequence of changes. |
Beta Was this translation helpful? Give feedback.
-
Also, the minimum value of maxPushConstantsSize is only 128 bytes, which
VSG uses completely with the two matrices. I've read that on some mobile
hardware the actual limit is 64 bytes, with usage above that simulated in
some slow way.
Tim
…On Sat, Jun 10, 2023 at 10:32 AM Vulkan made easy ***@***.***> wrote:
When you set up your graphics pipelines you'll need to specify the
vsg::PushConstantRanges
<https://github.com/vsg-dev/VulkanSceneGraph/blob/master/include/vsg/state/PipelineLayout.h#L35>
in the Pipeline setup, and then use assign the vsg::PushConstants
<https://github.com/vsg-dev/VulkanSceneGraph/blob/master/include/vsg/state/PushConstants.h>
to either a StateGroup above the subgaph you want to influence or added
before the draw calls if you have a sequence of changes.
—
Reply to this email directly, view it on GitHub
<#843 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABAQAOUYDIBSEDWILGBGJDXKQWJ5ANCNFSM6AAAAAAZAQ3ZSU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
.com>
|
Beta Was this translation helpful? Give feedback.
-
PushConstants in Vulkan are a small block of memory that can be copied cheaply to the GPU as part of the command buffer. You can't have multiple different PushConstants competing for the same space, so if you want extras above the projection and modelview matrices that the VSG uses for it's standard shaders and usage then you'll need to allocate after bigger than 128 bytes and place your additions after position 128, so the that VSG can set the projection at location 0 and modelview at location 64 without conflict. As Tim mentions how much memory is available for push constants is limited by hardware/drivers so you need to query this. As a general note, I would recommend against passing model matrices to shaders. I know there are lots of shader examples doing this online but it's not a good practice as it leads to precision problems handling numerically large datasets. The model matrix approach is fine for toy datasets but not anything beyond this. To avoid precision issues the VSG accumulates model matrices in the scene graph with the view matrix using double matrix math then passes to the GPU as a float modelview matrix. This approach solve the precision issue so that models don't jitter around on screen instead stay solid on screen. The use of modelview rather than model does maan that lighting and texgen calcs need to be done in eye space, so need to be passed to the GPU in eye space, again this is what the VSG does when passing light positions/direction - the eye space position is computed in eye space for you and passed to the GPU on each frame in eye space. |
Beta Was this translation helpful? Give feedback.
-
hi,
I found that in vsg PushConstantRanges only binding with projection matrix and model viewMatrix. I hope I can use PushConstantRange or PushConstants to bind with other data, such as changing color. Is there any way to do that?
Thanks a lot~
Beta Was this translation helpful? Give feedback.
All reactions