Jump to content
  • Advertisement
Sign in to follow this  
Borax Kid

Vulkan Make shader keep material properties ?

This topic is 621 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi.

 

I'm experimenting with Vulkan and wanted to try and build a material system.

 

In this repo: https://github.com/SaschaWillems/Vulkan in the SceneRendering example, the developer uses push constants to pass the material properties to the shader. (https://github.com/SaschaWillems/Vulkan/blob/master/scenerendering/scenerendering.cpp line 532 at the time I write this)

 

I was wondering if instead of sending the same material properties every frame even if they didn't change, is it possible to send them to the shader only when they change?

 

I thought about that because maybe in the future I'll want to display thousands of different models with different materials and I'm not sure if the push constants will keep up.

 

I hope I'm being understandable.

 

Thanks!

Share this post


Link to post
Share on other sites
Advertisement

You don't need to update the push constants if they haven't changed as long as the pipelines are compatible for push constants.

 

Do bear in mind that you don't get many bytes of push constants to play with, so it's unlikely that all your materials will be able to use push constants exclusively. To be honest, you'd be on more solid ground managing shader uniform blocks instead, then adding push constants later as an optimization.

 

Relevant quote from the spec.

 

 

Two pipeline layouts are defined to be “compatible for push constants” if they were created with identical push constant ranges. Two pipeline layouts are defined to be “compatible for set N” if they were created with matching (the same, or identically defined) descriptor set layouts for sets zero through N, and if they were created with identical push constant ranges.

Share this post


Link to post
Share on other sites

You don't need to update the push constants if they haven't changed as long as the pipelines are compatible for push constants.
 Oh that's nice! So does it work the same with Uniform Buffers ?

 

And thanks for answering

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!