diff options
author | gdkchan <gab.dark.100@gmail.com> | 2020-07-15 00:01:10 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-15 13:01:10 +1000 |
commit | 788ca6a411762035a6a7a88100c4b582b47ee82d (patch) | |
tree | d48bfb91aecaead2906ec2d390357546f8c0611f /Ryujinx.Graphics.Gpu/Memory/BufferManager.cs | |
parent | 16dafe63166d065f40b57a9b7cf8017a6ba0b1ef (diff) |
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
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory/BufferManager.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Memory/BufferManager.cs | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs index 533b0576..9712f58f 100644 --- a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs +++ b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs @@ -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; |