Initial tessellation shader support (#2534)
* Initial tessellation shader support * Nits * Re-arrange built-in table * This is not needed anymore * PR feedback
This commit is contained in:
parent
7603dbe3c8
commit
d512ce122c
42 changed files with 775 additions and 148 deletions
|
@ -129,7 +129,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
|
|||
_state.State.SetTexHeaderPoolCMaximumIndex,
|
||||
_state.State.SetBindlessTextureConstantBufferSlotSelect,
|
||||
false,
|
||||
PrimitiveTopology.Points);
|
||||
PrimitiveTopology.Points,
|
||||
default);
|
||||
|
||||
ShaderBundle cs = memoryManager.Physical.ShaderCache.GetComputeShader(
|
||||
_channel,
|
||||
|
|
|
@ -72,6 +72,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
nameof(ThreedClassState.VertexBufferState),
|
||||
nameof(ThreedClassState.VertexBufferEndAddress)),
|
||||
|
||||
new StateUpdateCallbackEntry(UpdateTessellationState,
|
||||
nameof(ThreedClassState.TessOuterLevel),
|
||||
nameof(ThreedClassState.TessInnerLevel),
|
||||
nameof(ThreedClassState.PatchVertices)),
|
||||
|
||||
new StateUpdateCallbackEntry(UpdateTfBufferState, nameof(ThreedClassState.TfBufferState)),
|
||||
new StateUpdateCallbackEntry(UpdateUserClipState, nameof(ThreedClassState.ClipDistanceEnable)),
|
||||
|
||||
|
@ -100,6 +105,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
nameof(ThreedClassState.ViewportExtents),
|
||||
nameof(ThreedClassState.YControl)),
|
||||
|
||||
new StateUpdateCallbackEntry(UpdatePolygonMode,
|
||||
nameof(ThreedClassState.PolygonModeFront),
|
||||
nameof(ThreedClassState.PolygonModeBack)),
|
||||
|
||||
new StateUpdateCallbackEntry(UpdateDepthBiasState,
|
||||
nameof(ThreedClassState.DepthBiasState),
|
||||
nameof(ThreedClassState.DepthBiasFactor),
|
||||
|
@ -259,6 +268,17 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates tessellation state based on the guest GPU state.
|
||||
/// </summary>
|
||||
private void UpdateTessellationState()
|
||||
{
|
||||
_context.Renderer.Pipeline.SetPatchParameters(
|
||||
_state.State.PatchVertices,
|
||||
_state.State.TessOuterLevel.ToSpan(),
|
||||
_state.State.TessInnerLevel.ToSpan());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates transform feedback buffer state based on the guest GPU state.
|
||||
/// </summary>
|
||||
|
@ -544,6 +564,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
_context.Renderer.Pipeline.SetViewports(0, viewports);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates polygon mode state based on current GPU state.
|
||||
/// </summary>
|
||||
private void UpdatePolygonMode()
|
||||
{
|
||||
_context.Renderer.Pipeline.SetPolygonMode(_state.State.PolygonModeFront, _state.State.PolygonModeBack);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates host depth bias (also called polygon offset) state based on current GPU state.
|
||||
/// </summary>
|
||||
|
@ -949,7 +977,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
_state.State.TexturePoolState.MaximumId,
|
||||
(int)_state.State.TextureBufferIndex,
|
||||
_state.State.EarlyZForce,
|
||||
_drawState.Topology);
|
||||
_drawState.Topology,
|
||||
_state.State.TessMode);
|
||||
|
||||
ShaderBundle gs = _channel.MemoryManager.Physical.ShaderCache.GetGraphicsShader(ref _state.State, _channel, gas, addresses);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ using Ryujinx.Graphics.GAL;
|
|||
using Ryujinx.Graphics.Gpu.Engine.InlineToMemory;
|
||||
using Ryujinx.Graphics.Gpu.Engine.Types;
|
||||
using Ryujinx.Graphics.Gpu.Image;
|
||||
using Ryujinx.Graphics.Shader;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
||||
|
@ -19,6 +20,43 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
Fragment
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tessellation mode.
|
||||
/// </summary>
|
||||
struct TessMode
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
public uint Packed;
|
||||
#pragma warning restore CS0649
|
||||
|
||||
/// <summary>
|
||||
/// Unpacks the tessellation abstract patch type.
|
||||
/// </summary>
|
||||
/// <returns>Abtract patch type</returns>
|
||||
public TessPatchType UnpackPatchType()
|
||||
{
|
||||
return (TessPatchType)(Packed & 3);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unpacks the spacing between tessellated vertices of the patch.
|
||||
/// </summary>
|
||||
/// <returns>Spacing between tessellated vertices</returns>
|
||||
public TessSpacing UnpackSpacing()
|
||||
{
|
||||
return (TessSpacing)((Packed >> 4) & 3);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unpacks the primitive winding order.
|
||||
/// </summary>
|
||||
/// <returns>True if clockwise, false if counter-clockwise</returns>
|
||||
public bool UnpackCw()
|
||||
{
|
||||
return (Packed & (1 << 8)) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transform feedback buffer state.
|
||||
/// </summary>
|
||||
|
@ -661,7 +699,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
public Boolean32 EarlyZForce;
|
||||
public fixed uint Reserved214[45];
|
||||
public uint SyncpointAction;
|
||||
public fixed uint Reserved2CC[44];
|
||||
public fixed uint Reserved2CC[21];
|
||||
public TessMode TessMode;
|
||||
public Array4<float> TessOuterLevel;
|
||||
public Array2<float> TessInnerLevel;
|
||||
public fixed uint Reserved33C[16];
|
||||
public Boolean32 RasterizeEnable;
|
||||
public Array4<TfBufferState> TfBufferState;
|
||||
public fixed uint Reserved400[192];
|
||||
|
@ -679,9 +721,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||
public float ClearDepthValue;
|
||||
public fixed uint ReservedD94[3];
|
||||
public uint ClearStencilValue;
|
||||
public fixed uint ReservedDA4[7];
|
||||
public fixed uint ReservedDA4[2];
|
||||
public PolygonMode PolygonModeFront;
|
||||
public PolygonMode PolygonModeBack;
|
||||
public Boolean32 PolygonSmoothEnable;
|
||||
public fixed uint ReservedDB8[2];
|
||||
public DepthBiasState DepthBiasState;
|
||||
public fixed uint ReservedDCC[5];
|
||||
public int PatchVertices;
|
||||
public fixed uint ReservedDD0[4];
|
||||
public uint TextureBarrier;
|
||||
public fixed uint ReservedDE4[7];
|
||||
public Array16<ScissorState> ScissorState;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue