mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-11-30 20:54:30 +01:00
Properly register TextureBuffer usage + Store Auto ref
This commit is contained in:
parent
810b5792a8
commit
e8dda2d5ef
@ -1133,6 +1133,11 @@ namespace Ryujinx.Graphics.Metal
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (storage is TextureBuffer textureBuffer)
|
||||||
|
{
|
||||||
|
textureBuffer.RebuildStorage(false);
|
||||||
|
}
|
||||||
|
|
||||||
var mtlTexture = storage.GetHandle();
|
var mtlTexture = storage.GetHandle();
|
||||||
|
|
||||||
MTLRenderStages renderStages = 0;
|
MTLRenderStages renderStages = 0;
|
||||||
@ -1345,6 +1350,11 @@ namespace Ryujinx.Graphics.Metal
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (storage is TextureBuffer textureBuffer)
|
||||||
|
{
|
||||||
|
textureBuffer.RebuildStorage(false);
|
||||||
|
}
|
||||||
|
|
||||||
var mtlTexture = storage.GetHandle();
|
var mtlTexture = storage.GetHandle();
|
||||||
|
|
||||||
if (segment.Stages.HasFlag(ResourceStages.Compute))
|
if (segment.Stages.HasFlag(ResourceStages.Compute))
|
||||||
|
@ -15,6 +15,7 @@ namespace Ryujinx.Graphics.Metal
|
|||||||
private int _size;
|
private int _size;
|
||||||
|
|
||||||
private int _bufferCount;
|
private int _bufferCount;
|
||||||
|
private Auto<DisposableBuffer> _buffer;
|
||||||
|
|
||||||
public TextureBuffer(MTLDevice device, MetalRenderer renderer, Pipeline pipeline, TextureCreateInfo info) : base(device, renderer, pipeline, info)
|
public TextureBuffer(MTLDevice device, MetalRenderer renderer, Pipeline pipeline, TextureCreateInfo info) : base(device, renderer, pipeline, info)
|
||||||
{
|
{
|
||||||
@ -32,25 +33,20 @@ namespace Ryujinx.Graphics.Metal
|
|||||||
MtlFormat = pixelFormat;
|
MtlFormat = pixelFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RebuildStorage()
|
public void RebuildStorage(bool write)
|
||||||
{
|
{
|
||||||
// Find the parent buffer, and try to build a texture from it.
|
if (MtlTexture != IntPtr.Zero)
|
||||||
|
|
||||||
// TODO: texture uses should register read/write usage on the assigned buffer.
|
|
||||||
Auto<DisposableBuffer> bufferAuto = Renderer.BufferManager.GetBuffer(_bufferHandle, false);
|
|
||||||
|
|
||||||
if (MtlTexture.NativePtr != 0)
|
|
||||||
{
|
{
|
||||||
MtlTexture.Dispose();
|
MtlTexture.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bufferAuto == null)
|
if (_buffer == null)
|
||||||
{
|
{
|
||||||
MtlTexture = default;
|
MtlTexture = default;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DisposableBuffer buffer = bufferAuto.Get(Pipeline.Cbs, _offset, _size);
|
DisposableBuffer buffer = _buffer.Get(Pipeline.Cbs, _offset, _size, write);
|
||||||
|
|
||||||
_descriptor.Width = (uint)(_size / Info.BytesPerPixel);
|
_descriptor.Width = (uint)(_size / Info.BytesPerPixel);
|
||||||
MtlTexture = buffer.Value.NewTexture(_descriptor, (ulong)_offset, (ulong)_size);
|
MtlTexture = buffer.Value.NewTexture(_descriptor, (ulong)_offset, (ulong)_size);
|
||||||
@ -123,7 +119,7 @@ namespace Ryujinx.Graphics.Metal
|
|||||||
_size = buffer.Size;
|
_size = buffer.Size;
|
||||||
_bufferCount = Renderer.BufferManager.BufferCount;
|
_bufferCount = Renderer.BufferManager.BufferCount;
|
||||||
|
|
||||||
RebuildStorage();
|
_buffer = Renderer.BufferManager.GetBuffer(_bufferHandle, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Release()
|
public override void Release()
|
||||||
|
Loading…
Reference in New Issue
Block a user