Compare commits

...

9 Commits

Author SHA1 Message Date
sunshineinabox 8568119e27
Merge feb915321d into ef81658fbd 2024-09-18 20:44:04 -05:00
gdkchan ef81658fbd
Implement support for shader ATOM.EXCH instruction (#7320)
* Implement support for shader ATOM.EXCH instruction

* Shader cache version bump

* Check type
2024-09-18 15:48:55 -03:00
sunshineinabox feb915321d
Merge branch 'master' into DepthBiasandEnable 2024-09-01 21:48:30 -07:00
sunshineinabox ab9025286d Partially revert previous commit as no need to set depthbias dynamically if depthbias is not enabled. 2024-07-21 15:59:04 -07:00
sunshineinabox 48ad342ee9 Resolve two validation errors that were created by changes
1. One stating that the bound pipeline is identical to the previous with a dynamic state that was previously static (DepthBias) which might cause issues in non Vulkan SDK 1.3 conformant drivers.

2. DynamicState command is sent without current pipeline having the dynamic state enabled.
2024-07-21 14:22:15 -07:00
sunshineinabox 20101e2ea3 Code review suggestions 2024-07-21 12:58:40 -07:00
sunshineinabox a7a49cc8fe Revert some changes that were out of scope/intent of commit 2024-07-20 19:07:19 -07:00
sunshineinabox 10506afc23 Avoid unncessary DepthBias state updates 2024-07-17 18:38:31 -07:00
sunshineinabox 7404d782ce Avoid setting DepthBias when not needed. 2024-07-17 18:38:31 -07:00
7 changed files with 101 additions and 46 deletions

View File

@ -5,6 +5,7 @@ namespace Ryujinx.Graphics.GAL
[Flags] [Flags]
public enum PolygonModeMask public enum PolygonModeMask
{ {
None = 0,
Point = 1 << 0, Point = 1 << 0,
Line = 1 << 1, Line = 1 << 1,
Fill = 1 << 2, Fill = 1 << 2,

View File

@ -841,19 +841,35 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
private void UpdateDepthBiasState() private void UpdateDepthBiasState()
{ {
if (_state.State.DepthBiasFactor == 0 && _state.State.DepthBiasUnits == 0)
{
if (_pipeline.BiasEnable != PolygonModeMask.None)
{
_pipeline.BiasEnable = PolygonModeMask.None;
_context.Renderer.Pipeline.SetDepthBias(PolygonModeMask.None, 0, 0, 0);
}
return;
}
var depthBias = _state.State.DepthBiasState; var depthBias = _state.State.DepthBiasState;
float factor = _state.State.DepthBiasFactor; float factor = _state.State.DepthBiasFactor;
float units = _state.State.DepthBiasUnits; float units = _state.State.DepthBiasUnits;
float clamp = _state.State.DepthBiasClamp; float clamp = _state.State.DepthBiasClamp;
PolygonModeMask enables; PolygonModeMask enables = PolygonModeMask.None;
enables = (depthBias.PointEnable ? PolygonModeMask.Point : 0); if (factor != 0 && units != 0)
enables |= (depthBias.LineEnable ? PolygonModeMask.Line : 0); {
enables |= (depthBias.FillEnable ? PolygonModeMask.Fill : 0); enables = (depthBias.PointEnable ? PolygonModeMask.Point : 0);
enables |= (depthBias.LineEnable ? PolygonModeMask.Line : 0);
enables |= (depthBias.FillEnable ? PolygonModeMask.Fill : 0);
}
_pipeline.BiasEnable = enables; _pipeline.BiasEnable = enables;
_context.Renderer.Pipeline.SetDepthBias(enables, factor, units / 2f, clamp); _context.Renderer.Pipeline.SetDepthBias(enables, factor, units / 2f, clamp);
} }

View File

@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
private const ushort FileFormatVersionMajor = 1; private const ushort FileFormatVersionMajor = 1;
private const ushort FileFormatVersionMinor = 2; private const ushort FileFormatVersionMinor = 2;
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor; private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
private const uint CodeGenVersion = 7131; private const uint CodeGenVersion = 7320;
private const string SharedTocFileName = "shared.toc"; private const string SharedTocFileName = "shared.toc";
private const string SharedDataFileName = "shared.data"; private const string SharedDataFileName = "shared.data";

View File

@ -833,6 +833,15 @@ namespace Ryujinx.Graphics.OpenGL
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp) public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
{ {
if (enables == PolygonModeMask.None || (factor == 0 && units == 0))
{
GL.Disable(EnableCap.PolygonOffsetPoint);
GL.Disable(EnableCap.PolygonOffsetLine);
GL.Disable(EnableCap.PolygonOffsetFill);
return;
}
if ((enables & PolygonModeMask.Point) != 0) if ((enables & PolygonModeMask.Point) != 0)
{ {
GL.Enable(EnableCap.PolygonOffsetPoint); GL.Enable(EnableCap.PolygonOffsetPoint);
@ -860,11 +869,6 @@ namespace Ryujinx.Graphics.OpenGL
GL.Disable(EnableCap.PolygonOffsetFill); GL.Disable(EnableCap.PolygonOffsetFill);
} }
if (enables == 0)
{
return;
}
if (HwCapabilities.SupportsPolygonOffsetClamp) if (HwCapabilities.SupportsPolygonOffsetClamp)
{ {
GL.PolygonOffsetClamp(factor, units, clamp); GL.PolygonOffsetClamp(factor, units, clamp);

View File

@ -222,30 +222,14 @@ namespace Ryujinx.Graphics.Shader.Instructions
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}."); context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
} }
break; break;
case AtomOp.And: case AtomOp.Min:
if (type == AtomSize.S32 || type == AtomSize.U32) if (type == AtomSize.S32)
{ {
res = context.AtomicAnd(storageKind, e0, e1, value); res = context.AtomicMinS32(storageKind, e0, e1, value);
} }
else else if (type == AtomSize.U32)
{ {
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}."); res = context.AtomicMinU32(storageKind, e0, e1, value);
}
break;
case AtomOp.Xor:
if (type == AtomSize.S32 || type == AtomSize.U32)
{
res = context.AtomicXor(storageKind, e0, e1, value);
}
else
{
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
}
break;
case AtomOp.Or:
if (type == AtomSize.S32 || type == AtomSize.U32)
{
res = context.AtomicOr(storageKind, e0, e1, value);
} }
else else
{ {
@ -266,20 +250,49 @@ namespace Ryujinx.Graphics.Shader.Instructions
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}."); context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
} }
break; break;
case AtomOp.Min: case AtomOp.And:
if (type == AtomSize.S32) if (type == AtomSize.S32 || type == AtomSize.U32)
{ {
res = context.AtomicMinS32(storageKind, e0, e1, value); res = context.AtomicAnd(storageKind, e0, e1, value);
}
else if (type == AtomSize.U32)
{
res = context.AtomicMinU32(storageKind, e0, e1, value);
} }
else else
{ {
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}."); context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
} }
break; break;
case AtomOp.Or:
if (type == AtomSize.S32 || type == AtomSize.U32)
{
res = context.AtomicOr(storageKind, e0, e1, value);
}
else
{
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
}
break;
case AtomOp.Xor:
if (type == AtomSize.S32 || type == AtomSize.U32)
{
res = context.AtomicXor(storageKind, e0, e1, value);
}
else
{
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
}
break;
case AtomOp.Exch:
if (type == AtomSize.S32 || type == AtomSize.U32)
{
res = context.AtomicSwap(storageKind, e0, e1, value);
}
else
{
context.TranslatorContext.GpuAccessor.Log($"Invalid reduction type: {type}.");
}
break;
default:
context.TranslatorContext.GpuAccessor.Log($"Invalid atomic operation: {op}.");
break;
} }
return res; return res;

