Size hints for copy regions and viewport dimensions to avoid data loss (#1686)

* Size hints for copy regions and viewport dimensions to avoid data loss

* Reword comment.

* Use info for the rule rather than calculating aligned size.

* Reorder min/max, remove spaces
This commit is contained in:
riperiperi 2020-11-10 00:41:13 +00:00 committed by GitHub
parent c3d62bd078
commit 02872833b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 111 additions and 45 deletions

View file

@ -5,6 +5,7 @@ using Ryujinx.Graphics.Gpu.Memory;
using Ryujinx.Graphics.Gpu.Shader;
using Ryujinx.Graphics.Gpu.State;
using Ryujinx.Graphics.Shader;
using Ryujinx.Graphics.Texture;
using System;
using System.Linq;
using System.Runtime.InteropServices;
@ -354,6 +355,9 @@ namespace Ryujinx.Graphics.Gpu.Engine
int samplesInX = msaaMode.SamplesInX();
int samplesInY = msaaMode.SamplesInY();
var extents = state.Get<ViewportExtents>(MethodOffset.ViewportExtents, 0);
Size sizeHint = new Size(extents.X + extents.Width, extents.Y + extents.Height, 1);
bool changedScale = false;
for (int index = 0; index < Constants.TotalRenderTargets; index++)
@ -369,7 +373,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
continue;
}
Texture color = TextureManager.FindOrCreateTexture(colorState, samplesInX, samplesInY);
Texture color = TextureManager.FindOrCreateTexture(colorState, samplesInX, samplesInY, sizeHint);
changedScale |= TextureManager.SetRenderTargetColor(index, color);
@ -388,7 +392,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
var dsState = state.Get<RtDepthStencilState>(MethodOffset.RtDepthStencilState);
var dsSize = state.Get<Size3D>(MethodOffset.RtDepthStencilSize);
depthStencil = TextureManager.FindOrCreateTexture(dsState, dsSize, samplesInX, samplesInY);
depthStencil = TextureManager.FindOrCreateTexture(dsState, dsSize, samplesInX, samplesInY, sizeHint);
}
changedScale |= TextureManager.SetRenderTargetDepthStencil(depthStencil);