WIP: Fix VTG As Compute after the Metal merger #574

Closed
GreemDev wants to merge 1 commits from fix/vk/vtgascompute into master
8 changed files with 54 additions and 3 deletions
Showing only changes of commit 93f92e73bd - Show all commits

View File

@ -15,6 +15,8 @@ namespace Ryujinx.Graphics.GAL
IWindow Window { get; }
uint ProgramCount { get; }
GraphicsBackend Backend { get; }
void BackgroundContextAction(Action action, bool alwaysBackground = false);

View File

@ -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)

View File

@ -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
/// </summary>
class VtgAsComputeContext : IDisposable
{
private const int DummyBufferSize = 16;
private readonly GpuContext _context;
/// <summary>
@ -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);
}
/// <summary>
/// Gets the range for a dummy 16 bytes buffer, filled with zeros.
/// </summary>
/// <returns>Dummy buffer range</returns>
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);
}
/// <summary>
/// Gets the range for a sequential index buffer, with ever incrementing index values.

View File

@ -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;
}
/// <summary>
/// Binds a dummy buffer as vertex buffer into a buffer texture.
/// </summary>
/// <param name="reservations">Shader resource binding reservations</param>
/// <param name="index">Buffer texture index</param>
/// <param name="format">Buffer texture format</param>
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);
}
/// <summary>
/// Binds a vertex buffer into a buffer texture.

View File

@ -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; }

View File

@ -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;

View File

@ -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;

View File

@ -22998,4 +22998,4 @@
}
}
]
}
}