-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Optimize shared texture creations #98760
base: master
Are you sure you want to change the base?
Optimize shared texture creations #98760
Conversation
This commit removes an unnecessary copy of `Texture::slice_trackers`, as it is always cleared afterward.
Texture texture = src_texture->duplicate_as_shared_texture(); | ||
texture.shared_fallback = nullptr; |
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 duplicate_as_shared_resource
should also avoid copying shared_fallback
so we don't have to manually set it to nullptr right after doing the copy
@@ -1055,7 +1053,7 @@ RID RenderingDevice::texture_create_shared_from_slice(const TextureView &p_view, | |||
slice_layers = 6; | |||
} | |||
|
|||
Texture texture = *src_texture; | |||
Texture texture = src_texture->duplicate_as_shared_texture(); |
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 find it a bit surprising that we don't call texture.slice_trackers.clear();
here.
CC @DarioSamo who added the call in texture_create_shared()
. Do you think this was missed by mistake? Or is there a reason to maintain the slice_tracker
when creating a shared texture from a slice?
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.
The clear is made in _texture_make_mutable
I think I'm not a big fan of the proposed solution as it adds another function to maintain and keep track of when the copy is made. |
I agree and I am not a big fan of my solution too : ) I am going to rework my PR with your solution, it's a nice idea. |
Fix #98733
This PR removes an unnecessary copy of
Texture::slice_trackers
, as it is always cleared afterward.Build: scons platform=linuxbsd optimize=speed_trace debug_symbols=yes
Profiler: Tracy
Test project: see MRP in #98733
Results with master branch:
Results with this PR: