mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-02-22 09:03:36 +00:00
SPIRV/GLSL: More scaling related fixes
This commit is contained in:
parent
3aa5397bad
commit
0a7fbb6bfd
3 changed files with 30 additions and 9 deletions
|
@ -780,6 +780,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.Config.Stage.SupportsRenderScale() &&
|
if (context.Config.Stage.SupportsRenderScale() &&
|
||||||
|
(texOp.Index < 2 || (texOp.Type & SamplerType.Mask) == SamplerType.Texture3D) &&
|
||||||
!isBindless &&
|
!isBindless &&
|
||||||
!isIndexed)
|
!isIndexed)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1733,8 +1733,14 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
var type = context.SamplersTypes[meta];
|
var type = context.SamplersTypes[meta];
|
||||||
bool hasLod = !type.HasFlag(SamplerType.Multisample) && type != SamplerType.TextureBuffer;
|
bool hasLod = !type.HasFlag(SamplerType.Multisample) && type != SamplerType.TextureBuffer;
|
||||||
|
|
||||||
int components = (type & SamplerType.Mask) == SamplerType.TextureCube ? 2 : type.GetDimensions();
|
int dimensions = (type & SamplerType.Mask) == SamplerType.TextureCube ? 2 : type.GetDimensions();
|
||||||
var resultType = components == 1 ? context.TypeS32() : context.TypeVector(context.TypeS32(), components);
|
|
||||||
|
if (type.HasFlag(SamplerType.Array))
|
||||||
|
{
|
||||||
|
dimensions++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var resultType = dimensions == 1 ? context.TypeS32() : context.TypeVector(context.TypeS32(), dimensions);
|
||||||
|
|
||||||
SpvInstruction result;
|
SpvInstruction result;
|
||||||
|
|
||||||
|
@ -1749,12 +1755,15 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
result = context.ImageQuerySize(resultType, image);
|
result = context.ImageQuerySize(resultType, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (components != 1)
|
if (dimensions != 1)
|
||||||
{
|
{
|
||||||
result = context.CompositeExtract(context.TypeS32(), result, (SpvLiteralInteger)texOp.Index);
|
result = context.CompositeExtract(context.TypeS32(), result, (SpvLiteralInteger)texOp.Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ScalingHelpers.ApplyUnscaling(context, texOp, result, isBindless, isIndexed);
|
if (texOp.Index < 2 || (type & SamplerType.Mask) == SamplerType.Texture3D)
|
||||||
|
{
|
||||||
|
result = ScalingHelpers.ApplyUnscaling(context, texOp, result, isBindless, isIndexed);
|
||||||
|
}
|
||||||
|
|
||||||
return new OperationResult(AggregateType.S32, result);
|
return new OperationResult(AggregateType.S32, result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,9 +105,20 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
|
|
||||||
context.AddLabel(mergeLabel);
|
context.AddLabel(mergeLabel);
|
||||||
|
|
||||||
var passthroughVector = context.CompositeConstruct(context.TypeVector(context.TypeBool(), 2), passthrough, passthrough);
|
var passthroughLabel = context.Label();
|
||||||
|
var finalMergeLabel = context.Label();
|
||||||
|
|
||||||
return context.Select(ivector2Type, passthroughVector, vector, context.Load(ivector2Type, localVector));
|
context.SelectionMerge(finalMergeLabel, SelectionControlMask.MaskNone);
|
||||||
|
context.BranchConditional(passthrough, passthroughLabel, finalMergeLabel);
|
||||||
|
|
||||||
|
context.AddLabel(passthroughLabel);
|
||||||
|
|
||||||
|
context.Store(localVector, vector);
|
||||||
|
context.Branch(finalMergeLabel);
|
||||||
|
|
||||||
|
context.AddLabel(finalMergeLabel);
|
||||||
|
|
||||||
|
return context.Load(ivector2Type, localVector);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -149,7 +160,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
var fragCoord = context.Load(context.TypeVector(context.TypeFP32(), 4), fragCoordPointer);
|
var fragCoord = context.Load(context.TypeVector(context.TypeFP32(), 4), fragCoordPointer);
|
||||||
var fragCoordXY = context.VectorShuffle(vector2Type, fragCoord, fragCoord, 0, 1);
|
var fragCoordXY = context.VectorShuffle(vector2Type, fragCoord, fragCoord, 0, 1);
|
||||||
|
|
||||||
var scaleMod = context.FMod(vector2Type, scaleVector, fragCoordXY);
|
var scaleMod = context.FMod(vector2Type, fragCoordXY, scaleVector);
|
||||||
var vectorInterpolated = context.FAdd(vector2Type, vectorScaled, scaleMod);
|
var vectorInterpolated = context.FAdd(vector2Type, vectorScaled, scaleMod);
|
||||||
|
|
||||||
context.Store(output, context.ConvertFToS(context.TypeVector(context.TypeS32(), 2), vectorInterpolated));
|
context.Store(output, context.ConvertFToS(context.TypeVector(context.TypeS32(), 2), vectorInterpolated));
|
||||||
|
@ -199,12 +210,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
scaleIndex = context.IAdd(context.TypeU32(), scaleIndex, context.Constant(context.TypeU32(), 1));
|
scaleIndex = context.IAdd(context.TypeU32(), scaleIndex, context.Constant(context.TypeU32(), 1));
|
||||||
|
|
||||||
var scaleElemPointer = context.AccessChain(pointerType, context.SupportBuffer, fieldIndex, scaleIndex);
|
var scaleElemPointer = context.AccessChain(pointerType, context.SupportBuffer, fieldIndex, scaleIndex);
|
||||||
var scale = context.Load(context.TypeFP32(), scaleElemPointer);
|
var scale = context.GlslFAbs(context.TypeFP32(), context.Load(context.TypeFP32(), scaleElemPointer));
|
||||||
|
|
||||||
var passthrough = context.FOrdEqual(context.TypeBool(), scale, context.Constant(context.TypeFP32(), 1f));
|
var passthrough = context.FOrdEqual(context.TypeBool(), scale, context.Constant(context.TypeFP32(), 1f));
|
||||||
|
|
||||||
var sizeFloat = context.ConvertSToF(context.TypeFP32(), size);
|
var sizeFloat = context.ConvertSToF(context.TypeFP32(), size);
|
||||||
var sizeUnscaled = context.FDiv(context.TypeFP32(), size, scale);
|
var sizeUnscaled = context.FDiv(context.TypeFP32(), sizeFloat, scale);
|
||||||
var sizeUnscaledInt = context.ConvertFToS(context.TypeS32(), sizeUnscaled);
|
var sizeUnscaledInt = context.ConvertFToS(context.TypeS32(), sizeUnscaled);
|
||||||
|
|
||||||
return context.Select(context.TypeS32(), passthrough, size, sizeUnscaledInt);
|
return context.Select(context.TypeS32(), passthrough, size, sizeUnscaledInt);
|
||||||
|
|
Loading…
Reference in a new issue