mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-28 05:55:48 +00:00
9dfe81770a
* Change AggregateType to include vector type counts * Replace VariableType uses with AggregateType and delete VariableType * Support new local vector types on SPIR-V and GLSL * Start using vector outputs for texture operations * Use vectors on more texture operations * Use vector output for ImageLoad operations * Replace all uses of single destination texture constructors with multi destination ones * Update textureGatherOffsets replacement to split vector operations * Shader cache version bump Co-authored-by: Ac_K <Acoustik666@gmail.com>
78 lines
No EOL
2 KiB
C#
78 lines
No EOL
2 KiB
C#
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
|
using Ryujinx.Graphics.Shader.Translation;
|
|
using System.Numerics;
|
|
|
|
using static Ryujinx.Graphics.Shader.StructuredIr.AstHelper;
|
|
|
|
namespace Ryujinx.Graphics.Shader.StructuredIr
|
|
{
|
|
class AstOperation : AstNode
|
|
{
|
|
public Instruction Inst { get; }
|
|
|
|
public int Index { get; }
|
|
|
|
private IAstNode[] _sources;
|
|
|
|
public int SourcesCount => _sources.Length;
|
|
|
|
public AstOperation(Instruction inst, IAstNode[] sources, int sourcesCount)
|
|
{
|
|
Inst = inst;
|
|
_sources = sources;
|
|
|
|
for (int index = 0; index < sources.Length; index++)
|
|
{
|
|
if (index < sourcesCount)
|
|
{
|
|
AddUse(sources[index], this);
|
|
}
|
|
else
|
|
{
|
|
AddDef(sources[index], this);
|
|
}
|
|
}
|
|
|
|
Index = 0;
|
|
}
|
|
|
|
public AstOperation(Instruction inst, int index, IAstNode[] sources, int sourcesCount) : this(inst, sources, sourcesCount)
|
|
{
|
|
Index = index;
|
|
}
|
|
|
|
public AstOperation(Instruction inst, params IAstNode[] sources) : this(inst, sources, sources.Length)
|
|
{
|
|
}
|
|
|
|
public IAstNode GetSource(int index)
|
|
{
|
|
return _sources[index];
|
|
}
|
|
|
|
public void SetSource(int index, IAstNode source)
|
|
{
|
|
RemoveUse(_sources[index], this);
|
|
|
|
AddUse(source, this);
|
|
|
|
_sources[index] = source;
|
|
}
|
|
|
|
public AggregateType GetVectorType(AggregateType scalarType)
|
|
{
|
|
int componentsCount = BitOperations.PopCount((uint)Index);
|
|
|
|
AggregateType type = scalarType;
|
|
|
|
switch (componentsCount)
|
|
{
|
|
case 2: type |= AggregateType.Vector2; break;
|
|
case 3: type |= AggregateType.Vector3; break;
|
|
case 4: type |= AggregateType.Vector4; break;
|
|
}
|
|
|
|
return type;
|
|
}
|
|
}
|
|
} |