diff options
| author | Mumogg <104529023+Mumogg@users.noreply.github.com> | 2026-11-23 20:46:46 -0600 |
|---|---|---|
| committer | Mumogg <104529023+Mumogg@users.noreply.github.com> | 2026-11-23 20:46:46 -0600 |
| commit | 74bf391fdae4e5d5c81314b8abe05412807d4f69 (patch) | |
| tree | 62e870b3945bf9ead2a08c28a2e23fbdc4ca358d /runtime/shims/xmem.cpp | |
| parent | 1a04df0b1b8f8592009a3049948bdd057badcad9 (diff) | |
merge follow-up: the test tree builds again
- xmem.cpp: rt::xmem::commit_physical_range and commit_physical_pages exist for the run-mapped xmem too (pages
are committed when allocated, so they only check the range), and main.cpp registers the slot 133 hook as main
does.
- vk_test_device.h: VK_EXT_external_memory_host and host_pointer_alignment are back next to the A8 render
target probe; d3d12_existing_heap_test and d3d12_xmem_placed_test use them.
- xs_proxy_mock_test.cpp: the stack's version, which tests the proxy that is in the tree (the automatic merge
left two list mocks in one switch).
- d3d12_xs_device.cpp: no include of vulkan_replay.h, which the proxy tests without Vulkan headers could not
compile, and the diagnostic that needed it is gone.
Every target builds with clang-cl 22.1.8 + xwin.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt
Diffstat (limited to 'runtime/shims/xmem.cpp')
| -rw-r--r-- | runtime/shims/xmem.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/runtime/shims/xmem.cpp b/runtime/shims/xmem.cpp index e5db2ce6d..e8988c046 100644 --- a/runtime/shims/xmem.cpp +++ b/runtime/shims/xmem.cpp | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | #include "shims.h" | 37 | #include "shims.h" |
| 38 | #include "startup_trace.h" | 38 | #include "startup_trace.h" |
| 39 | #include "../src/title_va_alias.h" | 39 | #include "../src/title_va_alias.h" |
| 40 | #include "xmem.h" | ||
| 40 | 41 | ||
| 41 | namespace { | 42 | namespace { |
| 42 | 43 | ||
| @@ -801,6 +802,36 @@ LPVOID WINAPI TitleVirtualAlloc(LPVOID address, SIZE_T size, DWORD allocation_ty | |||
| 801 | 802 | ||
| 802 | } // namespace | 803 | } // namespace |
| 803 | 804 | ||
| 805 | namespace rt::xmem { | ||
| 806 | |||
| 807 | // main's xmem commits physical pages on first touch and exposes these two for code that must see them committed | ||
| 808 | // (slot 133's import, d3d12_xmem_placed_test). Here a physical page is committed when it is allocated, so there is | ||
| 809 | // nothing to do: the range only has to be mapped, readable memory, and the page array non-null. | ||
| 810 | bool commit_physical_range(const void* address, std::size_t size) { | ||
| 811 | if (size == 0) return true; | ||
| 812 | const auto* at = static_cast<const std::uint8_t*>(address); | ||
| 813 | const auto* const end = at + size; | ||
| 814 | while (at < end) { | ||
| 815 | MEMORY_BASIC_INFORMATION info{}; | ||
| 816 | if (!VirtualQuery(at, &info, sizeof(info)) || info.State != MEM_COMMIT) { | ||
| 817 | SetLastError(ERROR_INVALID_ADDRESS); | ||
| 818 | return false; | ||
| 819 | } | ||
| 820 | at = static_cast<const std::uint8_t*>(info.BaseAddress) + info.RegionSize; | ||
| 821 | } | ||
| 822 | return true; | ||
| 823 | } | ||
| 824 | |||
| 825 | bool commit_physical_pages(const std::uint64_t* page_array, std::size_t count) { | ||
| 826 | if (count && !page_array) { | ||
| 827 | SetLastError(ERROR_INVALID_PARAMETER); | ||
| 828 | return false; | ||
| 829 | } | ||
| 830 | return true; | ||
| 831 | } | ||
| 832 | |||
| 833 | } // namespace rt::xmem | ||
| 834 | |||
| 804 | #define TITLE_VIRTUAL_ALLOC(dll) {dll, "VirtualAlloc", reinterpret_cast<void*>(&TitleVirtualAlloc)} | 835 | #define TITLE_VIRTUAL_ALLOC(dll) {dll, "VirtualAlloc", reinterpret_cast<void*>(&TitleVirtualAlloc)} |
| 805 | 836 | ||
| 806 | // The classic libraries and the memory api sets a title's imports name. | 837 | // The classic libraries and the memory api sets a title's imports name. |