diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2023-08-16 08:30:33 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-16 08:30:33 -0300 |
| commit | effd546331371928bc38bc8a48b0c26c7c59f3e9 (patch) | |
| tree | ec760ee09a3751abd3b5a261ad5be599942a3a35 /src/Ryujinx.Graphics.Gpu | |
| parent | 492a0463358e7706e0fb34537d55810d833ae695 (diff) | |
Implement scaled vertex format emulation (#5564)
* Implement scaled vertex format emulation
* Auto-format (whitespace)
* Delete ToVec4Type
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu')
3 files changed, 38 insertions, 6 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs index b2935a5b..e0607fbf 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs @@ -218,17 +218,34 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed { bool changed = false; ref Array32<AttributeType> attributeTypes = ref _graphics.AttributeTypes; + bool supportsScaledFormats = _context.Capabilities.SupportsScaledVertexFormats; for (int location = 0; location < state.Length; location++) { VertexAttribType type = state[location].UnpackType(); - AttributeType value = type switch + AttributeType value; + + if (supportsScaledFormats) + { + value = type switch + { + VertexAttribType.Sint => AttributeType.Sint, + VertexAttribType.Uint => AttributeType.Uint, + _ => AttributeType.Float, + }; + } + else { - VertexAttribType.Sint => AttributeType.Sint, - VertexAttribType.Uint => AttributeType.Uint, - _ => AttributeType.Float, - }; + value = type switch + { + VertexAttribType.Sint => AttributeType.Sint, + VertexAttribType.Uint => AttributeType.Uint, + VertexAttribType.Uscaled => AttributeType.Uscaled, + VertexAttribType.Sscaled => AttributeType.Sscaled, + _ => AttributeType.Float, + }; + } if (attributeTypes[location] != value) { diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs index b08e7f26..1f919d9b 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs @@ -932,6 +932,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// </summary> private void UpdateVertexAttribState() { + bool supportsScaledFormats = _context.Capabilities.SupportsScaledVertexFormats; uint vbEnableMask = _vbEnableMask; Span<VertexAttribDescriptor> vertexAttribs = stackalloc VertexAttribDescriptor[Constants.TotalVertexAttribs]; @@ -949,7 +950,19 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed continue; } - if (!FormatTable.TryGetAttribFormat(vertexAttrib.UnpackFormat(), out Format format)) + uint packedFormat = vertexAttrib.UnpackFormat(); + + if (!supportsScaledFormats) + { + packedFormat = vertexAttrib.UnpackType() switch + { + VertexAttribType.Uscaled => ((uint)VertexAttribType.Uint << 27) | (packedFormat & (0x3f << 21)), + VertexAttribType.Sscaled => ((uint)VertexAttribType.Sint << 27) | (packedFormat & (0x3f << 21)), + _ => packedFormat, + }; + } + + if (!FormatTable.TryGetAttribFormat(packedFormat, out Format format)) { Logger.Debug?.Print(LogClass.Gpu, $"Invalid attribute format 0x{vertexAttrib.UnpackFormat():X}."); diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs index 6d27f18d..e7a2d345 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs @@ -153,6 +153,8 @@ namespace Ryujinx.Graphics.Gpu.Shader public bool QueryHostSupportsNonConstantTextureOffset() => _context.Capabilities.SupportsNonConstantTextureOffset; + public bool QueryHostSupportsScaledVertexFormats() => _context.Capabilities.SupportsScaledVertexFormats; + public bool QueryHostSupportsShaderBallot() => _context.Capabilities.SupportsShaderBallot; public bool QueryHostSupportsShaderBarrierDivergence() => _context.Capabilities.SupportsShaderBarrierDivergence; |
