diff --git a/tools/build_xlate.py b/tools/build_xlate.py index 88ee3a50..87e84d91 100644 --- a/tools/build_xlate.py +++ b/tools/build_xlate.py @@ -99,8 +99,8 @@ def prepare_sources() -> Path: for junk in list(src.glob("src/*/obj")) + list(src.glob("src/*/bin")): shutil.rmtree(junk) patches = sorted((XLATE / "patches").glob("*.patch")) - if len(patches) != 36: - sys.exit(f"expected 36 patches, found {len(patches)}") + if len(patches) != 37: + sys.exit(f"expected 37 patches, found {len(patches)}") # build/xlate is inside this checkout, and git inside a repository reads a "diff --git" patch's paths from the # repository's top: those hunks fall outside the directory handed to --directory, git skips every file of the patch # and still exits 0. 0021-prmt-byte-permute.patch is the only one written in that form, so it used to be skipped in diff --git a/tools/xlate/patches/0038-texture-size-query-bounds.patch b/tools/xlate/patches/0038-texture-size-query-bounds.patch new file mode 100644 index 00000000..966fed82 --- /dev/null +++ b/tools/xlate/patches/0038-texture-size-query-bounds.patch @@ -0,0 +1,40 @@ +--- 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));