fix(recompiler): sample with texel offsets the guest computes, through maintenance8's Offset #303
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/303"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-02T00:24:24Z.
What
image_sample_*_oreads its texel offset from an address VGPR.EmitSampleOpaccepts only an immediate there and fails withrequires a constant texel offset for image samplingfor anything else. PPSA21564's title and menu post-processing programs move their offset into the VGPR under EXEC (v_mov_b32 v3, 1, which the IR reads back as a select of the old value), so those programs never compile on main.Changes:
ConstOffset, as before.Offsetimage operand, built with the existingPackedOffset(the same 6-bit signed fields). Vulkan allowsOffseton sampling instructions only withVK_KHR_maintenance8'smaintenance8feature, and SPIR-V requiresImageGatherExtendedfor it. Without both, the sample still fails, now withhas a texel offset that is not a constant, which image sampling takes only with VK_KHR_maintenance8 and shaderImageGatherExtended.VulkanDeviceenablesmaintenance8when the extension and feature are present and reports it through the newSpirvTarget::nonConstantImageOffsets.allow_offset_texture_operandfor the validation before and after optimization and for the optimizer's own validation.agc_shader_replay --maintenance8recompiles a dumped request for such a device.Tested
Linux (CachyOS, RTX 4090, NVIDIA 610.57.04, which exposes
VK_KHR_maintenance8).agc_shader_memory_testsgainsverifyComputedTexelOffsets, a wave32 compute program that samples withimage_sample_lz_o:v0, it fails withoutnonConstantImageOffsets;OpImageSampleExplicitLodcarryingOffset(notConstOffset) and declaresImageGatherExtended;ConstOffsetand noImageGatherExtended, with the flag and without it.The test also checks that the flag survives serialization, and
agc_shader_disk_cache_testschecks that it changes the cache key. With main's sources and only the flag assignments taken out of the test, the computed-offset program fails withopcode=ImageSampleRaw reason=requires a constant texel offset for image sampling; the literal-offset case passes on main too.ctest: 96/96 pass.PPSA21564: this change has been on my integration branch through repeated passes of my visual regression check (from the intro video through the title and save menu into gameplay; checkpoint frames, flicker, video tearing and FPS). Before it, the title and menu post-processing programs failed to compile there and the scene went black.
Related open PRs: #226 decodes more
_osample variants, which reach this same path; there is no shared function. #295 enables other device features a few hunks away inVulkanDevice.cpp.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository