Render/flickering problems when changing states

Here’s a video to better understand what’s the problem:

I have an entity:


And a custom render pass that draws the terrain mesh. So when i change states i add a Hidden component to this entity, at the same time i added for prepare function to return the correct result like so (just a snippet):

let changed = (old_vertex_count != self.vertex_count) || self.hidden;
self.change.prepare_result(index, changed)

In my draw_inline at the begining i have:

if self.vertex_count == 0 || self.hidden {

And i guess this all works well, until i switch back to the starting phase. The only way to stop it flickering is to resize the window (in which the swapchain gets recreated).

Any ideas why this is happening? Or I guess another question is how to correctly implement the hidding or not rendering the terrain while in the other state ( i don’t want to have to recreate it).

I don’t have any guesses. Is your code open source?

Unfortunately no, since I’m not sure if I want it to be commercial or not yet.

The best way to debug this kind of issue is to capture frames using RenderDoc or a similar tools (e.g. apitrace) and check why isn’t the geometry rendering in the offending frame. I suspect that there is some stale state or rogue call that gets executed and that causes some of the geometry to disappear. What you’d have to do then is figure out when and why this call happened in the engine. I’m not sure about Vulkan but Direct3D provides special debug calls (Begin/EndEventInt, SetMarkerInt) that you can use in engine to simplify tracking calls from the frame capture to the engine code.

1 Like