mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-15 23:39:57 -04:00
The translator declares every float storage image without a format and turns a load of it into OpImageRead, which SPIR-V allows only in a module that declares StorageImageReadWithoutFormat; only the write-side capability was declared. Of the 44,206 shader variants a 0.7.1 install stores, 117 compute shaders were invalid SPIR-V for that reason (the contributor's sweep with spirv-val, for NVIDIA's, AMD's and Intel's host options: 117 before, 0 after). The drivers tried accept them, so nothing crashed, but an invalid module is whatever a driver makes of it. The read now declares the capability, once a module. The translator's identity changes, so an updated install translates its shaders again (the carry pass serves the old translations meanwhile). Built here from the local package cache; tools/xlate_smoke.py's new compute case fails with the translator before the patch and passes with it, and both modules validate. Not played with the new translator. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit 62e5c345a2ec3e2cc70be49214997ff76e691309)
29 lines
1.6 KiB
Diff
29 lines
1.6 KiB
Diff
--- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs
|
|
+++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs
|
|
@@ -83,6 +83,7 @@
|
|
public bool IsMainFunction { get; private set; }
|
|
public bool MayHaveReturned { get; set; }
|
|
public bool WasNonUniformAccessDeclared { get; set; }
|
|
+ public bool WasReadWithoutFormatDeclared { get; set; }
|
|
|
|
public CodeGenContext(
|
|
StructuredProgramInfo info,
|
|
--- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs
|
|
+++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs
|
|
@@ -743,6 +743,15 @@
|
|
SpvInstruction imageComponentType = context.GetType(componentType);
|
|
AggregateType swizzledResultType = texOp.GetVectorType(componentType);
|
|
|
|
+ // NX2NAVI: an image declared without a format (ShaderProperties.GetTextureFormat) is read with OpImageRead,
|
|
+ // which SPIR-V allows only when the module declares StorageImageReadWithoutFormat; Vulkan 1.3, which the
|
|
+ // runtime requires, allows that capability on every device.
|
|
+ if (texOp.Format == TextureFormat.Unknown && !context.WasReadWithoutFormatDeclared)
|
|
+ {
|
|
+ context.AddCapability(Capability.StorageImageReadWithoutFormat);
|
|
+ context.WasReadWithoutFormatDeclared = true;
|
|
+ }
|
|
+
|
|
SpvInstruction texel = context.ImageRead(context.TypeVector(imageComponentType, 4), image, pCoords, ImageOperandsMask.MaskNone);
|
|
SpvInstruction result = GetSwizzledResult(context, texel, swizzledResultType, texOp.Index);
|
|
|