-
Notifications
You must be signed in to change notification settings - Fork 141
Fix texture copy when using multiple canvas #1481
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
base: master
Are you sure you want to change the base?
Conversation
@@ -121,6 +121,9 @@ namespace Babylon::Graphics | |||
TextureInfo GetTextureInfo(bgfx::TextureHandle handle); | |||
static bx::AllocatorI& GetDefaultAllocator() { return m_allocator; } | |||
|
|||
// call following method when a submit call is associated with the current acquired viewId | |||
void SetViewAsUsed(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we have to expose this new function because FrameBuffer
has to tell DeviceContext
this needs to be done when a Submit
happens. Is there any other case (other than Submit
) where we would need to do this, or is this really tied to FrameBuffer::Submit
?
If we need to expose this as a new function, would InvalidateView
be a better name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Framebuffer tells device context the view contains draw call. I've added a call for Clear
. InvalidateView
works for me!
@@ -1431,11 +1431,12 @@ namespace Babylon | |||
{ | |||
const auto textureDestination = info[0].As<Napi::Pointer<Graphics::Texture>>().Get(); | |||
const auto textureSource = info[1].As<Napi::Pointer<Graphics::Texture>>().Get(); | |||
|
|||
|
|||
// Append a task instead of calling blit immediately or blit happens before drawcalls. | |||
arcana::make_task(m_update.Scheduler(), *m_cancellationSource, [this, textureDestination, textureSource, cancellationSource = m_cancellationSource]() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try removing this? I think we might need to add this to the command queue for the ordering to be correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I tried and copy doesn't happen in the correct order when removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try putting it in the command queue?
There is an issue when using multiple dynamic textures (Canvas). Only the 1st one is properly displayed.
GLTF Node NegativeScale (0)
validation test looks like this:A Renderdoc capture gives this call trace:
Texture copies are all done at the same time in bgfx, at the end of sorted drawcalls of a viewid : https://github.com/bkaradzic/bgfx/blob/4602a01ce51611183d8ae8e320ca0f5305b79cb8/src/renderer_d3d11.cpp#L5739
All blit commands are submitted with the same ViewID. Which is confirmed when looking at this:
BabylonNative/Plugins/NativeEngine/Source/NativeEngine.cpp
Line 1438 in 9379cf3
Solution is incrementing ViewID in
Blit
and moving the call into DeviceContext as it doesn't rely on FrameBuffer state.Result: