-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Various updates of Avalonia.Vulkan and SilkNetDemo projects #9885
Closed
Closed
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5e24a17
Renamed IVulkanDeviceFactory.UsesShadedDevice to UsesSharedDevice
abenedik b47585e
Prevented creating a new VulkanDevice and immediatelly disposing it i…
abenedik ee38dfa
Added Size to ISwapchain and using PixelSize instead of Bounds to pre…
abenedik dbf44f4
Fixed log area from OpenGL to Vulkan
abenedik a1ef01a
Prevented calling DoCleanup when control is detached - this disposes …
abenedik 703c956
Added Dispose method to VulkanControlBase and updated sample code to …
abenedik 3b105ad
Updated using Fence in VulkanCommandBufferPool. The Fence should be u…
abenedik 8fa448a
Remved creating Fence in VulkanDemoControl because it is not used
abenedik f53f8cc
Implement disposing VulkanDevice and improved disposing VulkanControl…
abenedik 3e8ccde
Removed IDisposable from VulkanControlBase and added disposing of ima…
abenedik 8cafb0a
Fixed locking shared device - changed "lock" into "using" (!)
abenedik 37a0d7c
Prevented throwing an exception when the size of the surface is chang…
abenedik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm not quite sure that making a control to be disposable is a good idea. Any cleanup logic should happen in
OnDetachedFromVisualTree
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.
OnDetachedFromVisualTree is also called when VulkanControlBase is inside a TabControl and when user changes Tabs. Also, if user decides to move the control from one parent to another, this should not dispose all Vulkan resources. Ok, the VulkanBitmapChain that is used by the VulkanControlBase could be disposed in OnDetachedFromVisualTree. But calling OnVulkanDeInit is too "heavy" - if user would be showing a complex 3D scene we should not dispose all Vulkan resources because the control was hidden or moved. The user of VulkanControlBase should be aware that this control creates a lot of unmanaged resources and that it is his responsibility to clear that (for example, when the MainWindow is closed - as in the updated SilkNetDemo). When using only a single VulkanControlBase, then there is actually no need to clean anything because the OS will clean all resources; but when using multiple VulkanControlBase objects, user will need to manually dispose the resources when he knows they will no longer be used.
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.
VulkanControlBase is responsible for managing a swapchain and associated resources. When it's detached the swapchain becomes invalid and any associated resources like framebuffers should be disposed as well.
I'm currently working on something like SwapChainPanel and generic non-primary context creation APIs that would allow to manually manage resources that are shared between different vulkan-powered controls.
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.
Ok, I will remove the IDisposable from VulkanControlBase and will update the code so that in OnDetachedFromVisualTree the resources created by the VulkanControlBase will be disposed: VulkanBitmapChain and VulkanCommandBufferPool. But I would not call OnVulkanDeInit because OnDetachedFromVisualTree does not mean that all Vulkan resources should be disposed (actually I think OnVulkanDeInit should be removed because the VulkanControlBase cannot know when the Vulkan resources should be disposed). I would preserve the manual disposal of the Vulkan resource that are created in the VulkanDemoControl (they are disposed when the MainWindow is Unloaded). Is this ok?
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.
It still needs to inform the user code that swapchain images are no longer valid and that corresponding framebuffers should be 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.
Yes ok, I will update the PR with that.
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.
#9925 - see external memory interop spec.