Implement VK_DYNAMIC_STATE_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE_EXT
This commit is contained in:
parent
3fe159f4dd
commit
ecadc6a4f9
4 changed files with 47 additions and 5 deletions
|
@ -898,9 +898,19 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
public void SetDepthMode(DepthMode mode)
|
public void SetDepthMode(DepthMode mode)
|
||||||
{
|
{
|
||||||
bool oldMode = _newState.DepthMode;
|
bool oldMode;
|
||||||
_newState.DepthMode = mode == DepthMode.MinusOneToOne;
|
if (Gd.ExtendedDynamicState3Features.ExtendedDynamicState3DepthClipNegativeOneToOne)
|
||||||
if (_newState.DepthMode != oldMode)
|
{
|
||||||
|
oldMode = DynamicState.DepthMode;
|
||||||
|
DynamicState.SetDepthMode(mode == DepthMode.MinusOneToOne);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oldMode = _newState.DepthMode;
|
||||||
|
_newState.DepthMode = mode == DepthMode.MinusOneToOne;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Gd.ExtendedDynamicState3Features.ExtendedDynamicState3DepthClipNegativeOneToOne ? DynamicState.DepthMode : _newState.DepthMode) != oldMode)
|
||||||
{
|
{
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
private bool _alphaToCoverEnable;
|
private bool _alphaToCoverEnable;
|
||||||
private bool _alphaToOneEnable;
|
private bool _alphaToOneEnable;
|
||||||
|
|
||||||
|
public bool DepthMode;
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
private enum DirtyFlags
|
private enum DirtyFlags
|
||||||
{
|
{
|
||||||
|
@ -83,10 +85,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
AlphaToCover = 1 << 15,
|
AlphaToCover = 1 << 15,
|
||||||
AlphaToOne = 1 << 16,
|
AlphaToOne = 1 << 16,
|
||||||
PatchControlPoints = 1 << 17,
|
PatchControlPoints = 1 << 17,
|
||||||
|
DepthMode = 1 << 18,
|
||||||
Standard = Blend | DepthBias | Scissor | Stencil | Viewport | LineWidth,
|
Standard = Blend | DepthBias | Scissor | Stencil | Viewport | LineWidth,
|
||||||
Extended = CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnable,
|
Extended = CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnable,
|
||||||
Extended2 = RasterDiscard | LogicOp | PatchControlPoints,
|
Extended2 = RasterDiscard | LogicOp | PatchControlPoints,
|
||||||
Extended3 = DepthClampEnable | LogicOpEnable | AlphaToCover | AlphaToOne,
|
Extended3 = DepthClampEnable | LogicOpEnable | AlphaToCover | AlphaToOne | DepthMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
private DirtyFlags _dirty;
|
private DirtyFlags _dirty;
|
||||||
|
@ -316,6 +319,15 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetDepthMode(bool mode)
|
||||||
|
{
|
||||||
|
if (DepthMode != mode)
|
||||||
|
{
|
||||||
|
DepthMode = mode;
|
||||||
|
_dirty |= DirtyFlags.DepthMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ForceAllDirty(VulkanRenderer gd)
|
public void ForceAllDirty(VulkanRenderer gd)
|
||||||
{
|
{
|
||||||
_dirty = DirtyFlags.Standard;
|
_dirty = DirtyFlags.Standard;
|
||||||
|
@ -369,6 +381,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
_dirty &= ~DirtyFlags.LogicOpEnable;
|
_dirty &= ~DirtyFlags.LogicOpEnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!gd.ExtendedDynamicState3Features.ExtendedDynamicState3DepthClipNegativeOneToOne)
|
||||||
|
{
|
||||||
|
_dirty &= ~DirtyFlags.DepthMode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReplayIfDirty(VulkanRenderer gd, CommandBuffer commandBuffer)
|
public void ReplayIfDirty(VulkanRenderer gd, CommandBuffer commandBuffer)
|
||||||
|
@ -463,6 +480,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
RecordAlphaToOneEnable(gd, commandBuffer);
|
RecordAlphaToOneEnable(gd, commandBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_dirty.HasFlag(DirtyFlags.DepthMode))
|
||||||
|
{
|
||||||
|
RecordDepthMode(gd, commandBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
_dirty = DirtyFlags.None;
|
_dirty = DirtyFlags.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,6 +631,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
gd.ExtendedDynamicState2Api.CmdSetPatchControlPoints(commandBuffer, _patchControlPoints);
|
gd.ExtendedDynamicState2Api.CmdSetPatchControlPoints(commandBuffer, _patchControlPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly void RecordDepthMode(VulkanRenderer gd, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
gd.ExtendedDynamicState3Api.CmdSetDepthClipNegativeOneToOne(commandBuffer, DepthMode);
|
||||||
|
}
|
||||||
|
|
||||||
private readonly void RecordLineWidth(Vk api, CommandBuffer commandBuffer)
|
private readonly void RecordLineWidth(Vk api, CommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
if (!OperatingSystem.IsMacOS())
|
if (!OperatingSystem.IsMacOS())
|
||||||
|
|
|
@ -513,9 +513,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
var viewportDepthClipControlState = new PipelineViewportDepthClipControlCreateInfoEXT
|
var viewportDepthClipControlState = new PipelineViewportDepthClipControlCreateInfoEXT
|
||||||
{
|
{
|
||||||
SType = StructureType.PipelineViewportDepthClipControlCreateInfoExt,
|
SType = StructureType.PipelineViewportDepthClipControlCreateInfoExt,
|
||||||
NegativeOneToOne = DepthMode,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!gd.ExtendedDynamicState3Features.ExtendedDynamicState3DepthClipNegativeOneToOne)
|
||||||
|
{
|
||||||
|
viewportDepthClipControlState.NegativeOneToOne = DepthMode;
|
||||||
|
}
|
||||||
|
|
||||||
viewportState.PNext = &viewportDepthClipControlState;
|
viewportState.PNext = &viewportDepthClipControlState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -493,6 +493,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
ExtendedDynamicState3AlphaToCoverageEnable = supportedFeaturesExtExtendedDynamicState3.ExtendedDynamicState3AlphaToCoverageEnable,
|
ExtendedDynamicState3AlphaToCoverageEnable = supportedFeaturesExtExtendedDynamicState3.ExtendedDynamicState3AlphaToCoverageEnable,
|
||||||
ExtendedDynamicState3AlphaToOneEnable = supportedFeaturesExtExtendedDynamicState3.ExtendedDynamicState3AlphaToOneEnable,
|
ExtendedDynamicState3AlphaToOneEnable = supportedFeaturesExtExtendedDynamicState3.ExtendedDynamicState3AlphaToOneEnable,
|
||||||
ExtendedDynamicState3DepthClampEnable = supportedFeaturesExtExtendedDynamicState3.ExtendedDynamicState3DepthClampEnable,
|
ExtendedDynamicState3DepthClampEnable = supportedFeaturesExtExtendedDynamicState3.ExtendedDynamicState3DepthClampEnable,
|
||||||
|
ExtendedDynamicState3DepthClipNegativeOneToOne = supportedFeaturesExtExtendedDynamicState3.ExtendedDynamicState3DepthClipNegativeOneToOne,
|
||||||
};
|
};
|
||||||
|
|
||||||
pExtendedFeatures = &featuresExtendedDynamicState3;
|
pExtendedFeatures = &featuresExtendedDynamicState3;
|
||||||
|
|
Loading…
Reference in a new issue