mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-28 04:36:23 +02:00
misc: chore: Use explicit types in Shader project
This commit is contained in:
parent
68bbb29be6
commit
f2aa6b3a5b
39 changed files with 726 additions and 725 deletions
|
@ -153,7 +153,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
public static OperationResult Generate(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var handler = _instTable[(int)(operation.Inst & Instruction.Mask)];
|
||||
Func<CodeGenContext, AstOperation, OperationResult> handler = _instTable[(int)(operation.Inst & Instruction.Mask)];
|
||||
if (handler != null)
|
||||
{
|
||||
return handler(context, operation);
|
||||
|
@ -226,13 +226,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static OperationResult GenerateBallot(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
var uvec4Type = context.TypeVector(context.TypeU32(), 4);
|
||||
var execution = context.Constant(context.TypeU32(), Scope.Subgroup);
|
||||
SpvInstruction uvec4Type = context.TypeVector(context.TypeU32(), 4);
|
||||
SpvInstruction execution = context.Constant(context.TypeU32(), Scope.Subgroup);
|
||||
|
||||
var maskVector = context.GroupNonUniformBallot(uvec4Type, execution, context.Get(AggregateType.Bool, source));
|
||||
var mask = context.CompositeExtract(context.TypeU32(), maskVector, (SpvLiteralInteger)operation.Index);
|
||||
SpvInstruction maskVector = context.GroupNonUniformBallot(uvec4Type, execution, context.Get(AggregateType.Bool, source));
|
||||
SpvInstruction mask = context.CompositeExtract(context.TypeU32(), maskVector, (SpvLiteralInteger)operation.Index);
|
||||
|
||||
return new OperationResult(AggregateType.U32, mask);
|
||||
}
|
||||
|
@ -308,21 +308,21 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
Debug.Assert(funcId.Type == OperandType.Constant);
|
||||
|
||||
var (function, spvFunc) = context.GetFunction(funcId.Value);
|
||||
(StructuredFunction function, SpvInstruction spvFunc) = context.GetFunction(funcId.Value);
|
||||
|
||||
var args = new SpvInstruction[operation.SourcesCount - 1];
|
||||
SpvInstruction[] args = new SpvInstruction[operation.SourcesCount - 1];
|
||||
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
var operand = operation.GetSource(i + 1);
|
||||
IAstNode operand = operation.GetSource(i + 1);
|
||||
|
||||
AstOperand local = (AstOperand)operand;
|
||||
Debug.Assert(local.Type == OperandType.LocalVariable);
|
||||
args[i] = context.GetLocalPointer(local);
|
||||
}
|
||||
|
||||
var retType = function.ReturnType;
|
||||
var result = context.FunctionCall(context.GetType(retType), spvFunc, args);
|
||||
AggregateType retType = function.ReturnType;
|
||||
SpvInstruction result = context.FunctionCall(context.GetType(retType), spvFunc, args);
|
||||
return new OperationResult(retType, result);
|
||||
}
|
||||
|
||||
|
@ -398,11 +398,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static OperationResult GenerateConditionalSelect(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
var src3 = operation.GetSource(2);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
IAstNode src3 = operation.GetSource(2);
|
||||
|
||||
var cond = context.Get(AggregateType.Bool, src1);
|
||||
SpvInstruction cond = context.Get(AggregateType.Bool, src1);
|
||||
|
||||
if (operation.Inst.HasFlag(Instruction.FP64))
|
||||
{
|
||||
|
@ -420,70 +420,70 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static OperationResult GenerateConvertFP32ToFP64(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
return new OperationResult(AggregateType.FP64, context.FConvert(context.TypeFP64(), context.GetFP32(source)));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateConvertFP32ToS32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
return new OperationResult(AggregateType.S32, context.ConvertFToS(context.TypeS32(), context.GetFP32(source)));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateConvertFP32ToU32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
return new OperationResult(AggregateType.U32, context.ConvertFToU(context.TypeU32(), context.GetFP32(source)));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateConvertFP64ToFP32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
return new OperationResult(AggregateType.FP32, context.FConvert(context.TypeFP32(), context.GetFP64(source)));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateConvertFP64ToS32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
return new OperationResult(AggregateType.S32, context.ConvertFToS(context.TypeS32(), context.GetFP64(source)));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateConvertFP64ToU32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
return new OperationResult(AggregateType.U32, context.ConvertFToU(context.TypeU32(), context.GetFP64(source)));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateConvertS32ToFP32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
return new OperationResult(AggregateType.FP32, context.ConvertSToF(context.TypeFP32(), context.GetS32(source)));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateConvertS32ToFP64(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
return new OperationResult(AggregateType.FP64, context.ConvertSToF(context.TypeFP64(), context.GetS32(source)));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateConvertU32ToFP32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
return new OperationResult(AggregateType.FP32, context.ConvertUToF(context.TypeFP32(), context.GetU32(source)));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateConvertU32ToFP64(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
return new OperationResult(AggregateType.FP64, context.ConvertUToF(context.TypeFP64(), context.GetU32(source)));
|
||||
}
|
||||
|
@ -555,19 +555,19 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static OperationResult GenerateFindLSB(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = context.GetU32(operation.GetSource(0));
|
||||
SpvInstruction source = context.GetU32(operation.GetSource(0));
|
||||
return new OperationResult(AggregateType.U32, context.GlslFindILsb(context.TypeU32(), source));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateFindMSBS32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = context.GetS32(operation.GetSource(0));
|
||||
SpvInstruction source = context.GetS32(operation.GetSource(0));
|
||||
return new OperationResult(AggregateType.U32, context.GlslFindSMsb(context.TypeU32(), source));
|
||||
}
|
||||
|
||||
private static OperationResult GenerateFindMSBU32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = context.GetU32(operation.GetSource(0));
|
||||
SpvInstruction source = context.GetU32(operation.GetSource(0));
|
||||
return new OperationResult(AggregateType.U32, context.GlslFindUMsb(context.TypeU32(), source));
|
||||
}
|
||||
|
||||
|
@ -591,7 +591,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
{
|
||||
AstTextureOperation texOp = (AstTextureOperation)operation;
|
||||
|
||||
var componentType = texOp.Format.GetComponentType();
|
||||
AggregateType componentType = texOp.Format.GetComponentType();
|
||||
|
||||
bool isArray = (texOp.Type & SamplerType.Array) != 0;
|
||||
|
||||
|
@ -630,7 +630,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
elems[i] = Src(AggregateType.S32);
|
||||
}
|
||||
|
||||
var vectorType = context.TypeVector(context.TypeS32(), pCount);
|
||||
SpvInstruction vectorType = context.TypeVector(context.TypeS32(), pCount);
|
||||
pCoords = context.CompositeConstruct(vectorType, elems);
|
||||
}
|
||||
else
|
||||
|
@ -640,11 +640,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
SpvInstruction value = Src(componentType);
|
||||
|
||||
var pointer = context.ImageTexelPointer(imagePointerType, image, pCoords, context.Constant(context.TypeU32(), 0));
|
||||
var one = context.Constant(context.TypeU32(), 1);
|
||||
var zero = context.Constant(context.TypeU32(), 0);
|
||||
SpvInstruction pointer = context.ImageTexelPointer(imagePointerType, image, pCoords, context.Constant(context.TypeU32(), 0));
|
||||
SpvInstruction one = context.Constant(context.TypeU32(), 1);
|
||||
SpvInstruction zero = context.Constant(context.TypeU32(), 0);
|
||||
|
||||
var result = (texOp.Flags & TextureFlags.AtomicMask) switch
|
||||
SpvInstruction result = (texOp.Flags & TextureFlags.AtomicMask) switch
|
||||
{
|
||||
TextureFlags.Add => context.AtomicIAdd(resultType, pointer, one, zero, value),
|
||||
TextureFlags.Minimum => componentType == AggregateType.S32
|
||||
|
@ -670,7 +670,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
{
|
||||
AstTextureOperation texOp = (AstTextureOperation)operation;
|
||||
|
||||
var componentType = texOp.Format.GetComponentType();
|
||||
AggregateType componentType = texOp.Format.GetComponentType();
|
||||
|
||||
bool isArray = (texOp.Type & SamplerType.Array) != 0;
|
||||
|
||||
|
@ -708,7 +708,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
elems[i] = Src(AggregateType.S32);
|
||||
}
|
||||
|
||||
var vectorType = context.TypeVector(context.TypeS32(), pCount);
|
||||
SpvInstruction vectorType = context.TypeVector(context.TypeS32(), pCount);
|
||||
pCoords = context.CompositeConstruct(vectorType, elems);
|
||||
}
|
||||
else
|
||||
|
@ -716,11 +716,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
pCoords = Src(AggregateType.S32);
|
||||
}
|
||||
|
||||
var imageComponentType = context.GetType(componentType);
|
||||
var swizzledResultType = texOp.GetVectorType(componentType);
|
||||
SpvInstruction imageComponentType = context.GetType(componentType);
|
||||
AggregateType swizzledResultType = texOp.GetVectorType(componentType);
|
||||
|
||||
var texel = context.ImageRead(context.TypeVector(imageComponentType, 4), image, pCoords, ImageOperandsMask.MaskNone);
|
||||
var result = GetSwizzledResult(context, texel, swizzledResultType, texOp.Index);
|
||||
SpvInstruction texel = context.ImageRead(context.TypeVector(imageComponentType, 4), image, pCoords, ImageOperandsMask.MaskNone);
|
||||
SpvInstruction result = GetSwizzledResult(context, texel, swizzledResultType, texOp.Index);
|
||||
|
||||
return new OperationResult(componentType, result);
|
||||
}
|
||||
|
@ -765,7 +765,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
elems[i] = Src(AggregateType.S32);
|
||||
}
|
||||
|
||||
var vectorType = context.TypeVector(context.TypeS32(), pCount);
|
||||
SpvInstruction vectorType = context.TypeVector(context.TypeS32(), pCount);
|
||||
pCoords = context.CompositeConstruct(vectorType, elems);
|
||||
}
|
||||
else
|
||||
|
@ -773,7 +773,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
pCoords = Src(AggregateType.S32);
|
||||
}
|
||||
|
||||
var componentType = texOp.Format.GetComponentType();
|
||||
AggregateType componentType = texOp.Format.GetComponentType();
|
||||
|
||||
const int ComponentsCount = 4;
|
||||
|
||||
|
@ -796,7 +796,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
}
|
||||
}
|
||||
|
||||
var texel = context.CompositeConstruct(context.TypeVector(context.GetType(componentType), ComponentsCount), cElems);
|
||||
SpvInstruction texel = context.CompositeConstruct(context.TypeVector(context.GetType(componentType), ComponentsCount), cElems);
|
||||
|
||||
context.ImageWrite(image, pCoords, texel, ImageOperandsMask.MaskNone);
|
||||
|
||||
|
@ -805,7 +805,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static OperationResult GenerateIsNan(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
SpvInstruction result;
|
||||
|
||||
|
@ -853,7 +853,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
elems[i] = Src(AggregateType.FP32);
|
||||
}
|
||||
|
||||
var vectorType = context.TypeVector(context.TypeFP32(), pCount);
|
||||
SpvInstruction vectorType = context.TypeVector(context.TypeFP32(), pCount);
|
||||
pCoords = context.CompositeConstruct(vectorType, elems);
|
||||
}
|
||||
else
|
||||
|
@ -861,9 +861,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
pCoords = Src(AggregateType.FP32);
|
||||
}
|
||||
|
||||
var resultType = context.TypeVector(context.TypeFP32(), 2);
|
||||
var packed = context.ImageQueryLod(resultType, image, pCoords);
|
||||
var result = context.CompositeExtract(context.TypeFP32(), packed, (SpvLiteralInteger)texOp.Index);
|
||||
SpvInstruction resultType = context.TypeVector(context.TypeFP32(), 2);
|
||||
SpvInstruction packed = context.ImageQueryLod(resultType, image, pCoords);
|
||||
SpvInstruction result = context.CompositeExtract(context.TypeFP32(), packed, (SpvLiteralInteger)texOp.Index);
|
||||
|
||||
return new OperationResult(AggregateType.FP32, result);
|
||||
}
|
||||
|
@ -959,11 +959,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static OperationResult GenerateMultiplyHighS32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
|
||||
var resultType = context.TypeStruct(false, context.TypeS32(), context.TypeS32());
|
||||
var result = context.SMulExtended(resultType, context.GetS32(src1), context.GetS32(src2));
|
||||
SpvInstruction resultType = context.TypeStruct(false, context.TypeS32(), context.TypeS32());
|
||||
SpvInstruction result = context.SMulExtended(resultType, context.GetS32(src1), context.GetS32(src2));
|
||||
result = context.CompositeExtract(context.TypeS32(), result, 1);
|
||||
|
||||
return new OperationResult(AggregateType.S32, result);
|
||||
|
@ -971,11 +971,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static OperationResult GenerateMultiplyHighU32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
|
||||
var resultType = context.TypeStruct(false, context.TypeU32(), context.TypeU32());
|
||||
var result = context.UMulExtended(resultType, context.GetU32(src1), context.GetU32(src2));
|
||||
SpvInstruction resultType = context.TypeStruct(false, context.TypeU32(), context.TypeU32());
|
||||
SpvInstruction result = context.UMulExtended(resultType, context.GetU32(src1), context.GetU32(src2));
|
||||
result = context.CompositeExtract(context.TypeU32(), result, 1);
|
||||
|
||||
return new OperationResult(AggregateType.U32, result);
|
||||
|
@ -988,20 +988,20 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static OperationResult GeneratePackDouble2x32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var value0 = context.GetU32(operation.GetSource(0));
|
||||
var value1 = context.GetU32(operation.GetSource(1));
|
||||
var vector = context.CompositeConstruct(context.TypeVector(context.TypeU32(), 2), value0, value1);
|
||||
var result = context.GlslPackDouble2x32(context.TypeFP64(), vector);
|
||||
SpvInstruction value0 = context.GetU32(operation.GetSource(0));
|
||||
SpvInstruction value1 = context.GetU32(operation.GetSource(1));
|
||||
SpvInstruction vector = context.CompositeConstruct(context.TypeVector(context.TypeU32(), 2), value0, value1);
|
||||
SpvInstruction result = context.GlslPackDouble2x32(context.TypeFP64(), vector);
|
||||
|
||||
return new OperationResult(AggregateType.FP64, result);
|
||||
}
|
||||
|
||||
private static OperationResult GeneratePackHalf2x16(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var value0 = context.GetFP32(operation.GetSource(0));
|
||||
var value1 = context.GetFP32(operation.GetSource(1));
|
||||
var vector = context.CompositeConstruct(context.TypeVector(context.TypeFP32(), 2), value0, value1);
|
||||
var result = context.GlslPackHalf2x16(context.TypeU32(), vector);
|
||||
SpvInstruction value0 = context.GetFP32(operation.GetSource(0));
|
||||
SpvInstruction value1 = context.GetFP32(operation.GetSource(1));
|
||||
SpvInstruction vector = context.CompositeConstruct(context.TypeVector(context.TypeFP32(), 2), value0, value1);
|
||||
SpvInstruction result = context.GlslPackHalf2x16(context.TypeU32(), vector);
|
||||
|
||||
return new OperationResult(AggregateType.U32, result);
|
||||
}
|
||||
|
@ -1049,40 +1049,40 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static OperationResult GenerateShuffle(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var value = context.GetFP32(operation.GetSource(0));
|
||||
var index = context.GetU32(operation.GetSource(1));
|
||||
SpvInstruction value = context.GetFP32(operation.GetSource(0));
|
||||
SpvInstruction index = context.GetU32(operation.GetSource(1));
|
||||
|
||||
var result = context.GroupNonUniformShuffle(context.TypeFP32(), context.Constant(context.TypeU32(), (int)Scope.Subgroup), value, index);
|
||||
SpvInstruction result = context.GroupNonUniformShuffle(context.TypeFP32(), context.Constant(context.TypeU32(), (int)Scope.Subgroup), value, index);
|
||||
|
||||
return new OperationResult(AggregateType.FP32, result);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateShuffleDown(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var value = context.GetFP32(operation.GetSource(0));
|
||||
var index = context.GetU32(operation.GetSource(1));
|
||||
SpvInstruction value = context.GetFP32(operation.GetSource(0));
|
||||
SpvInstruction index = context.GetU32(operation.GetSource(1));
|
||||
|
||||
var result = context.GroupNonUniformShuffleDown(context.TypeFP32(), context.Constant(context.TypeU32(), (int)Scope.Subgroup), value, index);
|
||||
SpvInstruction result = context.GroupNonUniformShuffleDown(context.TypeFP32(), context.Constant(context.TypeU32(), (int)Scope.Subgroup), value, index);
|
||||
|
||||
return new OperationResult(AggregateType.FP32, result);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateShuffleUp(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var value = context.GetFP32(operation.GetSource(0));
|
||||
var index = context.GetU32(operation.GetSource(1));
|
||||
SpvInstruction value = context.GetFP32(operation.GetSource(0));
|
||||
SpvInstruction index = context.GetU32(operation.GetSource(1));
|
||||
|
||||
var result = context.GroupNonUniformShuffleUp(context.TypeFP32(), context.Constant(context.TypeU32(), (int)Scope.Subgroup), value, index);
|
||||
SpvInstruction result = context.GroupNonUniformShuffleUp(context.TypeFP32(), context.Constant(context.TypeU32(), (int)Scope.Subgroup), value, index);
|
||||
|
||||
return new OperationResult(AggregateType.FP32, result);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateShuffleXor(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var value = context.GetFP32(operation.GetSource(0));
|
||||
var index = context.GetU32(operation.GetSource(1));
|
||||
SpvInstruction value = context.GetFP32(operation.GetSource(0));
|
||||
SpvInstruction index = context.GetU32(operation.GetSource(1));
|
||||
|
||||
var result = context.GroupNonUniformShuffleXor(context.TypeFP32(), context.Constant(context.TypeU32(), (int)Scope.Subgroup), value, index);
|
||||
SpvInstruction result = context.GroupNonUniformShuffleXor(context.TypeFP32(), context.Constant(context.TypeU32(), (int)Scope.Subgroup), value, index);
|
||||
|
||||
return new OperationResult(AggregateType.FP32, result);
|
||||
}
|
||||
|
@ -1109,31 +1109,31 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static OperationResult GenerateSwizzleAdd(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var x = context.Get(AggregateType.FP32, operation.GetSource(0));
|
||||
var y = context.Get(AggregateType.FP32, operation.GetSource(1));
|
||||
var mask = context.Get(AggregateType.U32, operation.GetSource(2));
|
||||
SpvInstruction x = context.Get(AggregateType.FP32, operation.GetSource(0));
|
||||
SpvInstruction y = context.Get(AggregateType.FP32, operation.GetSource(1));
|
||||
SpvInstruction mask = context.Get(AggregateType.U32, operation.GetSource(2));
|
||||
|
||||
var v4float = context.TypeVector(context.TypeFP32(), 4);
|
||||
var one = context.Constant(context.TypeFP32(), 1.0f);
|
||||
var minusOne = context.Constant(context.TypeFP32(), -1.0f);
|
||||
var zero = context.Constant(context.TypeFP32(), 0.0f);
|
||||
var xLut = context.ConstantComposite(v4float, one, minusOne, one, zero);
|
||||
var yLut = context.ConstantComposite(v4float, one, one, minusOne, one);
|
||||
SpvInstruction v4float = context.TypeVector(context.TypeFP32(), 4);
|
||||
SpvInstruction one = context.Constant(context.TypeFP32(), 1.0f);
|
||||
SpvInstruction minusOne = context.Constant(context.TypeFP32(), -1.0f);
|
||||
SpvInstruction zero = context.Constant(context.TypeFP32(), 0.0f);
|
||||
SpvInstruction xLut = context.ConstantComposite(v4float, one, minusOne, one, zero);
|
||||
SpvInstruction yLut = context.ConstantComposite(v4float, one, one, minusOne, one);
|
||||
|
||||
var three = context.Constant(context.TypeU32(), 3);
|
||||
SpvInstruction three = context.Constant(context.TypeU32(), 3);
|
||||
|
||||
var threadId = GetScalarInput(context, IoVariable.SubgroupLaneId);
|
||||
var shift = context.BitwiseAnd(context.TypeU32(), threadId, three);
|
||||
SpvInstruction threadId = GetScalarInput(context, IoVariable.SubgroupLaneId);
|
||||
SpvInstruction shift = context.BitwiseAnd(context.TypeU32(), threadId, three);
|
||||
shift = context.ShiftLeftLogical(context.TypeU32(), shift, context.Constant(context.TypeU32(), 1));
|
||||
var lutIdx = context.ShiftRightLogical(context.TypeU32(), mask, shift);
|
||||
SpvInstruction lutIdx = context.ShiftRightLogical(context.TypeU32(), mask, shift);
|
||||
lutIdx = context.BitwiseAnd(context.TypeU32(), lutIdx, three);
|
||||
|
||||
var xLutValue = context.VectorExtractDynamic(context.TypeFP32(), xLut, lutIdx);
|
||||
var yLutValue = context.VectorExtractDynamic(context.TypeFP32(), yLut, lutIdx);
|
||||
SpvInstruction xLutValue = context.VectorExtractDynamic(context.TypeFP32(), xLut, lutIdx);
|
||||
SpvInstruction yLutValue = context.VectorExtractDynamic(context.TypeFP32(), yLut, lutIdx);
|
||||
|
||||
var xResult = context.FMul(context.TypeFP32(), x, xLutValue);
|
||||
var yResult = context.FMul(context.TypeFP32(), y, yLutValue);
|
||||
var result = context.FAdd(context.TypeFP32(), xResult, yResult);
|
||||
SpvInstruction xResult = context.FMul(context.TypeFP32(), x, xLutValue);
|
||||
SpvInstruction yResult = context.FMul(context.TypeFP32(), y, yLutValue);
|
||||
SpvInstruction result = context.FAdd(context.TypeFP32(), xResult, yResult);
|
||||
|
||||
return new OperationResult(AggregateType.FP32, result);
|
||||
}
|
||||
|
@ -1200,7 +1200,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
}
|
||||
}
|
||||
|
||||
var vectorType = context.TypeVector(intCoords ? context.TypeS32() : context.TypeFP32(), count);
|
||||
SpvInstruction vectorType = context.TypeVector(intCoords ? context.TypeS32() : context.TypeFP32(), count);
|
||||
return context.CompositeConstruct(vectorType, elems);
|
||||
}
|
||||
else
|
||||
|
@ -1222,7 +1222,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
elems[index] = Src(AggregateType.FP32);
|
||||
}
|
||||
|
||||
var vectorType = context.TypeVector(context.TypeFP32(), count);
|
||||
SpvInstruction vectorType = context.TypeVector(context.TypeFP32(), count);
|
||||
return context.CompositeConstruct(vectorType, elems);
|
||||
}
|
||||
else
|
||||
|
@ -1272,7 +1272,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
elems[index] = Src(AggregateType.S32);
|
||||
}
|
||||
|
||||
var vectorType = context.TypeVector(context.TypeS32(), count);
|
||||
SpvInstruction vectorType = context.TypeVector(context.TypeS32(), count);
|
||||
|
||||
return context.ConstantComposite(vectorType, elems);
|
||||
}
|
||||
|
@ -1327,8 +1327,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
compIdx = Src(AggregateType.S32);
|
||||
}
|
||||
|
||||
var operandsList = new List<SpvInstruction>();
|
||||
var operandsMask = ImageOperandsMask.MaskNone;
|
||||
List<SpvInstruction> operandsList = new List<SpvInstruction>();
|
||||
ImageOperandsMask operandsMask = ImageOperandsMask.MaskNone;
|
||||
|
||||
if (hasLodBias)
|
||||
{
|
||||
|
@ -1369,14 +1369,14 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
bool colorIsVector = isGather || !isShadow;
|
||||
|
||||
var resultType = colorIsVector ? context.TypeVector(context.TypeFP32(), 4) : context.TypeFP32();
|
||||
SpvInstruction resultType = colorIsVector ? context.TypeVector(context.TypeFP32(), 4) : context.TypeFP32();
|
||||
|
||||
if (intCoords)
|
||||
{
|
||||
image = context.Image(declaration.ImageType, image);
|
||||
}
|
||||
|
||||
var operands = operandsList.ToArray();
|
||||
SpvInstruction[] operands = operandsList.ToArray();
|
||||
|
||||
SpvInstruction result;
|
||||
|
||||
|
@ -1415,7 +1415,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
result = context.ImageSampleImplicitLod(resultType, image, pCoords, operandsMask, operands);
|
||||
}
|
||||
|
||||
var swizzledResultType = AggregateType.FP32;
|
||||
AggregateType swizzledResultType = AggregateType.FP32;
|
||||
|
||||
if (colorIsVector)
|
||||
{
|
||||
|
@ -1460,7 +1460,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
}
|
||||
else
|
||||
{
|
||||
var type = context.SamplersTypes[texOp.GetTextureSetAndBinding()];
|
||||
SamplerType type = context.SamplersTypes[texOp.GetTextureSetAndBinding()];
|
||||
bool hasLod = !type.HasFlag(SamplerType.Multisample) && type != SamplerType.TextureBuffer;
|
||||
|
||||
int dimensions = (type & SamplerType.Mask) == SamplerType.TextureCube ? 2 : type.GetDimensions();
|
||||
|
@ -1470,13 +1470,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
dimensions++;
|
||||
}
|
||||
|
||||
var resultType = dimensions == 1 ? context.TypeS32() : context.TypeVector(context.TypeS32(), dimensions);
|
||||
SpvInstruction resultType = dimensions == 1 ? context.TypeS32() : context.TypeVector(context.TypeS32(), dimensions);
|
||||
|
||||
SpvInstruction result;
|
||||
|
||||
if (hasLod)
|
||||
{
|
||||
var lod = context.GetS32(operation.GetSource(srcIndex));
|
||||
SpvInstruction lod = context.GetS32(operation.GetSource(srcIndex));
|
||||
result = context.ImageQuerySizeLod(resultType, image, lod);
|
||||
}
|
||||
else
|
||||
|
@ -1500,27 +1500,27 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static OperationResult GenerateUnpackDouble2x32(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var value = context.GetFP64(operation.GetSource(0));
|
||||
var vector = context.GlslUnpackDouble2x32(context.TypeVector(context.TypeU32(), 2), value);
|
||||
var result = context.CompositeExtract(context.TypeU32(), vector, operation.Index);
|
||||
SpvInstruction value = context.GetFP64(operation.GetSource(0));
|
||||
SpvInstruction vector = context.GlslUnpackDouble2x32(context.TypeVector(context.TypeU32(), 2), value);
|
||||
SpvInstruction result = context.CompositeExtract(context.TypeU32(), vector, operation.Index);
|
||||
|
||||
return new OperationResult(AggregateType.U32, result);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateUnpackHalf2x16(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var value = context.GetU32(operation.GetSource(0));
|
||||
var vector = context.GlslUnpackHalf2x16(context.TypeVector(context.TypeFP32(), 2), value);
|
||||
var result = context.CompositeExtract(context.TypeFP32(), vector, operation.Index);
|
||||
SpvInstruction value = context.GetU32(operation.GetSource(0));
|
||||
SpvInstruction vector = context.GlslUnpackHalf2x16(context.TypeVector(context.TypeFP32(), 2), value);
|
||||
SpvInstruction result = context.CompositeExtract(context.TypeFP32(), vector, operation.Index);
|
||||
|
||||
return new OperationResult(AggregateType.FP32, result);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateVectorExtract(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var vector = context.GetWithType(operation.GetSource(0), out AggregateType vectorType);
|
||||
var scalarType = vectorType & ~AggregateType.ElementCountMask;
|
||||
var resultType = context.GetType(scalarType);
|
||||
SpvInstruction vector = context.GetWithType(operation.GetSource(0), out AggregateType vectorType);
|
||||
AggregateType scalarType = vectorType & ~AggregateType.ElementCountMask;
|
||||
SpvInstruction resultType = context.GetType(scalarType);
|
||||
SpvInstruction result;
|
||||
|
||||
if (operation.GetSource(1) is AstOperand indexOperand && indexOperand.Type == OperandType.Constant)
|
||||
|
@ -1529,7 +1529,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
}
|
||||
else
|
||||
{
|
||||
var index = context.Get(AggregateType.S32, operation.GetSource(1));
|
||||
SpvInstruction index = context.Get(AggregateType.S32, operation.GetSource(1));
|
||||
result = context.VectorExtractDynamic(resultType, vector, index);
|
||||
}
|
||||
|
||||
|
@ -1538,22 +1538,22 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static OperationResult GenerateVoteAll(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var execution = context.Constant(context.TypeU32(), Scope.Subgroup);
|
||||
var result = context.GroupNonUniformAll(context.TypeBool(), execution, context.Get(AggregateType.Bool, operation.GetSource(0)));
|
||||
SpvInstruction execution = context.Constant(context.TypeU32(), Scope.Subgroup);
|
||||
SpvInstruction result = context.GroupNonUniformAll(context.TypeBool(), execution, context.Get(AggregateType.Bool, operation.GetSource(0)));
|
||||
return new OperationResult(AggregateType.Bool, result);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateVoteAllEqual(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var execution = context.Constant(context.TypeU32(), Scope.Subgroup);
|
||||
var result = context.GroupNonUniformAllEqual(context.TypeBool(), execution, context.Get(AggregateType.Bool, operation.GetSource(0)));
|
||||
SpvInstruction execution = context.Constant(context.TypeU32(), Scope.Subgroup);
|
||||
SpvInstruction result = context.GroupNonUniformAllEqual(context.TypeBool(), execution, context.Get(AggregateType.Bool, operation.GetSource(0)));
|
||||
return new OperationResult(AggregateType.Bool, result);
|
||||
}
|
||||
|
||||
private static OperationResult GenerateVoteAny(CodeGenContext context, AstOperation operation)
|
||||
{
|
||||
var execution = context.Constant(context.TypeU32(), Scope.Subgroup);
|
||||
var result = context.GroupNonUniformAny(context.TypeBool(), execution, context.Get(AggregateType.Bool, operation.GetSource(0)));
|
||||
SpvInstruction execution = context.Constant(context.TypeU32(), Scope.Subgroup);
|
||||
SpvInstruction result = context.GroupNonUniformAny(context.TypeBool(), execution, context.Get(AggregateType.Bool, operation.GetSource(0)));
|
||||
return new OperationResult(AggregateType.Bool, result);
|
||||
}
|
||||
|
||||
|
@ -1563,8 +1563,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitF,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitI)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
|
||||
SpvInstruction result;
|
||||
|
||||
|
@ -1589,10 +1589,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
AstOperation operation,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitU)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
|
||||
var result = emitU(context.TypeBool(), context.GetU32(src1), context.GetU32(src2));
|
||||
SpvInstruction result = emitU(context.TypeBool(), context.GetU32(src1), context.GetU32(src2));
|
||||
|
||||
return new OperationResult(AggregateType.Bool, result);
|
||||
}
|
||||
|
@ -1604,10 +1604,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
{
|
||||
SpvInstruction elemPointer = GetStoragePointer(context, operation, out AggregateType varType);
|
||||
|
||||
var value = context.Get(varType, operation.GetSource(operation.SourcesCount - 1));
|
||||
SpvInstruction value = context.Get(varType, operation.GetSource(operation.SourcesCount - 1));
|
||||
|
||||
var one = context.Constant(context.TypeU32(), 1);
|
||||
var zero = context.Constant(context.TypeU32(), 0);
|
||||
SpvInstruction one = context.Constant(context.TypeU32(), 1);
|
||||
SpvInstruction zero = context.Constant(context.TypeU32(), 0);
|
||||
|
||||
return new OperationResult(varType, emitU(context.GetType(varType), elemPointer, one, zero, value));
|
||||
}
|
||||
|
@ -1616,11 +1616,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
{
|
||||
SpvInstruction elemPointer = GetStoragePointer(context, operation, out AggregateType varType);
|
||||
|
||||
var value0 = context.Get(varType, operation.GetSource(operation.SourcesCount - 2));
|
||||
var value1 = context.Get(varType, operation.GetSource(operation.SourcesCount - 1));
|
||||
SpvInstruction value0 = context.Get(varType, operation.GetSource(operation.SourcesCount - 2));
|
||||
SpvInstruction value1 = context.Get(varType, operation.GetSource(operation.SourcesCount - 1));
|
||||
|
||||
var one = context.Constant(context.TypeU32(), 1);
|
||||
var zero = context.Constant(context.TypeU32(), 0);
|
||||
SpvInstruction one = context.Constant(context.TypeU32(), 1);
|
||||
SpvInstruction zero = context.Constant(context.TypeU32(), 0);
|
||||
|
||||
return new OperationResult(varType, context.AtomicCompareExchange(context.GetType(varType), elemPointer, one, zero, zero, value1, value0));
|
||||
}
|
||||
|
@ -1636,7 +1636,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
}
|
||||
else
|
||||
{
|
||||
var result = context.Load(context.GetType(varType), pointer);
|
||||
SpvInstruction result = context.Load(context.GetType(varType), pointer);
|
||||
return new OperationResult(varType, result);
|
||||
}
|
||||
}
|
||||
|
@ -1754,8 +1754,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
storageClass = isOutput ? StorageClass.Output : StorageClass.Input;
|
||||
|
||||
var ioDefinition = new IoDefinition(storageKind, ioVariable, location, component);
|
||||
var dict = isPerPatch
|
||||
IoDefinition ioDefinition = new IoDefinition(storageKind, ioVariable, location, component);
|
||||
Dictionary<IoDefinition, SpvInstruction> dict = isPerPatch
|
||||
? (isOutput ? context.OutputsPerPatch : context.InputsPerPatch)
|
||||
: (isOutput ? context.Outputs : context.Inputs);
|
||||
|
||||
|
@ -1773,7 +1773,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
{
|
||||
int fieldIndex = IoMap.GetPerVertexStructFieldIndex(perVertexBuiltIn.Value);
|
||||
|
||||
var indexes = new SpvInstruction[inputsCount + 1];
|
||||
SpvInstruction[] indexes = new SpvInstruction[inputsCount + 1];
|
||||
int index = 0;
|
||||
|
||||
if (IoMap.IsPerVertexArrayBuiltIn(storageKind, context.Definitions.Stage))
|
||||
|
@ -1823,7 +1823,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
pointer = context.AccessChain(context.TypePointer(storageClass, context.GetType(varType)), baseObj, e0, e1, e2);
|
||||
break;
|
||||
default:
|
||||
var indexes = new SpvInstruction[inputsCount];
|
||||
SpvInstruction[] indexes = new SpvInstruction[inputsCount];
|
||||
int index = 0;
|
||||
|
||||
for (; index < inputsCount; srcIndex++, index++)
|
||||
|
@ -1840,10 +1840,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
|
||||
private static SpvInstruction GetScalarInput(CodeGenContext context, IoVariable ioVariable)
|
||||
{
|
||||
var (_, varType) = IoMap.GetSpirvBuiltIn(ioVariable);
|
||||
(_, AggregateType varType) = IoMap.GetSpirvBuiltIn(ioVariable);
|
||||
varType &= AggregateType.ElementTypeMask;
|
||||
|
||||
var ioDefinition = new IoDefinition(StorageKind.Input, ioVariable);
|
||||
IoDefinition ioDefinition = new IoDefinition(StorageKind.Input, ioVariable);
|
||||
|
||||
return context.Load(context.GetType(varType), context.Inputs[ioDefinition]);
|
||||
}
|
||||
|
@ -1917,7 +1917,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
Func<SpvInstruction, SpvInstruction, SpvInstruction> emitF,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction> emitI)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
|
||||
if (operation.Inst.HasFlag(Instruction.FP64))
|
||||
{
|
||||
|
@ -1938,7 +1938,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
AstOperation operation,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction> emitB)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
return new OperationResult(AggregateType.Bool, emitB(context.TypeBool(), context.Get(AggregateType.Bool, source)));
|
||||
}
|
||||
|
||||
|
@ -1947,7 +1947,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
AstOperation operation,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction> emit)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
return new OperationResult(AggregateType.FP32, emit(context.TypeFP32(), context.GetFP32(source)));
|
||||
}
|
||||
|
||||
|
@ -1956,7 +1956,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
AstOperation operation,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction> emitS)
|
||||
{
|
||||
var source = operation.GetSource(0);
|
||||
IAstNode source = operation.GetSource(0);
|
||||
return new OperationResult(AggregateType.S32, emitS(context.TypeS32(), context.GetS32(source)));
|
||||
}
|
||||
|
||||
|
@ -1966,12 +1966,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitF,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitI)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
|
||||
if (operation.Inst.HasFlag(Instruction.FP64))
|
||||
{
|
||||
var result = emitF(context.TypeFP64(), context.GetFP64(src1), context.GetFP64(src2));
|
||||
SpvInstruction result = emitF(context.TypeFP64(), context.GetFP64(src1), context.GetFP64(src2));
|
||||
|
||||
if (!context.HostCapabilities.ReducedPrecision || operation.ForcePrecise)
|
||||
{
|
||||
|
@ -1982,7 +1982,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
}
|
||||
else if (operation.Inst.HasFlag(Instruction.FP32))
|
||||
{
|
||||
var result = emitF(context.TypeFP32(), context.GetFP32(src1), context.GetFP32(src2));
|
||||
SpvInstruction result = emitF(context.TypeFP32(), context.GetFP32(src1), context.GetFP32(src2));
|
||||
|
||||
if (!context.HostCapabilities.ReducedPrecision || operation.ForcePrecise)
|
||||
{
|
||||
|
@ -2002,8 +2002,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
AstOperation operation,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitB)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
|
||||
return new OperationResult(AggregateType.Bool, emitB(context.TypeBool(), context.Get(AggregateType.Bool, src1), context.Get(AggregateType.Bool, src2)));
|
||||
}
|
||||
|
@ -2013,8 +2013,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
AstOperation operation,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitS)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
|
||||
return new OperationResult(AggregateType.S32, emitS(context.TypeS32(), context.GetS32(src1), context.GetS32(src2)));
|
||||
}
|
||||
|
@ -2024,8 +2024,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
AstOperation operation,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitU)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
|
||||
return new OperationResult(AggregateType.U32, emitU(context.TypeU32(), context.GetU32(src1), context.GetU32(src2)));
|
||||
}
|
||||
|
@ -2036,13 +2036,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitF,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitI)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
var src3 = operation.GetSource(2);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
IAstNode src3 = operation.GetSource(2);
|
||||
|
||||
if (operation.Inst.HasFlag(Instruction.FP64))
|
||||
{
|
||||
var result = emitF(context.TypeFP64(), context.GetFP64(src1), context.GetFP64(src2), context.GetFP64(src3));
|
||||
SpvInstruction result = emitF(context.TypeFP64(), context.GetFP64(src1), context.GetFP64(src2), context.GetFP64(src3));
|
||||
|
||||
if (!context.HostCapabilities.ReducedPrecision || operation.ForcePrecise)
|
||||
{
|
||||
|
@ -2053,7 +2053,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
}
|
||||
else if (operation.Inst.HasFlag(Instruction.FP32))
|
||||
{
|
||||
var result = emitF(context.TypeFP32(), context.GetFP32(src1), context.GetFP32(src2), context.GetFP32(src3));
|
||||
SpvInstruction result = emitF(context.TypeFP32(), context.GetFP32(src1), context.GetFP32(src2), context.GetFP32(src3));
|
||||
|
||||
if (!context.HostCapabilities.ReducedPrecision || operation.ForcePrecise)
|
||||
{
|
||||
|
@ -2073,9 +2073,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
AstOperation operation,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitU)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
var src3 = operation.GetSource(2);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
IAstNode src3 = operation.GetSource(2);
|
||||
|
||||
return new OperationResult(AggregateType.U32, emitU(
|
||||
context.TypeU32(),
|
||||
|
@ -2089,9 +2089,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
AstOperation operation,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitS)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
var src3 = operation.GetSource(2);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
IAstNode src3 = operation.GetSource(2);
|
||||
|
||||
return new OperationResult(AggregateType.S32, emitS(
|
||||
context.TypeS32(),
|
||||
|
@ -2105,10 +2105,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|||
AstOperation operation,
|
||||
Func<SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction, SpvInstruction> emitS)
|
||||
{
|
||||
var src1 = operation.GetSource(0);
|
||||
var src2 = operation.GetSource(1);
|
||||
var src3 = operation.GetSource(2);
|
||||
var src4 = operation.GetSource(3);
|
||||
IAstNode src1 = operation.GetSource(0);
|
||||
IAstNode src2 = operation.GetSource(1);
|
||||
IAstNode src3 = operation.GetSource(2);
|
||||
IAstNode src4 = operation.GetSource(3);
|
||||
|
||||
return new OperationResult(AggregateType.U32, emitS(
|
||||
context.TypeU32(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue