mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 09:39:58 -04:00
The SPIR-V generator emitted OpCompositeExtract with the guest's component index even when it exceeded the image's size vector. A 2D texture's OpImageQuerySizeLod returns a v2int, so a guest request for the third component (depth) produced an extract of index 2, which is invalid SPIR-V. RADV crashed while compiling those variants during shader preparation. Return the constant 1 for a component past the texture's dimensions, the depth of a 1D/2D/cube texture, and apply the same guard in the GLSL generator. build_xlate.py now expects the added patch.
41 lines
1.8 KiB
Diff
41 lines
1.8 KiB
Diff
--- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs
|
|
+++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs
|
|
@@ -1677,7 +1677,13 @@
|
|
result = context.ImageQuerySize(resultType, image);
|
|
}
|
|
|
|
- if (dimensions != 1)
|
|
+ if (texOp.Index >= dimensions)
|
|
+ {
|
|
+ // A 1D/2D/cube texture has no size component beyond its dimensions; the
|
|
+ // missing component (depth for 1D/2D/cube) is 1.
|
|
+ result = context.Constant(context.TypeS32(), 1);
|
|
+ }
|
|
+ else if (dimensions != 1)
|
|
{
|
|
result = context.CompositeExtract(context.TypeS32(), result, texOp.Index);
|
|
}
|
|
--- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs
|
|
+++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs
|
|
@@ -466,7 +466,19 @@
|
|
bool hasLod = !definition.Type.HasFlag(SamplerType.Multisample) && (definition.Type & SamplerType.Mask) != SamplerType.TextureBuffer;
|
|
string texCall;
|
|
|
|
- if (hasLod)
|
|
+ int dimensions = (definition.Type & SamplerType.Mask) == SamplerType.TextureCube ? 2 : definition.Type.Dimensions;
|
|
+
|
|
+ if (definition.Type.HasFlag(SamplerType.Array))
|
|
+ {
|
|
+ dimensions++;
|
|
+ }
|
|
+
|
|
+ if (texOp.Index >= dimensions)
|
|
+ {
|
|
+ // A 1D/2D/cube texture has no size component beyond its dimensions.
|
|
+ texCall = "1";
|
|
+ }
|
|
+ else if (hasLod)
|
|
{
|
|
IAstNode lod = operation.GetSource(srcIndex);
|
|
string lodExpr = GetSourceExpr(context, lod, GetSrcVarType(operation.Inst, srcIndex));
|