Update topology with GpuAccessorState

This commit is contained in:
riperiperi 2022-03-08 20:52:59 +00:00
parent ba8887b848
commit 6c09cfff4c
4 changed files with 13 additions and 30 deletions

View file

@ -200,9 +200,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Starts draw. /// Starts draw.
/// This sets primitive type and instanced draw parameters. /// This sets primitive type and instanced draw parameters.
/// </summary> /// </summary>
/// <param name="engine">3D engine where this method is being called</param>
/// <param name="argument">Method call argument</param> /// <param name="argument">Method call argument</param>
public void DrawBegin(ThreedClass engine, int argument) public void DrawBegin(int argument)
{ {
bool incrementInstance = (argument & (1 << 26)) != 0; bool incrementInstance = (argument & (1 << 26)) != 0;
bool resetInstance = (argument & (1 << 27)) == 0; bool resetInstance = (argument & (1 << 27)) == 0;
@ -210,12 +209,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
if (_state.State.PrimitiveTypeOverrideEnable) if (_state.State.PrimitiveTypeOverrideEnable)
{ {
PrimitiveTypeOverride typeOverride = _state.State.PrimitiveTypeOverride; PrimitiveTypeOverride typeOverride = _state.State.PrimitiveTypeOverride;
DrawBegin(engine, incrementInstance, resetInstance, typeOverride.Convert()); DrawBegin(incrementInstance, resetInstance, typeOverride.Convert());
} }
else else
{ {
PrimitiveType type = (PrimitiveType)(argument & 0xffff); PrimitiveType type = (PrimitiveType)(argument & 0xffff);
DrawBegin(engine, incrementInstance, resetInstance, type.Convert()); DrawBegin(incrementInstance, resetInstance, type.Convert());
} }
} }
@ -223,11 +222,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Starts draw. /// Starts draw.
/// This sets primitive type and instanced draw parameters. /// This sets primitive type and instanced draw parameters.
/// </summary> /// </summary>
/// <param name="engine">3D engine where this method is being called</param>
/// <param name="incrementInstance">Indicates if the current instance should be incremented</param> /// <param name="incrementInstance">Indicates if the current instance should be incremented</param>
/// <param name="resetInstance">Indicates if the current instance should be set to zero</param> /// <param name="resetInstance">Indicates if the current instance should be set to zero</param>
/// <param name="topology">Primitive topology</param> /// <param name="topology">Primitive topology</param>
private void DrawBegin(ThreedClass engine, bool incrementInstance, bool resetInstance, PrimitiveTopology topology) private void DrawBegin(bool incrementInstance, bool resetInstance, PrimitiveTopology topology)
{ {
if (incrementInstance) if (incrementInstance)
{ {
@ -242,7 +240,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
if (_drawState.Topology != topology || !_topologySet) if (_drawState.Topology != topology || !_topologySet)
{ {
engine.SetPipelineTopology(topology);
_context.Renderer.Pipeline.SetPrimitiveTopology(topology); _context.Renderer.Pipeline.SetPrimitiveTopology(topology);
_drawState.Topology = topology; _drawState.Topology = topology;
_topologySet = true; _topologySet = true;
@ -312,7 +309,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ {
PrimitiveTypeOverride typeOverride = _state.State.PrimitiveTypeOverride; PrimitiveTypeOverride typeOverride = _state.State.PrimitiveTypeOverride;
DrawBegin(engine, instanced, !instanced, typeOverride.Convert()); DrawBegin(instanced, !instanced, typeOverride.Convert());
int firstIndex = argument & 0xffff; int firstIndex = argument & 0xffff;
int indexCount = (argument >> 16) & 0xfff; int indexCount = (argument >> 16) & 0xfff;
@ -406,7 +403,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ {
engine.Write(IndexBufferCountMethodOffset * 4, indexCount); engine.Write(IndexBufferCountMethodOffset * 4, indexCount);
engine.SetPipelineTopology(topology);
_context.Renderer.Pipeline.SetPrimitiveTopology(topology); _context.Renderer.Pipeline.SetPrimitiveTopology(topology);
_drawState.Topology = topology; _drawState.Topology = topology;
_topologySet = true; _topologySet = true;

View file

@ -192,15 +192,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
_updateTracker.SetAllDirty(); _updateTracker.SetAllDirty();
} }
/// <summary>
/// Sets topology for the current pipeline.
/// </summary>
/// <param name="topology">New topology value</param>
public void SetPipelineTopology(PrimitiveTopology topology)
{
_pipeline.Topology = topology;
}
/// <summary> /// <summary>
/// Updates host state for any modified guest state, since the last time this function was called. /// Updates host state for any modified guest state, since the last time this function was called.
/// </summary> /// </summary>

View file

@ -109,15 +109,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
_state.State.SetMmeShadowRamControl = (uint)control; _state.State.SetMmeShadowRamControl = (uint)control;
} }
/// <summary>
/// Sets topology for the current pipeline.
/// </summary>
/// <param name="topology">New topology value</param>
public void SetPipelineTopology(PrimitiveTopology topology)
{
_stateUpdater.SetPipelineTopology(topology);
}
/// <summary> /// <summary>
/// Updates current host state for all registers modified since the last call to this method. /// Updates current host state for all registers modified since the last call to this method.
/// </summary> /// </summary>
@ -352,7 +343,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// <param name="argument">Method call argument</param> /// <param name="argument">Method call argument</param>
private void DrawBegin(int argument) private void DrawBegin(int argument)
{ {
_drawManager.DrawBegin(this, argument); _drawManager.DrawBegin(argument);
} }
/// <summary> /// <summary>

View file

@ -232,7 +232,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
return cpShader; return cpShader;
} }
private void UpdatePipelineInfo(ref ThreedClassState state, ref ProgramPipelineState pipeline, GpuChannel channel) private void UpdatePipelineInfo(
ref ThreedClassState state,
ref ProgramPipelineState pipeline,
GpuChannelGraphicsState graphicsState,
GpuChannel channel)
{ {
channel.TextureManager.UpdateRenderTargets(); channel.TextureManager.UpdateRenderTargets();
@ -265,6 +269,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
pipeline.DepthStencilFormat = pipeline.DepthStencilEnable ? state.RtDepthStencilState.Format.Convert().Format : Format.D24UnormS8Uint; pipeline.DepthStencilFormat = pipeline.DepthStencilEnable ? state.RtDepthStencilState.Format.Convert().Format : Format.D24UnormS8Uint;
pipeline.VertexBufferCount = Constants.TotalVertexBuffers; pipeline.VertexBufferCount = Constants.TotalVertexBuffers;
pipeline.Topology = graphicsState.Topology;
} }
/// <summary> /// <summary>
@ -390,7 +395,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
} }
} }
UpdatePipelineInfo(ref state, ref pipeline, channel); UpdatePipelineInfo(ref state, ref pipeline, graphicsState, channel);
int fragmentOutputMap = shaders[5]?.Info.FragmentOutputMap ?? -1; int fragmentOutputMap = shaders[5]?.Info.FragmentOutputMap ?? -1;
IProgram hostProgram = _context.Renderer.CreateProgram(shaderSources.ToArray(), new ShaderInfo(fragmentOutputMap, pipeline)); IProgram hostProgram = _context.Renderer.CreateProgram(shaderSources.ToArray(), new ShaderInfo(fragmentOutputMap, pipeline));