Simple GPU fixes (#1093)

* Implement RasterizeEnable

* Match viewport count to hardware

* Simplify ScissorTest tracking around Blits

* Disable RasterizerDiscard around Blits and track its state

* Read RasterizeEnable reg as bool and add doc
This commit is contained in:
mageven 2020-04-07 14:49:45 +05:30 committed by GitHub
parent e99e6d0ad1
commit 468d8f841f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 66 additions and 18 deletions

View file

@ -53,6 +53,6 @@ namespace Ryujinx.Graphics.Gpu
/// <summary>
/// Maximum number of viewports.
/// </summary>
public const int TotalViewports = 8;
public const int TotalViewports = 16;
}
}

View file

@ -108,6 +108,11 @@ namespace Ryujinx.Graphics.Gpu.Engine
UpdateShaderState(state);
}
if (state.QueryModified(MethodOffset.RasterizeEnable))
{
UpdateRasterizerState(state);
}
if (state.QueryModified(MethodOffset.RtColorState,
MethodOffset.RtDepthStencilState,
MethodOffset.RtControl,
@ -211,6 +216,16 @@ namespace Ryujinx.Graphics.Gpu.Engine
CommitBindings();
}
/// <summary>
/// Updates Rasterizer primitive discard state based on guest gpu state.
/// </summary>
/// <param name="state">Current GPU state</param>
private void UpdateRasterizerState(GpuState state)
{
Boolean32 enable = state.Get<Boolean32>(MethodOffset.RasterizeEnable);
_context.Renderer.Pipeline.SetRasterizerDiscard(!enable);
}
/// <summary>
/// Ensures that the bindings are visible to the host GPU.
/// Note: this actually performs the binding using the host graphics API.

View file

@ -117,6 +117,9 @@ namespace Ryujinx.Graphics.Gpu.State
/// </summary>
private void InitializeDefaultState()
{
// Enable Rasterizer
_backingMemory[(int)MethodOffset.RasterizeEnable] = 1;
// Depth ranges.
for (int index = 0; index < 8; index++)
{

View file

@ -53,11 +53,11 @@ namespace Ryujinx.Graphics.Gpu.State
public static TableItem[] Table = new TableItem[]
{
new TableItem(MethodOffset.RtColorState, typeof(RtColorState), 8),
new TableItem(MethodOffset.ViewportTransform, typeof(ViewportTransform), 8),
new TableItem(MethodOffset.ViewportExtents, typeof(ViewportExtents), 8),
new TableItem(MethodOffset.ViewportTransform, typeof(ViewportTransform), Constants.TotalViewports),
new TableItem(MethodOffset.ViewportExtents, typeof(ViewportExtents), Constants.TotalViewports),
new TableItem(MethodOffset.VertexBufferDrawState, typeof(VertexBufferDrawState), 1),
new TableItem(MethodOffset.DepthBiasState, typeof(DepthBiasState), 1),
new TableItem(MethodOffset.ScissorState, typeof(ScissorState), 8),
new TableItem(MethodOffset.ScissorState, typeof(ScissorState), Constants.TotalViewports),
new TableItem(MethodOffset.StencilBackMasks, typeof(StencilBackMasks), 1),
new TableItem(MethodOffset.RtDepthStencilState, typeof(RtDepthStencilState), 1),
new TableItem(MethodOffset.VertexAttribState, typeof(VertexAttribState), 16),

View file

@ -16,6 +16,7 @@ namespace Ryujinx.Graphics.Gpu.State
DispatchParamsAddress = 0xad,
Dispatch = 0xaf,
CopyBuffer = 0xc0,
RasterizeEnable = 0xdf,
CopyBufferParams = 0x100,
CopyBufferSwizzle = 0x1c2,
CopyBufferDstTexture = 0x1c3,