Jump to content
  • Advertisement
Sign in to follow this  
vlj

Vulkan Vulkan and mipmap generation

This topic is 882 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

I'm implementing the Scalable Ambient Obscurance algorithm on Vulkan ; at some point the algorithm is generating a mipchain on a linearized depth texture. I use a render pass to generate a linear depth texture and do the actual SAO computation. Then I use 2 compute shaders for the bilateral filtering since I can use shared memory to lessen memory bandwidth pressure.

I wonder what is the best way to do it in Vulkan ; the mipmap generation step would occur between the depth linear step and the SAO computation one. I can use a compute shader for every mipmap level ; introducing CS between graphic shaders is however not recommended since on some gpu (geforce ?) it triggers a unit reconfiguration and a cache flush. Since there is no advantage in using shared memory here the penalty can't be counterbalanced as for the bilateral passes. I could use a CS for the sao computation algorithm too but I rely on the dFdX function which is only available in fragment shader.

I can use a render pass too however I'm not sure how it will map to hardware. Since mipmap levels have different size it means using as many render passes as there are mipmap level. I fear this scenario may be suboptimal for renderpass and that switching renderpasses may increase an overhead of some sort.

Share this post


Link to post
Share on other sites
Advertisement

On some of my back-ends, I implement mip-map generation using compute - which turned out to be faster than my PS based approach. The CS optimization that I used was to calculate and generate 3 mip levels per dispatch, which greatly reduces the number of passes required to compute the full chain.

i.e. I read 8x8 pixels, output 4x4 to the 1st RWTexture, 2x2 to the 2nd, and 1px to the 3rd.

 

You're right though that this graphics->compute->graphics transition could be quite bad on some GPU's... so maybe I should have two code-paths -- this CS mipping for some GPU's, and a PS fallback for others...

Share this post


Link to post
Share on other sites

I think vkCmdBlitImage is likely to be a superior option for mipmap generation than using a render pass per mipmap level. Not sure how vkCmdBlitImage stacks up against a compute shader though.

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!