Fix VertexId and InstanceId on Vulkan (#3833)

* Fix VertexId and InstanceId on Vulkan

* Shader cache version bump
This commit is contained in:
gdkchan 2022-11-11 13:22:49 -03:00 committed by GitHub
parent a6a67a2b7a
commit 51a27032f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 4 deletions

View file

@ -51,7 +51,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
offset |= AttributeConsts.LoadOutputMask;
}
Operand src = op.P ? AttributePerPatch(offset) : Attribute(offset);
Operand src = op.P ? AttributePerPatch(offset) : CreateInputAttribute(context, offset);
context.Copy(Register(rd), src);
}
@ -312,5 +312,22 @@ namespace Ryujinx.Graphics.Shader.Instructions
return attr;
}
private static Operand CreateInputAttribute(EmitterContext context, int attr)
{
if (context.Config.Options.TargetApi == TargetApi.Vulkan)
{
if (attr == AttributeConsts.InstanceId)
{
return context.ISubtract(Attribute(AttributeConsts.InstanceIndex), Attribute(AttributeConsts.BaseInstance));
}
else if (attr == AttributeConsts.VertexId)
{
return Attribute(AttributeConsts.VertexIndex);
}
}
return Attribute(attr);
}
}
}