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.OpenGL/Pipeline.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.OpenGL/Pipeline.cs')
-rw-r--r-- | Ryujinx.Graphics.OpenGL/Pipeline.cs | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Pipeline.cs b/Ryujinx.Graphics.OpenGL/Pipeline.cs index 9623c826..7537b44f 100644 --- a/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -45,6 +45,8 @@ namespace Ryujinx.Graphics.OpenGL private bool _scissor0Enable = false; + private bool _tfEnabled; + ColorF _blendConstant = new ColorF(0, 0, 0, 0); internal Pipeline() @@ -76,6 +78,12 @@ namespace Ryujinx.Graphics.OpenGL GL.MemoryBarrier(MemoryBarrierFlags.AllBarrierBits); } + public void BeginTransformFeedback(PrimitiveTopology topology) + { + GL.BeginTransformFeedback(topology.ConvertToTfType()); + _tfEnabled = true; + } + public void ClearRenderTargetColor(int index, uint componentMask, ColorF color) { GL.ColorMask( @@ -512,6 +520,12 @@ namespace Ryujinx.Graphics.OpenGL } } + public void EndTransformFeedback() + { + GL.EndTransformFeedback(); + _tfEnabled = false; + } + public void SetBlendState(int index, BlendDescriptor blend) { if (!blend.Enable) @@ -713,7 +727,17 @@ namespace Ryujinx.Graphics.OpenGL public void SetProgram(IProgram program) { _program = (Program)program; - _program.Bind(); + + if (_tfEnabled) + { + GL.PauseTransformFeedback(); + _program.Bind(); + GL.ResumeTransformFeedback(); + } + else + { + _program.Bind(); + } SetRenderTargetScale(_fpRenderScale[0]); } @@ -904,6 +928,22 @@ namespace Ryujinx.Graphics.OpenGL } } + public void SetTransformFeedbackBuffer(int index, BufferRange buffer) + { + const BufferRangeTarget target = BufferRangeTarget.TransformFeedbackBuffer; + + if (_tfEnabled) + { + GL.PauseTransformFeedback(); + GL.BindBufferRange(target, index, buffer.Handle.ToInt32(), (IntPtr)buffer.Offset, buffer.Size); + GL.ResumeTransformFeedback(); + } + else + { + GL.BindBufferRange(target, index, buffer.Handle.ToInt32(), (IntPtr)buffer.Offset, buffer.Size); + } + } + public void SetUniformBuffer(int index, ShaderStage stage, BufferRange buffer) { SetBuffer(index, stage, buffer, isStorage: false); @@ -1132,7 +1172,7 @@ namespace Ryujinx.Graphics.OpenGL { // If the event has been flushed, then just use the values on the CPU. // The query object may already be repurposed for another draw (eg. begin + end). - return false; + return false; } if (compare == 0 && evt.Type == QueryTarget.SamplesPassed && evt.ClearCounter) @@ -1145,7 +1185,7 @@ namespace Ryujinx.Graphics.OpenGL // The GPU will flush the queries to CPU and evaluate the condition there instead. GL.Flush(); // The thread will be stalled manually flushing the counter, so flush GL commands now. - return false; + return false; } public bool TryHostConditionalRendering(ICounterEvent value, ICounterEvent compare, bool isEqual) |