SPIR-V validation after optimization fails on a specialized module and aborts the title (Demon's Souls, Linux) #4205

Closed
opened 2026-10-12 01:19:37 +00:00 by btsouth · 4 comments
btsouth commented 2026-10-12 01:19:37 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by btsouth on 2026-10-12T01:19:37Z.


Note

Posted by an AI agent on behalf of Tyler.

With ANYPS5_ENABLE_SPIRV_TOOLS=ON and APS5_SPIRV_OPT=none, specialized modules are still optimized (the none shortcut in ValidateAndOptimizeSpirv only applies when specialize is false). In Demon's Souls PPSA01342 v1.005 (US), one of them failed validation after optimization during presentation and the process aborted:

[videoout] presentation failed: SPIR-V validation after optimization failed:
level=2 word=10090: The continue construct with the continue target '85[%85]' is not structurally post dominated by the back-edge block '14852[%14852]'
terminate called after throwing an instance of 'std::runtime_error'

The module passed the validation that runs before optimization, so the invalid structure comes from the optimizer passes. It is the same validation rule as #1921, which was about the recompiler's own output.

Skipping optimization of specialized modules avoids the crash here, and the title then presents frames. A narrower fix could be to log the failure and keep the unoptimized module when the optimized one fails validation, since the input already validated. I have not tested that change on its own.

Setup: main bab7b328 with #4049 and #758 merged locally, Release, Arch Linux kernel 7.2.8, GCC 16.2.1, RTX 4070 SUPER on driver 615.78.08. I did not capture the module. I can rerun with a shader dump if that would help.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5806999526 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4205). Originally posted by [btsouth](https://github.com/btsouth) on 2026-10-12T01:19:37Z. --- > [!NOTE] > Posted by an AI agent on behalf of Tyler. With `ANYPS5_ENABLE_SPIRV_TOOLS=ON` and `APS5_SPIRV_OPT=none`, specialized modules are still optimized (the `none` shortcut in `ValidateAndOptimizeSpirv` only applies when `specialize` is false). In Demon's Souls PPSA01342 v1.005 (US), one of them failed validation after optimization during presentation and the process aborted: ``` [videoout] presentation failed: SPIR-V validation after optimization failed: level=2 word=10090: The continue construct with the continue target '85[%85]' is not structurally post dominated by the back-edge block '14852[%14852]' terminate called after throwing an instance of 'std::runtime_error' ``` The module passed the validation that runs before optimization, so the invalid structure comes from the optimizer passes. It is the same validation rule as #1921, which was about the recompiler's own output. Skipping optimization of specialized modules avoids the crash here, and the title then presents frames. A narrower fix could be to log the failure and keep the unoptimized module when the optimized one fails validation, since the input already validated. I have not tested that change on its own. Setup: main bab7b328 with #4049 and #758 merged locally, Release, Arch Linux kernel 7.2.8, GCC 16.2.1, RTX 4070 SUPER on driver 615.78.08. I did not capture the module. I can rerun with a shader dump if that would help.
MarcZX10 commented 2026-10-12 01:26:22 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T01:26:22Z.


I confirmed ValidateAndOptimizeSpirv validates input before optimization, then throws if the optimized module fails validation. I am investigating a generic fallback to that validated input, with a regression test that exercises post-optimization validation failure. Could you attach the specialized SPIR-V dump (and, if possible, the corresponding unspecialized module) or a minimal reproducer? That would let me verify the same optimizer failure path against this report.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6116114496 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4205#issuecomment-6116114496). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T01:26:22Z. --- I confirmed `ValidateAndOptimizeSpirv` validates input before optimization, then throws if the optimized module fails validation. I am investigating a generic fallback to that validated input, with a regression test that exercises post-optimization validation failure. Could you attach the specialized SPIR-V dump (and, if possible, the corresponding unspecialized module) or a minimal reproducer? That would let me verify the same optimizer failure path against this report.
oneandonlydean commented 2026-10-12 06:18:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T06:18:14Z.


#4018 is on main now. It fixes this validation error (The continue construct ... is not structurally post dominated by the back-edge block) for a loop shader of the same title. Could you rerun on current main without #4241, and attach the specialized module if it still fails?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6118871955 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4205#issuecomment-6118871955). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T06:18:14Z. --- #4018 is on main now. It fixes this validation error (`The continue construct ... is not structurally post dominated by the back-edge block`) for a loop shader of the same title. Could you rerun on current main without #4241, and attach the specialized module if it still fails?
fisherjoey commented 2026-10-14 05:36:10 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-14T05:36:10Z.


@oneandonlydean rerun on current main without #4241: neither failure reproduces.

Setup: Demon's Souls PPSA01341 v1.07, Linux, RTX 5070 Ti, NVIDIA 595.91. main 7a0c838ca with ANYPS5_ENABLE_SPIRV_TOOLS=ON and the default optimizer (no APS5_SPIRV_OPT). The build also has local merges of #758, without which the title stops before this point, and #5181, which keeps memory under my run cap. No #4241.

Result in a 1200 s run: initialization finished at 13.8 s and the main loop started at 51.5 s. The title ran at about 17.9 fps for about 600 s, and then the tutorial level loaded, compiling 2857 new modules, until the time limit. The log has no validation after optimization or not structurally post dominated errors and no shader registration failures. The level itself wasn't reached in this run, because compiling with the tools on is slower.

On the 10-11 base (7a84b222, tools on) the same title aborted at t+19 on shader 0x2489e0100 (word 6177, #4018's shader). With APS5_SPIRV_OPT=none it aborted after frame 3 on a specialized module (word 10069), the failure reported here. #4018 and #4600 have merged since.

From the Demon's Souls side, this can close.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161693920 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4205#issuecomment-6161693920). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-14T05:36:10Z. --- @oneandonlydean rerun on current `main` without #4241: neither failure reproduces. Setup: Demon's Souls PPSA01341 v1.07, Linux, RTX 5070 Ti, NVIDIA 595.91. `main` 7a0c838ca with `ANYPS5_ENABLE_SPIRV_TOOLS=ON` and the default optimizer (no `APS5_SPIRV_OPT`). The build also has local merges of #758, without which the title stops before this point, and #5181, which keeps memory under my run cap. No #4241. Result in a 1200 s run: initialization finished at 13.8 s and the main loop started at 51.5 s. The title ran at about 17.9 fps for about 600 s, and then the tutorial level loaded, compiling 2857 new modules, until the time limit. The log has no `validation after optimization` or `not structurally post dominated` errors and no shader registration failures. The level itself wasn't reached in this run, because compiling with the tools on is slower. On the 10-11 base (7a84b222, tools on) the same title aborted at t+19 on shader 0x2489e0100 (word 6177, #4018's shader). With `APS5_SPIRV_OPT=none` it aborted after frame 3 on a specialized module (word 10069), the failure reported here. #4018 and #4600 have merged since. From the Demon's Souls side, this can close. AI-assisted: yes
oneandonlydean commented 2026-10-14 05:43:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:43:16Z.


Closing: fixed on main by #4018 and #4600; fisherjoey's 1200 s Demon's Souls run on current main shows neither validation failure. If it comes back on current main, comment here with the shader and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161778308 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4205#issuecomment-6161778308). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T05:43:16Z. --- Closing: fixed on main by #4018 and #4600; fisherjoey's 1200 s Demon's Souls run on current `main` shows neither validation failure. If it comes back on current main, comment here with the shader and the log line.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#4205
No description provided.