diff options
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs | 90 |
1 files changed, 53 insertions, 37 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs index dea918cd..97a9eee4 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs @@ -232,42 +232,44 @@ namespace Ryujinx.Graphics.Gpu.Image if ((binding.Flags & TextureUsageFlags.NeedsScaleValue) != 0 && texture != null) { - switch (stage) + if ((binding.Flags & TextureUsageFlags.ResScaleUnsupported) != 0) { - case ShaderStage.Fragment: - if ((binding.Flags & TextureUsageFlags.ResScaleUnsupported) != 0) - { - changed |= texture.ScaleMode != TextureScaleMode.Blacklisted; - texture.BlacklistScale(); - break; - } - - float scale = texture.ScaleFactor; - - if (scale != 1) - { - Texture activeTarget = _channel.TextureManager.GetAnyRenderTarget(); + changed = texture.ScaleMode != TextureScaleMode.Blacklisted; + texture.BlacklistScale(); + } + else + { + switch (stage) + { + case ShaderStage.Fragment: + float scale = texture.ScaleFactor; - if (activeTarget != null && activeTarget.Info.Width / (float)texture.Info.Width == activeTarget.Info.Height / (float)texture.Info.Height) + if (scale != 1) { - // If the texture's size is a multiple of the sampler size, enable interpolation using gl_FragCoord. (helps "invent" new integer values between scaled pixels) - result = -scale; - break; + Texture activeTarget = _channel.TextureManager.GetAnyRenderTarget(); + + if (activeTarget != null && (activeTarget.Info.Width / (float)texture.Info.Width) == (activeTarget.Info.Height / (float)texture.Info.Height)) + { + // If the texture's size is a multiple of the sampler size, enable interpolation using gl_FragCoord. (helps "invent" new integer values between scaled pixels) + result = -scale; + break; + } } - } - result = scale; - break; + result = scale; + break; - case ShaderStage.Compute: - if ((binding.Flags & TextureUsageFlags.ResScaleUnsupported) != 0) - { - changed |= texture.ScaleMode != TextureScaleMode.Blacklisted; - texture.BlacklistScale(); - } + case ShaderStage.Vertex: + int fragmentIndex = (int)ShaderStage.Fragment - 1; + index += _textureBindingsCount[fragmentIndex] + _imageBindingsCount[fragmentIndex]; + + result = texture.ScaleFactor; + break; - result = texture.ScaleFactor; - break; + case ShaderStage.Compute: + result = texture.ScaleFactor; + break; + } } } @@ -284,13 +286,29 @@ namespace Ryujinx.Graphics.Gpu.Image /// <summary> /// Uploads texture and image scales to the backend when they are used. /// </summary> - /// <param name="stage">Current shader stage</param> - /// <param name="stageIndex">Shader stage index</param> - private void CommitRenderScale(ShaderStage stage, int stageIndex) + private void CommitRenderScale() { if (_scaleChanged) { - _context.Renderer.Pipeline.UpdateRenderScale(stage, _scales, _textureBindingsCount[stageIndex], _imageBindingsCount[stageIndex]); + int fragmentTotal = 0; + int total; + + if (!_isCompute) + { + int fragmentIndex = (int)ShaderStage.Fragment - 1; + fragmentTotal = _textureBindingsCount[fragmentIndex] + _imageBindingsCount[fragmentIndex]; + + int vertexIndex = (int)ShaderStage.Vertex - 1; + int vertexTotal = _textureBindingsCount[vertexIndex] + _imageBindingsCount[vertexIndex]; + + total = fragmentTotal + vertexTotal; + } + else + { + total = _textureBindingsCount[0] + _imageBindingsCount[0]; + } + + _context.Renderer.Pipeline.UpdateRenderScale(_scales, total, fragmentTotal); _scaleChanged = false; } @@ -312,8 +330,6 @@ namespace Ryujinx.Graphics.Gpu.Image { CommitTextureBindings(texturePool, ShaderStage.Compute, 0); CommitImageBindings (texturePool, ShaderStage.Compute, 0); - - CommitRenderScale(ShaderStage.Compute, 0); } else { @@ -323,11 +339,11 @@ namespace Ryujinx.Graphics.Gpu.Image CommitTextureBindings(texturePool, stage, stageIndex); CommitImageBindings (texturePool, stage, stageIndex); - - CommitRenderScale(stage, stageIndex); } } + CommitRenderScale(); + _rebind = false; } |