View File

@ -792,10 +792,30 @@ namespace Ryujinx.Graphics.Vulkan
public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp) public void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp)
{ {
DynamicState.SetDepthBias(factor, units, clamp); if (factor == 0 && units == 0 && !_newState.DepthBiasEnable)
{
return;
}
_newState.DepthBiasEnable = enables != 0; bool depthBiasEnable = (enables != PolygonModeMask.None) && (factor != 0 && units != 0);
SignalStateChange(); bool changed = false;
if (_newState.DepthBiasEnable != depthBiasEnable)
{
_newState.DepthBiasEnable = depthBiasEnable;
changed = true;
}
if (depthBiasEnable)
{
DynamicState.SetDepthBias(factor, units, clamp);
changed = true;
}
if (changed)
{
SignalStateChange();
}
} }
public void SetDepthClamp(bool clamp) public void SetDepthClamp(bool clamp)

View File

@ -571,6 +571,7 @@ namespace Ryujinx.Graphics.Vulkan
} }
bool supportsExtDynamicState = gd.Capabilities.SupportsExtendedDynamicState; bool supportsExtDynamicState = gd.Capabilities.SupportsExtendedDynamicState;
bool supportsFeedbackLoopDynamicState = gd.Capabilities.SupportsDynamicAttachmentFeedbackLoop; bool supportsFeedbackLoopDynamicState = gd.Capabilities.SupportsDynamicAttachmentFeedbackLoop;
DynamicState* dynamicStates = stackalloc DynamicState[MaxDynamicStatesCount]; DynamicState* dynamicStates = stackalloc DynamicState[MaxDynamicStatesCount];
@ -579,11 +580,11 @@ namespace Ryujinx.Graphics.Vulkan
dynamicStates[0] = DynamicState.Viewport; dynamicStates[0] = DynamicState.Viewport;
dynamicStates[1] = DynamicState.Scissor; dynamicStates[1] = DynamicState.Scissor;
dynamicStates[2] = DynamicState.DepthBias; dynamicStates[2] = DynamicState.StencilCompareMask;
dynamicStates[3] = DynamicState.StencilCompareMask; dynamicStates[3] = DynamicState.StencilWriteMask;
dynamicStates[4] = DynamicState.StencilWriteMask; dynamicStates[4] = DynamicState.StencilReference;
dynamicStates[5] = DynamicState.StencilReference; dynamicStates[5] = DynamicState.BlendConstants;
dynamicStates[6] = DynamicState.BlendConstants; dynamicStates[6] = DynamicState.DepthBias;
if (supportsExtDynamicState) if (supportsExtDynamicState)
{ {