Ryujinx/src/Ryujinx.Graphics.Vulkan
riperiperi 795539bc82
Vulkan: Use staging buffer for temporary constants (#6168)
* Vulkan: Use staging buffer for temporary constants

Helper shaders and post processing effects typically need some parameters to tell them what to do, which we pass via constant buffers that are created and destroyed each time.

This can vary in cost between different Vulkan drivers. It shows up on profiles on mesa and MoltenVK, so it's worth avoiding. Some games only do it once (BlitColor for present), others multiple times. It's also done for post processing filters and FSR upscaling, which creates two buffers.

For mirrors, I added the ability to reserve a range on the staging buffer for use as any type of binding. This PR allows these constant buffers to be instead temporarily allocated on the staging buffer, skipping allocation and buffer management costs entirely.

Two temporary allocations do remain:
- DrawTexture, because it doesn't have access to the command buffer scope
- Index buffer indirect conversion, because one of them is a storage buffer and thus is a little more complicated.

There's a small cost in that the uniform buffer takes up more space due to alignment requirements. At worst that's 256 bytes (on a GTX 1070) but more modern GPUs should have a better time.

Worth testing across different games and post effects to make sure they still work.

* Use temporary buffer for ConvertIndexBufferIndirect

* Simplify alignment passing for now

* Fix shader params length for CopyIncompatibleFormats

* Set data for helpershaders without overlap checks

The data is in the staging buffer, so its usage range is guarded using that.
2024-01-25 19:29:53 +01:00
..
Effects Vulkan: Use staging buffer for temporary constants (#6168) 2024-01-25 19:29:53 +01:00
MoltenVK [Ryujinx.Graphics.Vulkan] Address dotnet-format issues (#5378) 2023-07-01 12:31:42 +02:00
Queries Vulkan: Enumerate Query Pool properly (#6167) 2024-01-24 19:33:52 -03:00
Shaders Vulkan: Device Local and higher invocation count for buffer conversions (#5623) 2023-09-02 17:58:15 -03:00
Auto.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
AutoFlushCounter.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
BackgroundResources.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
BitMap.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
BitMapStruct.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
BufferAllocationType.cs Implement support for multi-range buffers using Vulkan sparse mappings (#5427) 2023-12-04 20:30:19 +01:00
BufferHolder.cs Vulkan: Use staging buffer for temporary constants (#6168) 2024-01-25 19:29:53 +01:00
BufferManager.cs Vulkan: Use staging buffer for temporary constants (#6168) 2024-01-25 19:29:53 +01:00
BufferMirrorRangeList.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
BufferState.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
BufferUsageBitmap.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
CacheByRange.cs [Ryujinx.Graphics.Vulkan] Address dotnet-format issues (#5378) 2023-07-01 12:31:42 +02:00
CommandBufferPool.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
CommandBufferScoped.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
Constants.cs Implement support for multi-range buffers using Vulkan sparse mappings (#5427) 2023-12-04 20:30:19 +01:00
DescriptorSetCollection.cs [Ryujinx.Graphics.Vulkan] Address dotnet-format issues (#5378) 2023-07-01 12:31:42 +02:00
DescriptorSetManager.cs Reduce the amount of descriptor pool allocations on Vulkan (#5673) 2023-09-26 02:00:02 +02:00
DescriptorSetTemplate.cs Vulkan: Use templates for descriptor updates (#6014) 2024-01-20 11:07:33 -03:00
DescriptorSetTemplateUpdater.cs Vulkan: Use templates for descriptor updates (#6014) 2024-01-20 11:07:33 -03:00
DescriptorSetUpdater.cs Vulkan: Use templates for descriptor updates (#6014) 2024-01-20 11:07:33 -03:00
DisposableBuffer.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
DisposableBufferView.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
DisposableFramebuffer.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
DisposableImage.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
DisposableImageView.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
DisposableMemory.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
DisposablePipeline.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
DisposableRenderPass.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
DisposableSampler.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
EnumConversion.cs Implement support for multi-range buffers using Vulkan sparse mappings (#5427) 2023-12-04 20:30:19 +01:00
FenceHelper.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
FenceHolder.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
FormatCapabilities.cs Implement scaled vertex format emulation (#5564) 2023-08-16 08:30:33 -03:00
FormatConverter.cs Move solution and projects to src 2023-04-27 23:51:14 +02:00
FormatTable.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
FramebufferParams.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
HardwareCapabilities.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
HashTableSlim.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
HelperShader.cs Vulkan: Use staging buffer for temporary constants (#6168) 2024-01-25 19:29:53 +01:00
HostMemoryAllocator.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
IdList.cs [Ryujinx.Graphics.Vulkan] Address dotnet-format issues (#5378) 2023-07-01 12:31:42 +02:00
IndexBufferPattern.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
IndexBufferState.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
MemoryAllocation.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
MemoryAllocator.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
MemoryAllocatorBlockList.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
MultiFenceHolder.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
NativeArray.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
PersistentFlushBuffer.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
PipelineBase.cs Vulkan: Use templates for descriptor updates (#6014) 2024-01-20 11:07:33 -03:00
PipelineConverter.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
PipelineDynamicState.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
PipelineFull.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
PipelineHelperShader.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
PipelineLayoutCache.cs [Ryujinx.Graphics.Vulkan] Address dotnet-format issues (#5378) 2023-07-01 12:31:42 +02:00
PipelineLayoutCacheEntry.cs Reduce the amount of descriptor pool allocations on Vulkan (#5673) 2023-09-26 02:00:02 +02:00
PipelineLayoutFactory.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
PipelineState.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
PipelineUid.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
ResourceBindingSegment.cs Delete ResourceAccess (#5626) 2023-09-05 22:59:21 +02:00
ResourceLayoutBuilder.cs Delete ResourceAccess (#5626) 2023-09-05 22:59:21 +02:00
Ryujinx.Graphics.Vulkan.csproj Migrate to .NET 8 (#5887) 2023-11-15 17:41:31 +01:00
SamplerHolder.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
SemaphoreHolder.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
Shader.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
ShaderCollection.cs Vulkan: Use templates for descriptor updates (#6014) 2024-01-20 11:07:33 -03:00
SpecInfo.cs [Ryujinx.Graphics.Vulkan] Address dotnet-format issues (#5378) 2023-07-01 12:31:42 +02:00
StagingBuffer.cs Vulkan: Use staging buffer for temporary constants (#6168) 2024-01-25 19:29:53 +01:00
SyncManager.cs [Ryujinx.Graphics.Vulkan] Address dotnet-format issues (#5378) 2023-07-01 12:31:42 +02:00
TextureBuffer.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
TextureCopy.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
TextureStorage.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
TextureView.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
Vendor.cs [Ryujinx.Graphics.Vulkan] Address dotnet-format issues (#5378) 2023-07-01 12:31:42 +02:00
VertexBufferState.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
VertexBufferUpdater.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
VulkanConfiguration.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
VulkanDebugMessenger.cs Fix some Vulkan validation errors (#5452) 2023-07-14 09:08:52 +02:00
VulkanException.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
VulkanInitialization.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
VulkanInstance.cs Move solution and projects to src 2023-04-27 23:51:14 +02:00
VulkanPhysicalDevice.cs Move solution and projects to src 2023-04-27 23:51:14 +02:00
VulkanRenderer.cs Vulkan: Cache delegate for EndRenderPass (#6132) 2024-01-16 13:22:20 +01:00
Window.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
WindowBase.cs editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00