Argument Buffers (#24)

* Stuff

* More arg buffer stuff

* Fixes

* Rebase

* Pass storage buffers to inline functions

* Fix binding

* Fix typo + Fix a couple shaders

* Enforce ids

* Dispose

* Mark used buffers as resident

* Update depth clear shader

* Fix non-contiguous struct defs

* Update ChangeBufferStride

* Fix StorageBuffer assignments

* Fix odyssey crash

* Retain buffer bindings

* Pad Std140

* Set texture data with safe buffers

* Clone buffers

* Always declare vert in

* Stop clears from breaking OpenGL games

* Fix depth clear

* Use invariant position

* Horribly inefficient texture & sampler arg buffers

* Fix missing struct access

* Minimise rebinds as much as possible

* Build arg buffers on staging buffer
This commit is contained in:
Isaac Marovitz 2024-06-25 14:25:31 +01:00
parent a71b5f1a3a
commit c8308d27f1
20 changed files with 721 additions and 402 deletions

View file

@ -104,7 +104,7 @@ namespace Ryujinx.Graphics.Metal
return BeginBlitPass();
}
public MTLComputeCommandEncoder GetOrCreateComputeEncoder()
public MTLComputeCommandEncoder GetOrCreateComputeEncoder(bool forDispatch = false)
{
MTLComputeCommandEncoder computeCommandEncoder;
if (CurrentEncoder == null || CurrentEncoderType != EncoderType.Compute)
@ -116,7 +116,10 @@ namespace Ryujinx.Graphics.Metal
computeCommandEncoder = new MTLComputeCommandEncoder(CurrentEncoder.Value);
}
_encoderStateManager.RebindComputeState(computeCommandEncoder);
if (forDispatch)
{
_encoderStateManager.RebindComputeState(computeCommandEncoder);
}
return computeCommandEncoder;
}
@ -190,7 +193,7 @@ namespace Ryujinx.Graphics.Metal
var textureInfo = new TextureCreateInfo((int)drawable.Texture.Width, (int)drawable.Texture.Height, (int)drawable.Texture.Depth, (int)drawable.Texture.MipmapLevelCount, (int)drawable.Texture.SampleCount, 0, 0, 0, Format.B8G8R8A8Unorm, 0, Target.Texture2D, SwizzleComponent.Red, SwizzleComponent.Green, SwizzleComponent.Blue, SwizzleComponent.Alpha);
var dst = new Texture(_device, _renderer, this, textureInfo, drawable.Texture, 0, 0);
_renderer.HelperShader.BlitColor(Cbs, src, dst, srcRegion, dstRegion, isLinear);
_renderer.HelperShader.BlitColor(Cbs, src, dst, srcRegion, dstRegion, isLinear, true);
EndCurrentPass();
@ -348,7 +351,7 @@ namespace Ryujinx.Graphics.Metal
public void DispatchCompute(int groupsX, int groupsY, int groupsZ, int groupSizeX, int groupSizeY, int groupSizeZ)
{
var computeCommandEncoder = GetOrCreateComputeEncoder();
var computeCommandEncoder = GetOrCreateComputeEncoder(true);
computeCommandEncoder.DispatchThreadgroups(
new MTLSize { width = (ulong)groupsX, height = (ulong)groupsY, depth = (ulong)groupsZ },