diff options
| author | gdk <gab.dark.100@gmail.com> | 2019-10-17 23:41:18 -0300 |
|---|---|---|
| committer | Thog <thog@protonmail.com> | 2020-01-09 02:13:00 +0100 |
| commit | 1b7d95519569639135a68e7ebda5148f3263217c (patch) | |
| tree | 52a5e471418bf28ce970a268e1b86b64abc9048f /Ryujinx.Graphics.Gpu/Engine | |
| parent | 717ace6f6ed65118148dc78976c6e818a095fa4d (diff) | |
Initial support for image stores, support texture sample on compute
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Engine')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/Compute.cs | 43 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MethodClear.cs | 4 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MethodDraw.cs | 10 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/Methods.cs | 103 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/ShaderCache.cs | 3 |
5 files changed, 111 insertions, 52 deletions
diff --git a/Ryujinx.Graphics.Gpu/Engine/Compute.cs b/Ryujinx.Graphics.Gpu/Engine/Compute.cs index c8627435..b5acca1c 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Compute.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Compute.cs @@ -1,3 +1,5 @@ +using Ryujinx.Graphics.GAL.Texture; +using Ryujinx.Graphics.Gpu.Image; using Ryujinx.Graphics.Gpu.State; using Ryujinx.Graphics.Shader; using System; @@ -23,10 +25,46 @@ namespace Ryujinx.Graphics.Gpu.Engine dispatchParams.UnpackBlockSizeY(), dispatchParams.UnpackBlockSizeZ()); - _context.Renderer.ComputePipeline.SetProgram(cs.Interface); + _context.Renderer.Pipeline.BindProgram(cs.Interface); + + PoolState samplerPool = _context.State.GetSamplerPoolState(); + + _textureManager.SetComputeSamplerPool(samplerPool.Address.Pack(), samplerPool.MaximumId); + + PoolState texturePool = _context.State.GetTexturePoolState(); + + _textureManager.SetComputeTexturePool(texturePool.Address.Pack(), texturePool.MaximumId); + + _textureManager.SetComputeTextureBufferIndex(_context.State.GetTextureBufferIndex()); ShaderProgramInfo info = cs.Shader.Info; + var textureBindings = new TextureBindingInfo[info.Textures.Count]; + + for (int index = 0; index < info.Textures.Count; index++) + { + var descriptor = info.Textures[index]; + + Target target = GetTarget(descriptor.Type); + + textureBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex); + } + + _textureManager.SetComputeTextures(textureBindings); + + var imageBindings = new TextureBindingInfo[info.Images.Count]; + + for (int index = 0; index < info.Images.Count; index++) + { + var descriptor = info.Images[index]; + + Target target = GetTarget(descriptor.Type); + + imageBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex); + } + + _textureManager.SetComputeImages(imageBindings); + uint sbEnableMask = 0; uint ubEnableMask = dispatchParams.UnpackUniformBuffersEnableMask(); @@ -73,8 +111,9 @@ namespace Ryujinx.Graphics.Gpu.Engine _bufferManager.SetComputeUniformBufferEnableMask(ubEnableMask); _bufferManager.CommitComputeBindings(); + _textureManager.CommitComputeBindings(); - _context.Renderer.ComputePipeline.Dispatch( + _context.Renderer.Pipeline.Dispatch( dispatchParams.UnpackGridSizeX(), dispatchParams.UnpackGridSizeY(), dispatchParams.UnpackGridSizeZ()); diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodClear.cs b/Ryujinx.Graphics.Gpu/Engine/MethodClear.cs index b4680fa5..2072f3fc 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodClear.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodClear.cs @@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Gpu.Engine clearColor.Blue, clearColor.Alpha); - _context.Renderer.GraphicsPipeline.ClearRenderTargetColor( + _context.Renderer.Pipeline.ClearRenderTargetColor( index, componentMask, color); @@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Engine stencilMask = _context.State.GetStencilTestState().FrontMask; } - _context.Renderer.GraphicsPipeline.ClearRenderTargetDepthStencil( + _context.Renderer.Pipeline.ClearRenderTargetDepthStencil( depthValue, clearDepth, stencilValue, diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodDraw.cs b/Ryujinx.Graphics.Gpu/Engine/MethodDraw.cs index dd360113..c340aeb8 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodDraw.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodDraw.cs @@ -61,7 +61,7 @@ namespace Ryujinx.Graphics.Gpu.Engine int firstVertex = _context.State.GetBaseVertex(); - _context.Renderer.GraphicsPipeline.DrawIndexed( + _context.Renderer.Pipeline.DrawIndexed( _indexCount, 1, _firstIndex, @@ -72,7 +72,7 @@ namespace Ryujinx.Graphics.Gpu.Engine { VertexBufferDrawState drawState = _context.State.GetVertexBufferDrawState(); - _context.Renderer.GraphicsPipeline.Draw( + _context.Renderer.Pipeline.Draw( drawState.Count, 1, drawState.First, @@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Gpu.Engine { PrimitiveType type = (PrimitiveType)(argument & 0xffff); - _context.Renderer.GraphicsPipeline.SetPrimitiveTopology(type.Convert()); + _context.Renderer.Pipeline.SetPrimitiveTopology(type.Convert()); PrimitiveType = type; @@ -112,7 +112,7 @@ namespace Ryujinx.Graphics.Gpu.Engine if (_instancedIndexed) { - _context.Renderer.GraphicsPipeline.DrawIndexed( + _context.Renderer.Pipeline.DrawIndexed( _instancedIndexCount, _instanceIndex + 1, _instancedFirstIndex, @@ -121,7 +121,7 @@ namespace Ryujinx.Graphics.Gpu.Engine } else { - _context.Renderer.GraphicsPipeline.Draw( + _context.Renderer.Pipeline.Draw( _instancedDrawStateCount, _instanceIndex + 1, _instancedDrawStateFirst, diff --git a/Ryujinx.Graphics.Gpu/Engine/Methods.cs b/Ryujinx.Graphics.Gpu/Engine/Methods.cs index db72a861..c35d6634 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Methods.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Methods.cs @@ -21,6 +21,7 @@ namespace Ryujinx.Graphics.Gpu.Engine private BufferManager _bufferManager; private TextureManager _textureManager; + public BufferManager BufferManager => _bufferManager; public TextureManager TextureManager => _textureManager; private bool _isAnyVbInstanced; @@ -33,7 +34,7 @@ namespace Ryujinx.Graphics.Gpu.Engine _shaderCache = new ShaderCache(_context); _bufferManager = new BufferManager(context); - _textureManager = new TextureManager(context, _bufferManager); + _textureManager = new TextureManager(context); RegisterCallbacks(); } @@ -61,7 +62,10 @@ namespace Ryujinx.Graphics.Gpu.Engine _context.State.RegisterUniformBufferBind3Callback(UniformBufferBind3); _context.State.RegisterUniformBufferBind4Callback(UniformBufferBind4); - _context.State.RegisterCallback(MethodOffset.InvalidateTextures, InvalidateTextures); + _context.State.RegisterCallback(MethodOffset.TextureBarrier, TextureBarrier); + _context.State.RegisterCallback(MethodOffset.InvalidateTextures, InvalidateTextures); + _context.State.RegisterCallback(MethodOffset.TextureBarrierTiled, TextureBarrierTiled); + _context.State.RegisterCallback(MethodOffset.ResetCounter, ResetCounter); @@ -153,18 +157,7 @@ namespace Ryujinx.Graphics.Gpu.Engine private void CommitBindings() { _bufferManager.CommitBindings(); - _textureManager.CommitBindings(); - } - - public void InvalidateRange(ulong address, ulong size) - { - _bufferManager.InvalidateRange(address, size); - _textureManager.InvalidateRange(address, size); - } - - public void InvalidateTextureRange(ulong address, ulong size) - { - _textureManager.InvalidateRange(address, size); + _textureManager.CommitGraphicsBindings(); } private void UpdateRenderTargetGroupState() @@ -272,7 +265,7 @@ namespace Ryujinx.Graphics.Gpu.Engine private void UpdateDepthTestState() { - _context.Renderer.GraphicsPipeline.SetDepthTest(new DepthTestDescriptor( + _context.Renderer.Pipeline.SetDepthTest(new DepthTestDescriptor( _context.State.GetDepthTestEnable().IsTrue(), _context.State.GetDepthWriteEnable().IsTrue(), _context.State.GetDepthTestFunc())); @@ -305,7 +298,7 @@ namespace Ryujinx.Graphics.Gpu.Engine extents.DepthFar); } - _context.Renderer.GraphicsPipeline.SetViewports(0, viewports); + _context.Renderer.Pipeline.SetViewports(0, viewports); } private void UpdateDepthBiasState() @@ -322,7 +315,7 @@ namespace Ryujinx.Graphics.Gpu.Engine enables |= (polygonOffset.LineEnable.IsTrue() ? PolygonModeMask.Line : 0); enables |= (polygonOffset.FillEnable.IsTrue() ? PolygonModeMask.Fill : 0); - _context.Renderer.GraphicsPipeline.SetDepthBias(enables, factor, units, clamp); + _context.Renderer.Pipeline.SetDepthBias(enables, factor, units, clamp); } private void UpdateStencilTestState() @@ -360,7 +353,7 @@ namespace Ryujinx.Graphics.Gpu.Engine backMask = test.FrontMask; } - _context.Renderer.GraphicsPipeline.SetStencilTest(new StencilTestDescriptor( + _context.Renderer.Pipeline.SetStencilTest(new StencilTestDescriptor( test.Enable.IsTrue(), test.FrontFunc, test.FrontSFail, @@ -382,16 +375,16 @@ namespace Ryujinx.Graphics.Gpu.Engine { PoolState samplerPool = _context.State.GetSamplerPoolState(); - _textureManager.SetSamplerPool(samplerPool.Address.Pack(), samplerPool.MaximumId); + _textureManager.SetGraphicsSamplerPool(samplerPool.Address.Pack(), samplerPool.MaximumId); } private void UpdateTexturePoolState() { PoolState texturePool = _context.State.GetTexturePoolState(); - _textureManager.SetTexturePool(texturePool.Address.Pack(), texturePool.MaximumId); + _textureManager.SetGraphicsTexturePool(texturePool.Address.Pack(), texturePool.MaximumId); - _textureManager.SetTextureBufferIndex(_context.State.GetTextureBufferIndex()); + _textureManager.SetGraphicsTextureBufferIndex(_context.State.GetTextureBufferIndex()); } private void UpdateInputAssemblerGroupState() @@ -439,14 +432,14 @@ namespace Ryujinx.Graphics.Gpu.Engine format); } - _context.Renderer.GraphicsPipeline.BindVertexAttribs(vertexAttribs); + _context.Renderer.Pipeline.BindVertexAttribs(vertexAttribs); } private void UpdatePrimitiveRestartState() { PrimitiveRestartState primitiveRestart = _context.State.Get<PrimitiveRestartState>(MethodOffset.PrimitiveRestartState); - _context.Renderer.GraphicsPipeline.SetPrimitiveRestart( + _context.Renderer.Pipeline.SetPrimitiveRestart( primitiveRestart.Enable, primitiveRestart.Index); } @@ -593,9 +586,9 @@ namespace Ryujinx.Graphics.Gpu.Engine { FaceState face = _context.State.GetFaceState(); - _context.Renderer.GraphicsPipeline.SetFaceCulling(face.CullEnable.IsTrue(), face.CullFace); + _context.Renderer.Pipeline.SetFaceCulling(face.CullEnable.IsTrue(), face.CullFace); - _context.Renderer.GraphicsPipeline.SetFrontFace(face.FrontFace); + _context.Renderer.Pipeline.SetFrontFace(face.FrontFace); } private void UpdateRtColorMask() @@ -616,7 +609,7 @@ namespace Ryujinx.Graphics.Gpu.Engine componentMasks[index] = componentMask; } - _context.Renderer.GraphicsPipeline.SetRenderTargetColorMasks(componentMasks); + _context.Renderer.Pipeline.SetRenderTargetColorMasks(componentMasks); } private void UpdateBlendState() @@ -638,7 +631,7 @@ namespace Ryujinx.Graphics.Gpu.Engine blend.AlphaSrcFactor, blend.AlphaDstFactor); - _context.Renderer.GraphicsPipeline.BindBlendState(index, descriptor); + _context.Renderer.Pipeline.BindBlendState(index, descriptor); } } @@ -696,12 +689,25 @@ namespace Ryujinx.Graphics.Gpu.Engine { var descriptor = info.Textures[index]; - Target target = GetTarget(descriptor.Target); + Target target = GetTarget(descriptor.Type); textureBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex); } - _textureManager.BindTextures(stage, textureBindings); + _textureManager.SetGraphicsTextures(stage, textureBindings); + + var imageBindings = new TextureBindingInfo[info.Images.Count]; + + for (int index = 0; index < info.Images.Count; index++) + { + var descriptor = info.Images[index]; + + Target target = GetTarget(descriptor.Type); + + imageBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex); + } + + _textureManager.SetGraphicsImages(stage, imageBindings); uint sbEnableMask = 0; uint ubEnableMask = 0; @@ -734,40 +740,43 @@ namespace Ryujinx.Graphics.Gpu.Engine _bufferManager.SetGraphicsUniformBufferEnableMask(stage, ubEnableMask); } - _context.Renderer.GraphicsPipeline.BindProgram(gs.Interface); + _context.Renderer.Pipeline.BindProgram(gs.Interface); } - private static Target GetTarget(Shader.TextureTarget target) + private static Target GetTarget(SamplerType type) { - target &= ~Shader.TextureTarget.Shadow; + type &= ~SamplerType.Shadow; - switch (target) + switch (type) { - case Shader.TextureTarget.Texture1D: + case SamplerType.Texture1D: return Target.Texture1D; - case Shader.TextureTarget.Texture1D | Shader.TextureTarget.Array: + case SamplerType.TextureBuffer: + return Target.TextureBuffer; + + case SamplerType.Texture1D | SamplerType.Array: return Target.Texture1DArray; - case Shader.TextureTarget.Texture2D: + case SamplerType.Texture2D: return Target.Texture2D; - case Shader.TextureTarget.Texture2D | Shader.TextureTarget.Array: + case SamplerType.Texture2D | SamplerType.Array: return Target.Texture2DArray; - case Shader.TextureTarget.Texture2D | Shader.TextureTarget.Multisample: + case SamplerType.Texture2D | SamplerType.Multisample: return Target.Texture2DMultisample; - case Shader.TextureTarget.Texture2D | Shader.TextureTarget.Multisample | Shader.TextureTarget.Array: + case SamplerType.Texture2D | SamplerType.Multisample | SamplerType.Array: return Target.Texture2DMultisampleArray; - case Shader.TextureTarget.Texture3D: + case SamplerType.Texture3D: return Target.Texture3D; - case Shader.TextureTarget.TextureCube: + case SamplerType.TextureCube: return Target.Cubemap; - case Shader.TextureTarget.TextureCube | Shader.TextureTarget.Array: + case SamplerType.TextureCube | SamplerType.Array: return Target.CubemapArray; } @@ -776,9 +785,19 @@ namespace Ryujinx.Graphics.Gpu.Engine return Target.Texture2D; } + private void TextureBarrier(int argument) + { + _context.Renderer.Pipeline.TextureBarrier(); + } + private void InvalidateTextures(int argument) { _textureManager.Flush(); } + + private void TextureBarrierTiled(int argument) + { + _context.Renderer.Pipeline.TextureBarrierTiled(); + } } }
\ No newline at end of file diff --git a/Ryujinx.Graphics.Gpu/Engine/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Engine/ShaderCache.cs index 79a84a6d..d280ea6f 100644 --- a/Ryujinx.Graphics.Gpu/Engine/ShaderCache.cs +++ b/Ryujinx.Graphics.Gpu/Engine/ShaderCache.cs @@ -107,7 +107,8 @@ namespace Ryujinx.Graphics.Gpu.Engine ShaderProgram program; const TranslationFlags flags = - TranslationFlags.Compute | + TranslationFlags.Compute | + TranslationFlags.DebugMode | TranslationFlags.Unspecialized; TranslationConfig translationConfig = new TranslationConfig(0x10000, _dumper.CurrentDumpIndex, flags); |
