mirror of
https://github.com/GreemDev/Ryujinx
synced 2024-12-22 11:56:36 +01:00
Compare commits
3 commits
bde47bb002
...
593bc122f8
Author | SHA1 | Date | |
---|---|---|---|
|
593bc122f8 | ||
|
08b7257be5 | ||
|
48f9ada59b |
50 changed files with 1846 additions and 664 deletions
|
@ -50,6 +50,10 @@ namespace Ryujinx.Graphics.GAL
|
||||||
public readonly bool SupportsViewportSwizzle;
|
public readonly bool SupportsViewportSwizzle;
|
||||||
public readonly bool SupportsIndirectParameters;
|
public readonly bool SupportsIndirectParameters;
|
||||||
public readonly bool SupportsDepthClipControl;
|
public readonly bool SupportsDepthClipControl;
|
||||||
|
public readonly bool SupportsExtendedDynamicState;
|
||||||
|
public readonly bool SupportsExtendedDynamicState2;
|
||||||
|
public readonly bool SupportsLogicOpDynamicState;
|
||||||
|
public readonly bool SupportsPatchControlPointsDynamicState;
|
||||||
|
|
||||||
public readonly int UniformBufferSetIndex;
|
public readonly int UniformBufferSetIndex;
|
||||||
public readonly int StorageBufferSetIndex;
|
public readonly int StorageBufferSetIndex;
|
||||||
|
@ -118,6 +122,10 @@ namespace Ryujinx.Graphics.GAL
|
||||||
bool supportsViewportSwizzle,
|
bool supportsViewportSwizzle,
|
||||||
bool supportsIndirectParameters,
|
bool supportsIndirectParameters,
|
||||||
bool supportsDepthClipControl,
|
bool supportsDepthClipControl,
|
||||||
|
bool supportsExtendedDynamicState,
|
||||||
|
bool supportsExtendedDynamicState2,
|
||||||
|
bool supportsLogicOpDynamicState,
|
||||||
|
bool supportsPatchControlPointsDynamicState,
|
||||||
int uniformBufferSetIndex,
|
int uniformBufferSetIndex,
|
||||||
int storageBufferSetIndex,
|
int storageBufferSetIndex,
|
||||||
int textureSetIndex,
|
int textureSetIndex,
|
||||||
|
@ -180,6 +188,10 @@ namespace Ryujinx.Graphics.GAL
|
||||||
SupportsViewportSwizzle = supportsViewportSwizzle;
|
SupportsViewportSwizzle = supportsViewportSwizzle;
|
||||||
SupportsIndirectParameters = supportsIndirectParameters;
|
SupportsIndirectParameters = supportsIndirectParameters;
|
||||||
SupportsDepthClipControl = supportsDepthClipControl;
|
SupportsDepthClipControl = supportsDepthClipControl;
|
||||||
|
SupportsExtendedDynamicState = supportsExtendedDynamicState;
|
||||||
|
SupportsExtendedDynamicState2 = supportsExtendedDynamicState2;
|
||||||
|
SupportsLogicOpDynamicState = supportsLogicOpDynamicState;
|
||||||
|
SupportsPatchControlPointsDynamicState = supportsPatchControlPointsDynamicState;
|
||||||
UniformBufferSetIndex = uniformBufferSetIndex;
|
UniformBufferSetIndex = uniformBufferSetIndex;
|
||||||
StorageBufferSetIndex = storageBufferSetIndex;
|
StorageBufferSetIndex = storageBufferSetIndex;
|
||||||
TextureSetIndex = textureSetIndex;
|
TextureSetIndex = textureSetIndex;
|
||||||
|
|
|
@ -2,6 +2,7 @@ namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public enum Face
|
public enum Face
|
||||||
{
|
{
|
||||||
|
None = 0,
|
||||||
Front = 0x404,
|
Front = 0x404,
|
||||||
Back = 0x405,
|
Back = 0x405,
|
||||||
FrontAndBack = 0x408,
|
FrontAndBack = 0x408,
|
||||||
|
|
|
@ -50,9 +50,9 @@ namespace Ryujinx.Graphics.GAL
|
||||||
void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp);
|
void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp);
|
||||||
void SetDepthClamp(bool clamp);
|
void SetDepthClamp(bool clamp);
|
||||||
void SetDepthMode(DepthMode mode);
|
void SetDepthMode(DepthMode mode);
|
||||||
void SetDepthTest(DepthTestDescriptor depthTest);
|
void SetDepthTest(DepthTestDescriptor depthTest, bool signalChange = true);
|
||||||
|
|
||||||
void SetFaceCulling(bool enable, Face face);
|
void SetFaceCulling(Face face);
|
||||||
|
|
||||||
void SetFrontFace(FrontFace frontFace);
|
void SetFrontFace(FrontFace frontFace);
|
||||||
|
|
||||||
|
@ -75,16 +75,16 @@ namespace Ryujinx.Graphics.GAL
|
||||||
|
|
||||||
void SetPrimitiveRestart(bool enable, int index);
|
void SetPrimitiveRestart(bool enable, int index);
|
||||||
|
|
||||||
void SetPrimitiveTopology(PrimitiveTopology topology);
|
void SetPrimitiveTopology(PrimitiveTopology topology, bool signalChange = true);
|
||||||
|
|
||||||
void SetProgram(IProgram program);
|
void SetProgram(IProgram program, bool signalChange = true);
|
||||||
|
|
||||||
void SetRasterizerDiscard(bool discard);
|
void SetRasterizerDiscard(bool discard);
|
||||||
|
|
||||||
void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask);
|
void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask, bool signalChange = true);
|
||||||
void SetRenderTargets(ITexture[] colors, ITexture depthStencil);
|
void SetRenderTargets(ITexture[] colors, ITexture depthStencil);
|
||||||
|
|
||||||
void SetScissors(ReadOnlySpan<Rectangle<int>> regions);
|
void SetScissors(ReadOnlySpan<Rectangle<int>> regions, bool signalChange = true);
|
||||||
|
|
||||||
void SetStencilTest(StencilTestDescriptor stencilTest);
|
void SetStencilTest(StencilTestDescriptor stencilTest);
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ namespace Ryujinx.Graphics.GAL
|
||||||
void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs);
|
void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs);
|
||||||
void SetVertexBuffers(ReadOnlySpan<VertexBufferDescriptor> vertexBuffers);
|
void SetVertexBuffers(ReadOnlySpan<VertexBufferDescriptor> vertexBuffers);
|
||||||
|
|
||||||
void SetViewports(ReadOnlySpan<Viewport> viewports);
|
void SetViewports(ReadOnlySpan<Viewport> viewports, bool signalChange = true);
|
||||||
|
|
||||||
void TextureBarrier();
|
void TextureBarrier();
|
||||||
void TextureBarrierTiled();
|
void TextureBarrierTiled();
|
||||||
|
|
|
@ -3,18 +3,16 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands
|
||||||
struct SetFaceCullingCommand : IGALCommand, IGALCommand<SetFaceCullingCommand>
|
struct SetFaceCullingCommand : IGALCommand, IGALCommand<SetFaceCullingCommand>
|
||||||
{
|
{
|
||||||
public readonly CommandType CommandType => CommandType.SetFaceCulling;
|
public readonly CommandType CommandType => CommandType.SetFaceCulling;
|
||||||
private bool _enable;
|
|
||||||
private Face _face;
|
private Face _face;
|
||||||
|
|
||||||
public void Set(bool enable, Face face)
|
public void Set(Face face)
|
||||||
{
|
{
|
||||||
_enable = enable;
|
|
||||||
_face = face;
|
_face = face;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Run(ref SetFaceCullingCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
public static void Run(ref SetFaceCullingCommand command, ThreadedRenderer threaded, IRenderer renderer)
|
||||||
{
|
{
|
||||||
renderer.Pipeline.SetFaceCulling(command._enable, command._face);
|
renderer.Pipeline.SetFaceCulling(command._face);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,15 +159,15 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDepthTest(DepthTestDescriptor depthTest)
|
public void SetDepthTest(DepthTestDescriptor depthTest, bool signalChange = true)
|
||||||
{
|
{
|
||||||
_renderer.New<SetDepthTestCommand>().Set(depthTest);
|
_renderer.New<SetDepthTestCommand>().Set(depthTest);
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFaceCulling(bool enable, Face face)
|
public void SetFaceCulling(Face face)
|
||||||
{
|
{
|
||||||
_renderer.New<SetFaceCullingCommand>().Set(enable, face);
|
_renderer.New<SetFaceCullingCommand>().Set(face);
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,13 +243,13 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPrimitiveTopology(PrimitiveTopology topology)
|
public void SetPrimitiveTopology(PrimitiveTopology topology, bool signalChange = true)
|
||||||
{
|
{
|
||||||
_renderer.New<SetPrimitiveTopologyCommand>().Set(topology);
|
_renderer.New<SetPrimitiveTopologyCommand>().Set(topology);
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetProgram(IProgram program)
|
public void SetProgram(IProgram program, bool signalChange = true)
|
||||||
{
|
{
|
||||||
_renderer.New<SetProgramCommand>().Set(Ref(program));
|
_renderer.New<SetProgramCommand>().Set(Ref(program));
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
|
@ -261,7 +261,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask)
|
public void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask, bool signalChange = true)
|
||||||
{
|
{
|
||||||
_renderer.New<SetRenderTargetColorMasksCommand>().Set(_renderer.CopySpan(componentMask));
|
_renderer.New<SetRenderTargetColorMasksCommand>().Set(_renderer.CopySpan(componentMask));
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
|
@ -273,7 +273,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetScissors(ReadOnlySpan<Rectangle<int>> scissors)
|
public void SetScissors(ReadOnlySpan<Rectangle<int>> scissors, bool signalChange = true)
|
||||||
{
|
{
|
||||||
_renderer.New<SetScissorsCommand>().Set(_renderer.CopySpan(scissors));
|
_renderer.New<SetScissorsCommand>().Set(_renderer.CopySpan(scissors));
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
|
@ -339,7 +339,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetViewports(ReadOnlySpan<Viewport> viewports)
|
public void SetViewports(ReadOnlySpan<Viewport> viewports, bool signalChange = true)
|
||||||
{
|
{
|
||||||
_renderer.New<SetViewportsCommand>().Set(_renderer.CopySpan(viewports));
|
_renderer.New<SetViewportsCommand>().Set(_renderer.CopySpan(viewports));
|
||||||
_renderer.QueueCommand();
|
_renderer.QueueCommand();
|
||||||
|
|
|
@ -51,11 +51,12 @@ namespace Ryujinx.Graphics.GAL
|
||||||
public StencilTestDescriptor StencilTest;
|
public StencilTestDescriptor StencilTest;
|
||||||
public FrontFace FrontFace;
|
public FrontFace FrontFace;
|
||||||
public Face CullMode;
|
public Face CullMode;
|
||||||
public bool CullEnable;
|
|
||||||
|
|
||||||
public PolygonModeMask BiasEnable;
|
public PolygonModeMask BiasEnable;
|
||||||
|
|
||||||
public float LineWidth;
|
public bool AlphaToCoverageEnable;
|
||||||
|
public bool AlphaToOneEnable;
|
||||||
|
|
||||||
// TODO: Polygon mode.
|
// TODO: Polygon mode.
|
||||||
public bool DepthClampEnable;
|
public bool DepthClampEnable;
|
||||||
public bool RasterizerDiscard;
|
public bool RasterizerDiscard;
|
||||||
|
@ -63,6 +64,9 @@ namespace Ryujinx.Graphics.GAL
|
||||||
public bool PrimitiveRestartEnable;
|
public bool PrimitiveRestartEnable;
|
||||||
public uint PatchControlPoints;
|
public uint PatchControlPoints;
|
||||||
|
|
||||||
|
public float DepthBiasUnits;
|
||||||
|
public float DepthBiasFactor;
|
||||||
|
|
||||||
public DepthMode DepthMode;
|
public DepthMode DepthMode;
|
||||||
|
|
||||||
public void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
|
public void SetVertexAttribs(ReadOnlySpan<VertexAttribDescriptor> vertexAttribs)
|
||||||
|
|
|
@ -854,6 +854,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
||||||
enables |= (depthBias.FillEnable ? PolygonModeMask.Fill : 0);
|
enables |= (depthBias.FillEnable ? PolygonModeMask.Fill : 0);
|
||||||
|
|
||||||
_pipeline.BiasEnable = enables;
|
_pipeline.BiasEnable = enables;
|
||||||
|
_pipeline.DepthBiasUnits = units / 2f;
|
||||||
|
_pipeline.DepthBiasFactor = factor;
|
||||||
|
|
||||||
_context.Renderer.Pipeline.SetDepthBias(enables, factor, units / 2f, clamp);
|
_context.Renderer.Pipeline.SetDepthBias(enables, factor, units / 2f, clamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1026,7 +1029,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
||||||
float width = _state.State.LineWidthSmooth;
|
float width = _state.State.LineWidthSmooth;
|
||||||
bool smooth = _state.State.LineSmoothEnable;
|
bool smooth = _state.State.LineSmoothEnable;
|
||||||
|
|
||||||
_pipeline.LineWidth = width;
|
|
||||||
_context.Renderer.Pipeline.SetLineParameters(width, smooth);
|
_context.Renderer.Pipeline.SetLineParameters(width, smooth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1196,9 +1198,16 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
||||||
var yControl = _state.State.YControl;
|
var yControl = _state.State.YControl;
|
||||||
var face = _state.State.FaceState;
|
var face = _state.State.FaceState;
|
||||||
|
|
||||||
_pipeline.CullEnable = face.CullEnable;
|
if (face.CullEnable)
|
||||||
|
{
|
||||||
_pipeline.CullMode = face.CullFace;
|
_pipeline.CullMode = face.CullFace;
|
||||||
_context.Renderer.Pipeline.SetFaceCulling(face.CullEnable, face.CullFace);
|
_context.Renderer.Pipeline.SetFaceCulling(face.CullFace);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_pipeline.CullMode = Face.None;
|
||||||
|
_context.Renderer.Pipeline.SetFaceCulling(Face.None);
|
||||||
|
}
|
||||||
|
|
||||||
UpdateFrontFace(yControl, face.FrontFace);
|
UpdateFrontFace(yControl, face.FrontFace);
|
||||||
}
|
}
|
||||||
|
@ -1388,6 +1397,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
||||||
bool alphaToCoverageEnable = (_state.State.MultisampleControl & 1) != 0;
|
bool alphaToCoverageEnable = (_state.State.MultisampleControl & 1) != 0;
|
||||||
bool alphaToOneEnable = (_state.State.MultisampleControl & 0x10) != 0;
|
bool alphaToOneEnable = (_state.State.MultisampleControl & 0x10) != 0;
|
||||||
|
|
||||||
|
_pipeline.AlphaToCoverageEnable = alphaToCoverageEnable;
|
||||||
|
_pipeline.AlphaToOneEnable = alphaToOneEnable;
|
||||||
_context.Renderer.Pipeline.SetMultisampleState(new MultisampleDescriptor(
|
_context.Renderer.Pipeline.SetMultisampleState(new MultisampleDescriptor(
|
||||||
alphaToCoverageEnable,
|
alphaToCoverageEnable,
|
||||||
_state.State.AlphaToCoverageDitherEnable,
|
_state.State.AlphaToCoverageDitherEnable,
|
||||||
|
|
|
@ -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 = 7353;
|
private const uint CodeGenVersion = 6877;
|
||||||
|
|
||||||
private const string SharedTocFileName = "shared.toc";
|
private const string SharedTocFileName = "shared.toc";
|
||||||
private const string SharedDataFileName = "shared.data";
|
private const string SharedDataFileName = "shared.data";
|
||||||
|
|
|
@ -22,6 +22,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
private readonly CancellationToken _cancellationToken;
|
private readonly CancellationToken _cancellationToken;
|
||||||
private readonly Action<ShaderCacheState, int, int> _stateChangeCallback;
|
private readonly Action<ShaderCacheState, int, int> _stateChangeCallback;
|
||||||
|
|
||||||
|
private readonly HashSet<ProgramPipelineState> _pipelineStateSet = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if the cache should be loaded.
|
/// Indicates if the cache should be loaded.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -232,10 +234,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
|
|
||||||
for (int index = 0; index < ThreadCount; index++)
|
for (int index = 0; index < ThreadCount; index++)
|
||||||
{
|
{
|
||||||
workThreads[index] = new Thread(ProcessAsyncQueue)
|
workThreads[index] = new Thread(ProcessAsyncQueue) { Name = $"GPU.AsyncTranslationThread.{index}", };
|
||||||
{
|
|
||||||
Name = $"GPU.AsyncTranslationThread.{index}",
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int programCount = _hostStorage.GetProgramCount();
|
int programCount = _hostStorage.GetProgramCount();
|
||||||
|
@ -305,6 +304,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
using var streams = _hostStorage.GetOutputStreams(_context);
|
using var streams = _hostStorage.GetOutputStreams(_context);
|
||||||
|
|
||||||
int packagedShaders = 0;
|
int packagedShaders = 0;
|
||||||
|
ProgramPipelineState currentPipelineState = default;
|
||||||
|
|
||||||
foreach (var kv in _programList)
|
foreach (var kv in _programList)
|
||||||
{
|
{
|
||||||
if (!Active)
|
if (!Active)
|
||||||
|
@ -314,12 +315,53 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
|
|
||||||
(CachedShaderProgram program, byte[] binaryCode) = kv.Value;
|
(CachedShaderProgram program, byte[] binaryCode) = kv.Value;
|
||||||
|
|
||||||
|
if (program.SpecializationState.PipelineState.HasValue && _context.Capabilities.SupportsExtendedDynamicState)
|
||||||
|
{
|
||||||
|
currentPipelineState = program.SpecializationState.PipelineState.Value;
|
||||||
|
|
||||||
|
if (_context.Capabilities.SupportsExtendedDynamicState)
|
||||||
|
{
|
||||||
|
currentPipelineState.StencilTest = default;
|
||||||
|
|
||||||
|
currentPipelineState.CullMode = 0;
|
||||||
|
currentPipelineState.FrontFace = 0;
|
||||||
|
currentPipelineState.DepthTest = default;
|
||||||
|
currentPipelineState.Topology = ConvertToClass(currentPipelineState.Topology);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_context.Capabilities.SupportsExtendedDynamicState2)
|
||||||
|
{
|
||||||
|
currentPipelineState.PrimitiveRestartEnable = false;
|
||||||
|
currentPipelineState.BiasEnable = 0;
|
||||||
|
currentPipelineState.RasterizerDiscard = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_context.Capabilities.SupportsLogicOpDynamicState)
|
||||||
|
{
|
||||||
|
currentPipelineState.LogicOp = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_context.Capabilities.SupportsPatchControlPointsDynamicState)
|
||||||
|
{
|
||||||
|
currentPipelineState.PatchControlPoints = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_pipelineStateSet.Contains(currentPipelineState) ||
|
||||||
|
!_context.Capabilities.SupportsExtendedDynamicState ||
|
||||||
|
!program.SpecializationState.PipelineState.HasValue)
|
||||||
|
{
|
||||||
_hostStorage.AddShader(_context, program, binaryCode, streams);
|
_hostStorage.AddShader(_context, program, binaryCode, streams);
|
||||||
|
|
||||||
_stateChangeCallback(ShaderCacheState.Packaging, ++packagedShaders, _programList.Count);
|
_stateChangeCallback(ShaderCacheState.Packaging, ++packagedShaders, _programList.Count);
|
||||||
}
|
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.Gpu, $"Rebuilt {_programList.Count} shaders successfully.");
|
if (_context.Capabilities.SupportsExtendedDynamicState)
|
||||||
|
{
|
||||||
|
_pipelineStateSet.Add(currentPipelineState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Logger.Info?.Print(LogClass.Gpu, $"Rebuilt {packagedShaders} shaders successfully.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -343,6 +385,29 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
_stateChangeCallback(ShaderCacheState.Loaded, programCount, programCount);
|
_stateChangeCallback(ShaderCacheState.Loaded, programCount, programCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PrimitiveTopology ConvertToClass(PrimitiveTopology topology)
|
||||||
|
{
|
||||||
|
return topology switch
|
||||||
|
{
|
||||||
|
PrimitiveTopology.Points => PrimitiveTopology.Points,
|
||||||
|
PrimitiveTopology.Lines or
|
||||||
|
PrimitiveTopology.LineStrip or
|
||||||
|
PrimitiveTopology.LinesAdjacency or
|
||||||
|
PrimitiveTopology.LineStripAdjacency => PrimitiveTopology.Lines,
|
||||||
|
PrimitiveTopology.Triangles or
|
||||||
|
PrimitiveTopology.TriangleStrip or
|
||||||
|
PrimitiveTopology.TriangleFan or
|
||||||
|
PrimitiveTopology.TrianglesAdjacency or
|
||||||
|
PrimitiveTopology.TriangleStripAdjacency or
|
||||||
|
PrimitiveTopology.Polygon => PrimitiveTopology.TriangleStrip,
|
||||||
|
PrimitiveTopology.Patches => PrimitiveTopology.Patches,
|
||||||
|
PrimitiveTopology.Quads => PrimitiveTopology.Quads,
|
||||||
|
PrimitiveTopology.QuadStrip => PrimitiveTopology.QuadStrip,
|
||||||
|
PrimitiveTopology.LineLoop => PrimitiveTopology.LineLoop,
|
||||||
|
_ => PrimitiveTopology.TriangleStrip,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enqueues a host program for compilation.
|
/// Enqueues a host program for compilation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -191,6 +191,10 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
supportsViewportSwizzle: HwCapabilities.SupportsViewportSwizzle,
|
supportsViewportSwizzle: HwCapabilities.SupportsViewportSwizzle,
|
||||||
supportsIndirectParameters: HwCapabilities.SupportsIndirectParameters,
|
supportsIndirectParameters: HwCapabilities.SupportsIndirectParameters,
|
||||||
supportsDepthClipControl: true,
|
supportsDepthClipControl: true,
|
||||||
|
supportsExtendedDynamicState: false,
|
||||||
|
supportsExtendedDynamicState2: false,
|
||||||
|
supportsLogicOpDynamicState: false,
|
||||||
|
supportsPatchControlPointsDynamicState: false,
|
||||||
uniformBufferSetIndex: 0,
|
uniformBufferSetIndex: 0,
|
||||||
storageBufferSetIndex: 1,
|
storageBufferSetIndex: 1,
|
||||||
textureSetIndex: 2,
|
textureSetIndex: 2,
|
||||||
|
|
|
@ -898,7 +898,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDepthTest(DepthTestDescriptor depthTest)
|
public void SetDepthTest(DepthTestDescriptor depthTest, bool signalChange = true)
|
||||||
{
|
{
|
||||||
if (depthTest.TestEnable)
|
if (depthTest.TestEnable)
|
||||||
{
|
{
|
||||||
|
@ -915,11 +915,11 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_depthTestEnable = depthTest.TestEnable;
|
_depthTestEnable = depthTest.TestEnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFaceCulling(bool enable, Face face)
|
public void SetFaceCulling(Face face)
|
||||||
{
|
{
|
||||||
_cullEnable = enable;
|
_cullEnable = face != Face.None;
|
||||||
|
|
||||||
if (!enable)
|
if (!_cullEnable)
|
||||||
{
|
{
|
||||||
GL.Disable(EnableCap.CullFace);
|
GL.Disable(EnableCap.CullFace);
|
||||||
return;
|
return;
|
||||||
|
@ -1107,12 +1107,12 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
GL.Enable(EnableCap.PrimitiveRestart);
|
GL.Enable(EnableCap.PrimitiveRestart);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPrimitiveTopology(PrimitiveTopology topology)
|
public void SetPrimitiveTopology(PrimitiveTopology topology, bool signalChange = true)
|
||||||
{
|
{
|
||||||
_primitiveType = topology.Convert();
|
_primitiveType = topology.Convert();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetProgram(IProgram program)
|
public void SetProgram(IProgram program, bool signalChange = true)
|
||||||
{
|
{
|
||||||
Program prg = (Program)program;
|
Program prg = (Program)program;
|
||||||
|
|
||||||
|
@ -1154,7 +1154,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_rasterizerDiscard = discard;
|
_rasterizerDiscard = discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMasks)
|
public void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMasks, bool signalChange = true)
|
||||||
{
|
{
|
||||||
_componentMasks = 0;
|
_componentMasks = 0;
|
||||||
|
|
||||||
|
@ -1195,7 +1195,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_framebuffer.SetDrawBuffers(colors.Length);
|
_framebuffer.SetDrawBuffers(colors.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetScissors(ReadOnlySpan<Rectangle<int>> regions)
|
public void SetScissors(ReadOnlySpan<Rectangle<int>> regions, bool signalChange = true)
|
||||||
{
|
{
|
||||||
int count = Math.Min(regions.Length, Constants.MaxViewports);
|
int count = Math.Min(regions.Length, Constants.MaxViewports);
|
||||||
|
|
||||||
|
@ -1388,7 +1388,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
_vertexArray.SetVertexBuffers(vertexBuffers);
|
_vertexArray.SetVertexBuffers(vertexBuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetViewports(ReadOnlySpan<Viewport> viewports)
|
public void SetViewports(ReadOnlySpan<Viewport> viewports, bool signalChange = true)
|
||||||
{
|
{
|
||||||
Array.Resize(ref _viewportArray, viewports.Length * 4);
|
Array.Resize(ref _viewportArray, viewports.Length * 4);
|
||||||
Array.Resize(ref _depthRangeArray, viewports.Length * 2);
|
Array.Resize(ref _depthRangeArray, viewports.Length * 2);
|
||||||
|
|
|
@ -257,8 +257,8 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||||
|
|
||||||
scissors[0] = new Rectangle<int>(0, 0, texture.Width, texture.Height);
|
scissors[0] = new Rectangle<int>(0, 0, texture.Width, texture.Height);
|
||||||
|
|
||||||
_pipeline.SetRenderTarget(texture, (uint)texture.Width, (uint)texture.Height);
|
_pipeline.SetRenderTarget(texture, (uint)texture.Width, (uint)texture.Height, false);
|
||||||
_pipeline.SetRenderTargetColorMasks(colorMasks);
|
_pipeline.SetRenderTargetColorMasks(colorMasks, false);
|
||||||
_pipeline.SetScissors(scissors);
|
_pipeline.SetScissors(scissors);
|
||||||
_pipeline.ClearRenderTargetColor(0, 0, 1, new ColorF(0f, 0f, 0f, 1f));
|
_pipeline.ClearRenderTargetColor(0, 0, 1, new ColorF(0f, 0f, 0f, 1f));
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,6 +238,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
Face.Back => CullModeFlags.BackBit,
|
Face.Back => CullModeFlags.BackBit,
|
||||||
Face.Front => CullModeFlags.FrontBit,
|
Face.Front => CullModeFlags.FrontBit,
|
||||||
Face.FrontAndBack => CullModeFlags.FrontAndBack,
|
Face.FrontAndBack => CullModeFlags.FrontAndBack,
|
||||||
|
Face.None => CullModeFlags.None,
|
||||||
_ => LogInvalidAndReturn(face, nameof(Face), CullModeFlags.BackBit),
|
_ => LogInvalidAndReturn(face, nameof(Face), CullModeFlags.BackBit),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -310,6 +311,25 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PrimitiveTopology ConvertToClass(this PrimitiveTopology topology)
|
||||||
|
{
|
||||||
|
return topology switch
|
||||||
|
{
|
||||||
|
PrimitiveTopology.PointList => PrimitiveTopology.PointList,
|
||||||
|
PrimitiveTopology.LineList or
|
||||||
|
PrimitiveTopology.LineStrip or
|
||||||
|
PrimitiveTopology.LineListWithAdjacency or
|
||||||
|
PrimitiveTopology.LineStripWithAdjacency => PrimitiveTopology.LineList,
|
||||||
|
PrimitiveTopology.TriangleList or
|
||||||
|
PrimitiveTopology.TriangleStrip or
|
||||||
|
PrimitiveTopology.TriangleFan or
|
||||||
|
PrimitiveTopology.TriangleListWithAdjacency or
|
||||||
|
PrimitiveTopology.TriangleStripWithAdjacency => PrimitiveTopology.TriangleStrip,
|
||||||
|
PrimitiveTopology.PatchList => PrimitiveTopology.PatchList,
|
||||||
|
_ => LogInvalidAndReturn(topology, nameof(PrimitiveTopology), PrimitiveTopology.TriangleStrip),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static StencilOp Convert(this GAL.StencilOp op)
|
public static StencilOp Convert(this GAL.StencilOp op)
|
||||||
{
|
{
|
||||||
return op switch
|
return op switch
|
||||||
|
|
|
@ -31,6 +31,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
public readonly bool SupportsShaderStorageImageMultisample;
|
public readonly bool SupportsShaderStorageImageMultisample;
|
||||||
public readonly bool SupportsConditionalRendering;
|
public readonly bool SupportsConditionalRendering;
|
||||||
public readonly bool SupportsExtendedDynamicState;
|
public readonly bool SupportsExtendedDynamicState;
|
||||||
|
public readonly PhysicalDeviceExtendedDynamicState2FeaturesEXT SupportsExtendedDynamicState2;
|
||||||
public readonly bool SupportsMultiView;
|
public readonly bool SupportsMultiView;
|
||||||
public readonly bool SupportsNullDescriptors;
|
public readonly bool SupportsNullDescriptors;
|
||||||
public readonly bool SupportsPushDescriptors;
|
public readonly bool SupportsPushDescriptors;
|
||||||
|
@ -46,6 +47,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
public readonly bool SupportsViewportArray2;
|
public readonly bool SupportsViewportArray2;
|
||||||
public readonly bool SupportsHostImportedMemory;
|
public readonly bool SupportsHostImportedMemory;
|
||||||
public readonly bool SupportsDepthClipControl;
|
public readonly bool SupportsDepthClipControl;
|
||||||
|
public readonly bool SupportsWideLines;
|
||||||
public readonly bool SupportsAttachmentFeedbackLoop;
|
public readonly bool SupportsAttachmentFeedbackLoop;
|
||||||
public readonly bool SupportsDynamicAttachmentFeedbackLoop;
|
public readonly bool SupportsDynamicAttachmentFeedbackLoop;
|
||||||
public readonly uint SubgroupSize;
|
public readonly uint SubgroupSize;
|
||||||
|
@ -54,6 +56,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
public readonly uint VertexBufferAlignment;
|
public readonly uint VertexBufferAlignment;
|
||||||
public readonly uint SubTexelPrecisionBits;
|
public readonly uint SubTexelPrecisionBits;
|
||||||
public readonly ulong MinResourceAlignment;
|
public readonly ulong MinResourceAlignment;
|
||||||
|
public readonly uint MaxTessellationPatchSize;
|
||||||
|
|
||||||
public HardwareCapabilities(
|
public HardwareCapabilities(
|
||||||
bool supportsIndexTypeUint8,
|
bool supportsIndexTypeUint8,
|
||||||
|
@ -71,6 +74,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
bool supportsShaderStorageImageMultisample,
|
bool supportsShaderStorageImageMultisample,
|
||||||
bool supportsConditionalRendering,
|
bool supportsConditionalRendering,
|
||||||
bool supportsExtendedDynamicState,
|
bool supportsExtendedDynamicState,
|
||||||
|
PhysicalDeviceExtendedDynamicState2FeaturesEXT supportsExtendedDynamicState2,
|
||||||
|
uint maxTessellationPatchSize,
|
||||||
bool supportsMultiView,
|
bool supportsMultiView,
|
||||||
bool supportsNullDescriptors,
|
bool supportsNullDescriptors,
|
||||||
bool supportsPushDescriptors,
|
bool supportsPushDescriptors,
|
||||||
|
@ -86,6 +91,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
bool supportsViewportArray2,
|
bool supportsViewportArray2,
|
||||||
bool supportsHostImportedMemory,
|
bool supportsHostImportedMemory,
|
||||||
bool supportsDepthClipControl,
|
bool supportsDepthClipControl,
|
||||||
|
bool supportsWideLines,
|
||||||
bool supportsAttachmentFeedbackLoop,
|
bool supportsAttachmentFeedbackLoop,
|
||||||
bool supportsDynamicAttachmentFeedbackLoop,
|
bool supportsDynamicAttachmentFeedbackLoop,
|
||||||
uint subgroupSize,
|
uint subgroupSize,
|
||||||
|
@ -110,6 +116,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
SupportsShaderStorageImageMultisample = supportsShaderStorageImageMultisample;
|
SupportsShaderStorageImageMultisample = supportsShaderStorageImageMultisample;
|
||||||
SupportsConditionalRendering = supportsConditionalRendering;
|
SupportsConditionalRendering = supportsConditionalRendering;
|
||||||
SupportsExtendedDynamicState = supportsExtendedDynamicState;
|
SupportsExtendedDynamicState = supportsExtendedDynamicState;
|
||||||
|
SupportsExtendedDynamicState2 = supportsExtendedDynamicState2;
|
||||||
|
MaxTessellationPatchSize = maxTessellationPatchSize;
|
||||||
SupportsMultiView = supportsMultiView;
|
SupportsMultiView = supportsMultiView;
|
||||||
SupportsNullDescriptors = supportsNullDescriptors;
|
SupportsNullDescriptors = supportsNullDescriptors;
|
||||||
SupportsPushDescriptors = supportsPushDescriptors;
|
SupportsPushDescriptors = supportsPushDescriptors;
|
||||||
|
@ -125,6 +133,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
SupportsViewportArray2 = supportsViewportArray2;
|
SupportsViewportArray2 = supportsViewportArray2;
|
||||||
SupportsHostImportedMemory = supportsHostImportedMemory;
|
SupportsHostImportedMemory = supportsHostImportedMemory;
|
||||||
SupportsDepthClipControl = supportsDepthClipControl;
|
SupportsDepthClipControl = supportsDepthClipControl;
|
||||||
|
SupportsWideLines = supportsWideLines;
|
||||||
SupportsAttachmentFeedbackLoop = supportsAttachmentFeedbackLoop;
|
SupportsAttachmentFeedbackLoop = supportsAttachmentFeedbackLoop;
|
||||||
SupportsDynamicAttachmentFeedbackLoop = supportsDynamicAttachmentFeedbackLoop;
|
SupportsDynamicAttachmentFeedbackLoop = supportsDynamicAttachmentFeedbackLoop;
|
||||||
SubgroupSize = subgroupSize;
|
SubgroupSize = subgroupSize;
|
||||||
|
|
|
@ -429,35 +429,35 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
if (dstIsDepthOrStencil)
|
if (dstIsDepthOrStencil)
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programDepthBlitMs : _programDepthBlit);
|
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programDepthBlitMs : _programDepthBlit, false);
|
||||||
_pipeline.SetDepthTest(new DepthTestDescriptor(true, true, CompareOp.Always));
|
_pipeline.SetDepthTest(new DepthTestDescriptor(true, true, CompareOp.Always), false);
|
||||||
}
|
}
|
||||||
else if (src.Info.Target.IsMultisample())
|
else if (src.Info.Target.IsMultisample())
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(_programColorBlitMs);
|
_pipeline.SetProgram(_programColorBlitMs, false);
|
||||||
}
|
}
|
||||||
else if (clearAlpha)
|
else if (clearAlpha)
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(_programColorBlitClearAlpha);
|
_pipeline.SetProgram(_programColorBlitClearAlpha, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(_programColorBlit);
|
_pipeline.SetProgram(_programColorBlit, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dstWidth = dst.Width;
|
int dstWidth = dst.Width;
|
||||||
int dstHeight = dst.Height;
|
int dstHeight = dst.Height;
|
||||||
|
|
||||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
|
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight, false);
|
||||||
_pipeline.SetRenderTargetColorMasks(new uint[] { 0xf });
|
_pipeline.SetRenderTargetColorMasks(new uint[] { 0xf }, false);
|
||||||
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dstWidth, dstHeight) });
|
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dstWidth, dstHeight) }, false);
|
||||||
|
|
||||||
if (clearAlpha)
|
if (clearAlpha)
|
||||||
{
|
{
|
||||||
_pipeline.ClearRenderTargetColor(0, 0, 1, new ColorF(0f, 0f, 0f, 1f));
|
_pipeline.ClearRenderTargetColor(0, 0, 1, new ColorF(0f, 0f, 0f, 1f));
|
||||||
}
|
}
|
||||||
|
|
||||||
_pipeline.SetViewports(viewports);
|
_pipeline.SetViewports(viewports, false);
|
||||||
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
||||||
_pipeline.Draw(4, 1, 0, 0);
|
_pipeline.Draw(4, 1, 0, 0);
|
||||||
|
|
||||||
|
@ -524,10 +524,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
int dstWidth = dst.Width;
|
int dstWidth = dst.Width;
|
||||||
int dstHeight = dst.Height;
|
int dstHeight = dst.Height;
|
||||||
|
|
||||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
|
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight, false);
|
||||||
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dstWidth, dstHeight) });
|
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dstWidth, dstHeight) }, false);
|
||||||
_pipeline.SetViewports(viewports);
|
_pipeline.SetViewports(viewports, false);
|
||||||
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip, false);
|
||||||
|
|
||||||
var aspectFlags = src.Info.Format.ConvertAspectFlags();
|
var aspectFlags = src.Info.Format.ConvertAspectFlags();
|
||||||
|
|
||||||
|
@ -589,12 +589,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
if (isDepth)
|
if (isDepth)
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programDepthBlitMs : _programDepthBlit);
|
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programDepthBlitMs : _programDepthBlit, false);
|
||||||
_pipeline.SetDepthTest(new DepthTestDescriptor(true, true, CompareOp.Always));
|
_pipeline.SetDepthTest(new DepthTestDescriptor(true, true, CompareOp.Always));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programStencilBlitMs : _programStencilBlit);
|
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programStencilBlitMs : _programStencilBlit, false);
|
||||||
_pipeline.SetStencilTest(CreateStencilTestDescriptor(true));
|
_pipeline.SetStencilTest(CreateStencilTestDescriptor(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,11 +684,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
program = _programColorClearF;
|
program = _programColorClearF;
|
||||||
}
|
}
|
||||||
|
|
||||||
_pipeline.SetProgram(program);
|
_pipeline.SetProgram(program, false);
|
||||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
|
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight, false);
|
||||||
_pipeline.SetRenderTargetColorMasks(new[] { componentMask });
|
_pipeline.SetRenderTargetColorMasks(new[] { componentMask }, false);
|
||||||
_pipeline.SetViewports(viewports);
|
_pipeline.SetViewports(viewports, false);
|
||||||
_pipeline.SetScissors(stackalloc Rectangle<int>[] { scissor });
|
_pipeline.SetScissors(stackalloc Rectangle<int>[] { scissor }, false);
|
||||||
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
||||||
_pipeline.Draw(4, 1, 0, 0);
|
_pipeline.Draw(4, 1, 0, 0);
|
||||||
_pipeline.Finish();
|
_pipeline.Finish();
|
||||||
|
@ -731,12 +731,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
0f,
|
0f,
|
||||||
1f);
|
1f);
|
||||||
|
|
||||||
_pipeline.SetProgram(_programDepthStencilClear);
|
_pipeline.SetProgram(_programDepthStencilClear, false);
|
||||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
|
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight, false);
|
||||||
_pipeline.SetViewports(viewports);
|
_pipeline.SetViewports(viewports, false);
|
||||||
_pipeline.SetScissors(stackalloc Rectangle<int>[] { scissor });
|
_pipeline.SetScissors(stackalloc Rectangle<int>[] { scissor }, false);
|
||||||
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip, false);
|
||||||
_pipeline.SetDepthTest(new DepthTestDescriptor(true, depthMask, CompareOp.Always));
|
_pipeline.SetDepthTest(new DepthTestDescriptor(true, depthMask, CompareOp.Always), false);
|
||||||
_pipeline.SetStencilTest(CreateStencilTestDescriptor(stencilMask != 0, stencilValue, 0xff, stencilMask));
|
_pipeline.SetStencilTest(CreateStencilTestDescriptor(stencilMask != 0, stencilValue, 0xff, stencilMask));
|
||||||
_pipeline.Draw(4, 1, 0, 0);
|
_pipeline.Draw(4, 1, 0, 0);
|
||||||
_pipeline.Finish();
|
_pipeline.Finish();
|
||||||
|
@ -794,8 +794,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
0f,
|
0f,
|
||||||
1f);
|
1f);
|
||||||
|
|
||||||
pipeline.SetProgram(_programColorBlit);
|
pipeline.SetProgram(_programColorBlit, false);
|
||||||
pipeline.SetViewports(viewports);
|
pipeline.SetViewports(viewports, false);
|
||||||
pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
||||||
pipeline.Draw(4, 1, 0, 0);
|
pipeline.Draw(4, 1, 0, 0);
|
||||||
|
|
||||||
|
@ -1129,16 +1129,16 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
0f,
|
0f,
|
||||||
1f);
|
1f);
|
||||||
|
|
||||||
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dst.Width, dst.Height) });
|
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dst.Width, dst.Height) }, false);
|
||||||
_pipeline.SetViewports(viewports);
|
_pipeline.SetViewports(viewports, false);
|
||||||
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip, false);
|
||||||
|
|
||||||
for (int z = 0; z < depth; z++)
|
for (int z = 0; z < depth; z++)
|
||||||
{
|
{
|
||||||
var srcView = Create2DLayerView(src, srcLayer + z, 0);
|
var srcView = Create2DLayerView(src, srcLayer + z, 0);
|
||||||
var dstView = Create2DLayerView(dst, dstLayer + z, 0);
|
var dstView = Create2DLayerView(dst, dstLayer + z, 0);
|
||||||
|
|
||||||
_pipeline.SetRenderTarget(dstView, (uint)dst.Width, (uint)dst.Height);
|
_pipeline.SetRenderTarget(dstView, (uint)dst.Width, (uint)dst.Height, false);
|
||||||
|
|
||||||
CopyMSDraw(srcView, aspectFlags, fromMS: true);
|
CopyMSDraw(srcView, aspectFlags, fromMS: true);
|
||||||
|
|
||||||
|
@ -1251,9 +1251,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
1f);
|
1f);
|
||||||
|
|
||||||
_pipeline.SetRenderTargetColorMasks(new uint[] { 0xf });
|
_pipeline.SetRenderTargetColorMasks(new uint[] { 0xf });
|
||||||
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dst.Width, dst.Height) });
|
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dst.Width, dst.Height) }, false);
|
||||||
_pipeline.SetViewports(viewports);
|
_pipeline.SetViewports(viewports, false);
|
||||||
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip, false);
|
||||||
|
|
||||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, buffer.Range) });
|
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, buffer.Range) });
|
||||||
|
|
||||||
|
@ -1264,7 +1264,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
var srcView = Create2DLayerView(src, srcLayer + z, 0);
|
var srcView = Create2DLayerView(src, srcLayer + z, 0);
|
||||||
var dstView = Create2DLayerView(dst, dstLayer + z, 0);
|
var dstView = Create2DLayerView(dst, dstLayer + z, 0);
|
||||||
|
|
||||||
_pipeline.SetRenderTarget(dstView, (uint)dst.Width, (uint)dst.Height);
|
_pipeline.SetRenderTarget(dstView, (uint)dst.Width, (uint)dst.Height, false);
|
||||||
|
|
||||||
CopyMSDraw(srcView, aspectFlags, fromMS: false);
|
CopyMSDraw(srcView, aspectFlags, fromMS: false);
|
||||||
|
|
||||||
|
@ -1281,7 +1281,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(_programColorDrawToMs);
|
_pipeline.SetProgram(_programColorDrawToMs, false);
|
||||||
|
|
||||||
var format = GetFormat(src.Info.BytesPerPixel);
|
var format = GetFormat(src.Info.BytesPerPixel);
|
||||||
var vkFormat = FormatTable.GetFormat(format);
|
var vkFormat = FormatTable.GetFormat(format);
|
||||||
|
@ -1358,12 +1358,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
if (isDepth)
|
if (isDepth)
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(fromMS ? _programDepthDrawToNonMs : _programDepthDrawToMs);
|
_pipeline.SetProgram(fromMS ? _programDepthDrawToNonMs : _programDepthDrawToMs, false);
|
||||||
_pipeline.SetDepthTest(new DepthTestDescriptor(true, true, CompareOp.Always));
|
_pipeline.SetDepthTest(new DepthTestDescriptor(true, true, CompareOp.Always));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_pipeline.SetProgram(fromMS ? _programStencilDrawToNonMs : _programStencilDrawToMs);
|
_pipeline.SetProgram(fromMS ? _programStencilDrawToNonMs : _programStencilDrawToMs, false);
|
||||||
_pipeline.SetStencilTest(CreateStencilTestDescriptor(true));
|
_pipeline.SetStencilTest(CreateStencilTestDescriptor(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.Common.Memory;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.Shader;
|
using Ryujinx.Graphics.Shader;
|
||||||
using Silk.NET.Vulkan;
|
using Silk.NET.Vulkan;
|
||||||
|
@ -74,6 +76,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
private readonly BufferState[] _transformFeedbackBuffers;
|
private readonly BufferState[] _transformFeedbackBuffers;
|
||||||
private readonly VertexBufferState[] _vertexBuffers;
|
private readonly VertexBufferState[] _vertexBuffers;
|
||||||
private ulong _vertexBuffersDirty;
|
private ulong _vertexBuffersDirty;
|
||||||
|
private bool _bindingsSet;
|
||||||
protected Rectangle<int> ClearScissor;
|
protected Rectangle<int> ClearScissor;
|
||||||
|
|
||||||
private readonly VertexBufferUpdater _vertexBufferUpdater;
|
private readonly VertexBufferUpdater _vertexBufferUpdater;
|
||||||
|
@ -87,6 +90,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
private bool _tfEnabled;
|
private bool _tfEnabled;
|
||||||
private bool _tfActive;
|
private bool _tfActive;
|
||||||
|
|
||||||
|
private readonly bool _supportExtDynamic;
|
||||||
|
private readonly bool _supportExtDynamic2;
|
||||||
|
|
||||||
private FeedbackLoopAspects _feedbackLoop;
|
private FeedbackLoopAspects _feedbackLoop;
|
||||||
private bool _passWritesDepthStencil;
|
private bool _passWritesDepthStencil;
|
||||||
|
|
||||||
|
@ -94,6 +100,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
public ulong DrawCount { get; private set; }
|
public ulong DrawCount { get; private set; }
|
||||||
public bool RenderPassActive { get; private set; }
|
public bool RenderPassActive { get; private set; }
|
||||||
|
|
||||||
|
private readonly int[] _vertexBufferBindings;
|
||||||
|
|
||||||
public unsafe PipelineBase(VulkanRenderer gd, Device device)
|
public unsafe PipelineBase(VulkanRenderer gd, Device device)
|
||||||
{
|
{
|
||||||
Gd = gd;
|
Gd = gd;
|
||||||
|
@ -126,7 +134,19 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
_storedBlend = new PipelineColorBlendAttachmentState[Constants.MaxRenderTargets];
|
_storedBlend = new PipelineColorBlendAttachmentState[Constants.MaxRenderTargets];
|
||||||
|
|
||||||
_newState.Initialize();
|
_supportExtDynamic = gd.Capabilities.SupportsExtendedDynamicState;
|
||||||
|
|
||||||
|
_supportExtDynamic2 = gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2;
|
||||||
|
|
||||||
|
_bindingsSet = false;
|
||||||
|
|
||||||
|
_vertexBufferBindings = new int[Constants.MaxVertexBuffers];
|
||||||
|
for (int i = 0; i < Constants.MaxVertexBuffers; i++)
|
||||||
|
{
|
||||||
|
_vertexBufferBindings[i] = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_newState.Initialize(gd.Capabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
|
@ -632,19 +652,46 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
if (texture is TextureView srcTexture)
|
if (texture is TextureView srcTexture)
|
||||||
{
|
{
|
||||||
var oldCullMode = _newState.CullMode;
|
CullModeFlags oldCullMode;
|
||||||
var oldStencilTestEnable = _newState.StencilTestEnable;
|
bool oldStencilTestEnable;
|
||||||
var oldDepthTestEnable = _newState.DepthTestEnable;
|
bool oldDepthTestEnable;
|
||||||
var oldDepthWriteEnable = _newState.DepthWriteEnable;
|
bool oldDepthWriteEnable;
|
||||||
var oldViewports = DynamicState.Viewports;
|
PrimitiveTopology oldTopology;
|
||||||
var oldViewportsCount = _newState.ViewportsCount;
|
Array16<Silk.NET.Vulkan.Viewport> oldViewports = DynamicState.Viewports;
|
||||||
var oldTopology = _topology;
|
uint oldViewportsCount;
|
||||||
|
|
||||||
|
if (_supportExtDynamic)
|
||||||
|
{
|
||||||
|
oldCullMode = DynamicState.CullMode;
|
||||||
|
oldStencilTestEnable = DynamicState.StencilTestEnable;
|
||||||
|
oldDepthTestEnable = DynamicState.DepthTestEnable;
|
||||||
|
oldDepthWriteEnable = DynamicState.DepthWriteEnable;
|
||||||
|
oldTopology = _topology;
|
||||||
|
oldViewportsCount = DynamicState.ViewportsCount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oldCullMode = _newState.CullMode;
|
||||||
|
oldStencilTestEnable = _newState.StencilTestEnable;
|
||||||
|
oldDepthTestEnable = _newState.DepthTestEnable;
|
||||||
|
oldDepthWriteEnable = _newState.DepthWriteEnable;
|
||||||
|
oldTopology = _topology;
|
||||||
|
oldViewportsCount = _newState.ViewportsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_supportExtDynamic)
|
||||||
|
{
|
||||||
|
DynamicState.SetCullMode(CullModeFlags.None);
|
||||||
|
DynamicState.SetDepthTestBool(false, false);
|
||||||
|
DynamicState.SetStencilTest(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_newState.CullMode = CullModeFlags.None;
|
_newState.CullMode = CullModeFlags.None;
|
||||||
_newState.StencilTestEnable = false;
|
_newState.StencilTestEnable = false;
|
||||||
_newState.DepthTestEnable = false;
|
_newState.DepthTestEnable = false;
|
||||||
_newState.DepthWriteEnable = false;
|
_newState.DepthWriteEnable = false;
|
||||||
SignalStateChange();
|
}
|
||||||
|
|
||||||
Gd.HelperShader.DrawTexture(
|
Gd.HelperShader.DrawTexture(
|
||||||
Gd,
|
Gd,
|
||||||
|
@ -654,16 +701,24 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
srcRegion,
|
srcRegion,
|
||||||
dstRegion);
|
dstRegion);
|
||||||
|
|
||||||
|
if (_supportExtDynamic)
|
||||||
|
{
|
||||||
|
DynamicState.SetCullMode(oldCullMode);
|
||||||
|
DynamicState.SetStencilTest(oldStencilTestEnable);
|
||||||
|
DynamicState.SetDepthTestBool(oldDepthTestEnable, oldDepthWriteEnable);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_newState.CullMode = oldCullMode;
|
_newState.CullMode = oldCullMode;
|
||||||
_newState.StencilTestEnable = oldStencilTestEnable;
|
_newState.StencilTestEnable = oldStencilTestEnable;
|
||||||
_newState.DepthTestEnable = oldDepthTestEnable;
|
_newState.DepthTestEnable = oldDepthTestEnable;
|
||||||
_newState.DepthWriteEnable = oldDepthWriteEnable;
|
_newState.DepthWriteEnable = oldDepthWriteEnable;
|
||||||
|
_newState.ViewportsCount = oldViewportsCount;
|
||||||
|
}
|
||||||
|
|
||||||
SetPrimitiveTopology(oldTopology);
|
SetPrimitiveTopology(oldTopology);
|
||||||
|
|
||||||
DynamicState.SetViewports(ref oldViewports, oldViewportsCount);
|
DynamicState.SetViewports(ref oldViewports, oldViewportsCount);
|
||||||
|
|
||||||
_newState.ViewportsCount = oldViewportsCount;
|
|
||||||
SignalStateChange();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -792,49 +847,103 @@ 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);
|
bool depthBiasEnable = (enables != 0) && (factor != 0 && units != 0);
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
_newState.DepthBiasEnable = enables != 0;
|
if (_supportExtDynamic2)
|
||||||
|
{
|
||||||
|
DynamicState.SetDepthBiasEnable(depthBiasEnable);
|
||||||
|
}
|
||||||
|
else if (_newState.DepthBiasEnable != depthBiasEnable)
|
||||||
|
{
|
||||||
|
_newState.DepthBiasEnable = depthBiasEnable;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (depthBiasEnable)
|
||||||
|
{
|
||||||
|
DynamicState.SetDepthBias(factor, units, clamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetDepthClamp(bool clamp)
|
public void SetDepthClamp(bool clamp)
|
||||||
{
|
{
|
||||||
_newState.DepthClampEnable = clamp;
|
_newState.DepthClampEnable = clamp;
|
||||||
|
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDepthMode(DepthMode mode)
|
public void SetDepthMode(DepthMode mode)
|
||||||
{
|
{
|
||||||
bool oldMode = _newState.DepthMode;
|
bool newMode = mode == DepthMode.MinusOneToOne;
|
||||||
_newState.DepthMode = mode == DepthMode.MinusOneToOne;
|
|
||||||
if (_newState.DepthMode != oldMode)
|
if (_newState.DepthMode == newMode)
|
||||||
{
|
{
|
||||||
SignalStateChange();
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDepthTest(DepthTestDescriptor depthTest)
|
_newState.DepthMode = newMode;
|
||||||
|
|
||||||
|
SignalStateChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDepthTest(DepthTestDescriptor depthTest, bool signalChange = true)
|
||||||
|
{
|
||||||
|
if (_supportExtDynamic)
|
||||||
|
{
|
||||||
|
DynamicState.SetDepthTestBool(depthTest.TestEnable, depthTest.WriteEnable);
|
||||||
|
if (depthTest.TestEnable)
|
||||||
|
{
|
||||||
|
DynamicState.SetDepthTestCompareOp(depthTest.Func.Convert());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
_newState.DepthTestEnable = depthTest.TestEnable;
|
_newState.DepthTestEnable = depthTest.TestEnable;
|
||||||
_newState.DepthWriteEnable = depthTest.WriteEnable;
|
_newState.DepthWriteEnable = depthTest.WriteEnable;
|
||||||
_newState.DepthCompareOp = depthTest.Func.Convert();
|
_newState.DepthCompareOp = depthTest.Func.Convert();
|
||||||
|
|
||||||
UpdatePassDepthStencil();
|
if (signalChange)
|
||||||
|
{
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetFaceCulling(bool enable, Face face)
|
UpdatePassDepthStencil();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFaceCulling(Face face)
|
||||||
{
|
{
|
||||||
_newState.CullMode = enable ? face.Convert() : CullModeFlags.None;
|
if (_supportExtDynamic)
|
||||||
|
{
|
||||||
|
DynamicState.SetCullMode(face.Convert());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_newState.CullMode = face.Convert();
|
||||||
|
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetFrontFace(FrontFace frontFace)
|
public void SetFrontFace(FrontFace frontFace)
|
||||||
|
{
|
||||||
|
if (_supportExtDynamic)
|
||||||
|
{
|
||||||
|
DynamicState.SetFrontFace(frontFace.Convert());
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
_newState.FrontFace = frontFace.Convert();
|
_newState.FrontFace = frontFace.Convert();
|
||||||
|
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetImage(ShaderStage stage, int binding, ITexture image)
|
public void SetImage(ShaderStage stage, int binding, ITexture image)
|
||||||
{
|
{
|
||||||
|
@ -872,28 +981,56 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
public void SetLineParameters(float width, bool smooth)
|
public void SetLineParameters(float width, bool smooth)
|
||||||
{
|
{
|
||||||
_newState.LineWidth = width;
|
if (!Gd.IsMoltenVk)
|
||||||
SignalStateChange();
|
{
|
||||||
|
DynamicState.SetLineWidth(Gd.Capabilities.SupportsWideLines ? width : 1.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetLogicOpState(bool enable, LogicalOp op)
|
public void SetLogicOpState(bool enable, LogicalOp op)
|
||||||
{
|
{
|
||||||
|
// Vendors other than NVIDIA have a bug where it enables logical operations even for float formats,
|
||||||
|
// so we need to force disable them here.
|
||||||
|
bool logicOpEnable = enable && (Gd.Vendor == Vendor.Nvidia || _newState.Internal.LogicOpsAllowed);
|
||||||
|
|
||||||
_newState.LogicOpEnable = enable;
|
_newState.LogicOpEnable = enable;
|
||||||
|
|
||||||
|
if (Gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2LogicOp)
|
||||||
|
{
|
||||||
|
if (logicOpEnable)
|
||||||
|
{
|
||||||
|
DynamicState.SetLogicOp(op.Convert());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_newState.LogicOp = op.Convert();
|
_newState.LogicOp = op.Convert();
|
||||||
|
}
|
||||||
|
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetMultisampleState(MultisampleDescriptor multisample)
|
public void SetMultisampleState(MultisampleDescriptor multisample)
|
||||||
{
|
{
|
||||||
_newState.AlphaToCoverageEnable = multisample.AlphaToCoverageEnable;
|
_newState.AlphaToCoverageEnable = multisample.AlphaToCoverageEnable;
|
||||||
|
|
||||||
_newState.AlphaToOneEnable = multisample.AlphaToOneEnable;
|
_newState.AlphaToOneEnable = multisample.AlphaToOneEnable;
|
||||||
|
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPatchParameters(int vertices, ReadOnlySpan<float> defaultOuterLevel, ReadOnlySpan<float> defaultInnerLevel)
|
public void SetPatchParameters(int vertices, ReadOnlySpan<float> defaultOuterLevel, ReadOnlySpan<float> defaultInnerLevel)
|
||||||
|
{
|
||||||
|
if (Gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2PatchControlPoints)
|
||||||
|
{
|
||||||
|
DynamicState.SetPatchControlPoints((uint)vertices);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
_newState.PatchControlPoints = (uint)vertices;
|
_newState.PatchControlPoints = (uint)vertices;
|
||||||
|
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Default levels (likely needs emulation on shaders?)
|
// TODO: Default levels (likely needs emulation on shaders?)
|
||||||
}
|
}
|
||||||
|
@ -909,13 +1046,22 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPrimitiveRestart(bool enable, int index)
|
public void SetPrimitiveRestart(bool enable, int index)
|
||||||
|
{
|
||||||
|
if (_supportExtDynamic2)
|
||||||
|
{
|
||||||
|
DynamicState.SetPrimitiveRestartEnable(enable);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
_newState.PrimitiveRestartEnable = enable;
|
_newState.PrimitiveRestartEnable = enable;
|
||||||
// TODO: What to do about the index?
|
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPrimitiveTopology(PrimitiveTopology topology)
|
// TODO: What to do about the index?
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPrimitiveTopology(PrimitiveTopology topology, bool signalChange = true)
|
||||||
{
|
{
|
||||||
_topology = topology;
|
_topology = topology;
|
||||||
|
|
||||||
|
@ -923,10 +1069,18 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
_newState.Topology = vkTopology;
|
_newState.Topology = vkTopology;
|
||||||
|
|
||||||
SignalStateChange();
|
if (_supportExtDynamic)
|
||||||
|
{
|
||||||
|
DynamicState.SetPrimitiveTopology(vkTopology);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetProgram(IProgram program)
|
if (signalChange)
|
||||||
|
{
|
||||||
|
SignalStateChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetProgram(IProgram program, bool signalChange = true)
|
||||||
{
|
{
|
||||||
var internalProgram = (ShaderCollection)program;
|
var internalProgram = (ShaderCollection)program;
|
||||||
var stages = internalProgram.GetInfos();
|
var stages = internalProgram.GetInfos();
|
||||||
|
@ -942,7 +1096,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
stages.CopyTo(_newState.Stages.AsSpan()[..stages.Length]);
|
stages.CopyTo(_newState.Stages.AsSpan()[..stages.Length]);
|
||||||
|
|
||||||
|
if (signalChange)
|
||||||
|
{
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
|
}
|
||||||
|
|
||||||
if (internalProgram.IsCompute)
|
if (internalProgram.IsCompute)
|
||||||
{
|
{
|
||||||
|
@ -967,19 +1124,27 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRasterizerDiscard(bool discard)
|
public void SetRasterizerDiscard(bool discard)
|
||||||
|
{
|
||||||
|
if (_supportExtDynamic2)
|
||||||
|
{
|
||||||
|
DynamicState.SetRasterizerDiscard(discard);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
_newState.RasterizerDiscardEnable = discard;
|
_newState.RasterizerDiscardEnable = discard;
|
||||||
|
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
|
}
|
||||||
|
|
||||||
if (!discard && Gd.IsQualcommProprietary)
|
if (!discard && Gd.IsQualcommProprietary)
|
||||||
{
|
{
|
||||||
// On Adreno, enabling rasterizer discard somehow corrupts the viewport state.
|
// On Adreno, enabling rasterizer discard somehow corrupts the viewport state.
|
||||||
// Force it to be updated on next use to work around this bug.
|
// Force it to be updated on next use to work around this bug.
|
||||||
DynamicState.ForceAllDirty();
|
DynamicState.ForceAllDirty(Gd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask)
|
public void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask, bool signalChange = true)
|
||||||
{
|
{
|
||||||
int count = Math.Min(Constants.MaxRenderTargets, componentMask.Length);
|
int count = Math.Min(Constants.MaxRenderTargets, componentMask.Length);
|
||||||
int writtenAttachments = 0;
|
int writtenAttachments = 0;
|
||||||
|
@ -1018,8 +1183,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
SetRenderTargetsInternal(_preMaskColors, _preMaskDepthStencil, true);
|
SetRenderTargetsInternal(_preMaskColors, _preMaskDepthStencil, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (signalChange)
|
||||||
{
|
{
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
|
}
|
||||||
|
|
||||||
if (writtenAttachments != _writtenAttachmentCount)
|
if (writtenAttachments != _writtenAttachmentCount)
|
||||||
{
|
{
|
||||||
|
@ -1043,7 +1211,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
SetRenderTargetsInternal(colors, depthStencil, Gd.IsTBDR);
|
SetRenderTargetsInternal(colors, depthStencil, Gd.IsTBDR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetScissors(ReadOnlySpan<Rectangle<int>> regions)
|
public void SetScissors(ReadOnlySpan<Rectangle<int>> regions, bool signalChange = true)
|
||||||
{
|
{
|
||||||
int maxScissors = Gd.Capabilities.SupportsMultiView ? Constants.MaxViewports : 1;
|
int maxScissors = Gd.Capabilities.SupportsMultiView ? Constants.MaxViewports : 1;
|
||||||
int count = Math.Min(maxScissors, regions.Length);
|
int count = Math.Min(maxScissors, regions.Length);
|
||||||
|
@ -1052,6 +1220,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
ClearScissor = regions[0];
|
ClearScissor = regions[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DynamicState.ScissorsCount = count;
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
var region = regions[i];
|
var region = regions[i];
|
||||||
|
@ -1061,23 +1231,36 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
DynamicState.SetScissor(i, new Rect2D(offset, extent));
|
DynamicState.SetScissor(i, new Rect2D(offset, extent));
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicState.ScissorsCount = count;
|
if (!_supportExtDynamic)
|
||||||
|
{
|
||||||
_newState.ScissorsCount = (uint)count;
|
_newState.ScissorsCount = (uint)count;
|
||||||
|
|
||||||
|
if (signalChange)
|
||||||
|
{
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetStencilTest(StencilTestDescriptor stencilTest)
|
public void SetStencilTest(StencilTestDescriptor stencilTest)
|
||||||
{
|
{
|
||||||
DynamicState.SetStencilMasks(
|
if (_supportExtDynamic)
|
||||||
(uint)stencilTest.BackFuncMask,
|
{
|
||||||
(uint)stencilTest.BackMask,
|
DynamicState.SetStencilTestandOp(
|
||||||
(uint)stencilTest.BackFuncRef,
|
stencilTest.BackSFail.Convert(),
|
||||||
(uint)stencilTest.FrontFuncMask,
|
stencilTest.BackDpPass.Convert(),
|
||||||
(uint)stencilTest.FrontMask,
|
stencilTest.BackDpFail.Convert(),
|
||||||
(uint)stencilTest.FrontFuncRef);
|
stencilTest.BackFunc.Convert(),
|
||||||
|
stencilTest.FrontSFail.Convert(),
|
||||||
|
stencilTest.FrontDpPass.Convert(),
|
||||||
|
stencilTest.FrontDpFail.Convert(),
|
||||||
|
stencilTest.FrontFunc.Convert(),
|
||||||
|
stencilTest.TestEnable);
|
||||||
|
|
||||||
_newState.StencilTestEnable = stencilTest.TestEnable;
|
UpdatePassDepthStencil();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_newState.StencilBackFailOp = stencilTest.BackSFail.Convert();
|
_newState.StencilBackFailOp = stencilTest.BackSFail.Convert();
|
||||||
_newState.StencilBackPassOp = stencilTest.BackDpPass.Convert();
|
_newState.StencilBackPassOp = stencilTest.BackDpPass.Convert();
|
||||||
_newState.StencilBackDepthFailOp = stencilTest.BackDpFail.Convert();
|
_newState.StencilBackDepthFailOp = stencilTest.BackDpFail.Convert();
|
||||||
|
@ -1086,11 +1269,20 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
_newState.StencilFrontPassOp = stencilTest.FrontDpPass.Convert();
|
_newState.StencilFrontPassOp = stencilTest.FrontDpPass.Convert();
|
||||||
_newState.StencilFrontDepthFailOp = stencilTest.FrontDpFail.Convert();
|
_newState.StencilFrontDepthFailOp = stencilTest.FrontDpFail.Convert();
|
||||||
_newState.StencilFrontCompareOp = stencilTest.FrontFunc.Convert();
|
_newState.StencilFrontCompareOp = stencilTest.FrontFunc.Convert();
|
||||||
|
_newState.StencilTestEnable = stencilTest.TestEnable;
|
||||||
|
|
||||||
UpdatePassDepthStencil();
|
UpdatePassDepthStencil();
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DynamicState.SetStencilMask((uint)stencilTest.BackFuncMask,
|
||||||
|
(uint)stencilTest.BackMask,
|
||||||
|
(uint)stencilTest.BackFuncRef,
|
||||||
|
(uint)stencilTest.FrontFuncMask,
|
||||||
|
(uint)stencilTest.FrontMask,
|
||||||
|
(uint)stencilTest.FrontFuncRef);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetStorageBuffers(ReadOnlySpan<BufferAssignment> buffers)
|
public void SetStorageBuffers(ReadOnlySpan<BufferAssignment> buffers)
|
||||||
{
|
{
|
||||||
_descriptorSetUpdater.SetStorageBuffers(CommandBuffer, buffers);
|
_descriptorSetUpdater.SetStorageBuffers(CommandBuffer, buffers);
|
||||||
|
@ -1207,12 +1399,24 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
int count = Math.Min(Constants.MaxVertexBuffers, vertexBuffers.Length);
|
int count = Math.Min(Constants.MaxVertexBuffers, vertexBuffers.Length);
|
||||||
|
|
||||||
_newState.Internal.VertexBindingDescriptions[0] = new VertexInputBindingDescription(0, 0, VertexInputRate.Vertex);
|
|
||||||
|
|
||||||
int validCount = 1;
|
int validCount = 1;
|
||||||
|
|
||||||
|
if (!_bindingsSet)
|
||||||
|
{
|
||||||
|
_newState.Internal.VertexBindingDescriptions[0] = new VertexInputBindingDescription(0, _supportExtDynamic && (!Gd.IsMoltenVk || Gd.SupportsMTL31) ? null : 0, VertexInputRate.Vertex);
|
||||||
|
|
||||||
|
for (int i = 1; i < count; i++)
|
||||||
|
{
|
||||||
|
_newState.Internal.VertexBindingDescriptions[i] = new VertexInputBindingDescription((uint)i);
|
||||||
|
}
|
||||||
|
|
||||||
|
_bindingsSet = true;
|
||||||
|
}
|
||||||
|
|
||||||
BufferHandle lastHandle = default;
|
BufferHandle lastHandle = default;
|
||||||
Auto<DisposableBuffer> lastBuffer = default;
|
Auto<DisposableBuffer> lastBuffer = default;
|
||||||
|
bool vertexBindingDescriptionChanged = false;
|
||||||
|
bool vertexDescriptionCountChanged = false;
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -1231,13 +1435,32 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
if (vb != null)
|
if (vb != null)
|
||||||
{
|
{
|
||||||
int binding = i + 1;
|
|
||||||
int descriptorIndex = validCount++;
|
int descriptorIndex = validCount++;
|
||||||
|
|
||||||
_newState.Internal.VertexBindingDescriptions[descriptorIndex] = new VertexInputBindingDescription(
|
if (_supportExtDynamic && (!Gd.IsMoltenVk || Gd.SupportsMTL31))
|
||||||
(uint)binding,
|
{
|
||||||
(uint)vertexBuffer.Stride,
|
if (_newState.Internal.VertexBindingDescriptions[descriptorIndex].InputRate != inputRate ||
|
||||||
inputRate);
|
_newState.Internal.VertexBindingDescriptions[descriptorIndex].Binding != _vertexBufferBindings[i])
|
||||||
|
{
|
||||||
|
_newState.Internal.VertexBindingDescriptions[descriptorIndex].InputRate = inputRate;
|
||||||
|
_newState.Internal.VertexBindingDescriptions[descriptorIndex].Binding = (uint)_vertexBufferBindings[i];
|
||||||
|
|
||||||
|
vertexBindingDescriptionChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_newState.Internal.VertexBindingDescriptions[descriptorIndex].InputRate != inputRate ||
|
||||||
|
_newState.Internal.VertexBindingDescriptions[descriptorIndex].Stride != vertexBuffer.Stride ||
|
||||||
|
_newState.Internal.VertexBindingDescriptions[descriptorIndex].Binding != _vertexBufferBindings[i])
|
||||||
|
{
|
||||||
|
_newState.Internal.VertexBindingDescriptions[descriptorIndex].Binding = (uint)_vertexBufferBindings[i];
|
||||||
|
_newState.Internal.VertexBindingDescriptions[descriptorIndex].Stride = (uint)vertexBuffer.Stride;
|
||||||
|
_newState.Internal.VertexBindingDescriptions[descriptorIndex].InputRate = inputRate;
|
||||||
|
|
||||||
|
vertexBindingDescriptionChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int vbSize = vertexBuffer.Buffer.Size;
|
int vbSize = vertexBuffer.Buffer.Size;
|
||||||
|
|
||||||
|
@ -1253,7 +1476,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ref var buffer = ref _vertexBuffers[binding];
|
ref var buffer = ref _vertexBuffers[_vertexBufferBindings[i]];
|
||||||
int oldScalarAlign = buffer.AttributeScalarAlignment;
|
int oldScalarAlign = buffer.AttributeScalarAlignment;
|
||||||
|
|
||||||
if (Gd.Capabilities.VertexBufferAlignment < 2 &&
|
if (Gd.Capabilities.VertexBufferAlignment < 2 &&
|
||||||
|
@ -1270,7 +1493,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
vbSize,
|
vbSize,
|
||||||
vertexBuffer.Stride);
|
vertexBuffer.Stride);
|
||||||
|
|
||||||
buffer.BindVertexBuffer(Gd, Cbs, (uint)binding, ref _newState, _vertexBufferUpdater);
|
buffer.BindVertexBuffer(Gd, Cbs, (uint)_vertexBufferBindings[i], ref _newState, _vertexBufferUpdater);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1286,7 +1509,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
vbSize,
|
vbSize,
|
||||||
vertexBuffer.Stride);
|
vertexBuffer.Stride);
|
||||||
|
|
||||||
_vertexBuffersDirty |= 1UL << binding;
|
_vertexBuffersDirty |= 1UL << _vertexBufferBindings[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.AttributeScalarAlignment = oldScalarAlign;
|
buffer.AttributeScalarAlignment = oldScalarAlign;
|
||||||
|
@ -1296,11 +1519,19 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
_vertexBufferUpdater.Commit(Cbs);
|
_vertexBufferUpdater.Commit(Cbs);
|
||||||
|
|
||||||
|
if (_newState.VertexBindingDescriptionsCount != validCount)
|
||||||
|
{
|
||||||
_newState.VertexBindingDescriptionsCount = (uint)validCount;
|
_newState.VertexBindingDescriptionsCount = (uint)validCount;
|
||||||
SignalStateChange();
|
vertexDescriptionCountChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetViewports(ReadOnlySpan<Viewport> viewports)
|
if (vertexDescriptionCountChanged || vertexBindingDescriptionChanged)
|
||||||
|
{
|
||||||
|
SignalStateChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetViewports(ReadOnlySpan<Viewport> viewports, bool signalChange = true)
|
||||||
{
|
{
|
||||||
int maxViewports = Gd.Capabilities.SupportsMultiView ? Constants.MaxViewports : 1;
|
int maxViewports = Gd.Capabilities.SupportsMultiView ? Constants.MaxViewports : 1;
|
||||||
int count = Math.Min(maxViewports, viewports.Length);
|
int count = Math.Min(maxViewports, viewports.Length);
|
||||||
|
@ -1325,9 +1556,16 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
Clamp(viewport.DepthFar)));
|
Clamp(viewport.DepthFar)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_supportExtDynamic)
|
||||||
|
{
|
||||||
_newState.ViewportsCount = (uint)count;
|
_newState.ViewportsCount = (uint)count;
|
||||||
|
|
||||||
|
if (signalChange)
|
||||||
|
{
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SwapBuffer(Auto<DisposableBuffer> from, Auto<DisposableBuffer> to)
|
public void SwapBuffer(Auto<DisposableBuffer> from, Auto<DisposableBuffer> to)
|
||||||
{
|
{
|
||||||
|
@ -1375,7 +1613,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
_vertexBuffersDirty = ulong.MaxValue >> (64 - _vertexBuffers.Length);
|
_vertexBuffersDirty = ulong.MaxValue >> (64 - _vertexBuffers.Length);
|
||||||
|
|
||||||
_descriptorSetUpdater.SignalCommandBufferChange();
|
_descriptorSetUpdater.SignalCommandBufferChange();
|
||||||
DynamicState.ForceAllDirty();
|
DynamicState.ForceAllDirty(Gd);
|
||||||
_currentPipelineHandle = 0;
|
_currentPipelineHandle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1529,9 +1767,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
if (Gd.Capabilities.SupportsDynamicAttachmentFeedbackLoop)
|
if (Gd.Capabilities.SupportsDynamicAttachmentFeedbackLoop)
|
||||||
{
|
{
|
||||||
|
_newState.FeedbackLoopDynamicState = true;
|
||||||
DynamicState.SetFeedbackLoop(aspects);
|
DynamicState.SetFeedbackLoop(aspects);
|
||||||
}
|
}
|
||||||
else
|
else if (Gd.Capabilities.SupportsAttachmentFeedbackLoop)
|
||||||
{
|
{
|
||||||
_newState.FeedbackLoopAspects = aspects;
|
_newState.FeedbackLoopAspects = aspects;
|
||||||
}
|
}
|
||||||
|
@ -1591,8 +1830,15 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stencil test being enabled doesn't necessarily mean a write, but it's not critical to check.
|
// Stencil test being enabled doesn't necessarily mean a write, but it's not critical to check.
|
||||||
|
if (_supportExtDynamic)
|
||||||
|
{
|
||||||
|
_passWritesDepthStencil |= (DynamicState.DepthTestEnable && DynamicState.DepthWriteEnable) || DynamicState.StencilTestEnable;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_passWritesDepthStencil |= (_newState.DepthTestEnable && _newState.DepthWriteEnable) || _newState.StencilTestEnable;
|
_passWritesDepthStencil |= (_newState.DepthTestEnable && _newState.DepthWriteEnable) || _newState.StencilTestEnable;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool RecreateGraphicsPipelineIfNeeded()
|
private bool RecreateGraphicsPipelineIfNeeded()
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,7 @@ using Silk.NET.Vulkan;
|
||||||
using System;
|
using System;
|
||||||
using Format = Silk.NET.Vulkan.Format;
|
using Format = Silk.NET.Vulkan.Format;
|
||||||
using PolygonMode = Silk.NET.Vulkan.PolygonMode;
|
using PolygonMode = Silk.NET.Vulkan.PolygonMode;
|
||||||
|
using PrimitiveTopology = Ryujinx.Graphics.GAL.PrimitiveTopology;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Vulkan
|
namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
|
@ -154,34 +155,37 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
public static PipelineState ToVulkanPipelineState(this ProgramPipelineState state, VulkanRenderer gd)
|
public static PipelineState ToVulkanPipelineState(this ProgramPipelineState state, VulkanRenderer gd)
|
||||||
{
|
{
|
||||||
|
var extendedDynamicState2 = gd.Capabilities.SupportsExtendedDynamicState2;
|
||||||
|
var extendedDynamicState = gd.Capabilities.SupportsExtendedDynamicState;
|
||||||
|
|
||||||
PipelineState pipeline = new();
|
PipelineState pipeline = new();
|
||||||
pipeline.Initialize();
|
pipeline.Initialize(gd.Capabilities);
|
||||||
|
|
||||||
// It is assumed that Dynamic State is enabled when this conversion is used.
|
// It is assumed that Dynamic State is enabled when this conversion is used.
|
||||||
|
|
||||||
pipeline.CullMode = state.CullEnable ? state.CullMode.Convert() : CullModeFlags.None;
|
|
||||||
|
|
||||||
pipeline.DepthBoundsTestEnable = false; // Not implemented.
|
pipeline.DepthBoundsTestEnable = false; // Not implemented.
|
||||||
|
|
||||||
pipeline.DepthClampEnable = state.DepthClampEnable;
|
pipeline.DepthClampEnable = state.DepthClampEnable;
|
||||||
|
|
||||||
pipeline.DepthTestEnable = state.DepthTest.TestEnable;
|
pipeline.AlphaToCoverageEnable = state.AlphaToCoverageEnable;
|
||||||
pipeline.DepthWriteEnable = state.DepthTest.WriteEnable;
|
pipeline.AlphaToOneEnable = state.AlphaToOneEnable;
|
||||||
pipeline.DepthCompareOp = state.DepthTest.Func.Convert();
|
|
||||||
pipeline.DepthMode = state.DepthMode == DepthMode.MinusOneToOne;
|
pipeline.DepthMode = state.DepthMode == DepthMode.MinusOneToOne;
|
||||||
|
|
||||||
pipeline.FrontFace = state.FrontFace.Convert();
|
|
||||||
|
|
||||||
pipeline.HasDepthStencil = state.DepthStencilEnable;
|
pipeline.HasDepthStencil = state.DepthStencilEnable;
|
||||||
pipeline.LineWidth = state.LineWidth;
|
|
||||||
pipeline.LogicOpEnable = state.LogicOpEnable;
|
|
||||||
pipeline.LogicOp = state.LogicOp.Convert();
|
|
||||||
|
|
||||||
pipeline.PatchControlPoints = state.PatchControlPoints;
|
|
||||||
pipeline.PolygonMode = PolygonMode.Fill; // Not implemented.
|
pipeline.PolygonMode = PolygonMode.Fill; // Not implemented.
|
||||||
pipeline.PrimitiveRestartEnable = state.PrimitiveRestartEnable;
|
|
||||||
pipeline.RasterizerDiscardEnable = state.RasterizerDiscard;
|
pipeline.Topology = gd.TopologyRemap(state.Topology).Convert();
|
||||||
pipeline.SamplesCount = (uint)state.SamplesCount;
|
|
||||||
|
if (!extendedDynamicState)
|
||||||
|
{
|
||||||
|
pipeline.DepthCompareOp = state.DepthTest.Func.Convert();
|
||||||
|
pipeline.CullMode = state.CullMode.Convert();
|
||||||
|
|
||||||
|
pipeline.DepthTestEnable = state.DepthTest.TestEnable;
|
||||||
|
pipeline.DepthWriteEnable = state.DepthTest.WriteEnable;
|
||||||
|
|
||||||
|
pipeline.FrontFace = state.FrontFace.Convert();
|
||||||
|
|
||||||
if (gd.Capabilities.SupportsMultiView)
|
if (gd.Capabilities.SupportsMultiView)
|
||||||
{
|
{
|
||||||
|
@ -194,9 +198,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
pipeline.ViewportsCount = 1;
|
pipeline.ViewportsCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pipeline.DepthBiasEnable = state.BiasEnable != 0;
|
pipeline.StencilTestEnable = state.StencilTest.TestEnable;
|
||||||
|
|
||||||
// Stencil masks and ref are dynamic, so are 0 in the Vulkan pipeline.
|
|
||||||
|
|
||||||
pipeline.StencilFrontFailOp = state.StencilTest.FrontSFail.Convert();
|
pipeline.StencilFrontFailOp = state.StencilTest.FrontSFail.Convert();
|
||||||
pipeline.StencilFrontPassOp = state.StencilTest.FrontDpPass.Convert();
|
pipeline.StencilFrontPassOp = state.StencilTest.FrontDpPass.Convert();
|
||||||
|
@ -207,10 +209,29 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
pipeline.StencilBackPassOp = state.StencilTest.BackDpPass.Convert();
|
pipeline.StencilBackPassOp = state.StencilTest.BackDpPass.Convert();
|
||||||
pipeline.StencilBackDepthFailOp = state.StencilTest.BackDpFail.Convert();
|
pipeline.StencilBackDepthFailOp = state.StencilTest.BackDpFail.Convert();
|
||||||
pipeline.StencilBackCompareOp = state.StencilTest.BackFunc.Convert();
|
pipeline.StencilBackCompareOp = state.StencilTest.BackFunc.Convert();
|
||||||
|
}
|
||||||
|
|
||||||
pipeline.StencilTestEnable = state.StencilTest.TestEnable;
|
if (!extendedDynamicState2.ExtendedDynamicState2)
|
||||||
|
{
|
||||||
|
pipeline.PrimitiveRestartEnable = state.PrimitiveRestartEnable;
|
||||||
|
pipeline.RasterizerDiscardEnable = state.RasterizerDiscard;
|
||||||
|
pipeline.DepthBiasEnable = (state.BiasEnable != 0) &&
|
||||||
|
(state.DepthBiasFactor != 0 && state.DepthBiasUnits != 0);
|
||||||
|
}
|
||||||
|
|
||||||
pipeline.Topology = gd.TopologyRemap(state.Topology).Convert();
|
if (!extendedDynamicState2.ExtendedDynamicState2LogicOp)
|
||||||
|
{
|
||||||
|
pipeline.LogicOp = state.LogicOp.Convert();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extendedDynamicState2.ExtendedDynamicState2PatchControlPoints)
|
||||||
|
{
|
||||||
|
pipeline.PatchControlPoints = state.PatchControlPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
pipeline.SamplesCount = (uint)state.SamplesCount;
|
||||||
|
|
||||||
|
pipeline.LogicOpEnable = state.LogicOpEnable;
|
||||||
|
|
||||||
int vaCount = Math.Min(Constants.MaxVertexAttributes, state.VertexAttribCount);
|
int vaCount = Math.Min(Constants.MaxVertexAttributes, state.VertexAttribCount);
|
||||||
int vbCount = Math.Min(Constants.MaxVertexBuffers, state.VertexBufferCount);
|
int vbCount = Math.Min(Constants.MaxVertexBuffers, state.VertexBufferCount);
|
||||||
|
@ -235,7 +256,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
|
|
||||||
int descriptorIndex = 1;
|
int descriptorIndex = 1;
|
||||||
pipeline.Internal.VertexBindingDescriptions[0] = new VertexInputBindingDescription(0, 0, VertexInputRate.Vertex);
|
pipeline.Internal.VertexBindingDescriptions[0] = new VertexInputBindingDescription(0, extendedDynamicState && (!gd.IsMoltenVk || gd.SupportsMTL31) ? null : 0, VertexInputRate.Vertex);
|
||||||
|
|
||||||
for (int i = 0; i < vbCount; i++)
|
for (int i = 0; i < vbCount; i++)
|
||||||
{
|
{
|
||||||
|
@ -255,7 +276,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
// TODO: Support divisor > 1
|
// TODO: Support divisor > 1
|
||||||
pipeline.Internal.VertexBindingDescriptions[descriptorIndex++] = new VertexInputBindingDescription(
|
pipeline.Internal.VertexBindingDescriptions[descriptorIndex++] = new VertexInputBindingDescription(
|
||||||
(uint)i + 1,
|
(uint)i + 1,
|
||||||
(uint)alignedStride,
|
extendedDynamicState && (!gd.IsMoltenVk || gd.SupportsMTL31) ? null : (uint)alignedStride,
|
||||||
inputRate);
|
inputRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using Ryujinx.Common.Memory;
|
using Ryujinx.Common.Memory;
|
||||||
using Silk.NET.Vulkan;
|
using Silk.NET.Vulkan;
|
||||||
using Silk.NET.Vulkan.Extensions.EXT;
|
using Silk.NET.Vulkan.Extensions.EXT;
|
||||||
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Vulkan
|
namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
|
@ -9,6 +11,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
private float _depthBiasSlopeFactor;
|
private float _depthBiasSlopeFactor;
|
||||||
private float _depthBiasConstantFactor;
|
private float _depthBiasConstantFactor;
|
||||||
private float _depthBiasClamp;
|
private float _depthBiasClamp;
|
||||||
|
private bool _depthBiasEnable;
|
||||||
|
|
||||||
public int ScissorsCount;
|
public int ScissorsCount;
|
||||||
private Array16<Rect2D> _scissors;
|
private Array16<Rect2D> _scissors;
|
||||||
|
@ -20,6 +23,23 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
private uint _frontWriteMask;
|
private uint _frontWriteMask;
|
||||||
private uint _frontReference;
|
private uint _frontReference;
|
||||||
|
|
||||||
|
private StencilOp _backFailOp;
|
||||||
|
private StencilOp _backPassOp;
|
||||||
|
private StencilOp _backDepthFailOp;
|
||||||
|
private CompareOp _backCompareOp;
|
||||||
|
private StencilOp _frontFailOp;
|
||||||
|
private StencilOp _frontPassOp;
|
||||||
|
private StencilOp _frontDepthFailOp;
|
||||||
|
private CompareOp _frontCompareOp;
|
||||||
|
|
||||||
|
private float _lineWidth;
|
||||||
|
|
||||||
|
public bool StencilTestEnable;
|
||||||
|
|
||||||
|
public bool DepthTestEnable;
|
||||||
|
public bool DepthWriteEnable;
|
||||||
|
private CompareOp _depthCompareOp;
|
||||||
|
|
||||||
private Array4<float> _blendConstants;
|
private Array4<float> _blendConstants;
|
||||||
|
|
||||||
private FeedbackLoopAspects _feedbackLoopAspects;
|
private FeedbackLoopAspects _feedbackLoopAspects;
|
||||||
|
@ -27,6 +47,20 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
public uint ViewportsCount;
|
public uint ViewportsCount;
|
||||||
public Array16<Viewport> Viewports;
|
public Array16<Viewport> Viewports;
|
||||||
|
|
||||||
|
public CullModeFlags CullMode;
|
||||||
|
private FrontFace _frontFace;
|
||||||
|
|
||||||
|
private bool _discard;
|
||||||
|
|
||||||
|
private LogicOp _logicOp;
|
||||||
|
|
||||||
|
private uint _patchControlPoints;
|
||||||
|
|
||||||
|
public PrimitiveTopology Topology;
|
||||||
|
|
||||||
|
private bool _primitiveRestartEnable;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
private enum DirtyFlags
|
private enum DirtyFlags
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
|
@ -36,7 +70,21 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
Stencil = 1 << 3,
|
Stencil = 1 << 3,
|
||||||
Viewport = 1 << 4,
|
Viewport = 1 << 4,
|
||||||
FeedbackLoop = 1 << 5,
|
FeedbackLoop = 1 << 5,
|
||||||
All = Blend | DepthBias | Scissor | Stencil | Viewport | FeedbackLoop,
|
CullMode = 1 << 6,
|
||||||
|
FrontFace = 1 << 7,
|
||||||
|
DepthTestBool = 1 << 8,
|
||||||
|
DepthTestCompareOp = 1 << 9,
|
||||||
|
StencilTestEnableAndStencilOp = 1 << 10,
|
||||||
|
LineWidth = 1 << 11,
|
||||||
|
RasterDiscard = 1 << 12,
|
||||||
|
LogicOp = 1 << 13,
|
||||||
|
PatchControlPoints = 1 << 14,
|
||||||
|
PrimitiveRestart = 1 << 15,
|
||||||
|
PrimitiveTopology = 1 << 16,
|
||||||
|
DepthBiasEnable = 1 << 17,
|
||||||
|
Standard = Blend | DepthBias | Scissor | Stencil | Viewport,
|
||||||
|
Extended = CullMode | FrontFace | DepthTestBool | DepthTestCompareOp | StencilTestEnableAndStencilOp | PrimitiveTopology,
|
||||||
|
Extended2 = RasterDiscard | PrimitiveRestart | DepthBiasEnable,
|
||||||
}
|
}
|
||||||
|
|
||||||
private DirtyFlags _dirty;
|
private DirtyFlags _dirty;
|
||||||
|
@ -47,7 +95,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
_blendConstants[1] = g;
|
_blendConstants[1] = g;
|
||||||
_blendConstants[2] = b;
|
_blendConstants[2] = b;
|
||||||
_blendConstants[3] = a;
|
_blendConstants[3] = a;
|
||||||
|
|
||||||
_dirty |= DirtyFlags.Blend;
|
_dirty |= DirtyFlags.Blend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,15 +107,64 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
_dirty |= DirtyFlags.DepthBias;
|
_dirty |= DirtyFlags.DepthBias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetDepthBiasEnable(bool enable)
|
||||||
|
{
|
||||||
|
_depthBiasEnable = enable;
|
||||||
|
_dirty |= DirtyFlags.DepthBiasEnable;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetScissor(int index, Rect2D scissor)
|
public void SetScissor(int index, Rect2D scissor)
|
||||||
{
|
{
|
||||||
_scissors[index] = scissor;
|
_scissors[index] = scissor;
|
||||||
|
|
||||||
_dirty |= DirtyFlags.Scissor;
|
_dirty |= DirtyFlags.Scissor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetStencilMasks(
|
public void SetDepthTestBool(bool testEnable, bool writeEnable)
|
||||||
uint backCompareMask,
|
{
|
||||||
|
DepthTestEnable = testEnable;
|
||||||
|
DepthWriteEnable = writeEnable;
|
||||||
|
_dirty |= DirtyFlags.DepthTestBool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDepthTestCompareOp(CompareOp depthTestOp)
|
||||||
|
{
|
||||||
|
_depthCompareOp = depthTestOp;
|
||||||
|
_dirty |= DirtyFlags.DepthTestCompareOp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetStencilTestandOp(
|
||||||
|
StencilOp backFailOp,
|
||||||
|
StencilOp backPassOp,
|
||||||
|
StencilOp backDepthFailOp,
|
||||||
|
CompareOp backCompareOp,
|
||||||
|
StencilOp frontFailOp,
|
||||||
|
StencilOp frontPassOp,
|
||||||
|
StencilOp frontDepthFailOp,
|
||||||
|
CompareOp frontCompareOp,
|
||||||
|
bool stencilTestEnable)
|
||||||
|
{
|
||||||
|
_backFailOp = backFailOp;
|
||||||
|
_backPassOp = backPassOp;
|
||||||
|
_backDepthFailOp = backDepthFailOp;
|
||||||
|
_backCompareOp = backCompareOp;
|
||||||
|
_frontFailOp = frontFailOp;
|
||||||
|
_frontPassOp = frontPassOp;
|
||||||
|
_frontDepthFailOp = frontDepthFailOp;
|
||||||
|
_frontCompareOp = frontCompareOp;
|
||||||
|
|
||||||
|
StencilTestEnable = stencilTestEnable;
|
||||||
|
|
||||||
|
_dirty |= DirtyFlags.StencilTestEnableAndStencilOp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetStencilTest(bool stencilTestEnable)
|
||||||
|
{
|
||||||
|
StencilTestEnable = stencilTestEnable;
|
||||||
|
|
||||||
|
_dirty |= DirtyFlags.StencilTestEnableAndStencilOp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetStencilMask(uint backCompareMask,
|
||||||
uint backWriteMask,
|
uint backWriteMask,
|
||||||
uint backReference,
|
uint backReference,
|
||||||
uint frontCompareMask,
|
uint frontCompareMask,
|
||||||
|
@ -81,27 +177,45 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
_frontCompareMask = frontCompareMask;
|
_frontCompareMask = frontCompareMask;
|
||||||
_frontWriteMask = frontWriteMask;
|
_frontWriteMask = frontWriteMask;
|
||||||
_frontReference = frontReference;
|
_frontReference = frontReference;
|
||||||
|
|
||||||
_dirty |= DirtyFlags.Stencil;
|
_dirty |= DirtyFlags.Stencil;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetViewport(int index, Viewport viewport)
|
public void SetViewport(int index, Viewport viewport)
|
||||||
{
|
{
|
||||||
Viewports[index] = viewport;
|
Viewports[index] = viewport;
|
||||||
|
|
||||||
_dirty |= DirtyFlags.Viewport;
|
_dirty |= DirtyFlags.Viewport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetViewports(ref Array16<Viewport> viewports, uint viewportsCount)
|
public void SetViewports(ref Array16<Viewport> viewports, uint viewportsCount)
|
||||||
|
{
|
||||||
|
if (!Viewports.Equals(viewports) || ViewportsCount != viewportsCount)
|
||||||
{
|
{
|
||||||
Viewports = viewports;
|
Viewports = viewports;
|
||||||
ViewportsCount = viewportsCount;
|
ViewportsCount = viewportsCount;
|
||||||
|
|
||||||
if (ViewportsCount != 0)
|
if (ViewportsCount != 0)
|
||||||
{
|
{
|
||||||
_dirty |= DirtyFlags.Viewport;
|
_dirty |= DirtyFlags.Viewport;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetCullMode(CullModeFlags cullMode)
|
||||||
|
{
|
||||||
|
CullMode = cullMode;
|
||||||
|
_dirty |= DirtyFlags.CullMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFrontFace(FrontFace frontFace)
|
||||||
|
{
|
||||||
|
_frontFace = frontFace;
|
||||||
|
_dirty |= DirtyFlags.FrontFace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLineWidth(float width)
|
||||||
|
{
|
||||||
|
_lineWidth = width;
|
||||||
|
_dirty |= DirtyFlags.LineWidth;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetFeedbackLoop(FeedbackLoopAspects aspects)
|
public void SetFeedbackLoop(FeedbackLoopAspects aspects)
|
||||||
{
|
{
|
||||||
|
@ -110,43 +224,149 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
_dirty |= DirtyFlags.FeedbackLoop;
|
_dirty |= DirtyFlags.FeedbackLoop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForceAllDirty()
|
public void SetRasterizerDiscard(bool discard)
|
||||||
{
|
{
|
||||||
_dirty = DirtyFlags.All;
|
_discard = discard;
|
||||||
|
_dirty |= DirtyFlags.RasterDiscard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPrimitiveRestartEnable(bool primitiveRestart)
|
||||||
|
{
|
||||||
|
_primitiveRestartEnable = primitiveRestart;
|
||||||
|
_dirty |= DirtyFlags.PrimitiveRestart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPrimitiveTopology(PrimitiveTopology primitiveTopology)
|
||||||
|
{
|
||||||
|
Topology = primitiveTopology;
|
||||||
|
_dirty |= DirtyFlags.PrimitiveTopology;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLogicOp(LogicOp op)
|
||||||
|
{
|
||||||
|
_logicOp = op;
|
||||||
|
_dirty |= DirtyFlags.LogicOp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPatchControlPoints(uint points)
|
||||||
|
{
|
||||||
|
_patchControlPoints = points;
|
||||||
|
_dirty |= DirtyFlags.PatchControlPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ForceAllDirty(VulkanRenderer gd)
|
||||||
|
{
|
||||||
|
_dirty = DirtyFlags.Standard;
|
||||||
|
|
||||||
|
if (gd.Capabilities.SupportsExtendedDynamicState)
|
||||||
|
{
|
||||||
|
_dirty |= DirtyFlags.Extended;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2)
|
||||||
|
{
|
||||||
|
_dirty |= DirtyFlags.Extended2;
|
||||||
|
|
||||||
|
if (gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2LogicOp)
|
||||||
|
{
|
||||||
|
_dirty |= DirtyFlags.LogicOp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2PatchControlPoints)
|
||||||
|
{
|
||||||
|
_dirty |= DirtyFlags.PatchControlPoints;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gd.IsMoltenVk)
|
||||||
|
{
|
||||||
|
_dirty |= DirtyFlags.LineWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gd.Capabilities.SupportsDynamicAttachmentFeedbackLoop)
|
||||||
|
{
|
||||||
|
_dirty |= DirtyFlags.FeedbackLoop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReplayIfDirty(VulkanRenderer gd, CommandBuffer commandBuffer)
|
public void ReplayIfDirty(VulkanRenderer gd, CommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
Vk api = gd.Api;
|
if (_dirty == DirtyFlags.None)
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.Blend))
|
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var api = gd.Api;
|
||||||
|
var extendedStateApi = gd.ExtendedDynamicStateApi;
|
||||||
|
var extendedState2Api = gd.ExtendedDynamicState2Api;
|
||||||
|
var dynamicFeedbackLoopApi = gd.DynamicFeedbackLoopApi;
|
||||||
|
|
||||||
|
DirtyFlags dirtyFlags = _dirty;
|
||||||
|
|
||||||
|
while (dirtyFlags != DirtyFlags.None)
|
||||||
|
{
|
||||||
|
int bitIndex = BitOperations.TrailingZeroCount((uint)dirtyFlags);
|
||||||
|
DirtyFlags currentFlag = (DirtyFlags)(1 << bitIndex);
|
||||||
|
|
||||||
|
switch (currentFlag)
|
||||||
|
{
|
||||||
|
case DirtyFlags.Blend:
|
||||||
RecordBlend(api, commandBuffer);
|
RecordBlend(api, commandBuffer);
|
||||||
}
|
break;
|
||||||
|
case DirtyFlags.DepthBias:
|
||||||
if (_dirty.HasFlag(DirtyFlags.DepthBias))
|
|
||||||
{
|
|
||||||
RecordDepthBias(api, commandBuffer);
|
RecordDepthBias(api, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.Scissor:
|
||||||
|
RecordScissor(gd, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.Stencil:
|
||||||
|
RecordStencil(api, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.Viewport:
|
||||||
|
RecordViewport(gd, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.FeedbackLoop:
|
||||||
|
RecordFeedbackLoop(dynamicFeedbackLoopApi, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.CullMode:
|
||||||
|
RecordCullMode(extendedStateApi, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.FrontFace:
|
||||||
|
RecordFrontFace(extendedStateApi, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.DepthTestBool:
|
||||||
|
RecordDepthTestBool(extendedStateApi, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.DepthTestCompareOp:
|
||||||
|
RecordDepthTestCompareOp(extendedStateApi, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.StencilTestEnableAndStencilOp:
|
||||||
|
RecordStencilTestAndOp(extendedStateApi, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.LineWidth:
|
||||||
|
RecordLineWidth(api, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.RasterDiscard:
|
||||||
|
RecordRasterizationDiscard(extendedState2Api, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.LogicOp:
|
||||||
|
RecordLogicOp(extendedState2Api, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.PatchControlPoints:
|
||||||
|
RecordPatchControlPoints(extendedState2Api, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.PrimitiveRestart:
|
||||||
|
RecordPrimitiveRestartEnable(gd, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.PrimitiveTopology:
|
||||||
|
RecordPrimitiveTopology(extendedStateApi, commandBuffer);
|
||||||
|
break;
|
||||||
|
case DirtyFlags.DepthBiasEnable:
|
||||||
|
RecordDepthBiasEnable(extendedState2Api, commandBuffer);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.Scissor))
|
dirtyFlags &= ~currentFlag;
|
||||||
{
|
|
||||||
RecordScissor(api, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.Stencil))
|
|
||||||
{
|
|
||||||
RecordStencilMasks(api, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.Viewport))
|
|
||||||
{
|
|
||||||
RecordViewport(api, commandBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirty.HasFlag(DirtyFlags.FeedbackLoop) && gd.Capabilities.SupportsDynamicAttachmentFeedbackLoop)
|
|
||||||
{
|
|
||||||
RecordFeedbackLoop(gd.DynamicFeedbackLoopApi, commandBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_dirty = DirtyFlags.None;
|
_dirty = DirtyFlags.None;
|
||||||
|
@ -162,15 +382,27 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
api.CmdSetDepthBias(commandBuffer, _depthBiasConstantFactor, _depthBiasClamp, _depthBiasSlopeFactor);
|
api.CmdSetDepthBias(commandBuffer, _depthBiasConstantFactor, _depthBiasClamp, _depthBiasSlopeFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RecordScissor(Vk api, CommandBuffer commandBuffer)
|
private readonly void RecordDepthBiasEnable(ExtExtendedDynamicState2 gd, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
gd.CmdSetDepthBiasEnable(commandBuffer, _depthBiasEnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RecordScissor(VulkanRenderer gd, CommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
if (ScissorsCount != 0)
|
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 RecordStencilMasks(Vk api, CommandBuffer commandBuffer)
|
private readonly void RecordStencil(Vk api, CommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
api.CmdSetStencilCompareMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backCompareMask);
|
api.CmdSetStencilCompareMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backCompareMask);
|
||||||
api.CmdSetStencilWriteMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backWriteMask);
|
api.CmdSetStencilWriteMask(commandBuffer, StencilFaceFlags.FaceBackBit, _backWriteMask);
|
||||||
|
@ -180,12 +412,107 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontReference);
|
api.CmdSetStencilReference(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RecordViewport(Vk api, CommandBuffer commandBuffer)
|
private readonly void RecordStencilTestAndOp(ExtExtendedDynamicState api, CommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
if (ViewportsCount != 0)
|
api.CmdSetStencilTestEnable(commandBuffer, StencilTestEnable);
|
||||||
{
|
|
||||||
api.CmdSetViewport(commandBuffer, 0, ViewportsCount, Viewports.AsSpan());
|
api.CmdSetStencilOp(commandBuffer, StencilFaceFlags.FaceBackBit, _backFailOp, _backPassOp, _backDepthFailOp, _backCompareOp);
|
||||||
|
api.CmdSetStencilOp(commandBuffer, StencilFaceFlags.FaceFrontBit, _frontFailOp, _frontPassOp, _frontDepthFailOp, _frontCompareOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RecordViewport(VulkanRenderer gd, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
if (ViewportsCount == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gd.Capabilities.SupportsExtendedDynamicState)
|
||||||
|
{
|
||||||
|
gd.ExtendedDynamicStateApi.CmdSetViewportWithCount(commandBuffer, ViewportsCount, Viewports.AsSpan());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gd.Api.CmdSetViewport(commandBuffer, 0, ViewportsCount, Viewports.AsSpan());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly void RecordCullMode(ExtExtendedDynamicState api, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
api.CmdSetCullMode(commandBuffer, CullMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly void RecordFrontFace(ExtExtendedDynamicState api, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
api.CmdSetFrontFace(commandBuffer, _frontFace);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly void RecordDepthTestBool(ExtExtendedDynamicState api, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
api.CmdSetDepthTestEnable(commandBuffer, DepthTestEnable);
|
||||||
|
|
||||||
|
api.CmdSetDepthWriteEnable(commandBuffer, DepthWriteEnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly void RecordDepthTestCompareOp(ExtExtendedDynamicState api, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
api.CmdSetDepthCompareOp(commandBuffer, _depthCompareOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly void RecordRasterizationDiscard(ExtExtendedDynamicState2 extendedDynamicState2Api, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
extendedDynamicState2Api.CmdSetRasterizerDiscardEnable(commandBuffer, _discard);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly void RecordPrimitiveRestartEnable(VulkanRenderer gd, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
bool primitiveRestartEnable = _primitiveRestartEnable;
|
||||||
|
|
||||||
|
bool topologySupportsRestart;
|
||||||
|
|
||||||
|
if (gd.Capabilities.SupportsPrimitiveTopologyListRestart)
|
||||||
|
{
|
||||||
|
topologySupportsRestart = gd.Capabilities.SupportsPrimitiveTopologyPatchListRestart ||
|
||||||
|
Topology != PrimitiveTopology.PatchList;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
topologySupportsRestart = Topology == PrimitiveTopology.LineStrip ||
|
||||||
|
Topology == PrimitiveTopology.TriangleStrip ||
|
||||||
|
Topology == PrimitiveTopology.TriangleFan ||
|
||||||
|
Topology == PrimitiveTopology.LineStripWithAdjacency ||
|
||||||
|
Topology == PrimitiveTopology.TriangleStripWithAdjacency;
|
||||||
|
}
|
||||||
|
|
||||||
|
primitiveRestartEnable &= topologySupportsRestart;
|
||||||
|
|
||||||
|
// Cannot disable primitiveRestartEnable for these Topologies on MacOS.
|
||||||
|
if (gd.IsMoltenVk)
|
||||||
|
{
|
||||||
|
primitiveRestartEnable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
gd.ExtendedDynamicState2Api.CmdSetPrimitiveRestartEnable(commandBuffer, primitiveRestartEnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly void RecordPrimitiveTopology(ExtExtendedDynamicState extendedDynamicStateApi, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
extendedDynamicStateApi.CmdSetPrimitiveTopology(commandBuffer, Topology);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly void RecordLogicOp(ExtExtendedDynamicState2 extendedDynamicState2Api, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
extendedDynamicState2Api.CmdSetLogicOp(commandBuffer, _logicOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly void RecordPatchControlPoints(ExtExtendedDynamicState2 extendedDynamicState2Api, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
extendedDynamicState2Api.CmdSetPatchControlPoints(commandBuffer, _patchControlPoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly void RecordLineWidth(Vk api, CommandBuffer commandBuffer)
|
||||||
|
{
|
||||||
|
api.CmdSetLineWidth(commandBuffer, _lineWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly void RecordFeedbackLoop(ExtAttachmentFeedbackLoopDynamicState api, CommandBuffer commandBuffer)
|
private readonly void RecordFeedbackLoop(ExtAttachmentFeedbackLoopDynamicState api, CommandBuffer commandBuffer)
|
||||||
|
|
|
@ -9,12 +9,16 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRenderTarget(TextureView view, uint width, uint height)
|
public void SetRenderTarget(TextureView view, uint width, uint height, bool signalChange = true)
|
||||||
{
|
{
|
||||||
CreateFramebuffer(view, width, height);
|
CreateFramebuffer(view, width, height);
|
||||||
CreateRenderPass();
|
CreateRenderPass();
|
||||||
|
|
||||||
|
if (signalChange)
|
||||||
|
{
|
||||||
SignalStateChange();
|
SignalStateChange();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void CreateFramebuffer(TextureView view, uint width, uint height)
|
private void CreateFramebuffer(TextureView view, uint width, uint height)
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,23 +11,17 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
public ulong Id0;
|
public ulong Id0;
|
||||||
public ulong Id1;
|
public ulong Id1;
|
||||||
|
|
||||||
public ulong Id2;
|
public ulong Id2;
|
||||||
public ulong Id3;
|
public ulong Id3;
|
||||||
|
|
||||||
public ulong Id4;
|
private readonly uint VertexAttributeDescriptionsCount => (byte)((Id0 >> 38) & 0xFF);
|
||||||
public ulong Id5;
|
private readonly uint VertexBindingDescriptionsCount => (byte)((Id0 >> 46) & 0xFF);
|
||||||
public ulong Id6;
|
private readonly uint ColorBlendAttachmentStateCount => (byte)((Id1 >> 8) & 0xFF);
|
||||||
|
private readonly bool HasDepthStencil => ((Id1 >> 63) & 0x1) != 0UL;
|
||||||
public ulong Id7;
|
|
||||||
public ulong Id8;
|
|
||||||
|
|
||||||
private readonly uint VertexAttributeDescriptionsCount => (byte)((Id5 >> 38) & 0xFF);
|
|
||||||
private readonly uint VertexBindingDescriptionsCount => (byte)((Id5 >> 46) & 0xFF);
|
|
||||||
private readonly uint ColorBlendAttachmentStateCount => (byte)((Id6 >> 8) & 0xFF);
|
|
||||||
private readonly bool HasDepthStencil => ((Id6 >> 63) & 0x1) != 0UL;
|
|
||||||
|
|
||||||
public Array32<VertexInputAttributeDescription> VertexAttributeDescriptions;
|
public Array32<VertexInputAttributeDescription> VertexAttributeDescriptions;
|
||||||
public Array33<VertexInputBindingDescription> VertexBindingDescriptions;
|
public Array32<VertexInputBindingDescription> VertexBindingDescriptions;
|
||||||
public Array8<PipelineColorBlendAttachmentState> ColorBlendAttachmentState;
|
public Array8<PipelineColorBlendAttachmentState> ColorBlendAttachmentState;
|
||||||
public Array9<Format> AttachmentFormats;
|
public Array9<Format> AttachmentFormats;
|
||||||
public uint AttachmentIntegerFormatMask;
|
public uint AttachmentIntegerFormatMask;
|
||||||
|
@ -40,9 +34,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
public bool Equals(ref PipelineUid other)
|
public bool Equals(ref PipelineUid other)
|
||||||
{
|
{
|
||||||
if (!Unsafe.As<ulong, Vector256<byte>>(ref Id0).Equals(Unsafe.As<ulong, Vector256<byte>>(ref other.Id0)) ||
|
if (!Unsafe.As<ulong, Vector256<byte>>(ref Id0).Equals(Unsafe.As<ulong, Vector256<byte>>(ref other.Id0)))
|
||||||
!Unsafe.As<ulong, Vector256<byte>>(ref Id4).Equals(Unsafe.As<ulong, Vector256<byte>>(ref other.Id4)) ||
|
|
||||||
!Unsafe.As<ulong, Vector128<byte>>(ref Id7).Equals(Unsafe.As<ulong, Vector128<byte>>(ref other.Id7)))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -80,12 +72,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
ulong hash64 = Id0 * 23 ^
|
ulong hash64 = Id0 * 23 ^
|
||||||
Id1 * 23 ^
|
Id1 * 23 ^
|
||||||
Id2 * 23 ^
|
Id2 * 23 ^
|
||||||
Id3 * 23 ^
|
Id3 * 23;
|
||||||
Id4 * 23 ^
|
|
||||||
Id5 * 23 ^
|
|
||||||
Id6 * 23 ^
|
|
||||||
Id7 * 23 ^
|
|
||||||
Id8 * 23;
|
|
||||||
|
|
||||||
for (int i = 0; i < (int)VertexAttributeDescriptionsCount; i++)
|
for (int i = 0; i < (int)VertexAttributeDescriptionsCount; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using PrimitiveTopology = Silk.NET.Vulkan.PrimitiveTopology;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Vulkan
|
namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
|
@ -538,7 +539,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
public void CreateBackgroundComputePipeline()
|
public void CreateBackgroundComputePipeline()
|
||||||
{
|
{
|
||||||
PipelineState pipeline = new();
|
PipelineState pipeline = new();
|
||||||
pipeline.Initialize();
|
pipeline.Initialize(_gd.Capabilities);
|
||||||
|
|
||||||
pipeline.Stages[0] = _shaders[0].GetInfo();
|
pipeline.Stages[0] = _shaders[0].GetInfo();
|
||||||
pipeline.StagesCount = 1;
|
pipeline.StagesCount = 1;
|
||||||
|
|
|
@ -73,16 +73,22 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
_buffer = autoBuffer;
|
_buffer = autoBuffer;
|
||||||
|
|
||||||
|
if (!gd.Capabilities.SupportsExtendedDynamicState)
|
||||||
|
{
|
||||||
state.Internal.VertexBindingDescriptions[DescriptorIndex].Stride = (uint)stride;
|
state.Internal.VertexBindingDescriptions[DescriptorIndex].Stride = (uint)stride;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
autoBuffer = gd.BufferManager.GetBuffer(cbs.CommandBuffer, _handle, false, out int size);
|
autoBuffer = gd.BufferManager.GetBuffer(cbs.CommandBuffer, _handle, false, out int size);
|
||||||
|
|
||||||
|
if (!gd.Capabilities.SupportsExtendedDynamicState)
|
||||||
|
{
|
||||||
// The original stride must be reapplied in case it was rewritten.
|
// The original stride must be reapplied in case it was rewritten.
|
||||||
state.Internal.VertexBindingDescriptions[DescriptorIndex].Stride = (uint)_stride;
|
state.Internal.VertexBindingDescriptions[DescriptorIndex].Stride = (uint)_stride;
|
||||||
|
}
|
||||||
|
|
||||||
if (_offset >= size)
|
if (_offset >= size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
{
|
{
|
||||||
if (_count != 0)
|
if (_count != 0)
|
||||||
{
|
{
|
||||||
if (_gd.Capabilities.SupportsExtendedDynamicState)
|
if (_gd.Capabilities.SupportsExtendedDynamicState && (_gd.SupportsMTL31 || !_gd.IsMoltenVk))
|
||||||
{
|
{
|
||||||
_gd.ExtendedDynamicStateApi.CmdBindVertexBuffers2(
|
_gd.ExtendedDynamicStateApi.CmdBindVertexBuffers2(
|
||||||
cbs.CommandBuffer,
|
cbs.CommandBuffer,
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
private static readonly string[] _desirableExtensions = {
|
private static readonly string[] _desirableExtensions = {
|
||||||
ExtConditionalRendering.ExtensionName,
|
ExtConditionalRendering.ExtensionName,
|
||||||
ExtExtendedDynamicState.ExtensionName,
|
ExtExtendedDynamicState.ExtensionName,
|
||||||
|
ExtExtendedDynamicState2.ExtensionName,
|
||||||
ExtTransformFeedback.ExtensionName,
|
ExtTransformFeedback.ExtensionName,
|
||||||
KhrDrawIndirectCount.ExtensionName,
|
KhrDrawIndirectCount.ExtensionName,
|
||||||
KhrPushDescriptor.ExtensionName,
|
KhrPushDescriptor.ExtensionName,
|
||||||
|
@ -314,6 +315,17 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
features2.PNext = &supportedFeaturesCustomBorderColor;
|
features2.PNext = &supportedFeaturesCustomBorderColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PhysicalDeviceExtendedDynamicState2FeaturesEXT supportedFeaturesExtExtendedDynamicState2 = new()
|
||||||
|
{
|
||||||
|
SType = StructureType.PhysicalDeviceExtendedDynamicState2FeaturesExt,
|
||||||
|
PNext = features2.PNext,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (physicalDevice.IsDeviceExtensionPresent(ExtExtendedDynamicState2.ExtensionName))
|
||||||
|
{
|
||||||
|
features2.PNext = &supportedFeaturesExtExtendedDynamicState2;
|
||||||
|
}
|
||||||
|
|
||||||
PhysicalDevicePrimitiveTopologyListRestartFeaturesEXT supportedFeaturesPrimitiveTopologyListRestart = new()
|
PhysicalDevicePrimitiveTopologyListRestartFeaturesEXT supportedFeaturesPrimitiveTopologyListRestart = new()
|
||||||
{
|
{
|
||||||
SType = StructureType.PhysicalDevicePrimitiveTopologyListRestartFeaturesExt,
|
SType = StructureType.PhysicalDevicePrimitiveTopologyListRestartFeaturesExt,
|
||||||
|
@ -416,6 +428,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
TessellationShader = supportedFeatures.TessellationShader,
|
TessellationShader = supportedFeatures.TessellationShader,
|
||||||
VertexPipelineStoresAndAtomics = supportedFeatures.VertexPipelineStoresAndAtomics,
|
VertexPipelineStoresAndAtomics = supportedFeatures.VertexPipelineStoresAndAtomics,
|
||||||
RobustBufferAccess = useRobustBufferAccess,
|
RobustBufferAccess = useRobustBufferAccess,
|
||||||
|
WideLines = supportedFeatures.WideLines,
|
||||||
SampleRateShading = supportedFeatures.SampleRateShading,
|
SampleRateShading = supportedFeatures.SampleRateShading,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -473,6 +486,20 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
pExtendedFeatures = &featuresExtendedDynamicState;
|
pExtendedFeatures = &featuresExtendedDynamicState;
|
||||||
|
|
||||||
|
if (physicalDevice.IsDeviceExtensionPresent(ExtExtendedDynamicState2.ExtensionName))
|
||||||
|
{
|
||||||
|
var featuresExtendedDynamicState2 = new PhysicalDeviceExtendedDynamicState2FeaturesEXT()
|
||||||
|
{
|
||||||
|
SType = StructureType.PhysicalDeviceExtendedDynamicState2FeaturesExt,
|
||||||
|
PNext = pExtendedFeatures,
|
||||||
|
ExtendedDynamicState2 = supportedFeaturesExtExtendedDynamicState2.ExtendedDynamicState2,
|
||||||
|
ExtendedDynamicState2LogicOp = supportedFeaturesExtExtendedDynamicState2.ExtendedDynamicState2LogicOp,
|
||||||
|
ExtendedDynamicState2PatchControlPoints = supportedFeaturesExtExtendedDynamicState2.ExtendedDynamicState2PatchControlPoints,
|
||||||
|
};
|
||||||
|
|
||||||
|
pExtendedFeatures = &featuresExtendedDynamicState2;
|
||||||
|
}
|
||||||
|
|
||||||
var featuresVk11 = new PhysicalDeviceVulkan11Features
|
var featuresVk11 = new PhysicalDeviceVulkan11Features
|
||||||
{
|
{
|
||||||
SType = StructureType.PhysicalDeviceVulkan11Features,
|
SType = StructureType.PhysicalDeviceVulkan11Features,
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
internal KhrSwapchain SwapchainApi { get; private set; }
|
internal KhrSwapchain SwapchainApi { get; private set; }
|
||||||
internal ExtConditionalRendering ConditionalRenderingApi { get; private set; }
|
internal ExtConditionalRendering ConditionalRenderingApi { get; private set; }
|
||||||
internal ExtExtendedDynamicState ExtendedDynamicStateApi { get; private set; }
|
internal ExtExtendedDynamicState ExtendedDynamicStateApi { get; private set; }
|
||||||
|
internal ExtExtendedDynamicState2 ExtendedDynamicState2Api { get; private set; }
|
||||||
internal KhrPushDescriptor PushDescriptorApi { get; private set; }
|
internal KhrPushDescriptor PushDescriptorApi { get; private set; }
|
||||||
internal ExtTransformFeedback TransformFeedbackApi { get; private set; }
|
internal ExtTransformFeedback TransformFeedbackApi { get; private set; }
|
||||||
internal KhrDrawIndirectCount DrawIndirectCountApi { get; private set; }
|
internal KhrDrawIndirectCount DrawIndirectCountApi { get; private set; }
|
||||||
|
@ -92,6 +93,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
internal bool IsIntelArc { get; private set; }
|
internal bool IsIntelArc { get; private set; }
|
||||||
internal bool IsQualcommProprietary { get; private set; }
|
internal bool IsQualcommProprietary { get; private set; }
|
||||||
internal bool IsMoltenVk { get; private set; }
|
internal bool IsMoltenVk { get; private set; }
|
||||||
|
internal bool SupportsMTL31 { get; private set; }
|
||||||
internal bool IsTBDR { get; private set; }
|
internal bool IsTBDR { get; private set; }
|
||||||
internal bool IsSharedMemory { get; private set; }
|
internal bool IsSharedMemory { get; private set; }
|
||||||
|
|
||||||
|
@ -117,6 +119,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
// Any device running on MacOS is using MoltenVK, even Intel and AMD vendors.
|
// Any device running on MacOS is using MoltenVK, even Intel and AMD vendors.
|
||||||
if (IsMoltenVk = OperatingSystem.IsMacOS())
|
if (IsMoltenVk = OperatingSystem.IsMacOS())
|
||||||
MVKInitialization.Initialize();
|
MVKInitialization.Initialize();
|
||||||
|
|
||||||
|
SupportsMTL31 = OperatingSystem.IsMacOSVersionAtLeast(14);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VulkanRenderer Create(
|
public static VulkanRenderer Create(
|
||||||
|
@ -139,6 +143,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
ExtendedDynamicStateApi = extendedDynamicStateApi;
|
ExtendedDynamicStateApi = extendedDynamicStateApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Api.TryGetDeviceExtension(_instance.Instance, _device, out ExtExtendedDynamicState2 extendedDynamicState2Api))
|
||||||
|
{
|
||||||
|
ExtendedDynamicState2Api = extendedDynamicState2Api;
|
||||||
|
}
|
||||||
|
|
||||||
if (Api.TryGetDeviceExtension(_instance.Instance, _device, out KhrPushDescriptor pushDescriptorApi))
|
if (Api.TryGetDeviceExtension(_instance.Instance, _device, out KhrPushDescriptor pushDescriptorApi))
|
||||||
{
|
{
|
||||||
PushDescriptorApi = pushDescriptorApi;
|
PushDescriptorApi = pushDescriptorApi;
|
||||||
|
@ -233,6 +242,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
SType = StructureType.PhysicalDevicePrimitiveTopologyListRestartFeaturesExt,
|
SType = StructureType.PhysicalDevicePrimitiveTopologyListRestartFeaturesExt,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PhysicalDeviceExtendedDynamicState2FeaturesEXT featuresExtendedDynamicState2 = new()
|
||||||
|
{
|
||||||
|
SType = StructureType.PhysicalDeviceExtendedDynamicState2FeaturesExt,
|
||||||
|
};
|
||||||
|
|
||||||
PhysicalDeviceRobustness2FeaturesEXT featuresRobustness2 = new()
|
PhysicalDeviceRobustness2FeaturesEXT featuresRobustness2 = new()
|
||||||
{
|
{
|
||||||
SType = StructureType.PhysicalDeviceRobustness2FeaturesExt,
|
SType = StructureType.PhysicalDeviceRobustness2FeaturesExt,
|
||||||
|
@ -273,6 +287,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
features2.PNext = &featuresPrimitiveTopologyListRestart;
|
features2.PNext = &featuresPrimitiveTopologyListRestart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_physicalDevice.IsDeviceExtensionPresent(ExtExtendedDynamicState2.ExtensionName))
|
||||||
|
{
|
||||||
|
featuresExtendedDynamicState2.PNext = features2.PNext;
|
||||||
|
features2.PNext = &featuresExtendedDynamicState2;
|
||||||
|
}
|
||||||
|
|
||||||
if (_physicalDevice.IsDeviceExtensionPresent("VK_EXT_robustness2"))
|
if (_physicalDevice.IsDeviceExtensionPresent("VK_EXT_robustness2"))
|
||||||
{
|
{
|
||||||
featuresRobustness2.PNext = features2.PNext;
|
featuresRobustness2.PNext = features2.PNext;
|
||||||
|
@ -406,6 +426,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
properties.Limits.FramebufferDepthSampleCounts &
|
properties.Limits.FramebufferDepthSampleCounts &
|
||||||
properties.Limits.FramebufferStencilSampleCounts;
|
properties.Limits.FramebufferStencilSampleCounts;
|
||||||
|
|
||||||
|
// Temporarily disable this, can be added back at a later date, make it easy to re-enable.
|
||||||
|
// Disabled because currently causing Device Lost error on NVIDIA.
|
||||||
|
featuresExtendedDynamicState2.ExtendedDynamicState2PatchControlPoints = false;
|
||||||
|
|
||||||
Capabilities = new HardwareCapabilities(
|
Capabilities = new HardwareCapabilities(
|
||||||
_physicalDevice.IsDeviceExtensionPresent("VK_EXT_index_type_uint8"),
|
_physicalDevice.IsDeviceExtensionPresent("VK_EXT_index_type_uint8"),
|
||||||
supportsCustomBorderColor,
|
supportsCustomBorderColor,
|
||||||
|
@ -422,6 +446,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
features2.Features.ShaderStorageImageMultisample,
|
features2.Features.ShaderStorageImageMultisample,
|
||||||
_physicalDevice.IsDeviceExtensionPresent(ExtConditionalRendering.ExtensionName),
|
_physicalDevice.IsDeviceExtensionPresent(ExtConditionalRendering.ExtensionName),
|
||||||
_physicalDevice.IsDeviceExtensionPresent(ExtExtendedDynamicState.ExtensionName),
|
_physicalDevice.IsDeviceExtensionPresent(ExtExtendedDynamicState.ExtensionName),
|
||||||
|
featuresExtendedDynamicState2,
|
||||||
|
_physicalDevice.PhysicalDeviceProperties.Limits.MaxTessellationPatchSize,
|
||||||
features2.Features.MultiViewport && !(IsMoltenVk && Vendor == Vendor.Amd), // Workaround for AMD on MoltenVK issue
|
features2.Features.MultiViewport && !(IsMoltenVk && Vendor == Vendor.Amd), // Workaround for AMD on MoltenVK issue
|
||||||
featuresRobustness2.NullDescriptor || IsMoltenVk,
|
featuresRobustness2.NullDescriptor || IsMoltenVk,
|
||||||
supportsPushDescriptors && !IsMoltenVk,
|
supportsPushDescriptors && !IsMoltenVk,
|
||||||
|
@ -437,6 +463,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
_physicalDevice.IsDeviceExtensionPresent("VK_NV_viewport_array2"),
|
_physicalDevice.IsDeviceExtensionPresent("VK_NV_viewport_array2"),
|
||||||
_physicalDevice.IsDeviceExtensionPresent(ExtExternalMemoryHost.ExtensionName),
|
_physicalDevice.IsDeviceExtensionPresent(ExtExternalMemoryHost.ExtensionName),
|
||||||
supportsDepthClipControl && featuresDepthClipControl.DepthClipControl,
|
supportsDepthClipControl && featuresDepthClipControl.DepthClipControl,
|
||||||
|
_physicalDevice.PhysicalDeviceFeatures.WideLines,
|
||||||
supportsAttachmentFeedbackLoop && featuresAttachmentFeedbackLoop.AttachmentFeedbackLoopLayout,
|
supportsAttachmentFeedbackLoop && featuresAttachmentFeedbackLoop.AttachmentFeedbackLoopLayout,
|
||||||
supportsDynamicAttachmentFeedbackLoop && featuresDynamicAttachmentFeedbackLoop.AttachmentFeedbackLoopDynamicState,
|
supportsDynamicAttachmentFeedbackLoop && featuresDynamicAttachmentFeedbackLoop.AttachmentFeedbackLoopDynamicState,
|
||||||
propertiesSubgroup.SubgroupSize,
|
propertiesSubgroup.SubgroupSize,
|
||||||
|
@ -772,6 +799,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
supportsViewportSwizzle: false,
|
supportsViewportSwizzle: false,
|
||||||
supportsIndirectParameters: true,
|
supportsIndirectParameters: true,
|
||||||
supportsDepthClipControl: Capabilities.SupportsDepthClipControl,
|
supportsDepthClipControl: Capabilities.SupportsDepthClipControl,
|
||||||
|
supportsExtendedDynamicState: Capabilities.SupportsExtendedDynamicState,
|
||||||
|
supportsExtendedDynamicState2: Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2,
|
||||||
|
supportsLogicOpDynamicState: Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2LogicOp,
|
||||||
|
supportsPatchControlPointsDynamicState: Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2PatchControlPoints,
|
||||||
uniformBufferSetIndex: PipelineBase.UniformSetIndex,
|
uniformBufferSetIndex: PipelineBase.UniformSetIndex,
|
||||||
storageBufferSetIndex: PipelineBase.StorageSetIndex,
|
storageBufferSetIndex: PipelineBase.StorageSetIndex,
|
||||||
textureSetIndex: PipelineBase.TextureSetIndex,
|
textureSetIndex: PipelineBase.TextureSetIndex,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.HLE.HOS.Applets.Browser;
|
using Ryujinx.HLE.HOS.Applets.Browser;
|
||||||
|
using Ryujinx.HLE.HOS.Applets.Cabinet;
|
||||||
using Ryujinx.HLE.HOS.Applets.Dummy;
|
using Ryujinx.HLE.HOS.Applets.Dummy;
|
||||||
using Ryujinx.HLE.HOS.Applets.Error;
|
using Ryujinx.HLE.HOS.Applets.Error;
|
||||||
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
|
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
|
||||||
|
@ -31,6 +32,8 @@ namespace Ryujinx.HLE.HOS.Applets
|
||||||
case AppletId.MiiEdit:
|
case AppletId.MiiEdit:
|
||||||
Logger.Warning?.Print(LogClass.Application, $"Please use the MiiEdit inside File/Open Applet");
|
Logger.Warning?.Print(LogClass.Application, $"Please use the MiiEdit inside File/Open Applet");
|
||||||
return new DummyApplet(system);
|
return new DummyApplet(system);
|
||||||
|
case AppletId.Cabinet:
|
||||||
|
return new CabinetApplet(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Application, $"Applet {applet} not implemented!");
|
Logger.Warning?.Print(LogClass.Application, $"Applet {applet} not implemented!");
|
||||||
|
|
195
src/Ryujinx.HLE/HOS/Applets/Cabinet/CabinetApplet.cs
Normal file
195
src/Ryujinx.HLE/HOS/Applets/Cabinet/CabinetApplet.cs
Normal file
|
@ -0,0 +1,195 @@
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
|
using Ryujinx.Common.Memory;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Hid.HidServer;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Hid;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Nfc.Nfp;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager;
|
||||||
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Ryujinx.HLE.HOS.Applets.Cabinet
|
||||||
|
{
|
||||||
|
internal unsafe class CabinetApplet : IApplet
|
||||||
|
{
|
||||||
|
private readonly Horizon _system;
|
||||||
|
private AppletSession _normalSession;
|
||||||
|
|
||||||
|
public event EventHandler AppletStateChanged;
|
||||||
|
|
||||||
|
public CabinetApplet(Horizon system)
|
||||||
|
{
|
||||||
|
_system = system;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultCode Start(AppletSession normalSession, AppletSession interactiveSession)
|
||||||
|
{
|
||||||
|
_normalSession = normalSession;
|
||||||
|
|
||||||
|
byte[] launchParams = _normalSession.Pop();
|
||||||
|
byte[] startParamBytes = _normalSession.Pop();
|
||||||
|
|
||||||
|
StartParamForAmiiboSettings startParam = IApplet.ReadStruct<StartParamForAmiiboSettings>(startParamBytes);
|
||||||
|
|
||||||
|
Logger.Stub?.PrintStub(LogClass.ServiceAm, $"CabinetApplet Start Type: {startParam.Type}");
|
||||||
|
|
||||||
|
switch (startParam.Type)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
StartNicknameAndOwnerSettings(ref startParam);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 3:
|
||||||
|
StartFormatter(ref startParam);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Logger.Error?.Print(LogClass.ServiceAm, $"Unknown AmiiboSettings type: {startParam.Type}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare the response
|
||||||
|
ReturnValueForAmiiboSettings returnValue = new()
|
||||||
|
{
|
||||||
|
AmiiboSettingsReturnFlag = (byte)AmiiboSettingsReturnFlag.HasRegisterInfo,
|
||||||
|
DeviceHandle = new DeviceHandle
|
||||||
|
{
|
||||||
|
Handle = 0 // Dummy device handle
|
||||||
|
},
|
||||||
|
RegisterInfo = startParam.RegisterInfo
|
||||||
|
};
|
||||||
|
|
||||||
|
// Push the response
|
||||||
|
_normalSession.Push(BuildResponse(returnValue));
|
||||||
|
AppletStateChanged?.Invoke(this, null);
|
||||||
|
|
||||||
|
_system.ReturnFocus();
|
||||||
|
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultCode GetResult()
|
||||||
|
{
|
||||||
|
_system.Device.System.NfpDevices.RemoveAt(0);
|
||||||
|
return ResultCode.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartFormatter(ref StartParamForAmiiboSettings startParam)
|
||||||
|
{
|
||||||
|
// Initialize RegisterInfo
|
||||||
|
startParam.RegisterInfo = new RegisterInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartNicknameAndOwnerSettings(ref StartParamForAmiiboSettings startParam)
|
||||||
|
{
|
||||||
|
_system.Device.UIHandler.DisplayCabinetDialog(out string newName);
|
||||||
|
byte[] nameBytes = Encoding.UTF8.GetBytes(newName);
|
||||||
|
Array41<byte> nickName = new Array41<byte>();
|
||||||
|
nameBytes.CopyTo(nickName.AsSpan());
|
||||||
|
startParam.RegisterInfo.Nickname = nickName;
|
||||||
|
NfpDevice devicePlayer1 = new()
|
||||||
|
{
|
||||||
|
NpadIdType = NpadIdType.Player1,
|
||||||
|
Handle = HidUtils.GetIndexFromNpadIdType(NpadIdType.Player1),
|
||||||
|
State = NfpDeviceState.SearchingForTag,
|
||||||
|
};
|
||||||
|
_system.Device.System.NfpDevices.Add(devicePlayer1);
|
||||||
|
_system.Device.UIHandler.DisplayCabinetMessageDialog();
|
||||||
|
string amiiboId = string.Empty;
|
||||||
|
bool scanned = false;
|
||||||
|
while (!scanned)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _system.Device.System.NfpDevices.Count; i++)
|
||||||
|
{
|
||||||
|
if (_system.Device.System.NfpDevices[i].State == NfpDeviceState.TagFound)
|
||||||
|
{
|
||||||
|
amiiboId = _system.Device.System.NfpDevices[i].AmiiboId;
|
||||||
|
scanned = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VirtualAmiibo.UpdateNickName(amiiboId, newName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] BuildResponse(ReturnValueForAmiiboSettings returnValue)
|
||||||
|
{
|
||||||
|
int size = Unsafe.SizeOf<ReturnValueForAmiiboSettings>();
|
||||||
|
byte[] bytes = new byte[size];
|
||||||
|
|
||||||
|
fixed (byte* bytesPtr = bytes)
|
||||||
|
{
|
||||||
|
Unsafe.Write(bytesPtr, returnValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T ReadStruct<T>(byte[] data) where T : unmanaged
|
||||||
|
{
|
||||||
|
if (data.Length < Unsafe.SizeOf<T>())
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Not enough data to read the struct");
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed (byte* dataPtr = data)
|
||||||
|
{
|
||||||
|
return Unsafe.Read<T>(dataPtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Structs
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
|
public unsafe struct TagInfo
|
||||||
|
{
|
||||||
|
public fixed byte Data[0x58];
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
|
public unsafe struct StartParamForAmiiboSettings
|
||||||
|
{
|
||||||
|
public byte ZeroValue; // Left at zero by sdknso
|
||||||
|
public byte Type;
|
||||||
|
public byte Flags;
|
||||||
|
public byte AmiiboSettingsStartParamOffset28;
|
||||||
|
public ulong AmiiboSettingsStartParam0;
|
||||||
|
|
||||||
|
public TagInfo TagInfo; // Only enabled when flags bit 1 is set
|
||||||
|
public RegisterInfo RegisterInfo; // Only enabled when flags bit 2 is set
|
||||||
|
|
||||||
|
public fixed byte StartParamExtraData[0x20];
|
||||||
|
|
||||||
|
public fixed byte Reserved[0x24];
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
|
public unsafe struct ReturnValueForAmiiboSettings
|
||||||
|
{
|
||||||
|
public byte AmiiboSettingsReturnFlag;
|
||||||
|
private byte Padding1;
|
||||||
|
private byte Padding2;
|
||||||
|
private byte Padding3;
|
||||||
|
public DeviceHandle DeviceHandle;
|
||||||
|
public TagInfo TagInfo;
|
||||||
|
public RegisterInfo RegisterInfo;
|
||||||
|
public fixed byte IgnoredBySdknso[0x24];
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
|
public struct DeviceHandle
|
||||||
|
{
|
||||||
|
public ulong Handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum AmiiboSettingsReturnFlag : byte
|
||||||
|
{
|
||||||
|
Cancel = 0,
|
||||||
|
HasTagInfo = 2,
|
||||||
|
HasRegisterInfo = 4,
|
||||||
|
HasTagInfoAndRegisterInfo = 6
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -93,6 +93,13 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||||
return registerInfo;
|
return registerInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void UpdateNickName(string amiiboId, string newNickName)
|
||||||
|
{
|
||||||
|
VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId);
|
||||||
|
virtualAmiiboFile.NickName = newNickName;
|
||||||
|
SaveAmiiboFile(virtualAmiiboFile);
|
||||||
|
}
|
||||||
|
|
||||||
public static bool OpenApplicationArea(string amiiboId, uint applicationAreaId)
|
public static bool OpenApplicationArea(string amiiboId, uint applicationAreaId)
|
||||||
{
|
{
|
||||||
VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId);
|
VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId);
|
||||||
|
|
|
@ -24,6 +24,18 @@ namespace Ryujinx.HLE.UI
|
||||||
/// <returns>True when OK is pressed, False otherwise.</returns>
|
/// <returns>True when OK is pressed, False otherwise.</returns>
|
||||||
bool DisplayMessageDialog(ControllerAppletUIArgs args);
|
bool DisplayMessageDialog(ControllerAppletUIArgs args);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Displays an Input Dialog box to the user so they can enter the Amiibo's new name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userText">Text that the user entered. Set to `null` on internal errors</param>
|
||||||
|
/// <returns>True when OK is pressed, False otherwise. Also returns True on internal errors</returns>
|
||||||
|
bool DisplayCabinetDialog(out string userText);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Displays a Message Dialog box to the user to notify them to scan the Amiibo.
|
||||||
|
/// </summary>
|
||||||
|
void DisplayCabinetMessageDialog();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tell the UI that we need to transition to another program.
|
/// Tell the UI that we need to transition to another program.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
|
using LibHac.Tools.Fs;
|
||||||
using Ryujinx.Common.Configuration;
|
using Ryujinx.Common.Configuration;
|
||||||
using Ryujinx.Common.Configuration.Hid;
|
using Ryujinx.Common.Configuration.Hid;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
|
@ -485,6 +486,19 @@ namespace Ryujinx.Headless.SDL2
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool DisplayCabinetDialog(out string userText)
|
||||||
|
{
|
||||||
|
// SDL2 doesn't support input dialogs
|
||||||
|
userText = "Ryujinx";
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisplayCabinetMessageDialog()
|
||||||
|
{
|
||||||
|
SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags.SDL_MESSAGEBOX_INFORMATION, "Cabinet Dialog", "Please scan your Amiibo now.", WindowHandle);
|
||||||
|
}
|
||||||
|
|
||||||
public bool DisplayMessageDialog(ControllerAppletUIArgs args)
|
public bool DisplayMessageDialog(ControllerAppletUIArgs args)
|
||||||
{
|
{
|
||||||
if (_ignoreControllerApplet) return false;
|
if (_ignoreControllerApplet) return false;
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "مطلقا",
|
"Never": "مطلقا",
|
||||||
"SwkbdMinCharacters": "يجب أن يبلغ طوله {0} حرفا على الأقل",
|
"SwkbdMinCharacters": "يجب أن يبلغ طوله {0} حرفا على الأقل",
|
||||||
"SwkbdMinRangeCharacters": "يجب أن يتكون من {0}-{1} حرفا",
|
"SwkbdMinRangeCharacters": "يجب أن يتكون من {0}-{1} حرفا",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "لوحة المفاتيح البرمجية",
|
"SoftwareKeyboard": "لوحة المفاتيح البرمجية",
|
||||||
"SoftwareKeyboardModeNumeric": "يجب أن يكون 0-9 أو '.' فقط",
|
"SoftwareKeyboardModeNumeric": "يجب أن يكون 0-9 أو '.' فقط",
|
||||||
"SoftwareKeyboardModeAlphabet": "يجب أن تكون الأحرف غير CJK فقط",
|
"SoftwareKeyboardModeAlphabet": "يجب أن تكون الأحرف غير CJK فقط",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "Niemals",
|
"Never": "Niemals",
|
||||||
"SwkbdMinCharacters": "Muss mindestens {0} Zeichen lang sein",
|
"SwkbdMinCharacters": "Muss mindestens {0} Zeichen lang sein",
|
||||||
"SwkbdMinRangeCharacters": "Muss {0}-{1} Zeichen lang sein",
|
"SwkbdMinRangeCharacters": "Muss {0}-{1} Zeichen lang sein",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "Software-Tastatur",
|
"SoftwareKeyboard": "Software-Tastatur",
|
||||||
"SoftwareKeyboardModeNumeric": "Darf nur 0-9 oder \".\" sein",
|
"SoftwareKeyboardModeNumeric": "Darf nur 0-9 oder \".\" sein",
|
||||||
"SoftwareKeyboardModeAlphabet": "Keine CJK-Zeichen",
|
"SoftwareKeyboardModeAlphabet": "Keine CJK-Zeichen",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "Ποτέ",
|
"Never": "Ποτέ",
|
||||||
"SwkbdMinCharacters": "Πρέπει να έχει μήκος τουλάχιστον {0} χαρακτήρες",
|
"SwkbdMinCharacters": "Πρέπει να έχει μήκος τουλάχιστον {0} χαρακτήρες",
|
||||||
"SwkbdMinRangeCharacters": "Πρέπει να έχει μήκος {0}-{1} χαρακτήρες",
|
"SwkbdMinRangeCharacters": "Πρέπει να έχει μήκος {0}-{1} χαρακτήρες",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "Εικονικό Πληκτρολόγιο",
|
"SoftwareKeyboard": "Εικονικό Πληκτρολόγιο",
|
||||||
"SoftwareKeyboardModeNumeric": "Πρέπει να είναι 0-9 ή '.' μόνο",
|
"SoftwareKeyboardModeNumeric": "Πρέπει να είναι 0-9 ή '.' μόνο",
|
||||||
"SoftwareKeyboardModeAlphabet": "Πρέπει να μην είναι μόνο χαρακτήρες CJK",
|
"SoftwareKeyboardModeAlphabet": "Πρέπει να μην είναι μόνο χαρακτήρες CJK",
|
||||||
|
|
|
@ -714,6 +714,9 @@
|
||||||
"Never": "Never",
|
"Never": "Never",
|
||||||
"SwkbdMinCharacters": "Must be at least {0} characters long",
|
"SwkbdMinCharacters": "Must be at least {0} characters long",
|
||||||
"SwkbdMinRangeCharacters": "Must be {0}-{1} characters long",
|
"SwkbdMinRangeCharacters": "Must be {0}-{1} characters long",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "Software Keyboard",
|
"SoftwareKeyboard": "Software Keyboard",
|
||||||
"SoftwareKeyboardModeNumeric": "Must be 0-9 or '.' only",
|
"SoftwareKeyboardModeNumeric": "Must be 0-9 or '.' only",
|
||||||
"SoftwareKeyboardModeAlphabet": "Must be non CJK-characters only",
|
"SoftwareKeyboardModeAlphabet": "Must be non CJK-characters only",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "Nunca",
|
"Never": "Nunca",
|
||||||
"SwkbdMinCharacters": "Debe tener al menos {0} caracteres",
|
"SwkbdMinCharacters": "Debe tener al menos {0} caracteres",
|
||||||
"SwkbdMinRangeCharacters": "Debe tener {0}-{1} caracteres",
|
"SwkbdMinRangeCharacters": "Debe tener {0}-{1} caracteres",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "Teclado de software",
|
"SoftwareKeyboard": "Teclado de software",
|
||||||
"SoftwareKeyboardModeNumeric": "Debe ser sólo 0-9 o '.'",
|
"SoftwareKeyboardModeNumeric": "Debe ser sólo 0-9 o '.'",
|
||||||
"SoftwareKeyboardModeAlphabet": "Solo deben ser caracteres no CJK",
|
"SoftwareKeyboardModeAlphabet": "Solo deben ser caracteres no CJK",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "Jamais",
|
"Never": "Jamais",
|
||||||
"SwkbdMinCharacters": "Doit comporter au moins {0} caractères",
|
"SwkbdMinCharacters": "Doit comporter au moins {0} caractères",
|
||||||
"SwkbdMinRangeCharacters": "Doit comporter entre {0} et {1} caractères",
|
"SwkbdMinRangeCharacters": "Doit comporter entre {0} et {1} caractères",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "Clavier logiciel",
|
"SoftwareKeyboard": "Clavier logiciel",
|
||||||
"SoftwareKeyboardModeNumeric": "Doit être 0-9 ou '.' uniquement",
|
"SoftwareKeyboardModeNumeric": "Doit être 0-9 ou '.' uniquement",
|
||||||
"SoftwareKeyboardModeAlphabet": "Doit être uniquement des caractères non CJK",
|
"SoftwareKeyboardModeAlphabet": "Doit être uniquement des caractères non CJK",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "אף פעם",
|
"Never": "אף פעם",
|
||||||
"SwkbdMinCharacters": "לפחות {0} תווים",
|
"SwkbdMinCharacters": "לפחות {0} תווים",
|
||||||
"SwkbdMinRangeCharacters": "באורך {0}-{1} תווים",
|
"SwkbdMinRangeCharacters": "באורך {0}-{1} תווים",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "מקלדת וירטואלית",
|
"SoftwareKeyboard": "מקלדת וירטואלית",
|
||||||
"SoftwareKeyboardModeNumeric": "חייב להיות בין 0-9 או '.' בלבד",
|
"SoftwareKeyboardModeNumeric": "חייב להיות בין 0-9 או '.' בלבד",
|
||||||
"SoftwareKeyboardModeAlphabet": "מחויב להיות ללא אותיות CJK",
|
"SoftwareKeyboardModeAlphabet": "מחויב להיות ללא אותיות CJK",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "Mai",
|
"Never": "Mai",
|
||||||
"SwkbdMinCharacters": "Non può avere meno di {0} caratteri",
|
"SwkbdMinCharacters": "Non può avere meno di {0} caratteri",
|
||||||
"SwkbdMinRangeCharacters": "Può avere da {0} a {1} caratteri",
|
"SwkbdMinRangeCharacters": "Può avere da {0} a {1} caratteri",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "Tastiera software",
|
"SoftwareKeyboard": "Tastiera software",
|
||||||
"SoftwareKeyboardModeNumeric": "Deve essere solo 0-9 o '.'",
|
"SoftwareKeyboardModeNumeric": "Deve essere solo 0-9 o '.'",
|
||||||
"SoftwareKeyboardModeAlphabet": "Deve essere solo caratteri non CJK",
|
"SoftwareKeyboardModeAlphabet": "Deve essere solo caratteri non CJK",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "決して",
|
"Never": "決して",
|
||||||
"SwkbdMinCharacters": "最低 {0} 文字必要です",
|
"SwkbdMinCharacters": "最低 {0} 文字必要です",
|
||||||
"SwkbdMinRangeCharacters": "{0}-{1} 文字にしてください",
|
"SwkbdMinRangeCharacters": "{0}-{1} 文字にしてください",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "ソフトウェアキーボード",
|
"SoftwareKeyboard": "ソフトウェアキーボード",
|
||||||
"SoftwareKeyboardModeNumeric": "0-9 または '.' のみでなければなりません",
|
"SoftwareKeyboardModeNumeric": "0-9 または '.' のみでなければなりません",
|
||||||
"SoftwareKeyboardModeAlphabet": "CJK文字以外のみ",
|
"SoftwareKeyboardModeAlphabet": "CJK文字以外のみ",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "절대 안 함",
|
"Never": "절대 안 함",
|
||||||
"SwkbdMinCharacters": "{0}자 이상이어야 함",
|
"SwkbdMinCharacters": "{0}자 이상이어야 함",
|
||||||
"SwkbdMinRangeCharacters": "{0}-{1}자 길이여야 함",
|
"SwkbdMinRangeCharacters": "{0}-{1}자 길이여야 함",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "소프트웨어 키보드",
|
"SoftwareKeyboard": "소프트웨어 키보드",
|
||||||
"SoftwareKeyboardModeNumeric": "0-9 또는 '.'만 가능",
|
"SoftwareKeyboardModeNumeric": "0-9 또는 '.'만 가능",
|
||||||
"SoftwareKeyboardModeAlphabet": "CJK 문자가 아닌 문자만 가능",
|
"SoftwareKeyboardModeAlphabet": "CJK 문자가 아닌 문자만 가능",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "Nigdy",
|
"Never": "Nigdy",
|
||||||
"SwkbdMinCharacters": "Musi mieć co najmniej {0} znaków",
|
"SwkbdMinCharacters": "Musi mieć co najmniej {0} znaków",
|
||||||
"SwkbdMinRangeCharacters": "Musi mieć długość od {0}-{1} znaków",
|
"SwkbdMinRangeCharacters": "Musi mieć długość od {0}-{1} znaków",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "Klawiatura Oprogramowania",
|
"SoftwareKeyboard": "Klawiatura Oprogramowania",
|
||||||
"SoftwareKeyboardModeNumeric": "Może składać się jedynie z 0-9 lub '.'",
|
"SoftwareKeyboardModeNumeric": "Może składać się jedynie z 0-9 lub '.'",
|
||||||
"SoftwareKeyboardModeAlphabet": "Nie może zawierać znaków CJK",
|
"SoftwareKeyboardModeAlphabet": "Nie może zawierać znaków CJK",
|
||||||
|
|
|
@ -701,6 +701,9 @@
|
||||||
"Never": "Nunca",
|
"Never": "Nunca",
|
||||||
"SwkbdMinCharacters": "Deve ter pelo menos {0} caracteres",
|
"SwkbdMinCharacters": "Deve ter pelo menos {0} caracteres",
|
||||||
"SwkbdMinRangeCharacters": "Deve ter entre {0}-{1} caracteres",
|
"SwkbdMinRangeCharacters": "Deve ter entre {0}-{1} caracteres",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "Teclado por Software",
|
"SoftwareKeyboard": "Teclado por Software",
|
||||||
"SoftwareKeyboardModeNumeric": "Deve ser somente 0-9 ou '.'",
|
"SoftwareKeyboardModeNumeric": "Deve ser somente 0-9 ou '.'",
|
||||||
"SoftwareKeyboardModeAlphabet": "Apenas devem ser caracteres não CJK.",
|
"SoftwareKeyboardModeAlphabet": "Apenas devem ser caracteres não CJK.",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "Никогда",
|
"Never": "Никогда",
|
||||||
"SwkbdMinCharacters": "Должно быть не менее {0} символов.",
|
"SwkbdMinCharacters": "Должно быть не менее {0} символов.",
|
||||||
"SwkbdMinRangeCharacters": "Должно быть {0}-{1} символов",
|
"SwkbdMinRangeCharacters": "Должно быть {0}-{1} символов",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "Программная клавиатура",
|
"SoftwareKeyboard": "Программная клавиатура",
|
||||||
"SoftwareKeyboardModeNumeric": "Должно быть в диапазоне 0-9 или '.'",
|
"SoftwareKeyboardModeNumeric": "Должно быть в диапазоне 0-9 или '.'",
|
||||||
"SoftwareKeyboardModeAlphabet": "Не должно быть CJK-символов",
|
"SoftwareKeyboardModeAlphabet": "Не должно быть CJK-символов",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "ไม่ต้อง",
|
"Never": "ไม่ต้อง",
|
||||||
"SwkbdMinCharacters": "ต้องมีความยาวของตัวอักษรอย่างน้อย {0} ตัว",
|
"SwkbdMinCharacters": "ต้องมีความยาวของตัวอักษรอย่างน้อย {0} ตัว",
|
||||||
"SwkbdMinRangeCharacters": "ต้องมีความยาวของตัวอักษร {0}-{1} ตัว",
|
"SwkbdMinRangeCharacters": "ต้องมีความยาวของตัวอักษร {0}-{1} ตัว",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "ซอฟต์แวร์คีย์บอร์ด",
|
"SoftwareKeyboard": "ซอฟต์แวร์คีย์บอร์ด",
|
||||||
"SoftwareKeyboardModeNumeric": "ต้องเป็น 0-9 หรือ '.' เท่านั้น",
|
"SoftwareKeyboardModeNumeric": "ต้องเป็น 0-9 หรือ '.' เท่านั้น",
|
||||||
"SoftwareKeyboardModeAlphabet": "ต้องเป็นตัวอักษรที่ไม่ใช่ประเภท CJK เท่านั้น",
|
"SoftwareKeyboardModeAlphabet": "ต้องเป็นตัวอักษรที่ไม่ใช่ประเภท CJK เท่านั้น",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "Hiçbir Zaman",
|
"Never": "Hiçbir Zaman",
|
||||||
"SwkbdMinCharacters": "En az {0} karakter uzunluğunda olmalı",
|
"SwkbdMinCharacters": "En az {0} karakter uzunluğunda olmalı",
|
||||||
"SwkbdMinRangeCharacters": "{0}-{1} karakter uzunluğunda olmalı",
|
"SwkbdMinRangeCharacters": "{0}-{1} karakter uzunluğunda olmalı",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "Yazılım Klavyesi",
|
"SoftwareKeyboard": "Yazılım Klavyesi",
|
||||||
"SoftwareKeyboardModeNumeric": "Sadece 0-9 veya '.' olabilir",
|
"SoftwareKeyboardModeNumeric": "Sadece 0-9 veya '.' olabilir",
|
||||||
"SoftwareKeyboardModeAlphabet": "Sadece CJK-characters olmayan karakterler olabilir",
|
"SoftwareKeyboardModeAlphabet": "Sadece CJK-characters olmayan karakterler olabilir",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "Ніколи",
|
"Never": "Ніколи",
|
||||||
"SwkbdMinCharacters": "Мінімальна кількість символів: {0}",
|
"SwkbdMinCharacters": "Мінімальна кількість символів: {0}",
|
||||||
"SwkbdMinRangeCharacters": "Має бути {0}-{1} символів",
|
"SwkbdMinRangeCharacters": "Має бути {0}-{1} символів",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "Програмна клавіатура",
|
"SoftwareKeyboard": "Програмна клавіатура",
|
||||||
"SoftwareKeyboardModeNumeric": "Повинно бути лише 0-9 або “.”",
|
"SoftwareKeyboardModeNumeric": "Повинно бути лише 0-9 або “.”",
|
||||||
"SoftwareKeyboardModeAlphabet": "Повинно бути лише не CJK-символи",
|
"SoftwareKeyboardModeAlphabet": "Повинно бути лише не CJK-символи",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "从不",
|
"Never": "从不",
|
||||||
"SwkbdMinCharacters": "不少于 {0} 个字符",
|
"SwkbdMinCharacters": "不少于 {0} 个字符",
|
||||||
"SwkbdMinRangeCharacters": "必须为 {0}-{1} 个字符",
|
"SwkbdMinRangeCharacters": "必须为 {0}-{1} 个字符",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "软键盘",
|
"SoftwareKeyboard": "软键盘",
|
||||||
"SoftwareKeyboardModeNumeric": "只能输入 0-9 或 \".\"",
|
"SoftwareKeyboardModeNumeric": "只能输入 0-9 或 \".\"",
|
||||||
"SoftwareKeyboardModeAlphabet": "仅支持非中文字符",
|
"SoftwareKeyboardModeAlphabet": "仅支持非中文字符",
|
||||||
|
|
|
@ -702,6 +702,9 @@
|
||||||
"Never": "從不",
|
"Never": "從不",
|
||||||
"SwkbdMinCharacters": "長度必須至少為 {0} 個字元",
|
"SwkbdMinCharacters": "長度必須至少為 {0} 個字元",
|
||||||
"SwkbdMinRangeCharacters": "長度必須為 {0} 到 {1} 個字元",
|
"SwkbdMinRangeCharacters": "長度必須為 {0} 到 {1} 個字元",
|
||||||
|
"CabinetTitle": "Cabinet Dialog",
|
||||||
|
"CabinetDialog": "Enter your Amiibo's new name",
|
||||||
|
"CabinetScanDialog": "Please scan your Amiibo now.",
|
||||||
"SoftwareKeyboard": "軟體鍵盤",
|
"SoftwareKeyboard": "軟體鍵盤",
|
||||||
"SoftwareKeyboardModeNumeric": "必須是 0 到 9 或「.」",
|
"SoftwareKeyboardModeNumeric": "必須是 0 到 9 或「.」",
|
||||||
"SoftwareKeyboardModeAlphabet": "必須是「非中日韓字元」 (non CJK)",
|
"SoftwareKeyboardModeAlphabet": "必須是「非中日韓字元」 (non CJK)",
|
||||||
|
|
|
@ -7,6 +7,7 @@ using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.Windows;
|
using Ryujinx.Ava.UI.Windows;
|
||||||
using Ryujinx.HLE;
|
using Ryujinx.HLE;
|
||||||
using Ryujinx.HLE.HOS.Applets;
|
using Ryujinx.HLE.HOS.Applets;
|
||||||
|
using Ryujinx.HLE.HOS.Applets.SoftwareKeyboard;
|
||||||
using Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy.Types;
|
using Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy.Types;
|
||||||
using Ryujinx.HLE.UI;
|
using Ryujinx.HLE.UI;
|
||||||
using Ryujinx.UI.Common.Configuration;
|
using Ryujinx.UI.Common.Configuration;
|
||||||
|
@ -155,6 +156,55 @@ namespace Ryujinx.Ava.UI.Applet
|
||||||
return error || okPressed;
|
return error || okPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool DisplayCabinetDialog(out string userText)
|
||||||
|
{
|
||||||
|
ManualResetEvent dialogCloseEvent = new(false);
|
||||||
|
bool okPressed = false;
|
||||||
|
string inputText = "My Amiibo";
|
||||||
|
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_parent.ViewModel.AppHost.NpadManager.BlockInputUpdates();
|
||||||
|
SoftwareKeyboardUIArgs args = new SoftwareKeyboardUIArgs();
|
||||||
|
args.KeyboardMode = KeyboardMode.Default;
|
||||||
|
args.InitialText = "Ryujinx";
|
||||||
|
args.StringLengthMin = 1;
|
||||||
|
args.StringLengthMax = 25;
|
||||||
|
(UserResult result, string userInput) = await SwkbdAppletDialog.ShowInputDialog(LocaleManager.Instance[LocaleKeys.CabinetDialog], args);
|
||||||
|
if (result == UserResult.Ok)
|
||||||
|
{
|
||||||
|
inputText = userInput;
|
||||||
|
okPressed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
dialogCloseEvent.Set();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialogCloseEvent.WaitOne();
|
||||||
|
_parent.ViewModel.AppHost.NpadManager.UnblockInputUpdates();
|
||||||
|
userText = inputText;
|
||||||
|
return okPressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisplayCabinetMessageDialog()
|
||||||
|
{
|
||||||
|
ManualResetEvent dialogCloseEvent = new(false);
|
||||||
|
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||||
|
{
|
||||||
|
dialogCloseEvent.Set();
|
||||||
|
await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.CabinetScanDialog],
|
||||||
|
string.Empty,
|
||||||
|
LocaleManager.Instance[LocaleKeys.InputDialogOk],
|
||||||
|
string.Empty,
|
||||||
|
LocaleManager.Instance[LocaleKeys.CabinetTitle]);
|
||||||
|
});
|
||||||
|
dialogCloseEvent.WaitOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ExecuteProgram(Switch device, ProgramSpecifyKind kind, ulong value)
|
public void ExecuteProgram(Switch device, ProgramSpecifyKind kind, ulong value)
|
||||||
{
|
{
|
||||||
device.Configuration.UserChannelPersistence.ExecuteProgram(kind, value);
|
device.Configuration.UserChannelPersistence.ExecuteProgram(kind, value);
|
||||||
|
|
Loading…
Reference in a new issue