|
@@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|
|
{
|
|
{
|
|
|
node = InsertCoordNormalization(context.Hfm, node, context.ResourceManager, context.GpuAccessor, context.Stage);
|
|
node = InsertCoordNormalization(context.Hfm, node, context.ResourceManager, context.GpuAccessor, context.Stage);
|
|
|
node = InsertCoordGatherBias(node, context.ResourceManager, context.GpuAccessor);
|
|
node = InsertCoordGatherBias(node, context.ResourceManager, context.GpuAccessor);
|
|
|
- node = InsertConstOffsets(node, context.ResourceManager, context.GpuAccessor);
|
|
|
|
|
|
|
+ node = InsertConstOffsets(node, context.GpuAccessor, context.Stage);
|
|
|
|
|
|
|
|
if (texOp.Type == SamplerType.TextureBuffer && !context.GpuAccessor.QueryHostSupportsSnormBufferTextureFormat())
|
|
if (texOp.Type == SamplerType.TextureBuffer && !context.GpuAccessor.QueryHostSupportsSnormBufferTextureFormat())
|
|
|
{
|
|
{
|
|
@@ -99,7 +99,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|
|
bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0;
|
|
bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0;
|
|
|
bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0;
|
|
bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0;
|
|
|
|
|
|
|
|
- if (texOp.Inst == Instruction.TextureSize &&
|
|
|
|
|
|
|
+ if (texOp.Inst == Instruction.TextureQuerySize &&
|
|
|
texOp.Index < 2 &&
|
|
texOp.Index < 2 &&
|
|
|
!isBindless &&
|
|
!isBindless &&
|
|
|
!isIndexed &&
|
|
!isIndexed &&
|
|
@@ -190,7 +190,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
LinkedListNode<INode> textureSizeNode = node.List.AddBefore(node, new TextureOperation(
|
|
LinkedListNode<INode> textureSizeNode = node.List.AddBefore(node, new TextureOperation(
|
|
|
- Instruction.TextureSize,
|
|
|
|
|
|
|
+ Instruction.TextureQuerySize,
|
|
|
texOp.Type,
|
|
texOp.Type,
|
|
|
texOp.Format,
|
|
texOp.Format,
|
|
|
texOp.Flags,
|
|
texOp.Flags,
|
|
@@ -259,7 +259,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
node.List.AddBefore(node, new TextureOperation(
|
|
node.List.AddBefore(node, new TextureOperation(
|
|
|
- Instruction.TextureSize,
|
|
|
|
|
|
|
+ Instruction.TextureQuerySize,
|
|
|
texOp.Type,
|
|
texOp.Type,
|
|
|
texOp.Format,
|
|
texOp.Format,
|
|
|
texOp.Flags,
|
|
texOp.Flags,
|
|
@@ -287,7 +287,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|
|
return node;
|
|
return node;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private static LinkedListNode<INode> InsertConstOffsets(LinkedListNode<INode> node, ResourceManager resourceManager, IGpuAccessor gpuAccessor)
|
|
|
|
|
|
|
+ private static LinkedListNode<INode> InsertConstOffsets(LinkedListNode<INode> node, IGpuAccessor gpuAccessor, ShaderStage stage)
|
|
|
{
|
|
{
|
|
|
// Non-constant texture offsets are not allowed (according to the spec),
|
|
// Non-constant texture offsets are not allowed (according to the spec),
|
|
|
// however some GPUs does support that.
|
|
// however some GPUs does support that.
|
|
@@ -440,7 +440,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|
|
|
|
|
|
|
sources.CopyTo(newSources, 0);
|
|
sources.CopyTo(newSources, 0);
|
|
|
|
|
|
|
|
- Operand[] texSizes = InsertTextureLod(node, texOp, lodSources, bindlessHandle, coordsCount);
|
|
|
|
|
|
|
+ Operand[] texSizes = InsertTextureLod(node, texOp, lodSources, bindlessHandle, coordsCount, stage);
|
|
|
|
|
|
|
|
int destIndex = 0;
|
|
int destIndex = 0;
|
|
|
|
|
|
|
@@ -502,7 +502,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- Operand[] texSizes = InsertTextureLod(node, texOp, lodSources, bindlessHandle, coordsCount);
|
|
|
|
|
|
|
+ Operand[] texSizes = InsertTextureLod(node, texOp, lodSources, bindlessHandle, coordsCount, stage);
|
|
|
|
|
|
|
|
for (int index = 0; index < coordsCount; index++)
|
|
for (int index = 0; index < coordsCount; index++)
|
|
|
{
|
|
{
|
|
@@ -554,21 +554,31 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|
|
TextureOperation texOp,
|
|
TextureOperation texOp,
|
|
|
Operand[] lodSources,
|
|
Operand[] lodSources,
|
|
|
Operand bindlessHandle,
|
|
Operand bindlessHandle,
|
|
|
- int coordsCount)
|
|
|
|
|
|
|
+ int coordsCount,
|
|
|
|
|
+ ShaderStage stage)
|
|
|
{
|
|
{
|
|
|
Operand[] texSizes = new Operand[coordsCount];
|
|
Operand[] texSizes = new Operand[coordsCount];
|
|
|
|
|
|
|
|
- Operand lod = Local();
|
|
|
|
|
|
|
+ Operand lod;
|
|
|
|
|
+
|
|
|
|
|
+ if (stage == ShaderStage.Fragment)
|
|
|
|
|
+ {
|
|
|
|
|
+ lod = Local();
|
|
|
|
|
|
|
|
- node.List.AddBefore(node, new TextureOperation(
|
|
|
|
|
- Instruction.Lod,
|
|
|
|
|
- texOp.Type,
|
|
|
|
|
- texOp.Format,
|
|
|
|
|
- texOp.Flags,
|
|
|
|
|
- texOp.Binding,
|
|
|
|
|
- 0,
|
|
|
|
|
- new[] { lod },
|
|
|
|
|
- lodSources));
|
|
|
|
|
|
|
+ node.List.AddBefore(node, new TextureOperation(
|
|
|
|
|
+ Instruction.Lod,
|
|
|
|
|
+ texOp.Type,
|
|
|
|
|
+ texOp.Format,
|
|
|
|
|
+ texOp.Flags,
|
|
|
|
|
+ texOp.Binding,
|
|
|
|
|
+ 0,
|
|
|
|
|
+ new[] { lod },
|
|
|
|
|
+ lodSources));
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ lod = Const(0);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
for (int index = 0; index < coordsCount; index++)
|
|
for (int index = 0; index < coordsCount; index++)
|
|
|
{
|
|
{
|
|
@@ -586,7 +596,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
node.List.AddBefore(node, new TextureOperation(
|
|
node.List.AddBefore(node, new TextureOperation(
|
|
|
- Instruction.TextureSize,
|
|
|
|
|
|
|
+ Instruction.TextureQuerySize,
|
|
|
texOp.Type,
|
|
texOp.Type,
|
|
|
texOp.Format,
|
|
texOp.Format,
|
|
|
texOp.Flags,
|
|
texOp.Flags,
|