Skip to content

Commit

Permalink
Fix texture wrapping not updating on consecutive WhitePixel use
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo committed Aug 8, 2024
1 parent aeffd4e commit 3a61875
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions osu.Framework/Graphics/Rendering/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,8 @@ public bool BindTexture(Texture texture, int unit, WrapMode? wrapModeS, WrapMode

if (texture is TextureWhitePixel && lastBoundTextureIsAtlas[unit])
{
setWrapMode(wrapModeS ?? texture.WrapModeS, wrapModeT ?? texture.WrapModeT);

// We can use the special white space from any atlas texture.
return true;
}
Expand Down Expand Up @@ -823,26 +825,35 @@ public bool BindTexture(INativeTexture texture, int unit = 0, WrapMode wrapModeS
if (!SetTextureImplementation(texture, unit))
return false;

setWrapMode(wrapModeS, wrapModeT);

lastBoundTexture[unit] = texture;
lastBoundTextureIsAtlas[unit] = false;
lastActiveTextureUnit = unit;

FrameStatistics.Increment(StatisticsCounterType.TextureBinds);
texture.TotalBindCount++;

return true;
}

private void setWrapMode(WrapMode wrapModeS, WrapMode wrapModeT)
{
if (wrapModeS != CurrentWrapModeS)
{
FlushCurrentBatch(FlushBatchSource.BindTexture);

CurrentWrapModeS = wrapModeS;
globalUniformsChanged = true;
}

if (wrapModeT != CurrentWrapModeT)
{
FlushCurrentBatch(FlushBatchSource.BindTexture);

CurrentWrapModeT = wrapModeT;
globalUniformsChanged = true;
}

lastBoundTexture[unit] = texture;
lastBoundTextureIsAtlas[unit] = false;
lastActiveTextureUnit = unit;

FrameStatistics.Increment(StatisticsCounterType.TextureBinds);
texture.TotalBindCount++;

return true;
}

/// <summary>
Expand Down

0 comments on commit 3a61875

Please sign in to comment.