fix(agc): keep failed import handles out of cleanup #7082
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7082"
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 Ondra97 on 2026-10-17T10:38:54Z.
What
A failed
vkCreateBufferorvkAllocateMemorycan leave an undefined non-null output.bindImportstored those outputs directly in the import entry, and fallback cleanup could callvkDestroyBufferorvkFreeMemoryon a handle that was never successfully created. This can turn an import failure into invalid driver calls instead of the intended copy fallback.Publish the buffer handle after successful creation and free imported memory only when the existing
allocatedflag confirms success. Binding failures still destroy the valid buffer and allocation. Failure reporting and file descriptor ownership stay intact.The Vulkan runtime-error rules leave error outputs undefined unless a command specifies otherwise. The regression injects host/device out-of-memory results with non-null error outputs, counts invalid release attempts before forwarding to the real backend, and checks ordinary cleanup and fresh imports. No physical memory exhaustion or invalid native destruction is induced.
Related: #6548 selects a coherent import memory type and #6499 retains imports across split ranges. Their implementations were compared; neither handles these failed outputs. The allocation-status guard leaves the type-selection line intact. #6548 already conflicts with main above
bindImport; this change adds no conflict block.Tested
Base:
bf2053816976bb9c821e37df58ef64a7362b81c7with the same regression cases. Fixed head:a963820ce4288db9d2ef56d3c696d232bea26191. Release,BUILD_TESTING=ON, SPIRV-Tools disabled. There are six cases per backend: create, allocate and bind, each withVK_ERROR_OUT_OF_HOST_MEMORYandVK_ERROR_OUT_OF_DEVICE_MEMORY. Each case registers a 64 KiB heap with imports set toUnwatch. The refused-import table is cleared before the successful retry, matching the existing refusal-cache policy.Windows (native host)
AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, driver 617.42 / 32.0.16.1742, Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0; Tracy enabled.
The two bind-error controls released their valid objects on both revisions. All six fresh imports on each native run copied 4096 bytes through real Vulkan buffers and verified GPU readback. Native device diagnostics:
vendor=0x10de,device=0x2705, host-import alignment 4096 bytes. Guards intercepted the baseline's invalid handles before they reached the driver.Full application/library build passed:
cmake --build build-runtime --target all libs --parallel 3. Of 27 selected tests, 26 passed, 0 failed, 1 skipped. The skip isagc_host_import_sparse, whose fixture is Linux-only.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andANYPS5_GPU=NVIDIA GeForce RTX 4070 Ti SUPERwere set:The primary CPU regression is
agc_host_import_retire_tests; the native regression isagc_driver_bda_device_tests --host-import-failures. Both passed without skips. Conventions and test registration passed.Linux (VirtualBox)
Ubuntu 24.04.5 LTS, kernel 7.0.0-31-generic, GCC 13.3.0, 4 vCPU and 8 GiB assigned RAM; VirtualBox 7.2.20r175154 on the Windows host above. Tracy disabled. Graphics: not exercised.
The same fixed head and required dependency sources were verified against Git objects. The CPU baseline reproduced four invalid release attempts; the fix produced zero, with all six import-failure cases and retries clean. Full application/library build, including the modified native-fixture compilation, passed. Of 8 selected CPU tests, 7 passed, 0 failed, 1 skipped.
agc_host_import_sparseskipped because/dev/udmabufis inaccessible; actual dma-buf importing is untested. In these commandsbuildis the prepared Linux build directory:Conventions and test registration passed. Full hosted Windows/Linux builds require a maintainer's manual workflow dispatch.
Linux graphics/Vulkan tests: NOT RUN — intentionally excluded from VirtualBox validation.
Native/bare-metal Linux was not tested.
Native Linux GPU validation: not tested.
No retail title run, FPS improvement or other GPU-vendor result is claimed.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T10:51:41Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/BdaDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/HostImportRetireHold.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-19T11:10:13Z.
@Ondra97 the overlap checker found your BDA fixture command-handling changes while I was validating a separate GPU-selection correction. The current fixture ignores
ANYPS5_GPU, so an AMD-requested run can actually execute on NVIDIA. ycbuzi originally reported that selection gap in #3358/#3882.The focused fork fix selects the requested device and queries/reports its actual handle. Full BDA execution now passes three times each on our RTX 5080 and Radeon Graphics, with Khronos validation and no new VUIDs; a test-only main control demonstrates the wrong-device failure. Details are in the existing report.
There are no import-behavior changes in my branch. The overlap is includes, command modes and the adjacent CTest registration. I propose #7082 first, then adapting this fixture-only follow-up while preserving your host-import mode and its attribution. Does that ordering work for you? I have kept the fix on our fork rather than opening an upstream PR before coordinating this overlap.
AI-assisted: yes, Codex.
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-19T12:00:32Z.
@Amoenus That ordering works for me: #7082 first, followed by your fixture-only GPU-selection fix.
I compared the cumulative diff with #7082. The fixes address separate problems, and the shared fixture changes can be combined. When adapting the follow-up, please preserve
--host-import-failures,Device(importFailures), the external-host-memory setup and theagc_driver_host_import_failure_handlesCTest registration alongside the new selection modes.If you open the follow-up before #7082 merges, please declare
Depends on: #7082. Thanks for checking the actual selected physical device and coordinating the overlap.AI-assisted: yes, Codex.