Skip to content
Open
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
24 changes: 24 additions & 0 deletions docs/d3d12_vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,30 @@ The compute path, end to end:
dynamic-rendering scope. Its layer count is the smallest layer count of the bound views.
- **Viewport:** it is flipped (negative height), because translated vertex shaders write D3D clip coordinates;
front-face winding then matches D3D12's.
- **Unchanged state** (D3D-393): a draw skips each bind and set whose value an earlier draw of the same list left
bound: the pipeline, set 0, the push constants (compared as their 144 bytes), viewport, scissor, topology,
primitive restart, both stencil references, blend constants, each vertex-buffer slot and the index buffer
(`detail::BoundDrawState`). Vulkan keeps bound state for the life of the command buffer, per bind point, and a
rendering scope's begin and end, a barrier, a transfer or `vkCmdClearAttachments` leave it alone, so it carries
from one draw's scope to the next. What does disturb it:
- Binding a pipeline replaces the state it does not declare dynamic. Every PSO declares the six dynamic states a
draw sets, and the vertex-input stride when it has vertex bindings, so only a PSO without vertex input makes
the vertex buffers bind again after it (the strides they were bound with are invalid then).
- Set 0 and push constants stay valid across layouts compatible for them. Every graphics layout has one
push-constant range, `{push_stages, 0, 144}`, and set 0 is the device's one bindless set, so both are keyed on
the stage flags as well as the value.
- A command that binds, or runs a helper that does, forgets everything: a dispatch, direct or indirect (it pushes
constants with a layout not compatible for push constants with the graphics ones), `SetPredication` on a buffer
(the capture dispatch), a copy through the predicated-copy or depth24 pass, `ResolveQueryData`, the
acceleration-structure commands, and any command kind added later (`detail::keeps_draw_state` names the ones
that keep the state). Each list starts with nothing known, since the caller may record anything between two
lists.

In `replay_cpu_bench` a draw goes from 16 Vulkan calls to 7 (indexed: 17 to 8), and the frame from 8.30 calls
per command to 4.65. `replay_draw_state_test` counts the calls for each rule with mocks; `d3d12_draw_state_test`
renders draws that change and keep state around clears, a copy, a dispatch, a query resolve, a bundle and a
pipeline without vertex input, on the layer and on the host's D3D12 (default adapter and WARP); without the
re-bind after that pipeline, the validation layer reports `VUID-vkCmdDraw-pStrides-04913`.
- Only the first viewport and scissor are used, and primitive restart is not modelled yet.

**Resources and heaps:**
Expand Down
21 changes: 21 additions & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2099,6 +2099,19 @@ if(TARGET Vulkan::Headers)
target_compile_options(d3d12_bundle_forbidden_test PRIVATE /W4 /permissive- /utf-8)
add_test(NAME d3d12_bundle_forbidden COMMAND d3d12_bundle_forbidden_test)
set_tests_properties(d3d12_bundle_forbidden PROPERTIES SKIP_RETURN_CODE 77)
# Draw state the replay keeps from one draw to the next or sets again (D3D-393), against the host runtime and
# WARP: state changes between draws, clears, a copy, a dispatch, a query resolve, a bundle and a pipeline
# without vertex input.
add_executable(d3d12_draw_state_test test/d3d12_draw_state_test.cpp ${LEONIDA_TEST_VS} ${LEONIDA_TEST_PS}
${LEONIDA_TEST_CS} ${LEONIDA_TEST_VS_FULLSCREEN})
target_link_libraries(d3d12_draw_state_test PRIVATE gta6rt_d3d12_com d3d12 dxgi)
target_compile_definitions(d3d12_draw_state_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX _CRT_SECURE_NO_WARNINGS
LEONIDA_TEST_VS_SPV="${LEONIDA_TEST_VS}" LEONIDA_TEST_PS_SPV="${LEONIDA_TEST_PS}"
LEONIDA_TEST_CS_SPV="${LEONIDA_TEST_CS}"
LEONIDA_TEST_VS_FULLSCREEN_SPV="${LEONIDA_TEST_VS_FULLSCREEN}")
target_compile_options(d3d12_draw_state_test PRIVATE /W4 /permissive- /utf-8)
add_test(NAME d3d12_draw_state COMMAND d3d12_draw_state_test)
set_tests_properties(d3d12_draw_state PROPERTIES SKIP_RETURN_CODE 77)
else()
message(STATUS "glslangValidator not found: d3d12_compute_test, d3d12_draw_test and d3d12_set0_compute_test are not built")
endif()
Expand Down Expand Up @@ -2287,6 +2300,14 @@ if(TARGET Vulkan::Headers)
target_compile_definitions(replay_query_edges_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
endif()
add_test(NAME replay_query_edges COMMAND replay_query_edges_test)
# Draw state still bound from the last draw is not set again, and is forgotten where it may be disturbed
# (D3D-393), with CPU mocks (no GPU or game data).
add_executable(replay_draw_state_test test/replay_draw_state_test.cpp)
target_link_libraries(replay_draw_state_test PRIVATE Vulkan::Headers)
if(WIN32)
target_compile_definitions(replay_draw_state_test PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
endif()
add_test(NAME replay_draw_state COMMAND replay_draw_state_test)
# GFX10 T#/S#/V# descriptor encoding and its Vulkan mappings (src/gfx10_descriptors.h).
add_executable(gfx10_descriptors_test test/gfx10_descriptors_test.cpp)
target_link_libraries(gfx10_descriptors_test PRIVATE Vulkan::Headers)
Expand Down
Loading