Page 1 of 1

Burn wipe doesn't work with Vulkan renderer

PostPosted: Tue May 07, 2019 8:23 am
by _mental_
Depending on hardware, burn wipe may produce no visible effect or just render some random garbage.

Validation layers reported the following error:
Code: Select allExpand view
Shader uses descriptor slot 1.1 (expected `VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER`) but not declared in pipeline layout

Re: Burn wipe doesn't work with Vulkan renderer

PostPosted: Tue May 07, 2019 8:59 am
by dpJudas
Assuming slot 1.1 means set 1, binding 1 the error means that the shader is using "layout(set = 1, binding = 1) uniform sampler2D texture2;" but the bound material does not have a second layer texture.

Looking at burn.fp the shader indeed does use texture2, so the error must be that the second layer texture is not bound. I'm not sure why that might be.

Re: Burn wipe doesn't work with Vulkan renderer

PostPosted: Tue May 07, 2019 10:40 am
by Graf Zahl
The burn shader is a bit of a hack to get the second texture in because it doesn't use a regular material for it. Can it be that you overlooked that part?

Re: Burn wipe doesn't work with Vulkan renderer

PostPosted: Tue May 07, 2019 2:15 pm
by dpJudas
Can you give me a link to the lines adding the second texture in the hwrenderer layer? It is quite plausible it doesn't handle the situation if it is unique.

Re: Burn wipe doesn't work with Vulkan renderer

PostPosted: Tue May 07, 2019 2:37 pm
by Graf Zahl
The actual material being used to render it is patched together in Wiper_Burn::SetTextures. But this isn't like a real material because the burn texture is not a static texture abd actually recreated for every frame. How does the Vulkan backend handle this? If it depends on a descriptor set that doesn't change it cannot really work.

Re: Burn wipe doesn't work with Vulkan renderer

PostPosted: Tue May 07, 2019 3:32 pm
by dpJudas
The Vulkan backend assumes that the material is static and doesn't change. It could validate that the descriptor is up to date, but that would be spending time on that in a time critical part of the renderer. I suppose the best way would be that the burn thing tells the hardware texture that its descriptor needs to be recreated.

Re: Burn wipe doesn't work with Vulkan renderer

PostPosted: Thu May 09, 2019 10:03 am
by dpJudas
Looking a bit closer at this I'm not sure the problem is with the descriptor itself. Wiper_Burn::SetTextures is only called once (when burn is started) and when the 2D drawer renders the effect for the first time mat->GetLayers() returns 1 (should return 2 according to the shader) when creating the descriptor.

Re: Burn wipe doesn't work with Vulkan renderer

PostPosted: Thu May 09, 2019 10:16 am
by dpJudas
It looks like somehow F2DDrawer::DTF_Burn gets applied to the wrong command. If a breakpoint is set in line 184 in Draw2D the material only has one layer. Interestingly, the prev command in the list points at the material created in Wiper_Burn::SetTexture but that draw command does not have the burn flag set.

Re: Burn wipe doesn't work with Vulkan renderer

PostPosted: Thu May 09, 2019 10:57 am
by dpJudas
Fixed this one.

Turns out there were two bugs. First, the hwrenderer layer added the layer to the wrong material - probably only worked on OpenGL because texture state lingers. And secondly there was the recreation of a texture each frame as Graf mentioned.

Re: Burn wipe doesn't work with Vulkan renderer

PostPosted: Thu May 09, 2019 11:41 am
by Firebrand
I can confirm that this wipe style now works properly on Vulkan :) , thank you for your work!

Re: Burn wipe doesn't work with Vulkan renderer

PostPosted: Thu May 09, 2019 11:44 am
by dpJudas
You're welcome. :)