Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions docs/d3d12_vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,15 @@ which has one array layer. `d3d12_descriptor_test` checks samples at four W coor
volume, plus minimum-LOD clamped views (inside the mip range via `VK_EXT_image_view_min_lod`, at or below
`MostDetailedMip`, and above the last mip).

Known gaps in the descriptor path: buffer shader-resource views and constant-buffer views (the V# a shader would
load for them; the structure is in `gfx10_descriptors.h`, the views are not written; buffer UAVs of every kind are,
section 3.4 "Buffer UAVs", `d3d12_m4_compute_test` and `d3d12_buffer_uav_test`);
A constant-buffer view is a raw GFX10 V# (`CreateConstantBufferView`): NUM_RECORDS is the view's size in bytes,
OOB_SELECT RAW, and STRIDE 16, a constant buffer's row. A buffer access with `idxen` adds index × STRIDE to the address,
and the retail title's UI batch programs read each vertex's matrix rows from their constant buffer by index: with
STRIDE 0 every index read row 0 and every UI shape fell on the line x = y (measured by ThatRecompDev/five-star-recomp,
GPL-3.0, commit `4c6bce59b`). RAW bounds a MUBUF access by its offset, not index × STRIDE, so the stride leaves that
bound at the view's size; an `s_buffer_load` bound becomes NUM_RECORDS × STRIDE, past the end of any constant the
program declares. `d3d12_compute_test` checks the words.

Known gaps in the descriptor path:
1D-array SRVs, 1D and 3D storage views, other typeless volume formats, multisampled depth/stencil and typeless
color SRVs, and shader-translator lowering for multisample loads. Single-sampled depth-plane views (`R24_UNORM_X8_TYPELESS`,
`R32_FLOAT_X8X24_TYPELESS`) are a T# of the texture's depth format (8_24_UNORM, X24_8_32_FLOAT) through the
Expand Down
9 changes: 8 additions & 1 deletion runtime/shims/d3d12_vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace {
// Every descriptor slot is this many bytes; an RTV or DSV slot holds a leonida::TargetView. The console's own
// increments are open question 4 in docs/d3d12_vulkan.md; the application reads them from the device, as it must.
constexpr UINT kDescriptorSize = descriptor_size;
constexpr std::uint32_t kConstantBufferRow = 16; // a CBV's V# STRIDE: the row an idxen access steps by (a float4)
// The first 64 KiB of the GPU address arena are never handed out: VA 0 stays invalid, and the page is kept zero
// for unbound vertex and index buffers to read (D3D12 reads zeros there).
constexpr VkDeviceSize kArenaReserved = 64 * 1024;
Expand Down Expand Up @@ -6399,6 +6400,12 @@ class Device final

// A constant-buffer view is a 16-byte GFX10 raw buffer V# in the first half of the slot (zeros in the rest).
// A null description, zero address, or zero size leaves the whole slot zeroed (null V#: reads return 0).
// STRIDE is 16, a constant buffer's row (a float4): a buffer access with idxen adds index × STRIDE to the
// address, and programs that index their constant buffer by row rely on it. With STRIDE 0 every index read row
// 0; ThatRecompDev/five-star-recomp (GPL-3.0, 4c6bce59b) measured that on the retail title, whose UI batch
// programs read each vertex's matrix rows by index and drew every UI shape on the line x = y. NUM_RECORDS stays in
// bytes and OOB_SELECT RAW, so the MUBUF bound is the view's size as before (RAW checks the offset, not
// index × STRIDE); an s_buffer_load bound becomes NUM_RECORDS × STRIDE, which no in-range constant load reaches.
void STDMETHODCALLTYPE CreateConstantBufferView(const D3D12_CONSTANT_BUFFER_VIEW_DESC* desc,
D3D12_CPU_DESCRIPTOR_HANDLE destination) override {
d3d12_trace::record("ID3D12Device::CreateConstantBufferView");
Expand All @@ -6407,7 +6414,7 @@ class Device final
if (!desc || !desc->BufferLocation || !desc->SizeInBytes) return;
leonida::gfx10::Buffer buffer{};
buffer.address = desc->BufferLocation;
buffer.stride = 0;
buffer.stride = kConstantBufferRow;
buffer.num_records = desc->SizeInBytes;
buffer.format = leonida::gfx10::format_from_vulkan(VK_FORMAT_R32_UINT);
buffer.oob_select = leonida::gfx10::OobSelect::raw;
Expand Down
4 changes: 2 additions & 2 deletions runtime/test/d3d12_compute_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,8 @@ int main() {
leonida::gfx10::Buffer decoded{};
EXPECT(leonida::gfx10::decode(raw, decoded));
EXPECT(decoded.address == expected_va);
EXPECT(decoded.stride == 0);
EXPECT(decoded.num_records == 256);
EXPECT(decoded.stride == 16); // a constant buffer's row: an idxen access steps by it
EXPECT(decoded.num_records == 256); // bytes, with OOB_SELECT RAW
EXPECT(decoded.format == leonida::gfx10::format_from_vulkan(VK_FORMAT_R32_UINT));
EXPECT(decoded.swizzle == leonida::gfx10::identity_swizzle);
EXPECT(decoded.oob_select == leonida::gfx10::OobSelect::raw);
Expand Down