diff options
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Engine')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/Compute.cs | 28 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs | 36 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs | 17 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MethodClear.cs | 2 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MethodCopyBuffer.cs | 6 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs | 4 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MethodDraw.cs | 2 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MethodUniformBufferBind.cs | 4 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MethodUniformBufferUpdate.cs | 2 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/Methods.cs | 85 |
10 files changed, 110 insertions, 76 deletions
diff --git a/Ryujinx.Graphics.Gpu/Engine/Compute.cs b/Ryujinx.Graphics.Gpu/Engine/Compute.cs index be317a7f..a7f6ec06 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Compute.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Compute.cs @@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Engine ulong gpuVa = (uint)qmd.ConstantBufferAddrLower(index) | (ulong)qmd.ConstantBufferAddrUpper(index) << 32; ulong size = (ulong)qmd.ConstantBufferSize(index); - BufferManager.SetComputeUniformBuffer(index, gpuVa, size); + state.Channel.BufferManager.SetComputeUniformBuffer(index, gpuVa, size); } ShaderBundle cs = ShaderCache.GetComputeShader( @@ -57,9 +57,9 @@ namespace Ryujinx.Graphics.Gpu.Engine var samplerPool = state.Get<PoolState>(MethodOffset.SamplerPoolState); var texturePool = state.Get<PoolState>(MethodOffset.TexturePoolState); - TextureManager.SetComputeSamplerPool(samplerPool.Address.Pack(), samplerPool.MaximumId, qmd.SamplerIndex); - TextureManager.SetComputeTexturePool(texturePool.Address.Pack(), texturePool.MaximumId); - TextureManager.SetComputeTextureBufferIndex(state.Get<int>(MethodOffset.TextureBufferIndex)); + state.Channel.TextureManager.SetComputeSamplerPool(samplerPool.Address.Pack(), samplerPool.MaximumId, qmd.SamplerIndex); + state.Channel.TextureManager.SetComputeTexturePool(texturePool.Address.Pack(), texturePool.MaximumId); + state.Channel.TextureManager.SetComputeTextureBufferIndex(state.Get<int>(MethodOffset.TextureBufferIndex)); ShaderProgramInfo info = cs.Shaders[0].Info; @@ -76,7 +76,7 @@ namespace Ryujinx.Graphics.Gpu.Engine continue; } - ulong cbDescAddress = BufferManager.GetComputeUniformBufferAddress(0); + ulong cbDescAddress = state.Channel.BufferManager.GetComputeUniformBufferAddress(0); int cbDescOffset = 0x260 + (cb.Slot - 8) * 0x10; @@ -84,14 +84,14 @@ namespace Ryujinx.Graphics.Gpu.Engine SbDescriptor cbDescriptor = _context.PhysicalMemory.Read<SbDescriptor>(cbDescAddress); - BufferManager.SetComputeUniformBuffer(cb.Slot, cbDescriptor.PackAddress(), (uint)cbDescriptor.Size); + state.Channel.BufferManager.SetComputeUniformBuffer(cb.Slot, cbDescriptor.PackAddress(), (uint)cbDescriptor.Size); } for (int index = 0; index < info.SBuffers.Count; index++) { BufferDescriptor sb = info.SBuffers[index]; - ulong sbDescAddress = BufferManager.GetComputeUniformBufferAddress(0); + ulong sbDescAddress = state.Channel.BufferManager.GetComputeUniformBufferAddress(0); int sbDescOffset = 0x310 + sb.Slot * 0x10; @@ -99,11 +99,11 @@ namespace Ryujinx.Graphics.Gpu.Engine SbDescriptor sbDescriptor = _context.PhysicalMemory.Read<SbDescriptor>(sbDescAddress); - BufferManager.SetComputeStorageBuffer(sb.Slot, sbDescriptor.PackAddress(), (uint)sbDescriptor.Size, sb.Flags); + state.Channel.BufferManager.SetComputeStorageBuffer(sb.Slot, sbDescriptor.PackAddress(), (uint)sbDescriptor.Size, sb.Flags); } - BufferManager.SetComputeStorageBufferBindings(info.SBuffers); - BufferManager.SetComputeUniformBufferBindings(info.CBuffers); + state.Channel.BufferManager.SetComputeStorageBufferBindings(info.SBuffers); + state.Channel.BufferManager.SetComputeUniformBufferBindings(info.CBuffers); var textureBindings = new TextureBindingInfo[info.Textures.Count]; @@ -121,7 +121,7 @@ namespace Ryujinx.Graphics.Gpu.Engine descriptor.Flags); } - TextureManager.SetComputeTextures(textureBindings); + state.Channel.TextureManager.SetComputeTextures(textureBindings); var imageBindings = new TextureBindingInfo[info.Images.Count]; @@ -141,10 +141,10 @@ namespace Ryujinx.Graphics.Gpu.Engine descriptor.Flags); } - TextureManager.SetComputeImages(imageBindings); + state.Channel.TextureManager.SetComputeImages(imageBindings); - TextureManager.CommitComputeBindings(); - BufferManager.CommitComputeBindings(); + state.Channel.TextureManager.CommitComputeBindings(); + state.Channel.BufferManager.CommitComputeBindings(); _context.Renderer.Pipeline.DispatchCompute( qmd.CtaRasterWidth, diff --git a/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs b/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs index d0fcf142..0e284ac5 100644 --- a/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs +++ b/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs @@ -26,6 +26,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo private struct CommandBuffer { /// <summary> + /// Processor used to process the command buffer. Contains channel state. + /// </summary> + public GPFifoProcessor Processor; + + /// <summary> /// The type of the command buffer. /// </summary> public CommandBufferType Type; @@ -60,11 +65,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo private readonly ConcurrentQueue<CommandBuffer> _commandBufferQueue; private CommandBuffer _currentCommandBuffer; + private GPFifoProcessor _prevChannelProcessor; private readonly bool _ibEnable; private readonly GpuContext _context; private readonly AutoResetEvent _event; - private readonly GPFifoProcessor _processor; private bool _interrupt; @@ -78,8 +83,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo _ibEnable = true; _context = context; _event = new AutoResetEvent(false); - - _processor = new GPFifoProcessor(context); } /// <summary> @@ -94,11 +97,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo /// Push a GPFIFO entry in the form of a prefetched command buffer. /// It is intended to be used by nvservices to handle special cases. /// </summary> + /// <param name="processor">Processor used to process <paramref name="commandBuffer"/></param> /// <param name="commandBuffer">The command buffer containing the prefetched commands</param> - public void PushHostCommandBuffer(int[] commandBuffer) + internal void PushHostCommandBuffer(GPFifoProcessor processor, int[] commandBuffer) { _commandBufferQueue.Enqueue(new CommandBuffer { + Processor = processor, Type = CommandBufferType.Prefetch, Words = commandBuffer, EntryAddress = ulong.MaxValue, @@ -109,9 +114,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo /// <summary> /// Create a CommandBuffer from a GPFIFO entry. /// </summary> + /// <param name="processor">Processor used to process the command buffer pointed to by <paramref name="entry"/></param> /// <param name="entry">The GPFIFO entry</param> /// <returns>A new CommandBuffer based on the GPFIFO entry</returns> - private CommandBuffer CreateCommandBuffer(GPEntry entry) + private static CommandBuffer CreateCommandBuffer(GPFifoProcessor processor, GPEntry entry) { CommandBufferType type = CommandBufferType.Prefetch; @@ -124,6 +130,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo return new CommandBuffer { + Processor = processor, Type = type, Words = null, EntryAddress = startAddress, @@ -134,8 +141,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo /// <summary> /// Pushes GPFIFO entries. /// </summary> + /// <param name="processor">Processor used to process the command buffers pointed to by <paramref name="entries"/></param> /// <param name="entries">GPFIFO entries</param> - public void PushEntries(ReadOnlySpan<ulong> entries) + internal void PushEntries(GPFifoProcessor processor, ReadOnlySpan<ulong> entries) { bool beforeBarrier = true; @@ -143,7 +151,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo { ulong entry = entries[index]; - CommandBuffer commandBuffer = CreateCommandBuffer(Unsafe.As<ulong, GPEntry>(ref entry)); + CommandBuffer commandBuffer = CreateCommandBuffer(processor, Unsafe.As<ulong, GPEntry>(ref entry)); if (beforeBarrier && commandBuffer.Type == CommandBufferType.Prefetch) { @@ -173,12 +181,24 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo /// </summary> public void DispatchCalls() { + // Use this opportunity to also dispose any pending channels that were closed. + _context.DisposePendingChannels(); + + // Process command buffers. while (_ibEnable && !_interrupt && _commandBufferQueue.TryDequeue(out CommandBuffer entry)) { _currentCommandBuffer = entry; _currentCommandBuffer.Fetch(_context); - _processor.Process(_currentCommandBuffer.Words); + // If we are changing the current channel, + // we need to force all the host state to be updated. + if (_prevChannelProcessor != entry.Processor) + { + _prevChannelProcessor = entry.Processor; + entry.Processor.ForceAllDirty(); + } + + entry.Processor.Process(_currentCommandBuffer.Words); } _interrupt = false; diff --git a/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs b/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs index 78912bcc..dc8a1c75 100644 --- a/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs +++ b/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs @@ -35,7 +35,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo /// Creates a new instance of the GPU General Purpose FIFO command processor. /// </summary> /// <param name="context">GPU context</param> - public GPFifoProcessor(GpuContext context) + /// <param name="channel">Channel that the GPFIFO processor belongs to</param> + public GPFifoProcessor(GpuContext context, GpuChannel channel) { _context = context; @@ -44,7 +45,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo for (int index = 0; index < _subChannels.Length; index++) { - _subChannels[index] = new GpuState(); + _subChannels[index] = new GpuState(channel); _context.Methods.RegisterCallbacks(_subChannels[index]); } @@ -186,5 +187,17 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo _subChannels[i].ShadowRamControl = control; } } + + /// <summary> + /// Forces a full host state update by marking all state as modified, + /// and also requests all GPU resources in use to be rebound. + /// </summary> + public void ForceAllDirty() + { + for (int index = 0; index < _subChannels.Length; index++) + { + _subChannels[index].ForceAllDirty(); + } + } } } diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodClear.cs b/Ryujinx.Graphics.Gpu/Engine/MethodClear.cs index ea33304a..5f6316dc 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodClear.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodClear.cs @@ -35,7 +35,7 @@ namespace Ryujinx.Graphics.Gpu.Engine UpdateRenderTargetState(state, useControl: false, singleUse: index); - TextureManager.UpdateRenderTargets(); + state.Channel.TextureManager.UpdateRenderTargets(); bool clearDepth = (argument & 1) != 0; bool clearStencil = (argument & 2) != 0; diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodCopyBuffer.cs b/Ryujinx.Graphics.Gpu/Engine/MethodCopyBuffer.cs index a1cf86ec..c4d8a83d 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodCopyBuffer.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodCopyBuffer.cs @@ -112,7 +112,7 @@ namespace Ryujinx.Graphics.Gpu.Engine if (completeSource && completeDest) { - Image.Texture target = TextureManager.FindTexture(dst, cbp, swizzle, dstLinear); + Image.Texture target = TextureCache.FindTexture(dst, cbp, swizzle, dstLinear); if (target != null) { ReadOnlySpan<byte> data; @@ -209,13 +209,13 @@ namespace Ryujinx.Graphics.Gpu.Engine swizzle.UnpackComponentSize() == 4) { // Fast path for clears when remap is enabled. - BufferManager.ClearBuffer(cbp.DstAddress, (uint)size * 4, state.Get<uint>(MethodOffset.CopyBufferConstA)); + BufferCache.ClearBuffer(cbp.DstAddress, (uint)size * 4, state.Get<uint>(MethodOffset.CopyBufferConstA)); } else { // TODO: Implement remap functionality. // Buffer to buffer copy. - BufferManager.CopyBuffer(cbp.SrcAddress, cbp.DstAddress, (uint)size); + BufferCache.CopyBuffer(cbp.SrcAddress, cbp.DstAddress, (uint)size); } } } diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs b/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs index da08f31a..d0570262 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs @@ -80,7 +80,7 @@ namespace Ryujinx.Graphics.Gpu.Engine srcX1 = 0; } - Texture srcTexture = TextureManager.FindOrCreateTexture(srcCopyTexture, offset, srcCopyTextureFormat, true, srcHint); + Texture srcTexture = TextureCache.FindOrCreateTexture(srcCopyTexture, offset, srcCopyTextureFormat, true, srcHint); if (srcTexture == null) { @@ -101,7 +101,7 @@ namespace Ryujinx.Graphics.Gpu.Engine dstCopyTextureFormat = dstCopyTexture.Format.Convert(); } - Texture dstTexture = TextureManager.FindOrCreateTexture(dstCopyTexture, 0, dstCopyTextureFormat, srcTexture.ScaleMode == TextureScaleMode.Scaled, dstHint); + Texture dstTexture = TextureCache.FindOrCreateTexture(dstCopyTexture, 0, dstCopyTextureFormat, srcTexture.ScaleMode == TextureScaleMode.Scaled, dstHint); if (dstTexture == null) { diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodDraw.cs b/Ryujinx.Graphics.Gpu/Engine/MethodDraw.cs index 88f2e8fe..fec1cc46 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodDraw.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodDraw.cs @@ -109,7 +109,7 @@ namespace Ryujinx.Graphics.Gpu.Engine BufferRange br = new BufferRange(_ibStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4); - _context.Methods.BufferManager.SetIndexBuffer(br, IndexType.UInt); + state.Channel.BufferManager.SetIndexBuffer(br, IndexType.UInt); _context.Renderer.Pipeline.DrawIndexed( inlineIndexCount, diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodUniformBufferBind.cs b/Ryujinx.Graphics.Gpu/Engine/MethodUniformBufferBind.cs index 16fb31d6..33533e8b 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodUniformBufferBind.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodUniformBufferBind.cs @@ -74,11 +74,11 @@ namespace Ryujinx.Graphics.Gpu.Engine ulong address = uniformBuffer.Address.Pack(); - BufferManager.SetGraphicsUniformBuffer((int)type, index, address, (uint)uniformBuffer.Size); + state.Channel.BufferManager.SetGraphicsUniformBuffer((int)type, index, address, (uint)uniformBuffer.Size); } else { - BufferManager.SetGraphicsUniformBuffer((int)type, index, 0, 0); + state.Channel.BufferManager.SetGraphicsUniformBuffer((int)type, index, 0, 0); } } } diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodUniformBufferUpdate.cs b/Ryujinx.Graphics.Gpu/Engine/MethodUniformBufferUpdate.cs index 3e1dd151..981d2e94 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodUniformBufferUpdate.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodUniformBufferUpdate.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Gpu.Engine { if (_ubFollowUpAddress != 0) { - BufferManager.ForceDirty(_ubFollowUpAddress - _ubByteCount, _ubByteCount); + BufferCache.ForceDirty(_ubFollowUpAddress - _ubByteCount, _ubByteCount); _ubFollowUpAddress = 0; } diff --git a/Ryujinx.Graphics.Gpu/Engine/Methods.cs b/Ryujinx.Graphics.Gpu/Engine/Methods.cs index 431ea449..39b3d13c 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Methods.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Methods.cs @@ -30,12 +30,12 @@ namespace Ryujinx.Graphics.Gpu.Engine /// <summary> /// GPU buffer manager. /// </summary> - public BufferManager BufferManager { get; } + public BufferCache BufferCache { get; } /// <summary> /// GPU texture manager. /// </summary> - public TextureManager TextureManager { get; } + public TextureCache TextureCache { get; } private bool _isAnyVbInstanced; private bool _vsUsesInstanceId; @@ -57,12 +57,12 @@ namespace Ryujinx.Graphics.Gpu.Engine _currentProgramInfo = new ShaderProgramInfo[Constants.ShaderStages]; - BufferManager = new BufferManager(context); - TextureManager = new TextureManager(context); + BufferCache = new BufferCache(context); + TextureCache = new TextureCache(context); context.MemoryManager.MemoryUnmapped += _counterCache.MemoryUnmappedHandler; - context.MemoryManager.MemoryUnmapped += TextureManager.MemoryUnmappedHandler; - context.MemoryManager.MemoryUnmapped += BufferManager.MemoryUnmappedHandler; + context.MemoryManager.MemoryUnmapped += TextureCache.MemoryUnmappedHandler; + context.MemoryManager.MemoryUnmapped += BufferCache.MemoryUnmappedHandler; } /// <summary> @@ -280,7 +280,7 @@ namespace Ryujinx.Graphics.Gpu.Engine UpdateLogicOpState(state); } - CommitBindings(); + CommitBindings(state); if (tfEnable && !_prevTfEnable) { @@ -303,18 +303,20 @@ namespace Ryujinx.Graphics.Gpu.Engine /// Ensures that the bindings are visible to the host GPU. /// Note: this actually performs the binding using the host graphics API. /// </summary> - private void CommitBindings() + /// <param name="state">Current GPU state</param> + private void CommitBindings(GpuState state) { - UpdateStorageBuffers(); + UpdateStorageBuffers(state); - TextureManager.CommitGraphicsBindings(); - BufferManager.CommitGraphicsBindings(); + state.Channel.TextureManager.CommitGraphicsBindings(); + state.Channel.BufferManager.CommitGraphicsBindings(); } /// <summary> /// Updates storage buffer bindings. /// </summary> - private void UpdateStorageBuffers() + /// <param name="state">Current GPU state</param> + private void UpdateStorageBuffers(GpuState state) { for (int stage = 0; stage < _currentProgramInfo.Length; stage++) { @@ -329,7 +331,7 @@ namespace Ryujinx.Graphics.Gpu.Engine { BufferDescriptor sb = info.SBuffers[index]; - ulong sbDescAddress = BufferManager.GetGraphicsUniformBufferAddress(stage, 0); + ulong sbDescAddress = state.Channel.BufferManager.GetGraphicsUniformBufferAddress(stage, 0); int sbDescOffset = 0x110 + stage * 0x100 + sb.Slot * 0x10; @@ -337,7 +339,7 @@ namespace Ryujinx.Graphics.Gpu.Engine SbDescriptor sbDescriptor = _context.PhysicalMemory.Read<SbDescriptor>(sbDescAddress); - BufferManager.SetGraphicsStorageBuffer(stage, sb.Slot, sbDescriptor.PackAddress(), (uint)sbDescriptor.Size, sb.Flags); + state.Channel.BufferManager.SetGraphicsStorageBuffer(stage, sb.Slot, sbDescriptor.PackAddress(), (uint)sbDescriptor.Size, sb.Flags); } } } @@ -372,14 +374,14 @@ namespace Ryujinx.Graphics.Gpu.Engine if (index >= count || !IsRtEnabled(colorState)) { - changedScale |= TextureManager.SetRenderTargetColor(index, null); + changedScale |= state.Channel.TextureManager.SetRenderTargetColor(index, null); continue; } - Texture color = TextureManager.FindOrCreateTexture(colorState, samplesInX, samplesInY, sizeHint); + Texture color = TextureCache.FindOrCreateTexture(colorState, samplesInX, samplesInY, sizeHint); - changedScale |= TextureManager.SetRenderTargetColor(index, color); + changedScale |= state.Channel.TextureManager.SetRenderTargetColor(index, color); } bool dsEnable = state.Get<Boolean32>(MethodOffset.RtDepthStencilEnable); @@ -391,15 +393,15 @@ namespace Ryujinx.Graphics.Gpu.Engine var dsState = state.Get<RtDepthStencilState>(MethodOffset.RtDepthStencilState); var dsSize = state.Get<Size3D>(MethodOffset.RtDepthStencilSize); - depthStencil = TextureManager.FindOrCreateTexture(dsState, dsSize, samplesInX, samplesInY, sizeHint); + depthStencil = TextureCache.FindOrCreateTexture(dsState, dsSize, samplesInX, samplesInY, sizeHint); } - changedScale |= TextureManager.SetRenderTargetDepthStencil(depthStencil); + changedScale |= state.Channel.TextureManager.SetRenderTargetDepthStencil(depthStencil); if (changedScale) { - TextureManager.UpdateRenderTargetScale(singleUse); - _context.Renderer.Pipeline.SetRenderTargetScale(TextureManager.RenderTargetScale); + state.Channel.TextureManager.UpdateRenderTargetScale(singleUse); + _context.Renderer.Pipeline.SetRenderTargetScale(state.Channel.TextureManager.RenderTargetScale); UpdateViewportTransform(state); UpdateScissorState(state); @@ -436,7 +438,7 @@ namespace Ryujinx.Graphics.Gpu.Engine int width = scissor.X2 - x; int height = scissor.Y2 - y; - float scale = TextureManager.RenderTargetScale; + float scale = state.Channel.TextureManager.RenderTargetScale; if (scale != 1f) { x = (int)(x * scale); @@ -545,7 +547,7 @@ namespace Ryujinx.Graphics.Gpu.Engine float width = scaleX * 2; float height = scaleY * 2; - float scale = TextureManager.RenderTargetScale; + float scale = state.Channel.TextureManager.RenderTargetScale; if (scale != 1f) { x *= scale; @@ -670,7 +672,7 @@ namespace Ryujinx.Graphics.Gpu.Engine ? texturePool.MaximumId : samplerPool.MaximumId; - TextureManager.SetGraphicsSamplerPool(samplerPool.Address.Pack(), maximumId, samplerIndex); + state.Channel.TextureManager.SetGraphicsSamplerPool(samplerPool.Address.Pack(), maximumId, samplerIndex); } /// <summary> @@ -681,9 +683,8 @@ namespace Ryujinx.Graphics.Gpu.Engine { var texturePool = state.Get<PoolState>(MethodOffset.TexturePoolState); - TextureManager.SetGraphicsTexturePool(texturePool.Address.Pack(), texturePool.MaximumId); - - TextureManager.SetGraphicsTextureBufferIndex(state.Get<int>(MethodOffset.TextureBufferIndex)); + state.Channel.TextureManager.SetGraphicsTexturePool(texturePool.Address.Pack(), texturePool.MaximumId); + state.Channel.TextureManager.SetGraphicsTextureBufferIndex(state.Get<int>(MethodOffset.TextureBufferIndex)); } /// <summary> @@ -771,7 +772,7 @@ namespace Ryujinx.Graphics.Gpu.Engine case IndexType.UInt: size *= 4; break; } - BufferManager.SetIndexBuffer(gpuVa, size, indexBuffer.Type); + state.Channel.BufferManager.SetIndexBuffer(gpuVa, size, indexBuffer.Type); // The index buffer affects the vertex buffer size calculation, we // need to ensure that they are updated. @@ -792,7 +793,7 @@ namespace Ryujinx.Graphics.Gpu.Engine if (!vertexBuffer.UnpackEnable()) { - BufferManager.SetVertexBuffer(index, 0, 0, 0, 0); + state.Channel.BufferManager.SetVertexBuffer(index, 0, 0, 0, 0); continue; } @@ -828,7 +829,7 @@ namespace Ryujinx.Graphics.Gpu.Engine size = (ulong)((firstInstance + drawState.First + drawState.Count) * stride); } - BufferManager.SetVertexBuffer(index, address, size, stride, divisor); + state.Channel.BufferManager.SetVertexBuffer(index, address, size, stride, divisor); } } @@ -1017,10 +1018,10 @@ namespace Ryujinx.Graphics.Gpu.Engine if (info == null) { - TextureManager.SetGraphicsTextures(stage, Array.Empty<TextureBindingInfo>()); - TextureManager.SetGraphicsImages(stage, Array.Empty<TextureBindingInfo>()); - BufferManager.SetGraphicsStorageBufferBindings(stage, null); - BufferManager.SetGraphicsUniformBufferBindings(stage, null); + state.Channel.TextureManager.SetGraphicsTextures(stage, Array.Empty<TextureBindingInfo>()); + state.Channel.TextureManager.SetGraphicsImages(stage, Array.Empty<TextureBindingInfo>()); + state.Channel.BufferManager.SetGraphicsStorageBufferBindings(stage, null); + state.Channel.BufferManager.SetGraphicsUniformBufferBindings(stage, null); continue; } @@ -1040,7 +1041,7 @@ namespace Ryujinx.Graphics.Gpu.Engine descriptor.Flags); } - TextureManager.SetGraphicsTextures(stage, textureBindings); + state.Channel.TextureManager.SetGraphicsTextures(stage, textureBindings); var imageBindings = new TextureBindingInfo[info.Images.Count]; @@ -1060,10 +1061,10 @@ namespace Ryujinx.Graphics.Gpu.Engine descriptor.Flags); } - TextureManager.SetGraphicsImages(stage, imageBindings); + state.Channel.TextureManager.SetGraphicsImages(stage, imageBindings); - BufferManager.SetGraphicsStorageBufferBindings(stage, info.SBuffers); - BufferManager.SetGraphicsUniformBufferBindings(stage, info.CBuffers); + state.Channel.BufferManager.SetGraphicsStorageBufferBindings(stage, info.SBuffers); + state.Channel.BufferManager.SetGraphicsUniformBufferBindings(stage, info.CBuffers); if (info.SBuffers.Count != 0) { @@ -1076,8 +1077,8 @@ namespace Ryujinx.Graphics.Gpu.Engine } } - BufferManager.SetGraphicsStorageBufferBindingsCount(storageBufferBindingsCount); - BufferManager.SetGraphicsUniformBufferBindingsCount(uniformBufferBindingsCount); + state.Channel.BufferManager.SetGraphicsStorageBufferBindingsCount(storageBufferBindingsCount); + state.Channel.BufferManager.SetGraphicsUniformBufferBindingsCount(uniformBufferBindingsCount); _context.Renderer.Pipeline.SetProgram(gs.HostProgram); } @@ -1094,12 +1095,12 @@ namespace Ryujinx.Graphics.Gpu.Engine if (!tfb.Enable) { - BufferManager.SetTransformFeedbackBuffer(index, 0, 0); + state.Channel.BufferManager.SetTransformFeedbackBuffer(index, 0, 0); continue; } - BufferManager.SetTransformFeedbackBuffer(index, tfb.Address.Pack(), (uint)tfb.Size); + state.Channel.BufferManager.SetTransformFeedbackBuffer(index, tfb.Address.Pack(), (uint)tfb.Size); } } |
