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
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
27 changes: 27 additions & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3728,6 +3728,33 @@ if(TARGET Vulkan::Headers)
# the thread (d3d12_compile_teardown_test).
set_tests_properties(d3d12_pso_validation PROPERTIES SKIP_RETURN_CODE 77
FAIL_REGULAR_EXPRESSION "Validation Error;VUID-")
# D3D-302: a StreamOutput PSO and SOSetTargets actually capture a draw's output, read back and checked
# against the shader's fixed vec4. The PS just needs a valid render target to rasterize into (its own
# output colour is not checked), so it is its own trivial shader rather than ps_draw's CBV-reading one.
set(LEONIDA_TEST_VS_STREAM_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated/vs_stream_output.spv)
set(LEONIDA_TEST_PS_STREAM_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated/ps_stream_output.spv)
foreach(pair "vs_stream_output.vert;${LEONIDA_TEST_VS_STREAM_OUTPUT}"
"ps_stream_output.frag;${LEONIDA_TEST_PS_STREAM_OUTPUT}")
list(GET pair 0 source)
list(GET pair 1 output)
add_custom_command(
OUTPUT ${output}
COMMAND ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} -V --target-env vulkan1.3 -o ${output}
${CMAKE_CURRENT_SOURCE_DIR}/test/glsl/${source}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test/glsl/${source}
COMMENT "Compiling the stream-output test shader ${source}"
VERBATIM)
endforeach()
add_executable(d3d12_stream_output_test test/d3d12_stream_output_test.cpp shims/d3d12_xs_device.cpp
${LEONIDA_TEST_VS_STREAM_OUTPUT} ${LEONIDA_TEST_PS_STREAM_OUTPUT})
target_link_libraries(d3d12_stream_output_test PRIVATE gta6rt_d3d12_com)
target_compile_definitions(d3d12_stream_output_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX
LEONIDA_TEST_VS_STREAM_OUTPUT_SPV="${LEONIDA_TEST_VS_STREAM_OUTPUT}"
LEONIDA_TEST_PS_STREAM_OUTPUT_SPV="${LEONIDA_TEST_PS_STREAM_OUTPUT}")
target_compile_options(d3d12_stream_output_test PRIVATE /W4 /permissive- /utf-8)
add_test(NAME d3d12_stream_output COMMAND d3d12_stream_output_test)
set_tests_properties(d3d12_stream_output PROPERTIES SKIP_RETURN_CODE 77
FAIL_REGULAR_EXPRESSION "Validation Error;VUID-")
# Conservative raster Tier 1, with geometric coverage bounds and host D3D12 references.
set(LEONIDA_CONSERVATIVE_VS ${CMAKE_CURRENT_BINARY_DIR}/generated/vs_conservative.spv)
set(LEONIDA_CONSERVATIVE_PS ${CMAKE_CURRENT_BINARY_DIR}/generated/ps_conservative.spv)
Expand Down
27 changes: 27 additions & 0 deletions runtime/shims/d3d12_com.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,22 @@ class GraphicsCommandList final
set_vertex_buffers(start, count, views);
}

// D3D-302. Unlike vertex buffers, an unbound slot inside [start, start+count) stays unbound (no zero-page
// fallback): the pipeline's StreamOutput declaration says how many slots it needs, and prepare_draw treats any
// of those left unbound as "stream output not active for this draw" rather than inventing a destination.
void STDMETHODCALLTYPE SOSetTargets(UINT start, UINT count, const D3D12_STREAM_OUTPUT_BUFFER_VIEW* views) override {
if (std::uint64_t(start) + count > so_buffers_.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), bound = views != nullptr](GraphicsCommandList& l) {
l.set_so_targets(start, count, bound ? copy.data() : nullptr);
});
return;
}
set_so_targets(start, count, views);
}

void STDMETHODCALLTYPE IASetIndexBuffer(const D3D12_INDEX_BUFFER_VIEW* view) override {
if (list_.closed()) return;
const std::optional<D3D12_INDEX_BUFFER_VIEW> copy = view ? std::optional(*view) : std::nullopt;
Expand Down Expand Up @@ -1563,6 +1579,7 @@ class GraphicsCommandList final
D3D12_GPU_VIRTUAL_ADDRESS sampler_base_ = 0;
std::uint32_t topology_ = 0; // D3D_PRIMITIVE_TOPOLOGY_UNDEFINED
std::array<leonida::VertexBufferView, D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT> vertex_buffers_{};
std::array<leonida::SOBufferView, D3D12_SO_BUFFER_SLOT_COUNT> so_buffers_{};
leonida::IndexBufferView index_{};
// SetGraphicsRootDescriptorTable / SetComputeRootDescriptorTable: VA, CBV/SRV/UAV slots the signature declares
std::vector<std::pair<std::uint64_t, std::uint32_t>> tables_;
Expand Down Expand Up @@ -1689,6 +1706,7 @@ class GraphicsCommandList final
sampler_base_ = 0;
topology_ = 0;
vertex_buffers_ = {};
so_buffers_ = {};
index_ = {};
viewport_ = {};
scissor_ = {};
Expand Down Expand Up @@ -1755,6 +1773,14 @@ class GraphicsCommandList final
}
}

void set_so_targets(UINT start, UINT count, const D3D12_STREAM_OUTPUT_BUFFER_VIEW* views) {
if (count) draw_views_stale_ = true;
for (UINT i = 0; i < count; ++i)
so_buffers_[start + i] = views ? leonida::SOBufferView{views[i].BufferLocation, views[i].SizeInBytes,
views[i].BufferFilledSizeLocation}
: leonida::SOBufferView{};
}

void set_index_buffer(const D3D12_INDEX_BUFFER_VIEW* view) {
const std::uint64_t va =
view ? leonida::title_gpu_views::to_host_view(view->BufferLocation, view->SizeInBytes) : 0;
Expand Down Expand Up @@ -1885,6 +1911,7 @@ class GraphicsCommandList final
auto views = std::make_shared<leonida::DrawViews>();
views->render_targets = render_targets_;
views->vertex_buffers = vertex_buffers_;
views->so_buffers = so_buffers_;
views->render_target_count = render_target_count_;
draw_views_ = std::move(views);
draw_views_stale_ = false;
Expand Down
12 changes: 12 additions & 0 deletions runtime/shims/d3d12_com.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@ 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 detected and enabled on `device` (D3D-302).
// Nothing uses it yet: a graphics PSO that declares StreamOutput is still refused and SOSetTargets is still not
// implemented. (#1630 adds the SO_STATISTICS query pools, which use it.)
bool transform_feedback = false;
// VK_EXT_transform_feedback's geometryStreams feature is enabled when the device offers it. Nothing rasterizes a
// StreamOutput RasterizedStream yet; it is here for the capture implementation that follows.
bool transform_feedback_geometry_streams = false;
// VkPhysicalDeviceTransformFeedbackPropertiesEXT limits, read when VK_EXT_transform_feedback is enabled: a
// StreamOutput PSO's NumStrides must not exceed max_transform_feedback_buffers, and a non-default
// RasterizedStream must be below max_transform_feedback_streams. Both 0 when the extension is not enabled.
std::uint32_t max_transform_feedback_buffers = 0;
std::uint32_t max_transform_feedback_streams = 0;
// 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