diff options
| author | ExCorvus <73470689+ExCorvus@users.noreply.github.com> | 2026-11-24 01:29:22 +0100 |
|---|---|---|
| committer | ExCorvus <73470689+ExCorvus@users.noreply.github.com> | 2026-11-24 01:29:22 +0100 |
| commit | f9c68577e3c640f2f1dbd4c7b19036eaf3cbd2a4 (patch) | |
| tree | d72e59ad7b0a2f977293cb16160a3b9d25ed218c /docs | |
| parent | a7ffc53c152aa725d9823655661a9e8cfd2d2a63 (diff) | |
d3d12: slot 133 textures answer GetGPUVirtualAddress with the title address
A retail title places a 256x256 R32_FLOAT texture through Xbox device slot 133
and then clears it through the value GetGPUVirtualAddress returns, used as a CPU
pointer. The layer answers 0 for a texture, as D3D12 does, so the title wrote
256 KB at address 0. XCL measured the same clear and returns the address the
title placed the resource at (its PR #168).
A slot-133 placed texture still gets its committed fallback image, but records
the title address and reports it from GetGPUVirtualAddress. Ordinary textures
still answer 0 and buffers are unchanged. The pixels do not alias the title's
pages yet, so a write through the address is not uploaded; that is the
page-mapper work and is called out in docs/d3d12_vulkan.md.
Tests: d3d12_existing_heap_test checks that the RENDER_TARGET layout and the
COMMON retry both answer the title address; it exits 0, and gta6rt links.
AI-assisted: DeepSeek V4.1 Flash 1017 (Alibaba Token Plan); coordinated by Qwen4 Max Preview.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/d3d12_vulkan.md | 11 | ||||
| -rw-r--r-- | docs/retail_boot_chain.md | 10 |
2 files changed, 16 insertions, 5 deletions
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index 0652c6c87..5f711aefa 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md | |||
| @@ -1478,11 +1478,20 @@ The layer therefore owns the console VAs. It returns them from `ID3D12Resource:: | |||
| 1478 | | Address space | Two ranges. A **BDA arena** holds buffers, descriptor heaps and shader code; its device address is `heap_base`. A separate **image key range** supplies unique console VAs for images; those keys are never added to `heap_base`. The arena's `VkBuffer` is created with all buffer usages the game can bind (uniform, storage, vertex, index, indirect, transfer) plus `SHADER_DEVICE_ADDRESS`, and its memory with `VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT`. | | 1478 | | Address space | Two ranges. A **BDA arena** holds buffers, descriptor heaps and shader code; its device address is `heap_base`. A separate **image key range** supplies unique console VAs for images; those keys are never added to `heap_base`. The arena's `VkBuffer` is created with all buffer usages the game can bind (uniform, storage, vertex, index, indirect, transfer) plus `SHADER_DEVICE_ADDRESS`, and its memory with `VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT`. | |
| 1479 | | Buffers | A buffer resource is a range in the arena's single `VkBuffer`: offset = its console VA, size = the resource size. Buffer commands bind the arena buffer with that offset, so its device address is exactly `arena_bda + offset`; no per-resource `VkBuffer` object is needed. | | 1479 | | Buffers | A buffer resource is a range in the arena's single `VkBuffer`: offset = its console VA, size = the resource size. Buffer commands bind the arena buffer with that offset, so its device address is exactly `arena_bda + offset`; no per-resource `VkBuffer` object is needed. | |
| 1480 | | Images | Each image gets a unique console VA key and lives in its own `VkDeviceMemory` (or a suballocated device-local image heap) with optimal tiling. Shader image access goes through the T#/hash table, so nothing dereferences the key. Keeping images out of the arena avoids forcing optimal-tiled images into the arena's memory type and keeps the arena sized by buffers, not textures. | | 1480 | | Images | Each image gets a unique console VA key and lives in its own `VkDeviceMemory` (or a suballocated device-local image heap) with optimal tiling. Shader image access goes through the T#/hash table, so nothing dereferences the key. Keeping images out of the arena avoids forcing optimal-tiled images into the arena's memory type and keeps the arena sized by buffers, not textures. | |
| 1481 | | Heaps and placed resources | `CreateHeap` reserves the requested size in the arena, so a buffer placed at a 64 KiB-aligned offset is that offset into the arena and its console VA is the heap's place plus the offset. A placed texture (1D, 2D or 3D) gets its own `VkDeviceMemory` and a null VA, as in D3D12. Tiled (`64KB_UNDEFINED_SWIZZLE` and Xbox `0x101`) 2D/3D placed textures (D3D-191) and multisampled 2D placed textures (D3D-222) share that backing, answer `GetResourceAllocationInfo` and `GetResourceTiling`, and check heap/offset alignments. Reserved buffers can use heap tile mappings (section 4.2). | | 1481 | | Heaps and placed resources | `CreateHeap` reserves the requested size in the arena, so a buffer placed at a 64 KiB-aligned offset is that offset into the arena and its console VA is the heap's place plus the offset. A placed texture (1D, 2D or 3D) gets its own `VkDeviceMemory`; one the title placed at its own address through the console's `CreatePlacedResourceX` (Xbox device slot 133) reports that title address from `GetGPUVirtualAddress`, as the console does — a title turns it into the CPU pointer it clears the texture through — while its pixels do not alias the title's pages yet. Any other texture answers a null VA, as on D3D12. Tiled (`64KB_UNDEFINED_SWIZZLE` and Xbox `0x101`) 2D/3D placed textures (D3D-191) and multisampled 2D placed textures (D3D-222) share that backing, answer `GetResourceAllocationInfo` and `GetResourceTiling`, and check heap/offset alignments. Reserved buffers can use heap tile mappings (section 4.2). | |
| 1482 | | Descriptor heaps | Shader-visible CBV/SRV/UAV and sampler heaps are allocated in the low 4 GB of the arena. RTV/DSV heaps are host-side only. | | 1482 | | Descriptor heaps | Shader-visible CBV/SRV/UAV and sampler heaps are allocated in the low 4 GB of the arena. RTV/DSV heaps are host-side only. | |
| 1483 | | Shader code | Each FSSM blob is uploaded to the arena; its console VA is the code base. | | 1483 | | Shader code | Each FSSM blob is uploaded to the arena; its console VA is the code base. | |
| 1484 | | Upload/readback | `D3D12_HEAP_TYPE_UPLOAD`/`READBACK` resources are separate host-visible buffers outside the arena. Their console VAs are only used by copy APIs; if the game binds one as a vertex/index buffer or reads it in a shader, the layer biases the view/descriptor by `-heap_base` so the shader's addition lands on the host BDA (**ASSUMPTION**; **measured to fail for a V#**, see below). | | 1484 | | Upload/readback | `D3D12_HEAP_TYPE_UPLOAD`/`READBACK` resources are separate host-visible buffers outside the arena. Their console VAs are only used by copy APIs; if the game binds one as a vertex/index buffer or reads it in a shader, the layer biases the view/descriptor by `-heap_base` so the shader's addition lands on the host BDA (**ASSUMPTION**; **measured to fail for a V#**, see below). | |
| 1485 | 1485 | ||
| 1486 | **Measured (XCL, retail title, PR #168):** the console answers a placed texture's `GetGPUVirtualAddress` with the | ||
| 1487 | address the title placed it at; the title clears a 256×256 `R32_FLOAT` texture through that value as a CPU pointer. | ||
| 1488 | On the PC, where D3D12 answers 0 for a texture, that write went to address 0. XCL returns the title address when the | ||
| 1489 | PC answers 0 and leaves buffers and resources with a PC address unchanged | ||
| 1490 | ([`real.rs`](https://github.com/ivall/xcl/blob/main/crates/xcl/src/hle/d3d12x/real.rs), PR | ||
| 1491 | [#168](https://github.com/ivall/xcl/pull/168)). Facts only: XCL is GPL-2.0-only and no code is copied. This layer | ||
| 1492 | sets a slot-133 fallback texture's `GetGPUVirtualAddress` to the title address; the image itself still does not | ||
| 1493 | alias the title's pages. | ||
| 1494 | |||
| 1486 | Non-arena buffers (upload/readback) can still be addressed by the shader without putting them in the arena: pass | 1495 | Non-arena buffers (upload/readback) can still be addressed by the shader without putting them in the arena: pass |
| 1487 | `console_va = host_bda - heap_base` (mod 2^64) in root descriptors and vertex/index/indirect views, so the shader's | 1496 | `console_va = host_bda - heap_base` (mod 2^64) in root descriptors and vertex/index/indirect views, so the shader's |
| 1488 | `heap_base + console_va` equals the host BDA. For descriptors, patch the V# base field the same way when the layer | 1497 | `heap_base + console_va` equals the host BDA. For descriptors, patch the V# base field the same way when the layer |
diff --git a/docs/retail_boot_chain.md b/docs/retail_boot_chain.md index f46c698b9..cbe29cf83 100644 --- a/docs/retail_boot_chain.md +++ b/docs/retail_boot_chain.md | |||
| @@ -88,10 +88,12 @@ proxy gets all 581 lists created and closed. | |||
| 88 | Xbox device slot 133 is `(va, const D3D12_RESOURCE_DESC*, state, clear, riid, out)` with `riid = IID_ID3D12Resource` | 88 | Xbox device slot 133 is `(va, const D3D12_RESOURCE_DESC*, state, clear, riid, out)` with `riid = IID_ID3D12Resource` |
| 89 | and `state = 0xFFFFFFFF`, which isn't a valid PC state. At the first call, `va` is the start of a physical-page | 89 | and `state = 0xFFFFFFFF`, which isn't a valid PC state. At the first call, `va` is the start of a physical-page |
| 90 | range the title had just reserved, and `desc` is a buffer of that range's size with Xbox bits in `Flags` above | 90 | range the title had just reserved, and `desc` is a buffer of that range's size with Xbox bits in `Flags` above |
| 91 | the PC flags. The shape matches the console `CreatePlacedResourceX`. The local stand-in creates a committed | 91 | the PC flags. The shape matches the console `CreatePlacedResourceX`. A buffer on those pages is imported with |
| 92 | DEFAULT-heap buffer from the desc, with `Flags` limited to the PC bits and `D3D12_RESOURCE_STATE_COMMON`. It is | 92 | `VK_EXT_external_memory_host` where the driver allows it, so the title's writes are the GPU's reads; a driver that |
| 93 | not tied to the VA, so what the title writes there doesn't reach the GPU. A real implementation needs the page | 93 | refuses falls back to a committed buffer. A texture gets a committed texture whose `GetGPUVirtualAddress` is the |
| 94 | mapper (#5378) or an imported host allocation. | 94 | title's address (the console behavior: a title clears a texture through that pointer), but its pixels do not alias |
| 95 | the title's pages yet. Both paths limit `Flags` to the PC bits; the buffer path also makes the Xbox layout word | ||
| 96 | `ROW_MAJOR`. | ||
| 95 | 97 | ||
| 96 | The proxy's slot table must also be longer than the title's highest slot. A shorter table leaves a null pointer, | 98 | The proxy's slot table must also be longer than the title's highest slot. A shorter table leaves a null pointer, |
| 97 | not an `E_NOTIMPL`. | 99 | not an `E_NOTIMPL`. |