diff options
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs index 9b58e014..ecfd763f 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs @@ -1,5 +1,6 @@ using Ryujinx.Common.Logging; using Ryujinx.Graphics.GAL; +using Ryujinx.Graphics.Gpu.Engine.Threed.Blender; using Ryujinx.Graphics.Gpu.Engine.Types; using Ryujinx.Graphics.Gpu.Image; using Ryujinx.Graphics.Gpu.Shader; @@ -26,6 +27,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed private readonly GpuChannel _channel; private readonly DeviceStateWithShadow<ThreedClassState> _state; private readonly DrawState _drawState; + private readonly AdvancedBlendManager _blendManager; private readonly StateUpdateTracker<ThreedClassState> _updateTracker; @@ -55,13 +57,21 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// <param name="channel">GPU channel</param> /// <param name="state">3D engine state</param> /// <param name="drawState">Draw state</param> + /// <param name="blendManager">Advanced blend manager</param> /// <param name="spec">Specialization state updater</param> - public StateUpdater(GpuContext context, GpuChannel channel, DeviceStateWithShadow<ThreedClassState> state, DrawState drawState, SpecializationStateUpdater spec) + public StateUpdater( + GpuContext context, + GpuChannel channel, + DeviceStateWithShadow<ThreedClassState> state, + DrawState drawState, + AdvancedBlendManager blendManager, + SpecializationStateUpdater spec) { _context = context; _channel = channel; _state = state; _drawState = drawState; + _blendManager = blendManager; _currentProgramInfo = new ShaderProgramInfo[Constants.ShaderStages]; _currentSpecState = spec; @@ -84,6 +94,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed new StateUpdateCallbackEntry(UpdateVertexAttribState, nameof(ThreedClassState.VertexAttribState)), new StateUpdateCallbackEntry(UpdateBlendState, + nameof(ThreedClassState.BlendUcodeEnable), + nameof(ThreedClassState.BlendUcodeSize), nameof(ThreedClassState.BlendIndependent), nameof(ThreedClassState.BlendConstant), nameof(ThreedClassState.BlendStateCommon), @@ -1154,6 +1166,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// </summary> private void UpdateBlendState() { + if (_state.State.BlendUcodeEnable != BlendUcodeEnable.Disabled) + { + if (_context.Capabilities.SupportsBlendEquationAdvanced && _blendManager.TryGetAdvancedBlend(out var blendDescriptor)) + { + // Try to HLE it using advanced blend on the host if we can. + _context.Renderer.Pipeline.SetBlendState(blendDescriptor); + return; + } + else + { + // TODO: Blend emulation fallback. + } + } + bool blendIndependent = _state.State.BlendIndependent; ColorF blendConstant = _state.State.BlendConstant; |