mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-09-27 09:37:57 +02:00
Vulkan: Buffer alignment
This commit is contained in:
committed by
KeatonTheBot
parent
491fb3ccfb
commit
59c277bc6c
@@ -54,6 +54,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public PinnedSpan<byte> GetData()
|
||||
{
|
||||
int minTexelBufferOffsetAlignment = (int)_gd.Capabilities.MinTexelBufferAlignment;
|
||||
|
||||
if (_offset % minTexelBufferOffsetAlignment != 0)
|
||||
{
|
||||
_offset += (minTexelBufferOffsetAlignment - (_offset % minTexelBufferOffsetAlignment));
|
||||
}
|
||||
|
||||
return _gd.GetBufferData(_bufferHandle, _offset, _size);
|
||||
}
|
||||
|
||||
@@ -84,6 +91,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
/// <inheritdoc/>
|
||||
public void SetData(MemoryOwner<byte> data)
|
||||
{
|
||||
int minTexelBufferOffsetAlignment = (int)_gd.Capabilities.MinTexelBufferAlignment;
|
||||
|
||||
if (_offset % minTexelBufferOffsetAlignment != 0)
|
||||
{
|
||||
_offset += (minTexelBufferOffsetAlignment - (_offset % minTexelBufferOffsetAlignment));
|
||||
}
|
||||
|
||||
_gd.SetBufferData(_bufferHandle, _offset, data.Span);
|
||||
data.Dispose();
|
||||
}
|
||||
@@ -102,8 +116,16 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public void SetStorage(BufferRange buffer)
|
||||
{
|
||||
int minTexelBufferOffsetAlignment = (int)_gd.Capabilities.MinTexelBufferAlignment;
|
||||
int bufferOffset = buffer.Offset;
|
||||
|
||||
if (bufferOffset % minTexelBufferOffsetAlignment != 0)
|
||||
{
|
||||
bufferOffset += (minTexelBufferOffsetAlignment - (bufferOffset % minTexelBufferOffsetAlignment));
|
||||
}
|
||||
|
||||
if (_bufferHandle == buffer.Handle &&
|
||||
_offset == buffer.Offset &&
|
||||
_offset == bufferOffset &&
|
||||
_size == buffer.Size &&
|
||||
_bufferCount == _gd.BufferManager.BufferCount)
|
||||
{
|
||||
@@ -111,7 +133,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
|
||||
_bufferHandle = buffer.Handle;
|
||||
_offset = buffer.Offset;
|
||||
_offset = bufferOffset;
|
||||
_size = buffer.Size;
|
||||
_bufferCount = _gd.BufferManager.BufferCount;
|
||||
|
||||
@@ -120,6 +142,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public BufferView GetBufferView(CommandBufferScoped cbs, bool write)
|
||||
{
|
||||
int minTexelBufferOffsetAlignment = (int)_gd.Capabilities.MinTexelBufferAlignment;
|
||||
|
||||
if (_offset % minTexelBufferOffsetAlignment != 0)
|
||||
{
|
||||
_offset += (minTexelBufferOffsetAlignment - (_offset % minTexelBufferOffsetAlignment));
|
||||
}
|
||||
|
||||
_bufferView ??= _gd.BufferManager.CreateView(_bufferHandle, VkFormat, _offset, _size, ReleaseImpl);
|
||||
|
||||
return _bufferView?.Get(cbs, _offset, _size, write).Value ?? default;
|
||||
|
||||
Reference in New Issue
Block a user