Fix inverse viewport transform vector type on SPIR-V

This commit is contained in:
gdk 2022-05-24 18:38:55 -03:00 committed by riperiperi
parent 281f16aa36
commit c832f55618
3 changed files with 9 additions and 8 deletions

View file

@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
private const ushort FileFormatVersionMajor = 1;
private const ushort FileFormatVersionMinor = 2;
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
private const uint CodeGenVersion = 7;
private const uint CodeGenVersion = 8;
private const string SharedTocFileName = "shared.toc";
private const string SharedDataFileName = "shared.data";

View file

@ -141,12 +141,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
}
var isBgraArrayType = context.TypeArray(context.TypeU32(), context.Constant(context.TypeU32(), SupportBuffer.FragmentIsBgraCount));
var viewportInverseVectorType = context.TypeVector(context.TypeFP32(), 4);
var renderScaleArrayType = context.TypeArray(context.TypeFP32(), context.Constant(context.TypeU32(), SupportBuffer.RenderScaleMaxCount));
context.Decorate(isBgraArrayType, Decoration.ArrayStride, (LiteralInteger)SupportBuffer.FieldSize);
context.Decorate(renderScaleArrayType, Decoration.ArrayStride, (LiteralInteger)SupportBuffer.FieldSize);
var supportBufferStructType = context.TypeStruct(false, context.TypeU32(), isBgraArrayType, context.GetType(AggregateType.FP32 | AggregateType.Vector), context.TypeS32(), renderScaleArrayType);
var supportBufferStructType = context.TypeStruct(false, context.TypeU32(), isBgraArrayType, viewportInverseVectorType, context.TypeS32(), renderScaleArrayType);
context.MemberDecorate(supportBufferStructType, 0, Decoration.Offset, (LiteralInteger)SupportBuffer.FragmentAlphaTestOffset);
context.MemberDecorate(supportBufferStructType, 1, Decoration.Offset, (LiteralInteger)SupportBuffer.FragmentIsBgraOffset);

View file

@ -1434,16 +1434,16 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
var y = context.Get(AggregateType.FP32, operation.GetSource(1));
var mask = context.Get(AggregateType.U32, operation.GetSource(2));
var v4float = context.TypeVector(context.TypeFP32(), (SpvLiteralInteger)4);
var one = context.Constant(context.TypeFP32(), (SpvLiteralInteger)1.0f);
var minusOne = context.Constant(context.TypeFP32(), (SpvLiteralInteger)(-1.0f));
var zero = context.Constant(context.TypeFP32(), (SpvLiteralInteger)0.0f);
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);
var threadId = context.GetAttribute(AggregateType.U32, AttributeConsts.LaneId, false);
var shift = context.BitwiseAnd(context.TypeU32(), threadId, context.Constant(context.TypeU32(), (SpvLiteralInteger)3));
shift = context.ShiftLeftLogical(context.TypeU32(), shift, context.Constant(context.TypeU32(), (SpvLiteralInteger)1));
var shift = context.BitwiseAnd(context.TypeU32(), threadId, context.Constant(context.TypeU32(), 3));
shift = context.ShiftLeftLogical(context.TypeU32(), shift, context.Constant(context.TypeU32(), 1));
var lutIdx = context.ShiftRightLogical(context.TypeU32(), mask, shift);
var xLutValue = context.VectorExtractDynamic(context.TypeFP32(), xLut, lutIdx);