aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2023-08-16 08:30:33 -0300
committerGitHub <noreply@github.com>2023-08-16 08:30:33 -0300
commiteffd546331371928bc38bc8a48b0c26c7c59f3e9 (patch)
treeec760ee09a3751abd3b5a261ad5be599942a3a35 /src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
parent492a0463358e7706e0fb34537d55810d833ae695 (diff)
Implement scaled vertex format emulation (#5564)1.1.989
* Implement scaled vertex format emulation * Auto-format (whitespace) * Delete ToVec4Type
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs')
-rw-r--r--src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
index 542ec74a..53d774d6 100644
--- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
+++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
@@ -61,7 +61,31 @@ namespace Ryujinx.Graphics.Shader.Instructions
}
else
{
- context.Copy(Register(rd), AttributeMap.GenerateAttributeLoad(context, primVertex, offset, isOutput, op.P));
+ value = AttributeMap.GenerateAttributeLoad(context, primVertex, offset, isOutput, op.P);
+
+ if (!context.TranslatorContext.Definitions.SupportsScaledVertexFormats &&
+ context.TranslatorContext.Stage == ShaderStage.Vertex &&
+ !op.O &&
+ offset >= 0x80 &&
+ offset < 0x280)
+ {
+ // The host does not support scaled vertex formats,
+ // the emulator should use a integer format, and
+ // we compensate here inserting the conversion to float.
+
+ AttributeType type = context.TranslatorContext.Definitions.GetAttributeType((offset - 0x80) >> 4);
+
+ if (type == AttributeType.Sscaled)
+ {
+ value = context.IConvertS32ToFP32(value);
+ }
+ else if (type == AttributeType.Uscaled)
+ {
+ value = context.IConvertU32ToFP32(value);
+ }
+ }
+
+ context.Copy(Register(rd), value);
}
}
else