From 83bdafccdab01322af8503e9ad21f52981e646c1 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 28 Sep 2021 18:52:27 -0300 Subject: [PATCH] Share scales array for graphics and compute (#2653) --- Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs | 11 +++-------- Ryujinx.Graphics.Gpu/Image/TextureManager.cs | 7 +++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs index 597c527dbc..d7691e13f3 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs @@ -62,12 +62,14 @@ namespace Ryujinx.Graphics.Gpu.Image /// The GPU context that the texture bindings manager belongs to /// The GPU channel that the texture bindings manager belongs to /// Texture pools cache used to get texture pools from + /// Array where the scales for the currently bound textures are stored /// True if the bindings manager is used for the compute engine - public TextureBindingsManager(GpuContext context, GpuChannel channel, TexturePoolCache poolCache, bool isCompute) + public TextureBindingsManager(GpuContext context, GpuChannel channel, TexturePoolCache poolCache, float[] scales, bool isCompute) { _context = context; _channel = channel; _texturePoolCache = poolCache; + _scales = scales; _isCompute = isCompute; int stages = isCompute ? 1 : Constants.ShaderStages; @@ -89,13 +91,6 @@ namespace Ryujinx.Graphics.Gpu.Image _textureState[stage] = new TextureStatePerStage[InitialTextureStateSize]; _imageState[stage] = new TextureStatePerStage[InitialImageStateSize]; } - - _scales = new float[64]; - - for (int i = 0; i < 64; i++) - { - _scales[i] = 1f; - } } /// diff --git a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs index 1d7b8df2f7..a6373872b9 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs @@ -35,8 +35,11 @@ namespace Ryujinx.Graphics.Gpu.Image TexturePoolCache texturePoolCache = new TexturePoolCache(context); - _cpBindingsManager = new TextureBindingsManager(context, channel, texturePoolCache, isCompute: true); - _gpBindingsManager = new TextureBindingsManager(context, channel, texturePoolCache, isCompute: false); + float[] scales = new float[64]; + new Span(scales).Fill(1f); + + _cpBindingsManager = new TextureBindingsManager(context, channel, texturePoolCache, scales, isCompute: true); + _gpBindingsManager = new TextureBindingsManager(context, channel, texturePoolCache, scales, isCompute: false); _rtColors = new Texture[Constants.TotalRenderTargets]; _rtHostColors = new ITexture[Constants.TotalRenderTargets];