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:
parent
ec3e848d79
commit
ee1038e542
22 changed files with 298 additions and 86 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue