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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ The biggest open pieces:
- **Shader translator on hardware**: compute, mesh and geometry now translate (see the translator contract in
[docs/design.md](docs/design.md)); still open are the vertex-shader input layout (`v0` = `VertexIndex` is
unverified if the console runs VS as NGG) and wave64 cross-half code in VS/PS/GS on 32-wide subgroups.
- **Xbox D3D12 → Vulkan**: mesh-shader draws, indirect draw state and stream output are still open; #313 tracks the
remaining method surface. The Windows integration exercises the first-run UI. [Plan and status](docs/d3d12_vulkan.md)
- **Xbox D3D12 → Vulkan**: mesh-shader draws and indirect draw state are still open; stream output now accepts a
`StreamOutput` PSO, binds `SOSetTargets` and captures draws with `VK_EXT_transform_feedback` (capture needs the
translated shader to carry `XfbBuffer`/`XfbStride`/`XfbOffset` decorations). #313 tracks the remaining method
surface. The Windows integration exercises the first-run UI. [Plan and status](docs/d3d12_vulkan.md)
- **Model recovery**: investigate the 71 unrecovered fragment candidates in [`levels.rpf`](docs/models.md#full-archive-re-count-at-e293917).

See [CONTRIBUTING.md](CONTRIBUTING.md). Never attach game files, extracted assets or generated shaders to issues or
Expand Down
22 changes: 13 additions & 9 deletions docs/d3d12_vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -3624,15 +3624,19 @@ Implemented (`QueryHeap` in `runtime/shims/d3d12_vulkan_device.cpp`, the query c
(`compare_invalid_arguments`, "query heap:", RTX 5070 / 621.14): `E_INVALIDARG` for no queries, a node other than
node 0, or a type past `PIPELINE_STATISTICS1` (7), checked before the output; a valid description with a null
output is then `E_UNEXPECTED`, not `S_FALSE`.
- **Stream-output statistics** (D3D-302). The layer has no stream output: a graphics PSO with `StreamOutput`
entries is refused and `SOSetTargets` is not implemented, so no primitive reaches a stream and every
`SO_STATISTICS_STREAM0..3` query counts 0 written and 0 needed. An `SO_STATISTICS` heap is therefore made without
a `VkQueryPool`: `BeginQuery`/`EndQuery` record nothing in Vulkan (D3D12's call rules are still kept, and the
heap's queries track ended or not as the others do), they overlap no other query, and `ResolveQueryData` writes
zeros (`vkCmdFillBuffer`, 16 bytes per query: `NumPrimitivesWritten`, `PrimitivesStorageNeeded`), with no
statistics split since nothing is dispatched. When stream output lands, the heap becomes a
`VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT` pool begun with `vkCmdBeginQueryIndexedEXT` on the stream, whose two
results are in the same order.
- **Stream-output statistics** (D3D-302). With `VK_EXT_transform_feedback` enabled on the device
(`D3D-TRANSFORM-FEEDBACK-DEVICE`), a graphics PSO with `StreamOutput` entries is accepted (its `RasterizedStream`
feeds the rasterizer; a non-zero one needs the `geometryStreams` feature), `SOSetTargets` binds the capture
buffers, and a draw bound to such a pipeline captures into them with
`vkCmdBindTransformFeedbackBuffersEXT` / `vkCmdBeginTransformFeedbackEXT` / `vkCmdEndTransformFeedbackEXT`. An
`SO_STATISTICS` heap is then a `VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT` pool begun and ended indexed on the
stream (`vkCmdBeginQueryIndexedEXT` / `vkCmdEndQueryIndexedEXT`), and `ResolveQueryData` copies the two 64-bit
results per query (16 bytes: `NumPrimitivesWritten`, `PrimitivesStorageNeeded`), in the same order. The capture is
driven by the shader's `XfbBuffer`/`XfbStride`/`XfbOffset` decorations in the translated SPIR-V. The
`BufferFilledSizeLocation` of a bound view is not written back yet (a follow-up). Without the feature, the layer has
no stream output: a `StreamOutput` PSO is refused, `SOSetTargets` binds nothing, an
`SO_STATISTICS` heap is made without a `VkQueryPool`, `BeginQuery`/`EndQuery` run nothing in Vulkan (the heap's
queries still track ended or not), and a resolve fills zeros.
- **Recording.** The list keeps D3D12's rules for the calls: timestamps only have `EndQuery`; every other query is
begun and ended in the same list with the same type, is not begun again while it runs, and is not resolved while
it runs; resolve offsets are multiples of 8. A list closed with a query still running reports `E_INVALIDARG` and
Expand Down
4 changes: 4 additions & 0 deletions docs/pipeline_check.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ driver gives it the same cache key in both programs. Measured on Windows with an
`VK_KHR_maintenance8` into the pipeline cache key even for compute shaders, so the checker enables both whenever
supported and keeps `meshShaderQueries` on.
- On a Windows RTX 5070 Ti (617.42), a compute-only seed missed with mesh features omitted and hit with the supported mesh and mesh-query features enabled on both devices. The shader, push constants and pipeline layout were identical. Cache-producing runs request this device configuration for every selected shader batch.
- On Windows with an AMD Radeon RX 7900 XT, `VK_EXT_transform_feedback` (with `transformFeedback` enabled, and
`geometryStreams` when the device offers it) is part of the key: the runtime enables it whenever the extension is
present (D3D-302), so the checker enables it too. Without it, `pipeline_cache_seed` failed 3 of 3 on that GPU and
passed 3 of 3 on `main`. NVIDIA leaves it out of the key, which is why it did not show up on the RTX 3080 Ti.
- The executable's file name is part of the key; its folder is not. A copy of the checker under another name
misses the cache the original wrote, and the runtime's device hits the checker's cache only from a program
with the checker's file name. So on this driver a cache written by `vk_pipeline_check.exe` does not hit in
Expand Down
31 changes: 31 additions & 0 deletions runtime/shims/d3d12_com.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,21 @@ class GraphicsCommandList final
set_index_buffer(view);
}

// Stream output (D3D-302): binds capture buffers for the streams the bound StreamOutput pipeline declares.
// A null view unbinds its slot. The views are captured into each Draw, so a later call cannot change a recorded
// draw. Each view's BufferLocation and BufferFilledSizeLocation are GPU VAs.
void STDMETHODCALLTYPE SOSetTargets(UINT start, UINT count, const D3D12_STREAM_OUTPUT_BUFFER_VIEW* views) override {
if (list_.closed()) return;
if (std::uint64_t(start) + count > stream_output_.size()) return check(false);
if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) {
std::vector<D3D12_STREAM_OUTPUT_BUFFER_VIEW> copy;
if (views) copy.assign(views, views + count);
defer([=, copy = std::move(copy)](GraphicsCommandList& l) { l.set_stream_output(start, count, copy.data()); });
return;
}
set_stream_output(start, count, views);
}

// A count of 0 unbinds the viewports; draws then rasterize nothing (record_draw).
void STDMETHODCALLTYPE RSSetViewports(UINT count, const D3D12_VIEWPORT* viewports) override {
if (type_ == D3D12_COMMAND_LIST_TYPE_BUNDLE) return check(false);
Expand Down Expand Up @@ -1523,6 +1538,8 @@ class GraphicsCommandList final
std::uint32_t topology_ = 0; // D3D_PRIMITIVE_TOPOLOGY_UNDEFINED
std::array<leonida::VertexBufferView, D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT> vertex_buffers_{};
leonida::IndexBufferView index_{};
// Stream output targets (D3D-302): the buffer views SOSetTargets bound, captured into each Draw.
std::array<leonida::StreamOutputBufferView, D3D12_SO_BUFFER_SLOT_COUNT> stream_output_{};
// SetGraphicsRootDescriptorTable / SetComputeRootDescriptorTable: VA, CBV/SRV/UAV slots the signature declares
std::vector<std::pair<std::uint64_t, std::uint32_t>> tables_;
bool directly_indexed_ = false;
Expand Down Expand Up @@ -1674,6 +1691,19 @@ class GraphicsCommandList final
: leonida::IndexBufferView{};
}

// D3D-302: store the stream-output buffer views SOSetTargets bound. A null view unbinds its slot.
void set_stream_output(UINT start, UINT count, const D3D12_STREAM_OUTPUT_BUFFER_VIEW* views) {
for (UINT i = 0; i < count; ++i) {
if (views) {
stream_output_[start + i] = leonida::StreamOutputBufferView{views[i].BufferLocation,
views[i].SizeInBytes,
views[i].BufferFilledSizeLocation};
} else {
stream_output_[start + i] = {};
}
}
}

// The compiled console ABI appends directly indexed heaps after the explicit root arguments: the resource heap's
// 32-bit shader VA, then the sampler heap's, each only when the signature has its flag. `slot` is the first
// dword after the arguments (RootArgumentLayout::*_arguments_end). The heaps are snapshotted for each command,
Expand Down Expand Up @@ -1907,6 +1937,7 @@ class GraphicsCommandList final
leonida::Draw draw{graphics_pipeline_, graphics_user_data(), draw_views(), depth_, index_, topology_, viewport_,
scissor_, blend_factor_, front_stencil_ref_, back_stencil_ref_, indexed, count, instances,
first, base_vertex, first_instance};
draw.stream_output = stream_output_;
draw.viewports = draw_viewports();
check(list_.draw(std::move(draw)));
}
Expand Down
7 changes: 7 additions & 0 deletions runtime/shims/d3d12_com.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ struct VulkanDeviceInfo {
// VK_EXT_mesh_shader's meshShaderQueries feature is enabled on `device`, so the clipping invocations of a mesh
// segment come from a mesh-primitives query (D3D-MESH-CLIPPING-COUNTER). Without it they read 0.
bool mesh_shader_queries = false;
// VK_EXT_transform_feedback with its transformFeedback feature is enabled on `device` (D3D-302): a graphics PSO
// that declares StreamOutput is accepted, SOSetTargets binds real buffers, and draws between them are captured
// with vkCmdBeginTransformFeedbackEXT/EndTransformFeedbackEXT. Without it, StreamOutput PSOs stay refused.
bool transform_feedback = false;
// VK_EXT_transform_feedback's geometryStreams feature is enabled: a StreamOutput RasterizedStream other than the
// vertex/geometry shader's stream 0 can be rasterized. Without it, only RasterizedStream 0 is accepted.
bool transform_feedback_geometry_streams = false;
// The core features enabled on `device`. Graphics PSOs that need independentBlend, fillModeNonSolid,
// depthBiasClamp or dualSrcBlend are refused unless it is set here.
VkPhysicalDeviceFeatures features{};
Expand Down
Loading