Initial transform feedback support (#1370)
* Initial transform feedback support * Some nits and fixes * Update ReportCounterType and Write method * Can't change shader or TFB bindings while TFB is active * Fix geometry shader input names with new naming
This commit is contained in:
parent
16dafe6316
commit
788ca6a411
23 changed files with 468 additions and 68 deletions
|
@ -24,8 +24,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
private Buffer[] _bufferOverlaps;
|
||||
|
||||
private IndexBuffer _indexBuffer;
|
||||
|
||||
private VertexBuffer[] _vertexBuffers;
|
||||
private BufferBounds[] _transformFeedbackBuffers;
|
||||
|
||||
private class BuffersPerStage
|
||||
{
|
||||
|
@ -56,6 +56,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
private bool _indexBufferDirty;
|
||||
private bool _vertexBuffersDirty;
|
||||
private uint _vertexBuffersEnableMask;
|
||||
private bool _transformFeedbackBuffersDirty;
|
||||
|
||||
private bool _rebind;
|
||||
|
||||
|
@ -73,6 +74,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
|
||||
_vertexBuffers = new VertexBuffer[Constants.TotalVertexBuffers];
|
||||
|
||||
_transformFeedbackBuffers = new BufferBounds[Constants.TotalTransformFeedbackBuffers];
|
||||
|
||||
_cpStorageBuffers = new BuffersPerStage(Constants.TotalCpStorageBuffers);
|
||||
_cpUniformBuffers = new BuffersPerStage(Constants.TotalCpUniformBuffers);
|
||||
|
||||
|
@ -144,6 +147,16 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
}
|
||||
}
|
||||
|
||||
public void SetTransformFeedbackBuffer(int index, ulong gpuVa, ulong size)
|
||||
{
|
||||
ulong address = TranslateAndCreateBuffer(gpuVa, size);
|
||||
|
||||
_transformFeedbackBuffers[index].Address = address;
|
||||
_transformFeedbackBuffers[index].Size = size;
|
||||
|
||||
_transformFeedbackBuffersDirty = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a storage buffer on the compute pipeline.
|
||||
/// Storage buffers can be read and written to on shaders.
|
||||
|
@ -522,6 +535,41 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
}
|
||||
}
|
||||
|
||||
if (_transformFeedbackBuffersDirty)
|
||||
{
|
||||
_transformFeedbackBuffersDirty = false;
|
||||
|
||||
for (int index = 0; index < Constants.TotalTransformFeedbackBuffers; index++)
|
||||
{
|
||||
BufferBounds tfb = _transformFeedbackBuffers[index];
|
||||
|
||||
if (tfb.Address == 0)
|
||||
{
|
||||
_context.Renderer.Pipeline.SetTransformFeedbackBuffer(index, new BufferRange(BufferHandle.Null, 0, 0));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
BufferRange buffer = GetBufferRange(tfb.Address, tfb.Size);
|
||||
|
||||
_context.Renderer.Pipeline.SetTransformFeedbackBuffer(index, buffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index = 0; index < Constants.TotalTransformFeedbackBuffers; index++)
|
||||
{
|
||||
BufferBounds tfb = _transformFeedbackBuffers[index];
|
||||
|
||||
if (tfb.Address == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
SynchronizeBufferRange(tfb.Address, tfb.Size);
|
||||
}
|
||||
}
|
||||
|
||||
if (_gpStorageBuffersDirty || _rebind)
|
||||
{
|
||||
_gpStorageBuffersDirty = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue