New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected texture clears when using camera-driven rendering (minimal not working example included). #6051
Comments
I am not a renderer expert at all, but I have played with your example, first to reproduce the issue , than to do some 'random' changes to see what happens. I have been able to make the example work (I think) with the following change, around
It seems that the texture cleaning is in relation ( but complex) with the reactivation of camera, my change just keep all camera active, and for the accumulation camera render to a single point when was expected to be Does not explain anything at all, but that's all I have for today. |
Digging a bit further I have found the culprit, even if not yet sure of the exact reason ( is it expected behaviour or bug). What is messing with your texture is the MSAA, default bevy behaviour is to have MSAA 4x, if I remove MSAA in your example it behaves as expected ( I think).
|
@Bobox214 words...cannot...describe... thank you for helping us understand this, even if it's first steps, this is the most progress we have seen in a while |
Happy to have helped a bit ! I won't be able to go further, I have not seen anything suspicious on the bevy side, and wonder if the issue is on the wgpu. I think that this is clearly related to msaa and probably the second texture needed for this feature. But why ?, I have not found. |
@Bobox214 I am curious to know: what made you think about MSAA as being a possible culprit? |
I found out this by doing some code debugging.
Now further debugging in bevy, it seems there is nothing wrong done. Or anything I could pinpoint before calling wgpu draw calls. |
Bevy version
0.8
Bug Information
Here's the minimal not working example.
bevy_pancam
is enabled, so you should be able to drag the camera around, but we suggest just maximizing the window upon startup, in order to see everything clearly.The basic setup here is: there's a large texture (the accumulation texture). We render into small squares (tile) of the accumulation texture sequentially. The accumulation texture has
ClearColorConfig::None
, which should in the background trigger a WGPULoadOp::Load
.Every so often, we skip rendering a tile. The problem is that: when this skip occurs, the accumulation texture is cleared entirely.
A little more detail:
every tick, we check to see if an event to draw a tile has been received (initially we send one such event, to start off the process);
if we are asked to draw stuff into a tile: we render some rects using bevy_prototype_lyon by using a camera targetting a 4096 x 4096 texture (the hi res image);
we take the 4096x4096 texture, and give it as a input (using Materials) to another camera which uses a viewport to target into
TILE_SIZE x TILE_SIZE
(whereTILE_SIZE = 64
) region of a large accumulation texture (here some downscaling happens); crucially, we queue sending of a rendering complete signal from the render deviceif a render complete signal was received we set
is_active
on the cameras responsible for rendering tofalse
, and we write a render complete eventwe check to see if a render complete event was written; if it was, we send the the next "draw a tile" event.
We used RenderDoc to see what is happening during a skip. It seems that an unnecessary texture clear is called. But we are not yet fully at home in RenderDoc, so perhaps are not getting as much info out of it as we might be able to.
We tried understanding the Bevy code to see where in the "lifecycle" of an
Image
the correspondingTexture
might be cleared, but we found it very hard to trace the "lifecycle" of anImage
and its correspondingTexture
to figure this out.We have been stumped by this for a while 😖
Any of the following would be welcome:
ideas on why the texture clear is happening, or where it is happening?
ideas on what we else we could try?
suggestions on what we can do to make the minimal not-working example easier to work with?
thoughts on whether you would like to see us upload RenderDoc captures?
The text was updated successfully, but these errors were encountered: