mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-11-22 18:15:11 +00:00
c6d82209ab
* Vertex Buffer Alignment part 1 * Update CacheByRange * Add Stride Change compute shader, fix storage buffers in helpers * An AMD exclusive * Reword * Change rules - stride conversion when attrs misalign * Fix stupid mistake * Fix background pipeline compile * Improve a few things. * Fix some feedback * Address Feedback (the shader binary didn't change when i changed the source to use the subgroup size) * Fix bug where rewritten buffer would be disposed instantly.
59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using Silk.NET.Vulkan;
|
|
using System;
|
|
|
|
namespace Ryujinx.Graphics.Vulkan
|
|
{
|
|
struct BufferState : IDisposable
|
|
{
|
|
public static BufferState Null => new BufferState(null, 0, 0);
|
|
|
|
private readonly int _offset;
|
|
private readonly int _size;
|
|
private readonly IndexType _type;
|
|
|
|
private readonly Auto<DisposableBuffer> _buffer;
|
|
|
|
public BufferState(Auto<DisposableBuffer> buffer, int offset, int size, IndexType type)
|
|
{
|
|
_buffer = buffer;
|
|
|
|
_offset = offset;
|
|
_size = size;
|
|
_type = type;
|
|
buffer?.IncrementReferenceCount();
|
|
}
|
|
|
|
public BufferState(Auto<DisposableBuffer> buffer, int offset, int size)
|
|
{
|
|
_buffer = buffer;
|
|
|
|
_offset = offset;
|
|
_size = size;
|
|
_type = IndexType.Uint16;
|
|
buffer?.IncrementReferenceCount();
|
|
}
|
|
|
|
public void BindIndexBuffer(Vk api, CommandBufferScoped cbs)
|
|
{
|
|
if (_buffer != null)
|
|
{
|
|
api.CmdBindIndexBuffer(cbs.CommandBuffer, _buffer.Get(cbs, _offset, _size).Value, (ulong)_offset, _type);
|
|
}
|
|
}
|
|
|
|
public void BindTransformFeedbackBuffer(VulkanRenderer gd, CommandBufferScoped cbs, uint binding)
|
|
{
|
|
if (_buffer != null)
|
|
{
|
|
var buffer = _buffer.Get(cbs, _offset, _size).Value;
|
|
|
|
gd.TransformFeedbackApi.CmdBindTransformFeedbackBuffers(cbs.CommandBuffer, binding, 1, buffer, (ulong)_offset, (ulong)_size);
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_buffer?.DecrementReferenceCount();
|
|
}
|
|
}
|
|
}
|