aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs2
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs4
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs8
-rw-r--r--Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs19
-rw-r--r--Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs5
-rw-r--r--Ryujinx.Graphics.Shader/Translation/AttributeInfo.cs4
6 files changed, 38 insertions, 4 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs b/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
index 02ae06f6..3f3a3c50 100644
--- a/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
@@ -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 = 3807;
+ private const uint CodeGenVersion = 3833;
private const string SharedTocFileName = "shared.toc";
private const string SharedDataFileName = "shared.data";
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs
index fd284316..67442e5a 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs
@@ -48,6 +48,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
{ AttributeConsts.TessCoordY, new BuiltInAttribute("gl_TessCoord.y", VariableType.F32) },
{ AttributeConsts.InstanceId, new BuiltInAttribute("gl_InstanceID", VariableType.S32) },
{ AttributeConsts.VertexId, new BuiltInAttribute("gl_VertexID", VariableType.S32) },
+ { AttributeConsts.BaseInstance, new BuiltInAttribute("gl_BaseInstance", VariableType.S32) },
+ { AttributeConsts.BaseVertex, new BuiltInAttribute("gl_BaseVertex", VariableType.S32) },
+ { AttributeConsts.InstanceIndex, new BuiltInAttribute("gl_InstanceIndex", VariableType.S32) },
+ { AttributeConsts.VertexIndex, new BuiltInAttribute("gl_VertexIndex", VariableType.S32) },
{ AttributeConsts.FrontFacing, new BuiltInAttribute("gl_FrontFacing", VariableType.Bool) },
// Special.
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs
index 9f8dd7df..c007b9a2 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs
@@ -704,8 +704,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
AttributeConsts.ClipDistance0 => BuiltIn.ClipDistance,
AttributeConsts.PointCoordX => BuiltIn.PointCoord,
AttributeConsts.TessCoordX => BuiltIn.TessCoord,
- AttributeConsts.InstanceId => BuiltIn.InstanceId, // FIXME: Invalid
- AttributeConsts.VertexId => BuiltIn.VertexId, // FIXME: Invalid
+ AttributeConsts.InstanceId => BuiltIn.InstanceId,
+ AttributeConsts.VertexId => BuiltIn.VertexId,
+ AttributeConsts.BaseInstance => BuiltIn.BaseInstance,
+ AttributeConsts.BaseVertex => BuiltIn.BaseVertex,
+ AttributeConsts.InstanceIndex => BuiltIn.InstanceIndex,
+ AttributeConsts.VertexIndex => BuiltIn.VertexIndex,
AttributeConsts.FrontFacing => BuiltIn.FrontFacing,
AttributeConsts.FragmentOutputDepth => BuiltIn.FragDepth,
AttributeConsts.ThreadKill => BuiltIn.HelperInvocation,
diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
index 7edf5deb..2f75d248 100644
--- a/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
+++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs
@@ -51,7 +51,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
offset |= AttributeConsts.LoadOutputMask;
}
- Operand src = op.P ? AttributePerPatch(offset) : Attribute(offset);
+ Operand src = op.P ? AttributePerPatch(offset) : CreateInputAttribute(context, offset);
context.Copy(Register(rd), src);
}
@@ -312,5 +312,22 @@ namespace Ryujinx.Graphics.Shader.Instructions
return attr;
}
+
+ private static Operand CreateInputAttribute(EmitterContext context, int attr)
+ {
+ if (context.Config.Options.TargetApi == TargetApi.Vulkan)
+ {
+ if (attr == AttributeConsts.InstanceId)
+ {
+ return context.ISubtract(Attribute(AttributeConsts.InstanceIndex), Attribute(AttributeConsts.BaseInstance));
+ }
+ else if (attr == AttributeConsts.VertexId)
+ {
+ return Attribute(AttributeConsts.VertexIndex);
+ }
+ }
+
+ return Attribute(attr);
+ }
}
} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs b/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs
index f4e39d0d..47367f89 100644
--- a/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs
+++ b/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs
@@ -95,5 +95,10 @@ namespace Ryujinx.Graphics.Shader.Translation
public const int LtMask = 0x2000040;
public const int ThreadKill = 0x2000044;
+
+ public const int BaseInstance = 0x2000050;
+ public const int BaseVertex = 0x2000054;
+ public const int InstanceIndex = 0x2000058;
+ public const int VertexIndex = 0x200005c;
}
} \ No newline at end of file
diff --git a/Ryujinx.Graphics.Shader/Translation/AttributeInfo.cs b/Ryujinx.Graphics.Shader/Translation/AttributeInfo.cs
index 35dd56e8..6e95722f 100644
--- a/Ryujinx.Graphics.Shader/Translation/AttributeInfo.cs
+++ b/Ryujinx.Graphics.Shader/Translation/AttributeInfo.cs
@@ -27,6 +27,10 @@ namespace Ryujinx.Graphics.Shader.Translation
{ AttributeConsts.TessCoordY, new AttributeInfo(AttributeConsts.TessCoordX, 1, 3, AggregateType.Vector | AggregateType.FP32) },
{ AttributeConsts.InstanceId, new AttributeInfo(AttributeConsts.InstanceId, 0, 1, AggregateType.S32) },
{ AttributeConsts.VertexId, new AttributeInfo(AttributeConsts.VertexId, 0, 1, AggregateType.S32) },
+ { AttributeConsts.BaseInstance, new AttributeInfo(AttributeConsts.BaseInstance, 0, 1, AggregateType.S32) },
+ { AttributeConsts.BaseVertex, new AttributeInfo(AttributeConsts.BaseVertex, 0, 1, AggregateType.S32) },
+ { AttributeConsts.InstanceIndex, new AttributeInfo(AttributeConsts.InstanceIndex, 0, 1, AggregateType.S32) },
+ { AttributeConsts.VertexIndex, new AttributeInfo(AttributeConsts.VertexIndex, 0, 1, AggregateType.S32) },
{ AttributeConsts.FrontFacing, new AttributeInfo(AttributeConsts.FrontFacing, 0, 1, AggregateType.Bool) },
// Special.