r/vulkan • u/Due-Baby9136 • 2d ago
Everything renders fine until vkQueuePresentKHR, where 3D disappears.
tldr:
3D objects won't appear on the window, yet RenderDoc shows everything renders and presents fine.
Cry for help:
I'm capturing with RenderDoc and can see that everything renders and presents fine, yet the 3D objects are missing after presenting the image on the window. Here's the capture file if you wish to check it out. To see what's actually shown on the window, you can extract the capture's thumbnail with: renderdoccmd thumb capture.rdc --out thumbnail.png
I've been on this for days and am finally relenting to reddit.
If anyone has seen this before, has ideas, or leads on how I could debug this, anything would be appreciated.
If you decide to delve deep within the capture file, take note this is a test program running on a bindless rendering engine.
Setup:
There's a camera with an identity model/view matrix and the following orthogonal matrix:
┌ 0.13636, 0.00000, 0.00000, 0.00000┐
│ 0.00000, 0.18182, 0.00000, 0.00000│
│ 0.00000, 0.00000, 0.00100, 0.00000│
└ 0.00000, 0.00000, 0.00000, 1.00000┘
Then, a blue 2D object is at (0, 0) with a size of (0.5, 0.5) in NDC space.
Finally, a magenta 3D object at (3, 0, 1) with a rotation of (0, 45, 45) degrees.
It has been solved!
My problem was I wasn't synchronizing the update of my camera matrices' buffer and the rendering of 3D objects, which means the projection/view/model multiplications were flawed.
To find it, I had to enable the validation layers' synchronization features, validate_sync and syncval_shader_accesses_heuristic.
If you end up in my position and want to enable them, go read this:
https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/main/docs/khronos_validation_layer.md#configuring-the-validation-layer
5
u/positivcheg 1d ago
Classic question. Validation layers completely 0 errors and warnings?
I usually turn depth test, cull none and things like that. In case if all validation layers are silent.
1
u/Due-Baby9136 1d ago
Yup, validation layers are silent. I hadn't thought of disabling the depth test, but, after trying, it doesn't help.
3
u/No_Celebration8219 2d ago
swap chain setup correctly? is your backbuffer set? Vulkan will render to any attached buffer so make sure you're setting the swapchain correctly.
1
u/Due-Baby9136 2d ago
Yes, it's correctly setup. I've cleared the color attachment to green to prove this. The 2D object also appear. The 3D one is the only one missing.
1
u/Due-Baby9136 1d ago
I've noticed removing the projection matrix of the 3D vertex shader let's 3D objects appear, given they end up in the NDC frustum, which is very unlikely without the projection/view/model multiplications.
But the matrix is fine by my knowledge, I think it might be a by-product of the actual problem.
2
u/ParaLizzardo 22h ago
You can try to open vulkan configurator app and crank up the settings for validation layer.
4
u/Chainsawkitten 1d ago
If it renders fine in RenderDoc but not outside, my usual assumption is incorrect synchronization/cache flushing/layout transitions.