Skip to content

Commit

Permalink
Fix res scale parameters not being updated in vertex shader (#3046)
Browse files Browse the repository at this point in the history
This fixes an issue where the render scale array would not be updated when technically the scales on the flat array were the same, but the start index for the vertex scales was different.
  • Loading branch information
riperiperi authored Jan 27, 2022
1 parent 0a0a95f commit fd6d3ec
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ private struct TextureStatePerStage

private readonly float[] _scales;
private bool _scaleChanged;
private int _lastFragmentTotal;

/// <summary>
/// Constructs a new instance of the texture bindings manager.
Expand Down Expand Up @@ -288,26 +289,30 @@ private bool UpdateScale(Texture texture, TextureBindingInfo binding, int index,
/// </summary>
private void CommitRenderScale()
{
if (_scaleChanged)
{
int fragmentTotal = 0;
int total;
// Stage 0 total: Compute or Vertex.
int total = _textureBindingsCount[0] + _imageBindingsCount[0];

if (!_isCompute)
{
int fragmentIndex = (int)ShaderStage.Fragment - 1;
fragmentTotal = _textureBindingsCount[fragmentIndex] + _imageBindingsCount[fragmentIndex];
int fragmentIndex = (int)ShaderStage.Fragment - 1;
int fragmentTotal = _isCompute ? 0 : (_textureBindingsCount[fragmentIndex] + _imageBindingsCount[fragmentIndex]);

int vertexIndex = (int)ShaderStage.Vertex - 1;
int vertexTotal = _textureBindingsCount[vertexIndex] + _imageBindingsCount[vertexIndex];
if (total != 0 && fragmentTotal != _lastFragmentTotal)
{
// Must update scales in the support buffer if:
// - Vertex stage has bindings.
// - Fragment stage binding count has been updated since last render scale update.

total = fragmentTotal + vertexTotal;
}
else
_scaleChanged = true;
}

if (_scaleChanged)
{
if (!_isCompute)
{
total = _textureBindingsCount[0] + _imageBindingsCount[0];
total += fragmentTotal; // Add the fragment bindings to the total.
}

_lastFragmentTotal = fragmentTotal;

_context.Renderer.Pipeline.UpdateRenderScale(_scales, total, fragmentTotal);

_scaleChanged = false;
Expand Down

0 comments on commit fd6d3ec

Please sign in to comment.