Implement scaled vertex format emulation (#5564)

* Implement scaled vertex format emulation

* Auto-format (whitespace)

* Delete ToVec4Type
This commit is contained in:
gdkchan 2023-08-16 08:30:33 -03:00 committed by GitHub
parent 492a046335
commit effd546331
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 164 additions and 8 deletions

View file

@ -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