diff --git a/src/Ryujinx.Graphics.GAL/IRenderer.cs b/src/Ryujinx.Graphics.GAL/IRenderer.cs index c2fdcbe4b..6991b5a34 100644 --- a/src/Ryujinx.Graphics.GAL/IRenderer.cs +++ b/src/Ryujinx.Graphics.GAL/IRenderer.cs @@ -15,6 +15,8 @@ namespace Ryujinx.Graphics.GAL IWindow Window { get; } uint ProgramCount { get; } + + GraphicsBackend Backend { get; } void BackgroundContextAction(Action action, bool alwaysBackground = false); diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs b/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs index 6375d290c..ce8864517 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs @@ -72,6 +72,8 @@ namespace Ryujinx.Graphics.GAL.Multithreading public IRenderer BaseRenderer => _baseRenderer; + public GraphicsBackend Backend => _baseRenderer.Backend; + public bool PreferThreading => _baseRenderer.PreferThreading; public ThreadedRenderer(IRenderer renderer) diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeContext.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeContext.cs index 34f2cfcad..dc5c8f8ec 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeContext.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeContext.cs @@ -1,4 +1,5 @@ using Ryujinx.Common; +using Ryujinx.Common.Configuration; using Ryujinx.Graphics.GAL; using System; using System.Collections.Generic; @@ -11,6 +12,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw /// class VtgAsComputeContext : IDisposable { + private const int DummyBufferSize = 16; + private readonly GpuContext _context; /// @@ -46,7 +49,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw 1, 1, 1, - format.GetBytesPerElement(), + renderer.Backend is GraphicsBackend.Metal + ? format.GetBytesPerElement() + : 1, format, DepthStencilMode.Depth, Target.TextureBuffer, @@ -518,6 +523,21 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw { return new BufferRange(_geometryIndexDataBuffer.Handle, offset, size, write); } + + /// + /// Gets the range for a dummy 16 bytes buffer, filled with zeros. + /// + /// Dummy buffer range + public BufferRange GetDummyBufferRange() + { + if (_dummyBuffer == BufferHandle.Null) + { + _dummyBuffer = _context.Renderer.CreateBuffer(DummyBufferSize, BufferAccess.DeviceMemory); + _context.Renderer.Pipeline.ClearBuffer(_dummyBuffer, 0, DummyBufferSize, 0); + } + + return new BufferRange(_dummyBuffer, 0, DummyBufferSize); + } /// /// Gets the range for a sequential index buffer, with ever incrementing index values. diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs index 2de324392..efb067acb 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs @@ -1,4 +1,5 @@ using Ryujinx.Common; +using Ryujinx.Common.Configuration; using Ryujinx.Common.Logging; using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Gpu.Engine.Types; @@ -147,6 +148,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw { _vacContext.VertexInfoBufferUpdater.SetVertexStride(index, 0, componentsCount); _vacContext.VertexInfoBufferUpdater.SetVertexOffset(index, 0, 0); + if (_context.Renderer.Backend is not GraphicsBackend.Metal) + SetDummyBufferTexture(_vertexAsCompute.Reservations, index, format); + continue; } @@ -162,6 +166,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw { _vacContext.VertexInfoBufferUpdater.SetVertexStride(index, 0, componentsCount); _vacContext.VertexInfoBufferUpdater.SetVertexOffset(index, 0, 0); + if (_context.Renderer.Backend is not GraphicsBackend.Metal) + SetDummyBufferTexture(_vertexAsCompute.Reservations, index, format); + continue; } @@ -340,6 +347,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw { return maxOutputVertices / verticesPerPrimitive; } + + /// + /// Binds a dummy buffer as vertex buffer into a buffer texture. + /// + /// Shader resource binding reservations + /// Buffer texture index + /// Buffer texture format + private readonly void SetDummyBufferTexture(ResourceReservations reservations, int index, Format format) + { + ITexture bufferTexture = _vacContext.EnsureBufferTexture(index + 2, format); + bufferTexture.SetStorage(_vacContext.GetDummyBufferRange()); + + _context.Renderer.Pipeline.SetTextureAndSampler(ShaderStage.Compute, reservations.GetVertexBufferTextureBinding(index), bufferTexture, null); + } /// /// Binds a vertex buffer into a buffer texture. diff --git a/src/Ryujinx.Graphics.Metal/MetalRenderer.cs b/src/Ryujinx.Graphics.Metal/MetalRenderer.cs index 7afd30886..ea290d288 100644 --- a/src/Ryujinx.Graphics.Metal/MetalRenderer.cs +++ b/src/Ryujinx.Graphics.Metal/MetalRenderer.cs @@ -31,6 +31,8 @@ namespace Ryujinx.Graphics.Metal public IPipeline Pipeline => _pipeline; public IWindow Window => _window; + public GraphicsBackend Backend => GraphicsBackend.Metal; + internal MTLCommandQueue BackgroundQueue { get; private set; } internal HelperShader HelperShader { get; private set; } internal BufferManager BufferManager { get; private set; } diff --git a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs index 6ead314fd..15c6dd277 100644 --- a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs +++ b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs @@ -20,6 +20,8 @@ namespace Ryujinx.Graphics.OpenGL private readonly Window _window; public IWindow Window => _window; + + public GraphicsBackend Backend => GraphicsBackend.OpenGl; private readonly TextureCopy _textureCopy; private readonly TextureCopy _backgroundTextureCopy; diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs index a4fcf5353..912137fcb 100644 --- a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs +++ b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs @@ -29,7 +29,9 @@ namespace Ryujinx.Graphics.Vulkan private bool _initialized; - public uint ProgramCount { get; set; } = 0; + public uint ProgramCount { get; set; } + + public GraphicsBackend Backend => GraphicsBackend.Vulkan; internal FormatCapabilities FormatCapabilities { get; private set; } internal HardwareCapabilities Capabilities; diff --git a/src/Ryujinx/Assets/locales.json b/src/Ryujinx/Assets/locales.json index 8a101d733..8ceef5f67 100644 --- a/src/Ryujinx/Assets/locales.json +++ b/src/Ryujinx/Assets/locales.json @@ -22998,4 +22998,4 @@ } } ] -} +} \ No newline at end of file