diff options
author | gdkchan <gab.dark.100@gmail.com> | 2021-08-26 20:44:47 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-27 01:44:47 +0200 |
commit | ee1038e54255797a94b89091f4d59b77daad1a7b (patch) | |
tree | 5ea62d8a2bae97004a4abe2ebf0a21c634b912dc /Ryujinx.Graphics.Shader/Decoders/Decoder.cs | |
parent | ec3e848d7998038ce22c41acdbf81032bf47991f (diff) |
Initial support for shader attribute indexing (#2546)
* Initial support for shader attribute indexing
* Support output indexing too, other improvements
* Fix order
* Address feedback
Diffstat (limited to 'Ryujinx.Graphics.Shader/Decoders/Decoder.cs')
-rw-r--r-- | Ryujinx.Graphics.Shader/Decoders/Decoder.cs | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/Ryujinx.Graphics.Shader/Decoders/Decoder.cs b/Ryujinx.Graphics.Shader/Decoders/Decoder.cs index 12b49d35..c2901eab 100644 --- a/Ryujinx.Graphics.Shader/Decoders/Decoder.cs +++ b/Ryujinx.Graphics.Shader/Decoders/Decoder.cs @@ -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); |