mirror of
https://github.com/Ryujinx-NX/Ryujinx.git
synced 2024-11-14 21:17:43 -07:00
Use Viewport and Scissor with count.
Topology Dynamic State is not working as intended. Need to add check to set correct Topology class. Circle back to this later. For now revert it. Some minor fixes.
This commit is contained in:
parent
e7fbc9a1be
commit
eaedc3ec9e
@ -693,9 +693,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
var oldStencilTestEnable = _supportExtDynamic ? DynamicState._stencilTestEnable : _newState.StencilTestEnable;
|
||||
var oldDepthTestEnable = _supportExtDynamic ? DynamicState._depthtestEnable : _newState.DepthTestEnable;
|
||||
var oldDepthWriteEnable = _supportExtDynamic ? DynamicState._depthwriteEnable : _newState.DepthWriteEnable;
|
||||
var oldTopology = _supportExtDynamic ? DynamicState. Topology : _newState.Topology;
|
||||
var oldTopology = _newState.Topology;
|
||||
var oldViewports = DynamicState.Viewports;
|
||||
var oldViewportsCount = _newState.ViewportsCount;
|
||||
var oldViewportsCount = _supportExtDynamic ? DynamicState.ViewportsCount : _newState.ViewportsCount;
|
||||
|
||||
if (_supportExtDynamic)
|
||||
{
|
||||
@ -726,7 +726,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
DynamicState.SetCullMode(oldCullMode);
|
||||
DynamicState.SetStencilTest(oldStencilTestEnable);
|
||||
DynamicState.SetDepthTestBool(oldDepthTestEnable, oldDepthWriteEnable);
|
||||
DynamicState.SetPrimitiveTopology(oldTopology);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -734,12 +733,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_newState.StencilTestEnable = oldStencilTestEnable;
|
||||
_newState.DepthTestEnable = oldDepthTestEnable;
|
||||
_newState.DepthWriteEnable = oldDepthWriteEnable;
|
||||
_newState.Topology = oldTopology;
|
||||
_newState.ViewportsCount = oldViewportsCount;
|
||||
}
|
||||
|
||||
_newState.Topology = oldTopology;
|
||||
|
||||
DynamicState.SetViewports(ref oldViewports, oldViewportsCount);
|
||||
|
||||
_newState.ViewportsCount = oldViewportsCount;
|
||||
SignalStateChange();
|
||||
}
|
||||
}
|
||||
@ -1023,14 +1023,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_topology = topology;
|
||||
|
||||
var vkTopology = Gd.TopologyRemap(topology).Convert();
|
||||
if (_supportExtDynamic)
|
||||
{
|
||||
DynamicState.SetPrimitiveTopology(vkTopology);
|
||||
}
|
||||
else
|
||||
{
|
||||
_newState.Topology = vkTopology;
|
||||
}
|
||||
|
||||
_newState.Topology = vkTopology;
|
||||
|
||||
SignalStateChange();
|
||||
}
|
||||
@ -1441,8 +1435,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Clamp(viewport.DepthNear),
|
||||
Clamp(viewport.DepthFar)));
|
||||
}
|
||||
|
||||
_newState.ViewportsCount = (uint)count;
|
||||
|
||||
if (!_supportExtDynamic)
|
||||
{
|
||||
_newState.ViewportsCount = (uint)count;
|
||||
}
|
||||
SignalStateChange();
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
public bool _depthtestEnable;
|
||||
public bool _depthwriteEnable;
|
||||
private CompareOp _depthCompareOp;
|
||||
|
||||
public PrimitiveTopology Topology;
|
||||
|
||||
|
||||
private Array4<float> _blendConstants;
|
||||
|
||||
public uint ViewportsCount;
|
||||
@ -63,10 +61,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
DepthTestBool = 1 << 7,
|
||||
DepthTestCompareOp = 1 << 8,
|
||||
StencilTestEnable = 1 << 9,
|
||||
Toplogy = 1 << 10,
|
||||
LineWidth = 1 << 11,
|
||||
LineWidth = 1 << 10,
|
||||
Standard = Blend | DepthBias | Scissor | Stencil | Viewport | LineWidth,
|
||||
Extended = CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnable | Toplogy,
|
||||
Extended = CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnable,
|
||||
}
|
||||
|
||||
private DirtyFlags _dirty;
|
||||
@ -112,13 +109,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_dirty |= DirtyFlags.DepthTestCompareOp;
|
||||
}
|
||||
|
||||
public void SetPrimitiveTopology(PrimitiveTopology topology)
|
||||
{
|
||||
Topology = topology;
|
||||
|
||||
_dirty |= DirtyFlags.Toplogy;
|
||||
}
|
||||
|
||||
public void SetStencilOp(StencilOp backFailOp,
|
||||
StencilOp backPassOp,
|
||||
StencilOp backDepthFailOp,
|
||||
@ -235,17 +225,17 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
if (_dirty.HasFlag(DirtyFlags.Scissor))
|
||||
{
|
||||
RecordScissor(gd.Api, commandBuffer);
|
||||
RecordScissor(gd, commandBuffer);
|
||||
}
|
||||
|
||||
if (_dirty.HasFlag(DirtyFlags.Stencil))
|
||||
{
|
||||
RecordStencil(gd.Api, commandBuffer);
|
||||
RecordStencil(gd, commandBuffer);
|
||||
}
|
||||
|
||||
if (_dirty.HasFlag(DirtyFlags.Viewport))
|
||||
{
|
||||
RecordViewport(gd.Api, commandBuffer);
|
||||
RecordViewport(gd, commandBuffer);
|
||||
}
|
||||
|
||||
if (_dirty.HasFlag(DirtyFlags.CullMode))
|
||||
@ -273,11 +263,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
RecordStencilTestEnable(gd.ExtendedDynamicStateApi, commandBuffer);
|
||||
}
|
||||
|
||||
if (_dirty.HasFlag(DirtyFlags.Toplogy))
|
||||
{
|
||||
RecordPrimitiveTopology(gd.ExtendedDynamicStateApi, commandBuffer);
|
||||
}
|
||||
|
||||
if (_dirty.HasFlag(DirtyFlags.LineWidth))
|
||||
{
|
||||
RecordLineWidth(gd.Api, commandBuffer);
|
||||
@ -296,30 +281,40 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
api.CmdSetDepthBias(commandBuffer, _depthBiasConstantFactor, _depthBiasClamp, _depthBiasSlopeFactor);
|
||||
}
|
||||
|
||||
private void RecordScissor(Vk api, CommandBuffer commandBuffer)
|
||||
private void RecordScissor(VulkanRenderer gd, CommandBuffer commandBuffer)
|
||||
{
|
||||
if (ScissorsCount != 0)
|
||||
{
|
||||
api.CmdSetScissor(commandBuffer, 0, (uint)ScissorsCount, _scissors.AsSpan());
|
||||
if (gd.Capabilities.SupportsExtendedDynamicState)
|
||||
{
|
||||
|
||||
gd.ExtendedDynamicStateApi.CmdSetScissorWithCount(commandBuffer, (uint)ScissorsCount,
|
||||
_scissors.AsSpan());
|
||||
}
|
||||
else
|
||||
{
|
||||
gd.Api.CmdSetScissor(commandBuffer, 0, (uint)ScissorsCount,
|
||||
_scissors.AsSpan());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly void RecordStencil(Vk api, CommandBuffer commandBuffer)
|
||||
private readonly void RecordStencil(VulkanRenderer gd, CommandBuffer commandBuffer)
|
||||
{
|
||||
if (_opToo)
|
||||
{
|
||||
api.CmdSetStencilOp(commandBuffer, StencilFaceFlags.FaceBackBit, _backfailop, _backpassop,
|
||||
gd.ExtendedDynamicStateApi.CmdSetStencilOp(commandBuffer, StencilFaceFlags.FaceBackBit, _backfailop, _backpassop,
|
||||
_backdepthfailop, _backcompareop);
|
||||
api.CmdSetStencilOp(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontfailop, _frontpassop,
|
||||
gd.ExtendedDynamicStateApi.CmdSetStencilOp(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontfailop, _frontpassop,
|
||||
_frontdepthfailop, _frontcompareop);
|
||||
}
|
||||
|
||||
api.CmdSetStencilCompareMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backCompareMask);
|
||||
api.CmdSetStencilWriteMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backWriteMask);
|
||||
api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceBackBit, _backReference);
|
||||
api.CmdSetStencilCompareMask(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontCompareMask);
|
||||
api.CmdSetStencilWriteMask(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontWriteMask);
|
||||
api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontReference);
|
||||
gd.Api.CmdSetStencilCompareMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backCompareMask);
|
||||
gd.Api.CmdSetStencilWriteMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backWriteMask);
|
||||
gd.Api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceBackBit, _backReference);
|
||||
gd.Api.CmdSetStencilCompareMask(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontCompareMask);
|
||||
gd.Api.CmdSetStencilWriteMask(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontWriteMask);
|
||||
gd.Api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontReference);
|
||||
}
|
||||
|
||||
private readonly void RecordStencilTestEnable(ExtExtendedDynamicState api, CommandBuffer commandBuffer)
|
||||
@ -327,11 +322,23 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
api.CmdSetStencilTestEnable(commandBuffer, _stencilTestEnable);
|
||||
}
|
||||
|
||||
private void RecordViewport(Vk api, CommandBuffer commandBuffer)
|
||||
private void RecordViewport(VulkanRenderer gd, CommandBuffer commandBuffer)
|
||||
{
|
||||
if (ViewportsCount != 0)
|
||||
if (ViewportsCount == 0)
|
||||
{
|
||||
api.CmdSetViewport(commandBuffer, 0, ViewportsCount, Viewports.AsSpan());
|
||||
return;
|
||||
}
|
||||
|
||||
if (gd.Capabilities.SupportsExtendedDynamicState)
|
||||
{
|
||||
|
||||
gd.ExtendedDynamicStateApi.CmdSetViewportWithCount(commandBuffer, ViewportsCount,
|
||||
Viewports.AsSpan());
|
||||
}
|
||||
else
|
||||
{
|
||||
gd.Api.CmdSetViewport(commandBuffer, 0, ViewportsCount,
|
||||
Viewports.AsSpan());
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,11 +363,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
api.CmdSetDepthCompareOp(commandBuffer, _depthCompareOp);
|
||||
}
|
||||
|
||||
private void RecordPrimitiveTopology(ExtExtendedDynamicState api, CommandBuffer commandBuffer)
|
||||
{
|
||||
api.CmdSetPrimitiveTopology(commandBuffer, Topology);
|
||||
}
|
||||
|
||||
private void RecordLineWidth(Vk api, CommandBuffer commandBuffer)
|
||||
{
|
||||
if (!OperatingSystem.IsMacOS())
|
||||
|
@ -455,18 +455,14 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
primitiveRestartEnable = true;
|
||||
}
|
||||
|
||||
|
||||
var inputAssemblyState = new PipelineInputAssemblyStateCreateInfo
|
||||
{
|
||||
SType = StructureType.PipelineInputAssemblyStateCreateInfo,
|
||||
PrimitiveRestartEnable = primitiveRestartEnable,
|
||||
Topology = Topology,
|
||||
};
|
||||
|
||||
if (!supportsExtDynamicState)
|
||||
{
|
||||
inputAssemblyState.Topology = Topology;
|
||||
}
|
||||
|
||||
var tessellationState = new PipelineTessellationStateCreateInfo
|
||||
{
|
||||
SType = StructureType.PipelineTessellationStateCreateInfo,
|
||||
@ -492,13 +488,17 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
rasterizationState.CullMode = CullMode;
|
||||
rasterizationState.FrontFace = FrontFace;
|
||||
}
|
||||
|
||||
|
||||
var viewportState = new PipelineViewportStateCreateInfo
|
||||
{
|
||||
SType = StructureType.PipelineViewportStateCreateInfo,
|
||||
ViewportCount = ViewportsCount,
|
||||
ScissorCount = ScissorsCount,
|
||||
};
|
||||
|
||||
if (!supportsExtDynamicState)
|
||||
{
|
||||
viewportState.ViewportCount = ViewportsCount;
|
||||
viewportState.ScissorCount = ScissorsCount;
|
||||
}
|
||||
|
||||
if (gd.Capabilities.SupportsDepthClipControl)
|
||||
{
|
||||
@ -608,7 +608,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
colorBlendState.PNext = &colorBlendAdvancedState;
|
||||
}
|
||||
|
||||
int dynamicStatesCount = supportsExtDynamicState ? (isMoltenVk ? 16 : 17) : (isMoltenVk ? 7 : 8);
|
||||
int dynamicStatesCount = supportsExtDynamicState ? (isMoltenVk ? 17 : 18) : (isMoltenVk ? 7 : 8);
|
||||
|
||||
DynamicState* dynamicStates = stackalloc DynamicState[dynamicStatesCount];
|
||||
|
||||
@ -627,7 +627,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
if (supportsExtDynamicState)
|
||||
{
|
||||
int index = 8;
|
||||
int index = (isMoltenVk ? 7 : 8);
|
||||
if (!isMoltenVk) {
|
||||
dynamicStates[index++] = DynamicState.VertexInputBindingStrideExt;
|
||||
}
|
||||
@ -637,7 +637,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
dynamicStates[index++] = DynamicState.DepthWriteEnableExt;
|
||||
dynamicStates[index++] = DynamicState.DepthCompareOpExt;
|
||||
dynamicStates[index++] = DynamicState.StencilTestEnableExt;
|
||||
dynamicStates[index++] = DynamicState.PrimitiveTopologyExt;
|
||||
dynamicStates[index++] = DynamicState.ViewportWithCountExt;
|
||||
dynamicStates[index++] = DynamicState.ScissorWithCountExt;
|
||||
dynamicStates[index] = DynamicState.StencilOpExt;
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,12 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||
{
|
||||
return level switch
|
||||
{
|
||||
AvaLogLevel.Verbose => RyuLogger.Debug,
|
||||
AvaLogLevel.Debug => RyuLogger.Debug,
|
||||
AvaLogLevel.Information => RyuLogger.Debug,
|
||||
AvaLogLevel.Warning => RyuLogger.Debug,
|
||||
AvaLogLevel.Error => RyuLogger.Error,
|
||||
AvaLogLevel.Fatal => RyuLogger.Error,
|
||||
AvaLogLevel.Verbose => RyuLogger.Trace,
|
||||
AvaLogLevel.Debug => RyuLogger.Trace,
|
||||
AvaLogLevel.Information => RyuLogger.Trace,
|
||||
AvaLogLevel.Warning => RyuLogger.Trace,
|
||||
AvaLogLevel.Error => RyuLogger.Trace,
|
||||
AvaLogLevel.Fatal => RyuLogger.Trace,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(level), level, null),
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user