Initial support for shader attribute indexing (#2546)

* Initial support for shader attribute indexing

* Support output indexing too, other improvements

* Fix order

* Address feedback
This commit is contained in:
gdkchan 2021-08-26 20:44:47 -03:00 committed by GitHub
parent ec3e848d79
commit ee1038e542
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 298 additions and 86 deletions

View file

@ -282,23 +282,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
// Populate used attributes.
if (op is IOpCodeAttribute opAttr)
{
for (int elemIndex = 0; elemIndex < opAttr.Count; elemIndex++)
{
int attr = opAttr.AttributeOffset + elemIndex * 4;
if (attr >= AttributeConsts.UserAttributeBase && attr < AttributeConsts.UserAttributeEnd)
{
int index = (attr - AttributeConsts.UserAttributeBase) / 16;
if (op.Emitter == InstEmit.Ast)
{
config.SetOutputUserAttribute(index);
}
else
{
config.SetInputUserAttribute(index);
}
}
}
SetUserAttributeUses(config, opAttr);
}
block.OpCodes.Add(op);
@ -310,6 +294,41 @@ namespace Ryujinx.Graphics.Shader.Decoders
block.UpdatePushOps();
}
private static void SetUserAttributeUses(ShaderConfig config, IOpCodeAttribute opAttr)
{
if (opAttr.Indexed)
{
if (opAttr.Emitter == InstEmit.Ast)
{
config.SetAllOutputUserAttributes();
}
else
{
config.SetAllInputUserAttributes();
}
}
else
{
for (int elemIndex = 0; elemIndex < opAttr.Count; elemIndex++)
{
int attr = opAttr.AttributeOffset + elemIndex * 4;
if (attr >= AttributeConsts.UserAttributeBase && attr < AttributeConsts.UserAttributeEnd)
{
int index = (attr - AttributeConsts.UserAttributeBase) / 16;
if (opAttr.Emitter == InstEmit.Ast)
{
config.SetOutputUserAttribute(index);
}
else
{
config.SetInputUserAttribute(index);
}
}
}
}
}
private static bool IsUnconditionalBranch(OpCode opCode)
{
return IsUnconditional(opCode) && IsControlFlowChange(opCode);