From 4c0eb91d7e6bdbe42ffa6e950e3288f8066de089 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Tue, 20 Sep 2022 22:38:48 +0100 Subject: Convert Quads to Triangles in Vulkan (#3715) * Add Index Buffer conversion for quads to Vulkan Also adds a reusable repeating pattern index buffer to use for non-indexed draws, and generalizes the conversion cache for buffers. * Fix some issues * End render pass before conversion * Resume transform feedback after we ensure we're in a pass. * Always generate UInt32 type indices for topology conversion * No it's not. * Remove unused code * Rely on TopologyRemap to convert quads to tris. * Remove double newline * Ensure render pass ends before stride or I8 conversion --- Ryujinx.Graphics.Vulkan/CacheByRange.cs | 50 +++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'Ryujinx.Graphics.Vulkan/CacheByRange.cs') diff --git a/Ryujinx.Graphics.Vulkan/CacheByRange.cs b/Ryujinx.Graphics.Vulkan/CacheByRange.cs index f9edca8a..4c47e1c1 100644 --- a/Ryujinx.Graphics.Vulkan/CacheByRange.cs +++ b/Ryujinx.Graphics.Vulkan/CacheByRange.cs @@ -10,14 +10,25 @@ namespace Ryujinx.Graphics.Vulkan struct I8ToI16CacheKey : ICacheKey { - public I8ToI16CacheKey() { } + // Used to notify the pipeline that bindings have invalidated on dispose. + private readonly VulkanRenderer _gd; + private Auto _buffer; + + public I8ToI16CacheKey(VulkanRenderer gd) + { + _gd = gd; + _buffer = null; + } public bool KeyEqual(ICacheKey other) { return other is I8ToI16CacheKey; } - public void Dispose() { } + public void Dispose() + { + _gd.PipelineInternal.DirtyIndexBuffer(_buffer); + } } struct AlignedVertexBufferCacheKey : ICacheKey @@ -55,6 +66,41 @@ namespace Ryujinx.Graphics.Vulkan } } + struct TopologyConversionCacheKey : ICacheKey + { + private IndexBufferPattern _pattern; + private int _indexSize; + + // Used to notify the pipeline that bindings have invalidated on dispose. + private readonly VulkanRenderer _gd; + private Auto _buffer; + + public TopologyConversionCacheKey(VulkanRenderer gd, IndexBufferPattern pattern, int indexSize) + { + _gd = gd; + _pattern = pattern; + _indexSize = indexSize; + _buffer = null; + } + + public bool KeyEqual(ICacheKey other) + { + return other is TopologyConversionCacheKey entry && + entry._pattern == _pattern && + entry._indexSize == _indexSize; + } + + public void SetBuffer(Auto buffer) + { + _buffer = buffer; + } + + public void Dispose() + { + _gd.PipelineInternal.DirtyIndexBuffer(_buffer); + } + } + struct CacheByRange where T : IDisposable { private struct Entry -- cgit v1.2.3