mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-11-15 09:35:27 +00:00
Fix incorrect vertex attribute format change (#5112)
* Fix incorrect vertex attribute format change * Only change vertex format if the host supports the new format
This commit is contained in:
parent
1cf6d7b7bb
commit
597388ecda
|
@ -65,6 +65,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
return (formatFeatureFlags & flags) == flags;
|
return (formatFeatureFlags & flags) == flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool BufferFormatSupports(FormatFeatureFlags flags, VkFormat format)
|
||||||
|
{
|
||||||
|
_api.GetPhysicalDeviceFormatProperties(_physicalDevice, format, out var fp);
|
||||||
|
|
||||||
|
return (fp.BufferFeatures & flags) == flags;
|
||||||
|
}
|
||||||
|
|
||||||
public bool OptimalFormatSupports(FormatFeatureFlags flags, GAL.Format format)
|
public bool OptimalFormatSupports(FormatFeatureFlags flags, GAL.Format format)
|
||||||
{
|
{
|
||||||
var formatFeatureFlags = _optimalTable[(int)format];
|
var formatFeatureFlags = _optimalTable[(int)format];
|
||||||
|
|
|
@ -551,7 +551,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
(uint)maxDrawCount,
|
(uint)maxDrawCount,
|
||||||
(uint)stride);
|
(uint)stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -414,7 +414,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
|
|
||||||
if (isMoltenVk)
|
if (isMoltenVk)
|
||||||
{
|
{
|
||||||
UpdateVertexAttributeDescriptions();
|
UpdateVertexAttributeDescriptions(gd);
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed (VertexInputAttributeDescription* pVertexAttributeDescriptions = &Internal.VertexAttributeDescriptions[0])
|
fixed (VertexInputAttributeDescription* pVertexAttributeDescriptions = &Internal.VertexAttributeDescriptions[0])
|
||||||
|
@ -641,7 +641,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateVertexAttributeDescriptions()
|
private void UpdateVertexAttributeDescriptions(VulkanRenderer gd)
|
||||||
{
|
{
|
||||||
// Vertex attributes exceeding the stride are invalid.
|
// Vertex attributes exceeding the stride are invalid.
|
||||||
// In metal, they cause glitches with the vertex shader fetching incorrect values.
|
// In metal, they cause glitches with the vertex shader fetching incorrect values.
|
||||||
|
@ -651,7 +651,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
for (int index = 0; index < VertexAttributeDescriptionsCount; index++)
|
for (int index = 0; index < VertexAttributeDescriptionsCount; index++)
|
||||||
{
|
{
|
||||||
var attribute = Internal.VertexAttributeDescriptions[index];
|
var attribute = Internal.VertexAttributeDescriptions[index];
|
||||||
ref var vb = ref Internal.VertexBindingDescriptions[(int)attribute.Binding];
|
int vbIndex = GetVertexBufferIndex(attribute.Binding);
|
||||||
|
|
||||||
|
if (vbIndex >= 0)
|
||||||
|
{
|
||||||
|
ref var vb = ref Internal.VertexBindingDescriptions[vbIndex];
|
||||||
|
|
||||||
Format format = attribute.Format;
|
Format format = attribute.Format;
|
||||||
|
|
||||||
|
@ -670,11 +674,29 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
format = newFormat;
|
format = newFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attribute.Format != format && gd.FormatCapabilities.BufferFormatSupports(FormatFeatureFlags.VertexBufferBit, format))
|
||||||
|
{
|
||||||
attribute.Format = format;
|
attribute.Format = format;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_vertexAttributeDescriptions2[index] = attribute;
|
_vertexAttributeDescriptions2[index] = attribute;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int GetVertexBufferIndex(uint binding)
|
||||||
|
{
|
||||||
|
for (int index = 0; index < VertexBindingDescriptionsCount; index++)
|
||||||
|
{
|
||||||
|
if (Internal.VertexBindingDescriptions[index].Binding == binding)
|
||||||
|
{
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Stages.Dispose();
|
Stages.Dispose();
|
||||||
|
|
Loading…
Reference in a new issue