Declare a texture whose size query reads its layer count as an array, so the count is the texture's own.

A program that only asks a combined-handle texture for its size got that texture declared as plain 2D, the runtime bound a one-layer view, and the layer count read as 1 where the console answers the texture's real count. The game's particle vertex shaders read exactly that count, of a texture their pixel shaders sample as a 2D array, and use it as the frame count of a flipbook, so such particles stayed on their first frame. A size query that reads the component after a 1D or 2D type's dimensions now makes the declaration an array; a plain texture bound through an array view still reports one layer. 74 of the stored shader variants change (the contributor's sweep, all valid; a reader here found the same 74 in a shader cache on this PC), and the contributor's before-and-after pictures differ in the one scene tried, the Wallmaster's warning disc.

Goes in with the image read capability so that installs translate their shaders again once. Built here; tools/xlate_smoke.py's new case reports the texture as plain 2D with the translator before the patch and as a 2D array with it, and all three modules validate. Not played with the new translator.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
(cherry picked from commit e4fac75190b4baf3811feef45b3302a9216cb8b2)
This commit is contained in:
chrg6
2026-11-11 00:14:44 -05:00
parent 6628cf69f0
commit 6cd03fb630
3 changed files with 51 additions and 9 deletions

View File

@@ -0,0 +1,24 @@
--- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs
+++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs
@@ -1116,6 +1116,21 @@
else
{
type = context.TranslatorContext.GpuAccessor.QuerySamplerType(imm);
+
+ // NX2NAVI: a size query that reads the component after a 1D or 2D type's dimensions asks for the layer
+ // count, so the texture is an array. That holds for any 1D or 2D type here: the accessor's answer, or the 2D
+ // it answers for a handle it has no type for. The game's particle vertex shaders read only the layer count
+ // of such a handle, which their pixel shaders sample as a 2D array, and use it as the frame count of a
+ // flipbook; declared 2D, the binding is a one-layer view and the count reads as 1. A plain texture bound
+ // through an array view still reports one layer. Not handled: a program that samples the same handle as a
+ // plain 2D texture before this query gets an arrayed declaration for that sample (invalid SPIR-V).
+ if (query == TexQuery.TexHeaderDimension &&
+ ((type & SamplerType.Mask) == SamplerType.Texture1D || (type & SamplerType.Mask) == SamplerType.Texture2D) &&
+ !type.HasFlag(SamplerType.Array) &&
+ (componentMask & (1 << type.Dimensions)) != 0)
+ {
+ type |= SamplerType.Array;
+ }
}
TextureFlags flags = isBindless ? TextureFlags.Bindless : TextureFlags.None;