mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-02-23 01:20:21 +00:00
SPIR-V: Fix TextureSize for MS and Buffer sampler types
This commit is contained in:
parent
95d5a50042
commit
324d0528d3
3 changed files with 19 additions and 6 deletions
|
@ -25,6 +25,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
public Instruction SharedMemory { get; set; }
|
public Instruction SharedMemory { get; set; }
|
||||||
public Instruction InputsArray { get; set; }
|
public Instruction InputsArray { get; set; }
|
||||||
public Instruction OutputsArray { get; set; }
|
public Instruction OutputsArray { get; set; }
|
||||||
|
public Dictionary<TextureMeta, SamplerType> SamplersTypes { get; } = new Dictionary<TextureMeta, SamplerType>();
|
||||||
public Dictionary<TextureMeta, (Instruction, Instruction, Instruction)> Samplers { get; } = new Dictionary<TextureMeta, (Instruction, Instruction, Instruction)>();
|
public Dictionary<TextureMeta, (Instruction, Instruction, Instruction)> Samplers { get; } = new Dictionary<TextureMeta, (Instruction, Instruction, Instruction)>();
|
||||||
public Dictionary<TextureMeta, (Instruction, Instruction)> Images { get; } = new Dictionary<TextureMeta, (Instruction, Instruction)>();
|
public Dictionary<TextureMeta, (Instruction, Instruction)> Images { get; } = new Dictionary<TextureMeta, (Instruction, Instruction)>();
|
||||||
public Dictionary<int, Instruction> Inputs { get; } = new Dictionary<int, Instruction>();
|
public Dictionary<int, Instruction> Inputs { get; } = new Dictionary<int, Instruction>();
|
||||||
|
|
|
@ -213,6 +213,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
var sampledImageVariable = context.Variable(sampledImagePointerType, StorageClass.UniformConstant);
|
var sampledImageVariable = context.Variable(sampledImagePointerType, StorageClass.UniformConstant);
|
||||||
|
|
||||||
context.Samplers.Add(meta, (imageType, sampledImageType, sampledImageVariable));
|
context.Samplers.Add(meta, (imageType, sampledImageType, sampledImageVariable));
|
||||||
|
context.SamplersTypes.Add(meta, descriptor.Type);
|
||||||
|
|
||||||
context.Name(sampledImageVariable, $"{GetStagePrefix(context.Config.Stage)}_tex{nameSuffix}");
|
context.Name(sampledImageVariable, $"{GetStagePrefix(context.Config.Stage)}_tex{nameSuffix}");
|
||||||
context.Decorate(sampledImageVariable, Decoration.DescriptorSet, (LiteralInteger)setIndex);
|
context.Decorate(sampledImageVariable, Decoration.DescriptorSet, (LiteralInteger)setIndex);
|
||||||
|
|
|
@ -1662,10 +1662,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
index = context.GetS32(texOp.GetSource(0));
|
index = context.GetS32(texOp.GetSource(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
int lodSrcIndex = isBindless || isIndexed ? 1 : 0;
|
|
||||||
|
|
||||||
var lod = context.GetS32(operation.GetSource(lodSrcIndex));
|
|
||||||
|
|
||||||
var meta = new TextureMeta(texOp.CbufSlot, texOp.Handle, texOp.Format);
|
var meta = new TextureMeta(texOp.CbufSlot, texOp.Handle, texOp.Format);
|
||||||
|
|
||||||
(var imageType, var sampledImageType, var sampledImageVariable) = context.Samplers[meta];
|
(var imageType, var sampledImageType, var sampledImageVariable) = context.Samplers[meta];
|
||||||
|
@ -1679,9 +1675,24 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int components = (texOp.Type & SamplerType.Mask) == SamplerType.TextureCube ? 2 : texOp.Type.GetDimensions();
|
var type = context.SamplersTypes[meta];
|
||||||
|
bool hasLod = !type.HasFlag(SamplerType.Multisample) && type != SamplerType.TextureBuffer;
|
||||||
|
|
||||||
|
int components = (type & SamplerType.Mask) == SamplerType.TextureCube ? 2 : type.GetDimensions();
|
||||||
var resultType = components == 1 ? context.TypeS32() : context.TypeVector(context.TypeS32(), components);
|
var resultType = components == 1 ? context.TypeS32() : context.TypeVector(context.TypeS32(), components);
|
||||||
var result = context.ImageQuerySizeLod(resultType, image, lod);
|
|
||||||
|
SpvInstruction result;
|
||||||
|
|
||||||
|
if (hasLod)
|
||||||
|
{
|
||||||
|
int lodSrcIndex = isBindless || isIndexed ? 1 : 0;
|
||||||
|
var lod = context.GetS32(operation.GetSource(lodSrcIndex));
|
||||||
|
result = context.ImageQuerySizeLod(resultType, image, lod);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = context.ImageQuerySize(resultType, image);
|
||||||
|
}
|
||||||
|
|
||||||
if (components != 1)
|
if (components != 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue