Pass texture set index everywhere
This commit is contained in:
parent
f83a4739ce
commit
566ad9209d
17 changed files with 182 additions and 67 deletions
|
@ -1,4 +1,4 @@
|
|||
using Ryujinx.Graphics.Shader.CodeGen;
|
||||
using Ryujinx.Graphics.Shader.CodeGen;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.Shader
|
||||
|
|
|
@ -278,7 +278,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
flags |= TextureFlags.Bindless;
|
||||
}
|
||||
|
||||
int binding = isBindless ? 0 : context.ResourceManager.GetTextureOrImageBinding(
|
||||
SetBindingPair setAndBinding = isBindless ? default : context.ResourceManager.GetTextureOrImageBinding(
|
||||
Instruction.ImageAtomic,
|
||||
type,
|
||||
format,
|
||||
|
@ -286,7 +286,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
TextureOperation.DefaultCbufSlot,
|
||||
imm);
|
||||
|
||||
Operand res = context.ImageAtomic(type, format, flags, binding, sources);
|
||||
Operand res = context.ImageAtomic(type, format, flags, setAndBinding, sources);
|
||||
|
||||
context.Copy(d, res);
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
|
||||
TextureFormat format = isBindless ? TextureFormat.Unknown : ShaderProperties.GetTextureFormat(context.TranslatorContext.GpuAccessor, handle);
|
||||
|
||||
int binding = isBindless ? 0 : context.ResourceManager.GetTextureOrImageBinding(
|
||||
SetBindingPair setAndBinding = isBindless ? default : context.ResourceManager.GetTextureOrImageBinding(
|
||||
Instruction.ImageLoad,
|
||||
type,
|
||||
format,
|
||||
|
@ -397,7 +397,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
TextureOperation.DefaultCbufSlot,
|
||||
handle);
|
||||
|
||||
context.ImageLoad(type, format, flags, binding, (int)componentMask, dests, sources);
|
||||
context.ImageLoad(type, format, flags, setAndBinding, (int)componentMask, dests, sources);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -432,7 +432,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
|
||||
TextureFormat format = GetTextureFormat(size);
|
||||
|
||||
int binding = isBindless ? 0 : context.ResourceManager.GetTextureOrImageBinding(
|
||||
SetBindingPair setAndBinding = isBindless ? default : context.ResourceManager.GetTextureOrImageBinding(
|
||||
Instruction.ImageLoad,
|
||||
type,
|
||||
format,
|
||||
|
@ -440,7 +440,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
TextureOperation.DefaultCbufSlot,
|
||||
handle);
|
||||
|
||||
context.ImageLoad(type, format, flags, binding, compMask, dests, sources);
|
||||
context.ImageLoad(type, format, flags, setAndBinding, compMask, dests, sources);
|
||||
|
||||
switch (size)
|
||||
{
|
||||
|
@ -552,7 +552,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
flags |= TextureFlags.Bindless;
|
||||
}
|
||||
|
||||
int binding = isBindless ? 0 : context.ResourceManager.GetTextureOrImageBinding(
|
||||
SetBindingPair setAndBinding = isBindless ? default : context.ResourceManager.GetTextureOrImageBinding(
|
||||
Instruction.ImageAtomic,
|
||||
type,
|
||||
format,
|
||||
|
@ -560,7 +560,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
TextureOperation.DefaultCbufSlot,
|
||||
imm);
|
||||
|
||||
context.ImageAtomic(type, format, flags, binding, sources);
|
||||
context.ImageAtomic(type, format, flags, setAndBinding, sources);
|
||||
}
|
||||
|
||||
private static void EmitSust(
|
||||
|
@ -679,7 +679,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
flags |= TextureFlags.Coherent;
|
||||
}
|
||||
|
||||
int binding = isBindless ? 0 : context.ResourceManager.GetTextureOrImageBinding(
|
||||
SetBindingPair setAndBinding = isBindless ? default : context.ResourceManager.GetTextureOrImageBinding(
|
||||
Instruction.ImageStore,
|
||||
type,
|
||||
format,
|
||||
|
@ -687,7 +687,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
TextureOperation.DefaultCbufSlot,
|
||||
handle);
|
||||
|
||||
context.ImageStore(type, format, flags, binding, sources);
|
||||
context.ImageStore(type, format, flags, setAndBinding, sources);
|
||||
}
|
||||
|
||||
private static int GetComponentSizeInBytesLog2(SuatomSize size)
|
||||
|
|
|
@ -885,7 +885,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
return Register(dest++, RegisterType.Gpr);
|
||||
}
|
||||
|
||||
int binding = isBindless ? 0 : context.ResourceManager.GetTextureOrImageBinding(
|
||||
SetBindingPair setAndBinding = isBindless ? default : context.ResourceManager.GetTextureOrImageBinding(
|
||||
Instruction.Lod,
|
||||
type,
|
||||
TextureFormat.Unknown,
|
||||
|
@ -913,7 +913,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
else
|
||||
{
|
||||
// The instruction component order is the inverse of GLSL's.
|
||||
Operand res = context.Lod(type, flags, binding, compIndex ^ 1, sources);
|
||||
Operand res = context.Lod(type, flags, setAndBinding, compIndex ^ 1, sources);
|
||||
|
||||
res = context.FPMultiply(res, ConstF(256.0f));
|
||||
|
||||
|
@ -1116,12 +1116,12 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
}
|
||||
|
||||
TextureFlags flags = isBindless ? TextureFlags.Bindless : TextureFlags.None;
|
||||
int binding;
|
||||
SetBindingPair setAndBinding;
|
||||
|
||||
switch (query)
|
||||
{
|
||||
case TexQuery.TexHeaderDimension:
|
||||
binding = isBindless ? 0 : context.ResourceManager.GetTextureOrImageBinding(
|
||||
setAndBinding = isBindless ? default : context.ResourceManager.GetTextureOrImageBinding(
|
||||
Instruction.TextureQuerySize,
|
||||
type,
|
||||
TextureFormat.Unknown,
|
||||
|
@ -1140,13 +1140,13 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
break;
|
||||
}
|
||||
|
||||
context.Copy(d, context.TextureQuerySize(type, flags, binding, compIndex, sources));
|
||||
context.Copy(d, context.TextureQuerySize(type, flags, setAndBinding, compIndex, sources));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TexQuery.TexHeaderTextureType:
|
||||
binding = isBindless ? 0 : context.ResourceManager.GetTextureOrImageBinding(
|
||||
setAndBinding = isBindless ? default : context.ResourceManager.GetTextureOrImageBinding(
|
||||
Instruction.TextureQuerySamples,
|
||||
type,
|
||||
TextureFormat.Unknown,
|
||||
|
@ -1171,7 +1171,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
|
||||
if (d != null)
|
||||
{
|
||||
context.Copy(d, context.TextureQuerySamples(type, flags, binding, sources));
|
||||
context.Copy(d, context.TextureQuerySamples(type, flags, setAndBinding, sources));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1191,7 +1191,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
Operand[] dests,
|
||||
Operand[] sources)
|
||||
{
|
||||
int binding = flags.HasFlag(TextureFlags.Bindless) ? 0 : context.ResourceManager.GetTextureOrImageBinding(
|
||||
SetBindingPair setAndBinding = flags.HasFlag(TextureFlags.Bindless) ? default : context.ResourceManager.GetTextureOrImageBinding(
|
||||
Instruction.TextureSample,
|
||||
type,
|
||||
TextureFormat.Unknown,
|
||||
|
@ -1199,7 +1199,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
|||
TextureOperation.DefaultCbufSlot,
|
||||
handle);
|
||||
|
||||
context.TextureSample(type, flags, binding, componentMask, dests, sources);
|
||||
context.TextureSample(type, flags, setAndBinding, componentMask, dests, sources);
|
||||
}
|
||||
|
||||
private static SamplerType ConvertSamplerType(TexDim dimensions)
|
||||
|
|
|
@ -8,7 +8,9 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
|
|||
public TextureFormat Format { get; set; }
|
||||
public TextureFlags Flags { get; private set; }
|
||||
|
||||
public int Set { get; private set; }
|
||||
public int Binding { get; private set; }
|
||||
public int SamplerSet { get; private set; }
|
||||
public int SamplerBinding { get; private set; }
|
||||
|
||||
public TextureOperation(
|
||||
|
@ -16,6 +18,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
|
|||
SamplerType type,
|
||||
TextureFormat format,
|
||||
TextureFlags flags,
|
||||
int set,
|
||||
int binding,
|
||||
int compIndex,
|
||||
Operand[] dests,
|
||||
|
@ -24,24 +27,28 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
|
|||
Type = type;
|
||||
Format = format;
|
||||
Flags = flags;
|
||||
Set = set;
|
||||
Binding = binding;
|
||||
SamplerSet = -1;
|
||||
SamplerBinding = -1;
|
||||
}
|
||||
|
||||
public void TurnIntoArray(int binding)
|
||||
public void TurnIntoArray(SetBindingPair setAndBinding)
|
||||
{
|
||||
Flags &= ~TextureFlags.Bindless;
|
||||
Binding = binding;
|
||||
Set = setAndBinding.SetIndex;
|
||||
Binding = setAndBinding.Binding;
|
||||
}
|
||||
|
||||
public void TurnIntoArray(int textureBinding, int samplerBinding)
|
||||
public void TurnIntoArray(SetBindingPair textureSetAndBinding, SetBindingPair samplerSetAndBinding)
|
||||
{
|
||||
TurnIntoArray(textureBinding);
|
||||
TurnIntoArray(textureSetAndBinding);
|
||||
|
||||
SamplerBinding = samplerBinding;
|
||||
SamplerSet = samplerSetAndBinding.SetIndex;
|
||||
SamplerBinding = samplerSetAndBinding.Binding;
|
||||
}
|
||||
|
||||
public void SetBinding(int binding)
|
||||
public void SetBinding(SetBindingPair setAndBinding)
|
||||
{
|
||||
if ((Flags & TextureFlags.Bindless) != 0)
|
||||
{
|
||||
|
@ -50,7 +57,8 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
|
|||
RemoveSource(0);
|
||||
}
|
||||
|
||||
Binding = binding;
|
||||
Set = setAndBinding.SetIndex;
|
||||
Binding = setAndBinding.Binding;
|
||||
}
|
||||
|
||||
public void SetLodLevelFlag()
|
||||
|
|
|
@ -38,4 +38,4 @@ namespace Ryujinx.Graphics.Shader
|
|||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
|||
public TextureFormat Format { get; }
|
||||
public TextureFlags Flags { get; }
|
||||
|
||||
public int Set { get; }
|
||||
public int Binding { get; }
|
||||
public int SamplerSet { get; }
|
||||
public int SamplerBinding { get; }
|
||||
|
||||
public bool IsSeparate => SamplerBinding >= 0;
|
||||
|
@ -18,7 +20,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
|||
SamplerType type,
|
||||
TextureFormat format,
|
||||
TextureFlags flags,
|
||||
int set,
|
||||
int binding,
|
||||
int samplerSet,
|
||||
int samplerBinding,
|
||||
int index,
|
||||
params IAstNode[] sources) : base(inst, StorageKind.None, false, index, sources, sources.Length)
|
||||
|
@ -26,7 +30,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
|||
Type = type;
|
||||
Format = format;
|
||||
Flags = flags;
|
||||
Set = set;
|
||||
Binding = binding;
|
||||
SamplerSet = samplerSet;
|
||||
SamplerBinding = samplerBinding;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,7 +169,17 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
|||
|
||||
AstTextureOperation GetAstTextureOperation(TextureOperation texOp)
|
||||
{
|
||||
return new AstTextureOperation(inst, texOp.Type, texOp.Format, texOp.Flags, texOp.Binding, texOp.SamplerBinding, texOp.Index, sources);
|
||||
return new AstTextureOperation(
|
||||
inst,
|
||||
texOp.Type,
|
||||
texOp.Format,
|
||||
texOp.Flags,
|
||||
texOp.Set,
|
||||
texOp.Binding,
|
||||
texOp.SamplerSet,
|
||||
texOp.SamplerBinding,
|
||||
texOp.Index,
|
||||
sources);
|
||||
}
|
||||
|
||||
int componentsCount = BitOperations.PopCount((uint)operation.Index);
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
this.TextureSample(
|
||||
SamplerType.TextureBuffer,
|
||||
TextureFlags.IntCoords,
|
||||
ResourceManager.Reservations.IndexBufferTextureBinding,
|
||||
ResourceManager.Reservations.GetIndexBufferTextureSetAndBinding(),
|
||||
1,
|
||||
new[] { vertexIndexVr },
|
||||
new[] { this.IAdd(ibBaseOffset, outputVertexOffset) });
|
||||
|
@ -145,7 +145,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
this.TextureSample(
|
||||
SamplerType.TextureBuffer,
|
||||
TextureFlags.IntCoords,
|
||||
ResourceManager.Reservations.TopologyRemapBufferTextureBinding,
|
||||
ResourceManager.Reservations.GetTopologyRemapBufferTextureSetAndBinding(),
|
||||
1,
|
||||
new[] { vertexIndex },
|
||||
new[] { this.IAdd(baseVertex, Const(index)) });
|
||||
|
|
|
@ -618,12 +618,21 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
SamplerType type,
|
||||
TextureFormat format,
|
||||
TextureFlags flags,
|
||||
int binding,
|
||||
SetBindingPair setAndBinding,
|
||||
Operand[] sources)
|
||||
{
|
||||
Operand dest = Local();
|
||||
|
||||
context.Add(new TextureOperation(Instruction.ImageAtomic, type, format, flags, binding, 0, new[] { dest }, sources));
|
||||
context.Add(new TextureOperation(
|
||||
Instruction.ImageAtomic,
|
||||
type,
|
||||
format,
|
||||
flags,
|
||||
setAndBinding.SetIndex,
|
||||
setAndBinding.Binding,
|
||||
0,
|
||||
new[] { dest },
|
||||
sources));
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
@ -633,12 +642,21 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
SamplerType type,
|
||||
TextureFormat format,
|
||||
TextureFlags flags,
|
||||
int binding,
|
||||
SetBindingPair setAndBinding,
|
||||
int compMask,
|
||||
Operand[] dests,
|
||||
Operand[] sources)
|
||||
{
|
||||
context.Add(new TextureOperation(Instruction.ImageLoad, type, format, flags, binding, compMask, dests, sources));
|
||||
context.Add(new TextureOperation(
|
||||
Instruction.ImageLoad,
|
||||
type,
|
||||
format,
|
||||
flags,
|
||||
setAndBinding.SetIndex,
|
||||
setAndBinding.Binding,
|
||||
compMask,
|
||||
dests,
|
||||
sources));
|
||||
}
|
||||
|
||||
public static void ImageStore(
|
||||
|
@ -646,10 +664,19 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
SamplerType type,
|
||||
TextureFormat format,
|
||||
TextureFlags flags,
|
||||
int binding,
|
||||
SetBindingPair setAndBinding,
|
||||
Operand[] sources)
|
||||
{
|
||||
context.Add(new TextureOperation(Instruction.ImageStore, type, format, flags, binding, 0, null, sources));
|
||||
context.Add(new TextureOperation(
|
||||
Instruction.ImageStore,
|
||||
type,
|
||||
format,
|
||||
flags,
|
||||
setAndBinding.SetIndex,
|
||||
setAndBinding.Binding,
|
||||
0,
|
||||
null,
|
||||
sources));
|
||||
}
|
||||
|
||||
public static Operand IsNan(this EmitterContext context, Operand a, Instruction fpType = Instruction.FP32)
|
||||
|
@ -718,13 +745,22 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
this EmitterContext context,
|
||||
SamplerType type,
|
||||
TextureFlags flags,
|
||||
int binding,
|
||||
SetBindingPair setAndBinding,
|
||||
int compIndex,
|
||||
Operand[] sources)
|
||||
{
|
||||
Operand dest = Local();
|
||||
|
||||
context.Add(new TextureOperation(Instruction.Lod, type, TextureFormat.Unknown, flags, binding, compIndex, new[] { dest }, sources));
|
||||
context.Add(new TextureOperation(
|
||||
Instruction.Lod,
|
||||
type,
|
||||
TextureFormat.Unknown,
|
||||
flags,
|
||||
setAndBinding.SetIndex,
|
||||
setAndBinding.Binding,
|
||||
compIndex,
|
||||
new[] { dest },
|
||||
sources));
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
@ -889,24 +925,42 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
this EmitterContext context,
|
||||
SamplerType type,
|
||||
TextureFlags flags,
|
||||
int binding,
|
||||
SetBindingPair setAndBinding,
|
||||
int compMask,
|
||||
Operand[] dests,
|
||||
Operand[] sources)
|
||||
{
|
||||
context.Add(new TextureOperation(Instruction.TextureSample, type, TextureFormat.Unknown, flags, binding, compMask, dests, sources));
|
||||
context.Add(new TextureOperation(
|
||||
Instruction.TextureSample,
|
||||
type,
|
||||
TextureFormat.Unknown,
|
||||
flags,
|
||||
setAndBinding.SetIndex,
|
||||
setAndBinding.Binding,
|
||||
compMask,
|
||||
dests,
|
||||
sources));
|
||||
}
|
||||
|
||||
public static Operand TextureQuerySamples(
|
||||
this EmitterContext context,
|
||||
SamplerType type,
|
||||
TextureFlags flags,
|
||||
int binding,
|
||||
SetBindingPair setAndBinding,
|
||||
Operand[] sources)
|
||||
{
|
||||
Operand dest = Local();
|
||||
|
||||
context.Add(new TextureOperation(Instruction.TextureQuerySamples, type, TextureFormat.Unknown, flags, binding, 0, new[] { dest }, sources));
|
||||
context.Add(new TextureOperation(
|
||||
Instruction.TextureQuerySamples,
|
||||
type,
|
||||
TextureFormat.Unknown,
|
||||
flags,
|
||||
setAndBinding.SetIndex,
|
||||
setAndBinding.Binding,
|
||||
0,
|
||||
new[] { dest },
|
||||
sources));
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
@ -915,13 +969,22 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
this EmitterContext context,
|
||||
SamplerType type,
|
||||
TextureFlags flags,
|
||||
int binding,
|
||||
SetBindingPair setAndBinding,
|
||||
int compIndex,
|
||||
Operand[] sources)
|
||||
{
|
||||
Operand dest = Local();
|
||||
|
||||
context.Add(new TextureOperation(Instruction.TextureQuerySize, type, TextureFormat.Unknown, flags, binding, compIndex, new[] { dest }, sources));
|
||||
context.Add(new TextureOperation(
|
||||
Instruction.TextureQuerySize,
|
||||
type,
|
||||
TextureFormat.Unknown,
|
||||
flags,
|
||||
setAndBinding.SetIndex,
|
||||
setAndBinding.Binding,
|
||||
compIndex,
|
||||
new[] { dest },
|
||||
sources));
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
bool hasSampler = !texOp.Inst.IsImage();
|
||||
|
||||
int textureBinding = resourceManager.GetTextureOrImageBinding(
|
||||
SetBindingPair textureSetAndBinding = resourceManager.GetTextureOrImageBinding(
|
||||
texOp.Inst,
|
||||
texOp.Type,
|
||||
texOp.Format,
|
||||
|
@ -111,7 +111,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
texOp.InsertSource(1, samplerIndex);
|
||||
|
||||
int samplerBinding = resourceManager.GetTextureOrImageBinding(
|
||||
SetBindingPair samplerSetAndBinding = resourceManager.GetTextureOrImageBinding(
|
||||
texOp.Inst,
|
||||
SamplerType.None,
|
||||
texOp.Format,
|
||||
|
@ -120,11 +120,11 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
TextureHandle.PackOffsets(0, 0, TextureHandleType.Direct),
|
||||
samplerPoolLength);
|
||||
|
||||
texOp.TurnIntoArray(textureBinding, samplerBinding);
|
||||
texOp.TurnIntoArray(textureSetAndBinding, samplerSetAndBinding);
|
||||
}
|
||||
else
|
||||
{
|
||||
texOp.TurnIntoArray(textureBinding);
|
||||
texOp.TurnIntoArray(textureSetAndBinding);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -445,7 +445,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
}
|
||||
}
|
||||
|
||||
int binding = resourceManager.GetTextureOrImageBinding(
|
||||
SetBindingPair setAndBinding = resourceManager.GetTextureOrImageBinding(
|
||||
texOp.Inst,
|
||||
texOp.Type,
|
||||
texOp.Format,
|
||||
|
@ -453,7 +453,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
cbufSlot,
|
||||
cbufOffset);
|
||||
|
||||
texOp.SetBinding(binding);
|
||||
texOp.SetBinding(setAndBinding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
|
||||
private static void TurnIntoArray(ResourceManager resourceManager, TextureOperation texOp, int cbufSlot, int handleIndex, int length)
|
||||
{
|
||||
int binding = resourceManager.GetTextureOrImageBinding(
|
||||
SetBindingPair setAndBinding = resourceManager.GetTextureOrImageBinding(
|
||||
texOp.Inst,
|
||||
texOp.Type,
|
||||
texOp.Format,
|
||||
|
@ -230,7 +230,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
handleIndex,
|
||||
length);
|
||||
|
||||
texOp.TurnIntoArray(binding);
|
||||
texOp.TurnIntoArray(setAndBinding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
return false;
|
||||
}
|
||||
|
||||
public int GetTextureOrImageBinding(
|
||||
public SetBindingPair GetTextureOrImageBinding(
|
||||
Instruction inst,
|
||||
SamplerType type,
|
||||
TextureFormat format,
|
||||
|
@ -243,7 +243,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
format = TextureFormat.Unknown;
|
||||
}
|
||||
|
||||
int binding = GetTextureOrImageBinding(
|
||||
SetBindingPair setAndBinding = GetTextureOrImageBinding(
|
||||
cbufSlot,
|
||||
handle,
|
||||
arrayLength,
|
||||
|
@ -258,10 +258,10 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
_gpuAccessor.RegisterTexture(handle, cbufSlot);
|
||||
|
||||
return binding;
|
||||
return setAndBinding;
|
||||
}
|
||||
|
||||
private int GetTextureOrImageBinding(
|
||||
private SetBindingPair GetTextureOrImageBinding(
|
||||
int cbufSlot,
|
||||
int handle,
|
||||
int arrayLength,
|
||||
|
@ -381,7 +381,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
Properties.AddOrUpdateTexture(definition);
|
||||
}
|
||||
|
||||
return binding;
|
||||
return new SetBindingPair(setIndex, binding);
|
||||
}
|
||||
|
||||
private static TextureMeta MergeTextureMeta(TextureMeta meta, TextureMeta existingMeta)
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
public const int MaxVertexBufferTextures = 32;
|
||||
|
||||
private const int TextureSetIndex = 2; // TODO: Get from GPU accessor.
|
||||
|
||||
public int VertexInfoConstantBufferBinding { get; }
|
||||
public int VertexOutputStorageBufferBinding { get; }
|
||||
public int GeometryVertexOutputStorageBufferBinding { get; }
|
||||
|
@ -163,6 +165,21 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
return _vertexBufferTextureBaseBinding + vaLocation;
|
||||
}
|
||||
|
||||
public SetBindingPair GetVertexBufferTextureSetAndBinding(int vaLocation)
|
||||
{
|
||||
return new SetBindingPair(TextureSetIndex, GetVertexBufferTextureBinding(vaLocation));
|
||||
}
|
||||
|
||||
public SetBindingPair GetIndexBufferTextureSetAndBinding()
|
||||
{
|
||||
return new SetBindingPair(TextureSetIndex, IndexBufferTextureBinding);
|
||||
}
|
||||
|
||||
public SetBindingPair GetTopologyRemapBufferTextureSetAndBinding()
|
||||
{
|
||||
return new SetBindingPair(TextureSetIndex, TopologyRemapBufferTextureBinding);
|
||||
}
|
||||
|
||||
internal bool TryGetOffset(StorageKind storageKind, int location, int component, out int offset)
|
||||
{
|
||||
return _offsets.TryGetValue(new IoDefinition(storageKind, IoVariable.UserDefined, location, component), out offset);
|
||||
|
|
|
@ -182,6 +182,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
texOp.Type,
|
||||
texOp.Format,
|
||||
texOp.Flags,
|
||||
texOp.Set,
|
||||
texOp.Binding,
|
||||
index,
|
||||
new[] { coordSize },
|
||||
|
@ -251,6 +252,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
texOp.Type,
|
||||
texOp.Format,
|
||||
texOp.Flags,
|
||||
texOp.Set,
|
||||
texOp.Binding,
|
||||
index,
|
||||
new[] { coordSize },
|
||||
|
@ -471,6 +473,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
texOp.Type,
|
||||
texOp.Format,
|
||||
texOp.Flags & ~(TextureFlags.Offset | TextureFlags.Offsets),
|
||||
texOp.Set,
|
||||
texOp.Binding,
|
||||
1 << 3, // W component: i=0, j=0
|
||||
new[] { dests[destIndex++] },
|
||||
|
@ -527,6 +530,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
texOp.Type,
|
||||
texOp.Format,
|
||||
texOp.Flags & ~(TextureFlags.Offset | TextureFlags.Offsets),
|
||||
texOp.Set,
|
||||
texOp.Binding,
|
||||
componentIndex,
|
||||
dests,
|
||||
|
@ -573,6 +577,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
texOp.Type,
|
||||
texOp.Format,
|
||||
texOp.Flags,
|
||||
texOp.Set,
|
||||
texOp.Binding,
|
||||
index,
|
||||
new[] { texSizes[index] },
|
||||
|
@ -603,6 +608,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
texOp.Type,
|
||||
texOp.Format,
|
||||
texOp.Flags,
|
||||
texOp.Set,
|
||||
texOp.Binding,
|
||||
0,
|
||||
new[] { lod },
|
||||
|
@ -633,6 +639,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
texOp.Type,
|
||||
texOp.Format,
|
||||
texOp.Flags,
|
||||
texOp.Set,
|
||||
texOp.Binding,
|
||||
index,
|
||||
new[] { texSizes[index] },
|
||||
|
|
|
@ -54,6 +54,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
{
|
||||
bool needsSextNorm = context.Definitions.IsAttributePackedRgb10A2Signed(location);
|
||||
|
||||
SetBindingPair setAndBinding = context.ResourceManager.Reservations.GetVertexBufferTextureSetAndBinding(location);
|
||||
Operand temp = needsSextNorm ? Local() : dest;
|
||||
Operand vertexElemOffset = GenerateVertexOffset(context.ResourceManager, node, location, 0);
|
||||
|
||||
|
@ -62,7 +63,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
SamplerType.TextureBuffer,
|
||||
TextureFormat.Unknown,
|
||||
TextureFlags.IntCoords,
|
||||
context.ResourceManager.Reservations.GetVertexBufferTextureBinding(location),
|
||||
setAndBinding.SetIndex,
|
||||
setAndBinding.Binding,
|
||||
1 << component,
|
||||
new[] { temp },
|
||||
new[] { vertexElemOffset }));
|
||||
|
@ -75,6 +77,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
}
|
||||
else
|
||||
{
|
||||
SetBindingPair setAndBinding = context.ResourceManager.Reservations.GetVertexBufferTextureSetAndBinding(location);
|
||||
Operand temp = component > 0 ? Local() : dest;
|
||||
Operand vertexElemOffset = GenerateVertexOffset(context.ResourceManager, node, location, component);
|
||||
|
||||
|
@ -83,7 +86,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
SamplerType.TextureBuffer,
|
||||
TextureFormat.Unknown,
|
||||
TextureFlags.IntCoords,
|
||||
context.ResourceManager.Reservations.GetVertexBufferTextureBinding(location),
|
||||
setAndBinding.SetIndex,
|
||||
setAndBinding.Binding,
|
||||
1,
|
||||
new[] { temp },
|
||||
new[] { vertexElemOffset }));
|
||||
|
|
|
@ -412,8 +412,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
if (Stage == ShaderStage.Vertex)
|
||||
{
|
||||
int ibBinding = resourceManager.Reservations.IndexBufferTextureBinding;
|
||||
TextureDefinition indexBuffer = new(2, ibBinding, "ib_data", SamplerType.TextureBuffer);
|
||||
SetBindingPair ibSetAndBinding = resourceManager.Reservations.GetIndexBufferTextureSetAndBinding();
|
||||
TextureDefinition indexBuffer = new(ibSetAndBinding.SetIndex, ibSetAndBinding.Binding, "ib_data", SamplerType.TextureBuffer);
|
||||
resourceManager.Properties.AddOrUpdateTexture(indexBuffer);
|
||||
|
||||
int inputMap = _program.AttributeUsage.UsedInputAttributes;
|
||||
|
@ -421,8 +421,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
while (inputMap != 0)
|
||||
{
|
||||
int location = BitOperations.TrailingZeroCount(inputMap);
|
||||
int binding = resourceManager.Reservations.GetVertexBufferTextureBinding(location);
|
||||
TextureDefinition vaBuffer = new(2, binding, $"vb_data{location}", SamplerType.TextureBuffer);
|
||||
SetBindingPair setAndBinding = resourceManager.Reservations.GetVertexBufferTextureSetAndBinding(location);
|
||||
TextureDefinition vaBuffer = new(setAndBinding.SetIndex, setAndBinding.Binding, $"vb_data{location}", SamplerType.TextureBuffer);
|
||||
resourceManager.Properties.AddOrUpdateTexture(vaBuffer);
|
||||
|
||||
inputMap &= ~(1 << location);
|
||||
|
@ -430,8 +430,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
}
|
||||
else if (Stage == ShaderStage.Geometry)
|
||||
{
|
||||
int trbBinding = resourceManager.Reservations.TopologyRemapBufferTextureBinding;
|
||||
TextureDefinition remapBuffer = new(2, trbBinding, "trb_data", SamplerType.TextureBuffer);
|
||||
SetBindingPair trbSetAndBinding = resourceManager.Reservations.GetTopologyRemapBufferTextureSetAndBinding();
|
||||
TextureDefinition remapBuffer = new(trbSetAndBinding.SetIndex, trbSetAndBinding.Binding, "trb_data", SamplerType.TextureBuffer);
|
||||
resourceManager.Properties.AddOrUpdateTexture(remapBuffer);
|
||||
|
||||
int geometryVbOutputSbBinding = resourceManager.Reservations.GeometryVertexOutputStorageBufferBinding;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CommandLine;
|
||||
using CommandLine;
|
||||
using Ryujinx.Graphics.Shader;
|
||||
using Ryujinx.Graphics.Shader.Translation;
|
||||
using System;
|
||||
|
|
Loading…
Add table
Reference in a new issue