From 0ceece32c0db5aa961bcdb1727ad39b470a0376c Mon Sep 17 00:00:00 2001 From: The Void Date: Tue, 24 Nov 2026 18:53:34 +0100 Subject: [PATCH] startup: defer heap-indexed root signatures and refuse real draws under them Device slot 16 records whether a title root signature indexes the CBV/SRV/UAV heap (0x400) or the sampler heap (0x800) directly. Command-list slot 34 keeps tracking the title's parameters for every root signature but no longer sets a flagged one on the desktop list, where the title's heaps are never bound (debug layer message ID 1419). Unflagged roots keep the immediate bind. Root SRVs (slot 44) are not forwarded under a deferred root. A real draw under a deferred root is decided by heap_indexed_root.h: it binds only when the list mirrors every indexed heap at the indices the draw reads and all root state can be restored. The stand-in has neither, so the draw is refused with a specific reason, counted and logged. Tests: startup_heap_indexed_root (device-free decision matrix, two mutated controls) and startup_root_heap_{warp,hardware} (root CBV draw with the debug layer on, each flag alone, both and none, with a plain-list fail-first control that must report 1419). Refs #870 Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- CMakeLists.txt | 16 ++- docs/experiments.md | 9 ++ docs/startup-runtime.md | 24 ++++ src/startup_stubs/d3d12_xs_device.cpp | 79 ++++++++++-- src/startup_stubs/heap_indexed_root.h | 74 +++++++++++ tests/startup_heap_indexed_root_check.cpp | 147 ++++++++++++++++++++++ tests/startup_root_heap.cpp | 101 +++++++++++++++ tests/startup_root_heap_check.py | 85 +++++++++++++ tests/startup_stream_draw.cpp | 6 + tests/startup_stream_setup.cpp | 45 ++++++- tests/startup_stream_setup.h | 3 + 11 files changed, 577 insertions(+), 12 deletions(-) create mode 100644 src/startup_stubs/heap_indexed_root.h create mode 100644 tests/startup_heap_indexed_root_check.cpp create mode 100644 tests/startup_root_heap.cpp create mode 100644 tests/startup_root_heap_check.py diff --git a/CMakeLists.txt b/CMakeLists.txt index b6d0c0a25d..950f02dfc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -568,7 +568,7 @@ set_tests_properties(startup_dump_fence_removed_control_warp PROPERTIES ENVIRONM WILL_FAIL TRUE) add_executable(startup_stream_consumer tests/startup_stream_consumer.cpp tests/startup_stream_setup.cpp tests/startup_stream_draw.cpp - tests/startup_address_srv.cpp tests/startup_root_cbv.cpp) + tests/startup_address_srv.cpp tests/startup_root_cbv.cpp tests/startup_root_heap.cpp) target_compile_features(startup_stream_consumer PRIVATE cxx_std_17) target_link_libraries(startup_stream_consumer PRIVATE d3d12_xs_shim startup_stub_xg_xs d3d12 dxgi) target_sources(startup_stream_consumer PRIVATE tests/startup_frame_copy.cpp) @@ -779,6 +779,16 @@ add_test(NAME startup_translated_sampler_bindings COMMAND startup_translated_sam add_test(NAME startup_translated_sampler_bindings_shared_axis_control COMMAND startup_translated_sampler_bindings_check --mutate shared-axis) set_tests_properties(startup_translated_sampler_bindings_shared_axis_control PROPERTIES WILL_FAIL TRUE) +# Real-draw decision for title root signatures that index descriptor heaps directly +# (src/startup_stubs/heap_indexed_root.h), without a device. The mutated runs are the negative controls. +add_executable(startup_heap_indexed_root_check tests/startup_heap_indexed_root_check.cpp) +target_include_directories(startup_heap_indexed_root_check PRIVATE src) +target_compile_features(startup_heap_indexed_root_check PRIVATE cxx_std_17) +add_test(NAME startup_heap_indexed_root COMMAND startup_heap_indexed_root_check) +foreach(mutation IN ITEMS sampler-alone bind-unrestorable) + add_test(NAME startup_heap_indexed_root_${mutation}_control COMMAND startup_heap_indexed_root_check --mutate ${mutation}) + set_tests_properties(startup_heap_indexed_root_${mutation}_control PROPERTIES WILL_FAIL TRUE) +endforeach() target_sources(offscreen_check PRIVATE tests/startup_image_3d.cpp) target_sources(offscreen_check PRIVATE tests/startup_flat_param.cpp) # The storage root handed to the executable ends in a separator and is never cut off @@ -1781,6 +1791,10 @@ if(EXISTS "${INTAKE_PYTHON}") "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_root_cbv_check.py" "$" ${backend}) set_tests_properties(startup_root_cbv_${backend} PROPERTIES TIMEOUT 90 SKIP_RETURN_CODE 77) + add_test(NAME startup_root_heap_${backend} COMMAND "${CMAKE_COMMAND}" -E env "X2W_FXC=${STARTUP_FXC}" + "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_root_heap_check.py" + "$" ${backend}) + set_tests_properties(startup_root_heap_${backend} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77) add_test(NAME startup_address_srv_${backend} COMMAND "${CMAKE_COMMAND}" -E env "X2W_FXC=${STARTUP_FXC}" "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_address_srv_check.py" "$" "${backend}") diff --git a/docs/experiments.md b/docs/experiments.md index 3a2dd05431..51e48daf91 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -10705,3 +10705,12 @@ Command-list slot 42 records the address of a root parameter declared as a CBV, cmake --build --preset dev --target startup_stream_consumer ctest --preset dev --no-tests=error -R "^startup_root_cbv_(warp|hardware)$" -V ``` + +## Startup heap-indexed root signatures + +Command-list slot 34 no longer sets a title root signature flagged `CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED` or `SAMPLER_HEAP_DIRECTLY_INDEXED` on the desktop list, because the title's heaps are not forwarded there (debug layer message ID 1419). Real draws under such a root are refused with a specific reason. The decision matrix (`tests/startup_heap_indexed_root_check.cpp`) runs without a device; its two mutated runs must fail. The draw fixture (`tests/startup_root_heap_check.py`) is synthetic only and reuses the root CBV draw with the debug layer on; a plain desktop list with the same root signature must first report ID 1419 for each flag, or the run is a capability skip. Details are in [startup-runtime.md](startup-runtime.md#heap-indexed-root-signatures). + +```powershell +cmake --build --preset dev --target startup_stream_consumer startup_heap_indexed_root_check +ctest --preset dev --no-tests=error -R "^startup_(heap_indexed_root.*|root_heap_(warp|hardware))$" -V +``` diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index de16625a77..3b678972e6 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -182,6 +182,30 @@ the console shift, not yet seen in a title log; `startup_root_cbv_{warp,hardware unbound, a null-overwrite and a wrong-type call. Rebinding the same root signature keeps the address. Switching to a different signature invalidates the stored root addresses. +## Heap-indexed root signatures + +Device slot 16 records whether a title root signature was created with +`D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED` (`0x400`), `SAMPLER_HEAP_DIRECTLY_INDEXED` (`0x800`) +or both. Command-list slot 32 only tracks the heaps a title sets and never forwards them, so setting such a root +signature on the desktop list made the debug layer report message ID 1419 for each flag. Slot 34 now keeps +tracking the title's parameters, root addresses and constants for every root signature, but sets only an unflagged +one on the desktop list, as before; a flagged one is deferred (`root signature ... with heap flags 0x... not set on +the desktop list`, first three). Root SRVs (slot 44) are not forwarded under a deferred root. Translated draws use +their own root signature (no flags) and are unaffected. + +A real draw under a deferred root is decided by `src/startup_stubs/heap_indexed_root.h`: it may bind only when the +list holds a mirror of every heap the root indexes, covering the indices the draw reads, and every root constant, +descriptor table and root descriptor can be set again. A one-entry sampler heap covers only index 0 and never stands +in for the view heap. The stand-in has no mirrored heap and cannot restore that state, so it refuses every real draw +under a flagged root, counts it by reason and logs `real draw refused: root signature heap flags 0x..., ` +(first three per reason, then every 1000th). The `x2w-render totals` line reports `heap-indexed roots deferred N +(real draws refused: view heap, sampler heap, both heaps, state)`. On current main no source-built path reaches a +real draw (`compile_translation` returns no shader), so the refusal itself is checked only by the device-free +`startup_heap_indexed_root` matrix. `startup_root_heap_{warp,hardware}` runs the root CBV draw with the debug layer +on, for each flag alone, both and neither: a plain desktop list with the same root signature and no heaps must +produce one ID 1419 per flag first (otherwise the run skips with 77), and through the stand-in no such message may +appear while the translated draw keeps its colour. + ## Composite provenance fixture Issue #1628 asks whether a uniform colour left in a composite's destination came from the composite or was diff --git a/src/startup_stubs/d3d12_xs_device.cpp b/src/startup_stubs/d3d12_xs_device.cpp index c91c2b97f7..946e5d559a 100644 --- a/src/startup_stubs/d3d12_xs_device.cpp +++ b/src/startup_stubs/d3d12_xs_device.cpp @@ -19,6 +19,7 @@ #include "startup_stubs/draw_bmp.h" #include "startup_stubs/draw_dump_tracking.h" #include "startup_stubs/translated_sampler_bindings.h" +#include "startup_stubs/heap_indexed_root.h" #include "startup_stubs/bc7_4k_s.h" #include "startup_stubs/bc64_chain.h" #include "startup_stubs/derived_blend.h" @@ -1418,6 +1419,20 @@ std::unordered_map>& root_infos() static std::unordered_map> map; return map; } +// The heap-indexing flags (x2w_startup::root_flags_heap_indexed) each title root signature was created with. +std::unordered_map& root_heap_flag_map() +{ + static std::unordered_map map; + return map; +} +UINT root_heap_flags(const Wrapper* root) +{ + AcquireSRWLockShared(&root_lock); + const auto found = root_heap_flag_map().find(root); + const UINT flags = found == root_heap_flag_map().end() ? 0 : found->second; + ReleaseSRWLockShared(&root_lock); + return flags; +} const std::vector* root_info(const Wrapper* root) { AcquireSRWLockShared(&root_lock); @@ -1428,7 +1443,8 @@ const std::vector* root_info(const Wrapper* root) } // Device slot 16, desktop CreateRootSignature(node, blob, size, riid, ppv); the parameter list is -// kept for the translated shaders (register and space of each root descriptor). +// kept for the translated shaders (register and space of each root descriptor), and the heap-indexing +// flags for command-list slot 34. HRESULT __stdcall device_create_root_signature(Wrapper* self, UINT node, const void* blob, SIZE_T size, const GUID* iid, void** out) { if (!out || !iid) return E_POINTER; @@ -1445,10 +1461,12 @@ HRESULT __stdcall device_create_root_signature(Wrapper* self, UINT node, const v Wrapper* w = wrap(root, root_signature_kind); note_root_blob(w, blob, size); std::vector parameters; + UINT heap_flags = 0; ID3D12VersionedRootSignatureDeserializer* deserializer = nullptr; if (SUCCEEDED(D3D12CreateVersionedRootSignatureDeserializer(blob, size, IID_PPV_ARGS(&deserializer)))) { const D3D12_VERSIONED_ROOT_SIGNATURE_DESC* desc = nullptr; if (SUCCEEDED(deserializer->GetRootSignatureDescAtVersion(D3D_ROOT_SIGNATURE_VERSION_1_1, &desc)) && desc) { + heap_flags = static_cast(desc->Desc_1_1.Flags) & x2w_startup::root_flags_heap_indexed; for (UINT i = 0; i < desc->Desc_1_1.NumParameters; ++i) { const auto& parameter = desc->Desc_1_1.pParameters[i]; RootParameter info{parameter.ParameterType, 0, 0}; @@ -1468,11 +1486,12 @@ HRESULT __stdcall device_create_root_signature(Wrapper* self, UINT node, const v for (std::size_t i = 0; i < parameters.size() && used < 220; ++i) used += std::snprintf(text + used, sizeof(text) - used, " %d:r%u,s%u", parameters[i].type, parameters[i].shader_register, parameters[i].space); - log("x2w-d3d12 Device::CreateRootSignature size=0x%llx -> %p parameters (type:register,space)%s", static_cast(size), - static_cast(w), text); + log("x2w-d3d12 Device::CreateRootSignature size=0x%llx -> %p heap flags 0x%x parameters (type:register,space)%s", + static_cast(size), static_cast(w), heap_flags, text); } AcquireSRWLockExclusive(&root_lock); root_infos()[w] = std::move(parameters); + root_heap_flag_map()[w] = heap_flags; ReleaseSRWLockExclusive(&root_lock); *out = w; return S_OK; @@ -1631,6 +1650,10 @@ struct Pass { bool topology_ok = false; unsigned srv_bound = 0; // bit per root parameter with a desktop address bound const std::vector* root = nullptr; + // Heap-indexing flags of the title root signature last set by slot 34. While nonzero, that root signature is + // deferred: it is not set on the desktop list, root SRVs are not forwarded, and real draws go through decide_real_root. + UINT root_heap_flags = 0; + ID3D12RootSignature* deferred_root = nullptr; std::vector> states; // resources this list moved out of COMMON // What the title bound, kept for draws through translated pipelines: Wrapper* pipeline = nullptr; @@ -1660,6 +1683,8 @@ struct Pass { UINT default_viewport_h = 0, default_scissor_h = 0; }; LONG render_draws, render_draws_skipped, render_pipelines_real, render_pipelines_missing; +// Heap-indexed title root signatures not set on the desktop list, and real draws refused under one, by decision. +LONG heap_roots_deferred, heap_root_refusals[x2w_startup::real_root_decision_count]; ID3D12GraphicsCommandList* recording(Wrapper* self) { return self->own().list_open ? static_cast(self->own().real) : nullptr; } Pass& pass_of(Wrapper* self) @@ -1727,7 +1752,9 @@ void __stdcall list_pipeline(Wrapper* self, void* pipeline) InterlockedIncrement(pass.pipeline_real ? &render_pipelines_real : &render_pipelines_missing); if (auto* list = recording(self); list && pass.pipeline_real) list->SetPipelineState(static_cast(w->own().real)); } -// List slot 34 (desktop 30 + 4), SetGraphicsRootSignature. +// List slot 34 (desktop 30 + 4), SetGraphicsRootSignature. The title's parameters are tracked for translated +// draws either way. A root signature that indexes a descriptor heap directly is not set on the desktop list: the +// title's heaps are never forwarded there (slot 32), so the debug layer would reject it (message ID 1419). void __stdcall list_graphics_root(Wrapper* self, void* root) { Wrapper* w = as_wrapper(root); @@ -1737,8 +1764,19 @@ void __stdcall list_graphics_root(Wrapper* self, void* root) std::fill_n(pass.root_address, 16, 0); pass.root = params; pass.srv_bound = 0; - if (auto* list = recording(self); list && w && w->own().kind == root_signature_kind && w->own().real) + const bool real = w && w->own().kind == root_signature_kind && w->own().real; + pass.root_heap_flags = real ? root_heap_flags(w) : 0; + pass.deferred_root = pass.root_heap_flags ? static_cast(w->own().real) : nullptr; + auto* list = recording(self); + if (!list || !real) return; + if (!pass.root_heap_flags) { list->SetGraphicsRootSignature(static_cast(w->own().real)); + return; + } + const LONG deferred = InterlockedIncrement(&heap_roots_deferred); + if (deferred <= 3) + log("x2w-render root signature %p with heap flags 0x%x not set on the desktop list (title heaps are not forwarded)", + static_cast(w), pass.root_heap_flags); } DXGI_FORMAT view_format_of(u64 desktop_handle, ID3D12Resource* target) { @@ -1881,7 +1919,8 @@ void __stdcall list_root_srv(Wrapper* self, UINT parameter, u64 address) Pass& pass = pass_of(self); if (parameter < 32) pass.srv_bound &= ~(1u << parameter); if (parameter < 16) pass.root_address[parameter] = address; - if (!list || !pass.root || parameter >= pass.root->size() || parameter >= 32 || + // Under a deferred heap-indexed root the desktop list holds another root signature; only the title address is kept. + if (!list || !pass.root || pass.root_heap_flags || parameter >= pass.root->size() || parameter >= 32 || (*pass.root)[parameter].type != D3D12_ROOT_PARAMETER_TYPE_SRV) return; const std::size_t bytes = readable_window(address, 0x10000); @@ -1926,6 +1965,25 @@ void __stdcall list_draw(Wrapper* self, UINT vertices, UINT instances, UINT firs : &untranslated_draws); return; } + if (list && pass.root_heap_flags) { + // The desktop list holds no copy of the title's heaps, and the root constants and descriptor tables the + // title set are kept only as title values, so the deferred root signature cannot be set with its state. + x2w_startup::RealRootDraw request; + request.root_flags = pass.root_heap_flags; + request.state_restorable = false; + const x2w_startup::RealRootDecision decision = x2w_startup::decide_real_root(request); + if (decision != x2w_startup::RealRootDecision::bind) { + const LONG n = InterlockedIncrement(&heap_root_refusals[static_cast(decision)]); + InterlockedIncrement(&render_draws_skipped); + if (n <= 3 || n % 1000 == 0) + log("x2w-render real draw refused: root signature heap flags 0x%x, %s (%ld so far)", pass.root_heap_flags, + x2w_startup::real_root_reason(decision), n); + return; + } + // Not reached with the facts above: a change that mirrors the title heaps and restores the root state on the + // list, with an end-to-end fixture, makes the deferred bind here. + list->SetGraphicsRootSignature(pass.deferred_root); + } // The translated vertex shaders read their fetch table through root parameter 0. if (list && pass.pipeline_real && pass.targets_bound && pass.topology_ok && pass.topology != 0x11 && (pass.srv_bound & 1)) { list->DrawInstanced(vertices, instances, first_vertex, first_instance); @@ -3110,11 +3168,16 @@ HRESULT __stdcall queue_present(Wrapper* self, UINT planes, const void* plane_pa if (render_mode() && frame % 300 == 0) log("x2w-render totals: resets %ld (failed %ld), closes %ld, clears %ld, executes %ld, draws %ld (skipped %ld), " "translated draws %ld (not drawn %ld), pipelines translated %ld / missing %ld, null bindings %ld (entry %ld, buffer %ld, token %ld, wrapper %ld, dimension %ld), " - "textures uploaded %ld (%ld KiB, unreadable %ld)", render_resets, + "textures uploaded %ld (%ld KiB, unreadable %ld), heap-indexed roots deferred %ld (real draws refused: view heap %ld, " + "sampler heap %ld, both heaps %ld, state %ld)", render_resets, render_reset_failures, render_closes, render_clears, render_executes, render_draws, render_draws_skipped, translated_draws, untranslated_draws, translation_ready, translation_missing, null_total, null_causes[0], null_causes[1], null_causes[2], null_causes[3], null_causes[4], textures_uploaded, - texture_bytes_uploaded, textures_unreadable); + texture_bytes_uploaded, textures_unreadable, heap_roots_deferred, + heap_root_refusals[static_cast(x2w_startup::RealRootDecision::view_heap_missing)], + heap_root_refusals[static_cast(x2w_startup::RealRootDecision::sampler_heap_missing)], + heap_root_refusals[static_cast(x2w_startup::RealRootDecision::both_heaps_missing)], + heap_root_refusals[static_cast(x2w_startup::RealRootDecision::state_not_restorable)]); if (render_mode() && frame % 300 == 0) { // Which command-list slots the title called in the last 300 frames, per frame. char line[2048]; diff --git a/src/startup_stubs/heap_indexed_root.h b/src/startup_stubs/heap_indexed_root.h new file mode 100644 index 0000000000..67abfb0398 --- /dev/null +++ b/src/startup_stubs/heap_indexed_root.h @@ -0,0 +1,74 @@ +#pragma once + +// Title root signatures that index descriptor heaps directly: D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED +// (0x400) and D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED (0x800). The desktop debug layer rejects setting +// such a root signature on a list that has no heap of that type bound (message ID 1419 for the sampler heap). The +// stand-in only tracks the heaps a title sets (command-list slot 32) and never forwards them, so slot 34 does not set a +// flagged root signature on the desktop list. Translated draws keep using their own root signature. A real draw under +// a flagged root is decided here: it may bind the deferred root signature only when the list holds every heap the root +// indexes, at the indices the draw reads, and every root parameter value can be set again. + +#include + +#include + +namespace x2w_startup { + +// The flag values, spelled out so older headers build. +constexpr UINT root_flag_view_heap_indexed = 0x400; +constexpr UINT root_flag_sampler_heap_indexed = 0x800; +constexpr UINT root_flags_heap_indexed = root_flag_view_heap_indexed | root_flag_sampler_heap_indexed; + +inline bool root_heap_indexed(UINT root_flags) { return (root_flags & root_flags_heap_indexed) != 0; } + +// The highest heap index a draw reads is not known (a shader may compute it); only a heap holding the whole title heap covers it. +constexpr UINT unknown_heap_index = UINT_MAX; + +// A shader-visible desktop heap of one type that is set on the list and holds the title heap's descriptors at the title's indices. +struct MirroredHeap { + bool bound = false; // a heap of this type is set on the desktop list + UINT entries = 0; // title entries it holds, from index 0 + bool whole = false; // it holds every entry of the title heap +}; + +struct RealRootDraw { + UINT root_flags = 0; + MirroredHeap views, samplers; + UINT highest_view = unknown_heap_index; // highest view-heap index the draw reads + UINT highest_sampler = unknown_heap_index; // highest sampler-heap index the draw reads + bool state_restorable = false; // every root constant, descriptor table and root descriptor can be set again +}; + +enum class RealRootDecision { bind, view_heap_missing, sampler_heap_missing, both_heaps_missing, state_not_restorable }; +constexpr int real_root_decision_count = 5; + +inline const char* real_root_reason(RealRootDecision decision) +{ + switch (decision) { + case RealRootDecision::bind: return "bind"; + case RealRootDecision::view_heap_missing: return "view heap missing"; + case RealRootDecision::sampler_heap_missing: return "sampler heap missing"; + case RealRootDecision::both_heaps_missing: return "view and sampler heaps missing"; + case RealRootDecision::state_not_restorable: return "root state not restorable"; + } + return "unknown"; +} + +inline bool heap_covers(const MirroredHeap& heap, UINT highest) +{ + return heap.bound && (heap.whole || (highest != unknown_heap_index && highest < heap.entries)); +} + +// An unflagged root signature is set by slot 34 as before, so nothing is deferred and nothing needs restoring. +inline RealRootDecision decide_real_root(const RealRootDraw& draw) +{ + if (!root_heap_indexed(draw.root_flags)) return RealRootDecision::bind; + const bool views = !(draw.root_flags & root_flag_view_heap_indexed) || heap_covers(draw.views, draw.highest_view); + const bool samplers = !(draw.root_flags & root_flag_sampler_heap_indexed) || heap_covers(draw.samplers, draw.highest_sampler); + if (!views && !samplers) return RealRootDecision::both_heaps_missing; + if (!views) return RealRootDecision::view_heap_missing; + if (!samplers) return RealRootDecision::sampler_heap_missing; + return draw.state_restorable ? RealRootDecision::bind : RealRootDecision::state_not_restorable; +} + +} // namespace x2w_startup diff --git a/tests/startup_heap_indexed_root_check.cpp b/tests/startup_heap_indexed_root_check.cpp new file mode 100644 index 0000000000..3cb5f2e2a9 --- /dev/null +++ b/tests/startup_heap_indexed_root_check.cpp @@ -0,0 +1,147 @@ +// Checks src/startup_stubs/heap_indexed_root.h without a device: whether a real draw under a title root signature +// with D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED (0x400) and/or SAMPLER_HEAP_DIRECTLY_INDEXED (0x800) +// may bind it, or which refusal applies. Every combination of the flags, the two heaps (absent, one entry, a few +// entries, the whole title heap), the highest index the draw reads, and whether the root state can be restored is +// compared with expectations written out below. +// +// startup_heap_indexed_root_check [--mutate sampler-alone|bind-unrestorable] +// +// The mutations change the expectations to those of a wrong decision (a one-entry sampler heap that satisfies any +// root, or a bind without the root state); each must make the check fail. +#include "startup_stubs/heap_indexed_root.h" + +#include +#include +#include + +namespace { +using namespace x2w_startup; +using D = RealRootDecision; +int failures, cases; +bool sampler_alone, bind_unrestorable; + +const char* name_of(D d) { return real_root_reason(d); } + +void expect(const char* label, const RealRootDraw& draw, D expected) +{ + ++cases; + const D got = decide_real_root(draw); + if (got == expected) return; + ++failures; + if (failures <= 20) + std::printf("FAIL %s: flags 0x%x views{%d,%u,%d} highest %u samplers{%d,%u,%d} highest %u restorable %d -> %s, expected %s\n", + label, draw.root_flags, draw.views.bound, draw.views.entries, draw.views.whole, draw.highest_view, + draw.samplers.bound, draw.samplers.entries, draw.samplers.whole, draw.highest_sampler, + draw.state_restorable, name_of(got), name_of(expected)); +} + +RealRootDraw make(UINT flags, MirroredHeap views, UINT highest_view, MirroredHeap samplers, UINT highest_sampler, bool restorable) +{ + RealRootDraw draw; + draw.root_flags = flags; + draw.views = views; + draw.samplers = samplers; + draw.highest_view = highest_view; + draw.highest_sampler = highest_sampler; + draw.state_restorable = restorable; + return draw; +} + +const MirroredHeap absent{}; +const MirroredHeap one{true, 1, false}; +const MirroredHeap four{true, 4, false}; +const MirroredHeap whole{true, 4, true}; +constexpr UINT unknown = unknown_heap_index; + +// The named cases from the review of #870. +void named() +{ + // Unflagged: bound at slot 34 as before, whatever the heaps or the state. + expect("unflagged, nothing", make(0, absent, unknown, absent, unknown, false), D::bind); + expect("unflagged, heaps", make(0, whole, 0, whole, 0, true), D::bind); + // Each flag alone. + expect("views flag, no heap", make(0x400, absent, 0, whole, 0, true), D::view_heap_missing); + expect("views flag, heap", make(0x400, whole, unknown, absent, unknown, true), D::bind); + expect("sampler flag, no heap", make(0x800, whole, 0, absent, 0, true), D::sampler_heap_missing); + expect("sampler flag, one-entry heap, index 0", make(0x800, absent, unknown, one, 0, true), D::bind); + expect("sampler flag, one-entry heap, index 1", make(0x800, absent, unknown, one, 1, true), D::sampler_heap_missing); + expect("sampler flag, one-entry heap, index unknown", make(0x800, absent, unknown, one, unknown, true), D::sampler_heap_missing); + // Both flags: a sampler heap alone never satisfies a root that also indexes the view heap. + expect("both flags, one-entry sampler heap alone", make(0xc00, absent, 0, one, 0, true), D::view_heap_missing); + expect("both flags, whole sampler heap alone", make(0xc00, absent, 0, whole, unknown, true), D::view_heap_missing); + expect("both flags, view heap alone", make(0xc00, whole, unknown, absent, 0, true), D::sampler_heap_missing); + expect("both flags, neither heap", make(0xc00, absent, 0, absent, 0, true), D::both_heaps_missing); + expect("both flags, both heaps", make(0xc00, whole, unknown, whole, unknown, true), D::bind); + // The root state: constants and descriptor tables that cannot be set again keep the draw refused. + expect("both flags, both heaps, state lost", make(0xc00, whole, unknown, whole, unknown, false), D::state_not_restorable); + expect("views flag, heap, state lost", make(0x400, whole, 0, absent, 0, false), D::state_not_restorable); + expect("sampler flag, heap, state lost", make(0x800, absent, 0, whole, 0, false), D::state_not_restorable); + // A missing heap is named before the state. + expect("sampler flag, no heap, state lost", make(0x800, absent, 0, absent, 0, false), D::sampler_heap_missing); + // Other root signature flags do not make a root heap-indexed. + expect("input layout flag only", make(0x1, absent, 0, absent, 0, false), D::bind); + expect("input layout flag with sampler flag", make(0x801, absent, 0, absent, 0, true), D::sampler_heap_missing); + // The stand-in's request: no mirrored heap, indices unknown, state not restorable. + expect("stand-in, views flag", make(0x400, absent, unknown, absent, unknown, false), D::view_heap_missing); + expect("stand-in, sampler flag", make(0x800, absent, unknown, absent, unknown, false), D::sampler_heap_missing); + expect("stand-in, both flags", make(0xc00, absent, unknown, absent, unknown, false), D::both_heaps_missing); +} + +// Whether a heap holds the indices a draw reads, from its fields; one-entry heaps are where --mutate sampler-alone lies. +bool covers(const MirroredHeap& heap, UINT highest, bool sampler) +{ + if (sampler && sampler_alone && heap.bound) return true; + if (!heap.bound) return false; + if (heap.whole) return true; + if (highest == unknown) return false; + return highest < heap.entries; +} + +D expected_for(UINT flags, const MirroredHeap& views, UINT highest_view, const MirroredHeap& samplers, UINT highest_sampler, + bool restorable) +{ + const bool indexes_views = (flags & 0x400) != 0, indexes_samplers = (flags & 0x800) != 0; + if (!indexes_views && !indexes_samplers) return D::bind; + const bool view_missing = indexes_views && !covers(views, highest_view, false); + // --mutate sampler-alone: any bound sampler heap is enough, also for the view heap. + const bool sampler_missing = indexes_samplers && !covers(samplers, highest_sampler, true); + const bool views_waived = sampler_alone && samplers.bound; + if (view_missing && !views_waived && sampler_missing) return D::both_heaps_missing; + if (view_missing && !views_waived) return D::view_heap_missing; + if (sampler_missing) return D::sampler_heap_missing; + if (!restorable && !bind_unrestorable) return D::state_not_restorable; + return D::bind; +} + +void matrix() +{ + const UINT flags[] = {0x0, 0x400, 0x800, 0xc00}; + const MirroredHeap heaps[] = {absent, one, four, whole}; + const UINT highest[] = {0, 1, 3, 4, unknown}; + char label[64]; + for (UINT f : flags) + for (const MirroredHeap& v : heaps) + for (UINT hv : highest) + for (const MirroredHeap& s : heaps) + for (UINT hs : highest) + for (bool restorable : {false, true}) { + std::snprintf(label, sizeof(label), "matrix 0x%x", f); + expect(label, make(f, v, hv, s, hs, restorable), expected_for(f, v, hv, s, hs, restorable)); + } +} +} // namespace + +int main(int argc, char** argv) +{ + if (argc == 3 && std::strcmp(argv[1], "--mutate") == 0) { + sampler_alone = std::strcmp(argv[2], "sampler-alone") == 0; + bind_unrestorable = std::strcmp(argv[2], "bind-unrestorable") == 0; + if (!sampler_alone && !bind_unrestorable) return 2; + } else if (argc != 1) { + return 2; + } + if (!sampler_alone && !bind_unrestorable) named(); + matrix(); + std::printf("%d of %d heap-indexed root decisions as expected\n", cases - failures, cases); + return failures ? 1 : 0; +} diff --git a/tests/startup_root_heap.cpp b/tests/startup_root_heap.cpp new file mode 100644 index 0000000000..9000aa8b6c --- /dev/null +++ b/tests/startup_root_heap.cpp @@ -0,0 +1,101 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include "startup_stream_setup.h" + +// X2W_TEST_DEBUG_LAYER=1 with X2W_TEST_ROOT_CBV (startup_root_cbv.cpp) and optional X2W_TEST_ROOT_FLAGS: every +// debug layer message of severity error or worse is counted through a message callback. +// +// root_heap_control with root signature flags, the title root signature's blob is set on a plain desktop list +// with no descriptor heaps. That must produce at least one message (the fail-first control); +// the IDs it produced are the ones counted afterwards. Without one, the run is a skip (77). +// root_heap_report after the stand-in's list ran: how many messages had a control ID (ID 1419 is always +// counted), and how many other errors there were. +namespace { +using Microsoft::WRL::ComPtr; +std::atomic errors{0}; +std::set control_ids; +std::set seen_ids; +SRWLOCK ids_lock = SRWLOCK_INIT; +int counted = 0, other = 0; +ComPtr queue1; + +void WINAPI on_message(D3D12_MESSAGE_CATEGORY, D3D12_MESSAGE_SEVERITY severity, D3D12_MESSAGE_ID id, LPCSTR text, void*) +{ + if (severity > D3D12_MESSAGE_SEVERITY_ERROR) return; + AcquireSRWLockExclusive(&ids_lock); + seen_ids.insert(static_cast(id)); + if (static_cast(id) == 1419 || control_ids.count(static_cast(id))) ++counted; + else ++other; + ReleaseSRWLockExclusive(&ids_lock); + if (++errors <= 12) std::printf("debug layer id %d: %.300s\n", static_cast(id), text); +} +} // namespace + +int root_heap_control(ID3D12Device* desktop) +{ + if (!GetEnvironmentVariableW(L"X2W_TEST_DEBUG_LAYER", nullptr, 0)) return 0; + DWORD cookie = 0; + if (FAILED(desktop->QueryInterface(IID_PPV_ARGS(&queue1))) || + FAILED(queue1->RegisterMessageCallback(on_message, D3D12_MESSAGE_CALLBACK_FLAG_NONE, nullptr, &cookie))) { + std::printf("no debug layer message callback: skipped\n"); + return 77; + } + if (!GetEnvironmentVariableW(L"X2W_TEST_ROOT_FLAGS", nullptr, 0)) { + std::printf("control: none (no root signature flags)\n"); + return 0; + } + const std::vector& blob = stream_root_blob(); + D3D12_COMMAND_QUEUE_DESC queue_desc{}; + ComPtr queue; + ComPtr allocator; + ComPtr list; + ComPtr root; + ComPtr fence; + if (blob.empty() || FAILED(desktop->CreateRootSignature(0, blob.data(), blob.size(), IID_PPV_ARGS(&root)))) { + std::printf("the desktop device rejects the root signature: skipped\n"); + return 77; + } + if (FAILED(desktop->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&queue))) || + FAILED(desktop->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&allocator))) || + FAILED(desktop->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, allocator.Get(), nullptr, IID_PPV_ARGS(&list))) || + FAILED(desktop->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence)))) return 50; + list->SetGraphicsRootSignature(root.Get()); + list->Close(); + ID3D12CommandList* lists[] = {list.Get()}; + queue->ExecuteCommandLists(1, lists); + queue->Signal(fence.Get(), 1); + const ULONGLONG deadline = GetTickCount64() + 10000; + while (fence->GetCompletedValue() < 1 && GetTickCount64() < deadline) Sleep(1); + if (fence->GetCompletedValue() < 1) return 51; + AcquireSRWLockExclusive(&ids_lock); + control_ids = seen_ids; + seen_ids.clear(); + const int control = counted + other; + counted = other = 0; + ReleaseSRWLockExclusive(&ids_lock); + std::printf("control: %d messages, ids", control); + for (int id : control_ids) std::printf(" %d", id); + std::printf("\n"); + if (!control) { + std::printf("the debug layer reports nothing for the control: skipped\n"); + return 77; + } + return 0; +} + +int root_heap_report() +{ + if (!queue1) return 0; + AcquireSRWLockExclusive(&ids_lock); + const int stand_in = counted, rest = other; + ReleaseSRWLockExclusive(&ids_lock); + std::printf("stand-in list: %d messages with a control id or id 1419, %d other errors\n", stand_in, rest); + return 0; +} diff --git a/tests/startup_root_heap_check.py b/tests/startup_root_heap_check.py new file mode 100644 index 0000000000..80779663fe --- /dev/null +++ b/tests/startup_root_heap_check.py @@ -0,0 +1,85 @@ +"""Title root signatures that index descriptor heaps directly are not set on the desktop list (command-list slot 34). + +The fixture is startup_root_cbv's translated draw (a pixel shader that reads four floats through root parameter 0), +run with the desktop debug layer on and the root signature created with D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_ +DIRECTLY_INDEXED (0x400), SAMPLER_HEAP_DIRECTLY_INDEXED (0x800), both, or neither. For each flagged case the same +root signature is first set on a plain desktop list with no descriptor heaps; that fail-first control must produce +debug layer errors (ID 1419 for the sampler heap), or the run is a capability skip (77). Through the stand-in, no +error with a control ID or ID 1419 may appear, and the translated draw must still show the colour the title bound. +""" +from pathlib import Path +import re +import subprocess +import sys +import tempfile + +from startup_address_srv_check import prepare_draw_cache +from startup_root_cbv_check import CLEAR, HLSL + +YELLOW = bytes((255, 255, 0, 255)) +CASES = ( + # root CBV mode, root signature flags, colour of the drawn half + ("bound", 0x0, YELLOW), # unflagged: set on the desktop list as before + ("bound", 0x400, YELLOW), # view heap indexed + ("bound", 0x800, YELLOW), # sampler heap indexed + ("bound", 0xC00, YELLOW), # both + ("null", 0xC00, bytes(4)), # a cleared root CBV under a flagged root + ("switch_root", 0xC00, bytes(4)), # switching between two flagged roots clears the stored address +) + + +def run(directory, consumer, backend, mode, flags): + folder = directory / f"{mode}-{flags:x}" + folder.mkdir() + modes = {"X2W_TEST_ROOT_CBV": mode, "X2W_TEST_DEBUG_LAYER": "1", "X2W_TRAP_LOG": str(folder / "trap.log")} + if flags: + modes["X2W_TEST_ROOT_FLAGS"] = hex(flags) + try: + env, args, output = prepare_draw_cache(folder, consumer, HLSL, modes, "srv 0 buf root 0") + except subprocess.CalledProcessError as error: + if error.returncode == 77: # no debug layer, or the root signature flags are rejected + return None, "" + raise + result = subprocess.run([*args, backend, output], env=env, capture_output=True, text=True) + print(result.stdout, end="") + if result.returncode == 77: + return None, result.stdout + if result.returncode: + raise RuntimeError(f"consumer failed ({result.returncode})\n{result.stderr[-5000:]}") + return output.read_bytes(), result.stdout + + +def check(directory, consumer, backend): + for mode, flags, drawn in CASES: + pixels, stdout = run(directory, consumer, backend, mode, flags) + if pixels is None: + return 77 + expected = (drawn * 4 + CLEAR * 4) * 4 + if pixels != expected: + raise AssertionError(f"{mode} 0x{flags:x}: actual {pixels.hex()} expected {expected.hex()}") + # Fail-first control: one ID 1419 message per flag (view heap, sampler heap) on a plain desktop list. + control = re.search(r"^control: (\d+) messages, ids([ \d]*)$", stdout, re.M) + if flags and (not control or int(control.group(1)) == 0): + raise AssertionError(f"{mode} 0x{flags:x}: no fail-first control result") + if flags and (control.group(2).split() != ["1419"] or int(control.group(1)) != bin(flags).count("1")): + raise AssertionError(f"{mode} 0x{flags:x}: the control did not produce one ID 1419 per flag: {control.group(0)}") + stand_in = re.search(r"^stand-in list: (\d+) messages with a control id or id 1419, (\d+) other errors$", stdout, re.M) + if not stand_in: + raise AssertionError(f"{mode} 0x{flags:x}: no stand-in message count") + if int(stand_in.group(1)): + raise AssertionError(f"{mode} 0x{flags:x}: {stand_in.group(0)}") + log = (directory / f"{mode}-{flags:x}" / "trap.log").read_text(errors="replace") + deferred = re.findall(r"root signature \S+ with heap flags (0x[0-9a-f]+) not set on the desktop list", log) + # Slot 34 calls: one, or three for switch_root (root, alternate, root); the stand-in logs the first three. + expected_deferred = [hex(flags)] * (3 if mode == "switch_root" else 1) if flags else [] + if deferred != expected_deferred: + raise AssertionError(f"{mode} 0x{flags:x}: deferred root lines {deferred}, expected {expected_deferred}") + ids = control.group(2).strip() if control else "none" + print(f"{backend} {mode} flags 0x{flags:x}: 32 pixels exact; control ids [{ids}]; " + f"stand-in 0 matching messages, {stand_in.group(2)} other errors") + return 0 + + +if __name__ == "__main__": + with tempfile.TemporaryDirectory() as temporary: + sys.exit(check(Path(temporary), *sys.argv[1:])) diff --git a/tests/startup_stream_draw.cpp b/tests/startup_stream_draw.cpp index 7fc1ff8faa..2da72156d5 100644 --- a/tests/startup_stream_draw.cpp +++ b/tests/startup_stream_draw.cpp @@ -271,7 +271,9 @@ int check_stream_draw(IDXGIAdapter* adapter, void* guest, void* pso, const char* extern int draw_bc_chain(void*, void*); if (const int result = draw_bc_chain(guest, list)) return result; } else if (GetEnvironmentVariableW(L"X2W_TEST_ROOT_CBV", nullptr, 0)) { + extern int root_heap_control(ID3D12Device*); extern int draw_root_cbv(void*); + if (const int result = root_heap_control(desktop.Get())) return result; if (const int result = draw_root_cbv(list)) return result; } else if (GetEnvironmentVariableW(L"X2W_TEST_1D_SRV", nullptr, 0)) { extern int draw_1d_srvs(void*, void*); @@ -350,6 +352,10 @@ int check_stream_draw(IDXGIAdapter* adapter, void* guest, void* pso, const char* last = 2; } if (const int rc = submit(last)) return rc; + if (GetEnvironmentVariableW(L"X2W_TEST_ROOT_CBV", nullptr, 0)) { + extern int root_heap_report(); + if (const int rc = root_heap_report()) return rc; + } return read_stream_target(desktop.Get(), frame, pixels); } diff --git a/tests/startup_stream_setup.cpp b/tests/startup_stream_setup.cpp index 2d153788bd..636d8efddf 100644 --- a/tests/startup_stream_setup.cpp +++ b/tests/startup_stream_setup.cpp @@ -34,9 +34,29 @@ struct Stream { namespace { void* stream_root = nullptr; void* stream_alternate_root = nullptr; +std::vector stream_root_bytes; + +// X2W_TEST_ROOT_FLAGS: root signature flags (startup_root_heap.cpp). A root signature with flags is serialized as +// version 1.1, which carries the descriptor-heap indexing flags; without flags the version 1.0 blob is unchanged. +HRESULT serialize_root(const D3D12_ROOT_SIGNATURE_DESC& desc, ComPtr& blob) +{ + if (!desc.Flags) return D3D12SerializeRootSignature(&desc, D3D_ROOT_SIGNATURE_VERSION_1, &blob, nullptr); + std::vector parameters(desc.NumParameters); + for (UINT i = 0; i < desc.NumParameters; ++i) { + const D3D12_ROOT_PARAMETER& p = desc.pParameters[i]; + if (p.ParameterType != D3D12_ROOT_PARAMETER_TYPE_CBV && p.ParameterType != D3D12_ROOT_PARAMETER_TYPE_SRV) return E_INVALIDARG; + parameters[i].ParameterType = p.ParameterType; + parameters[i].Descriptor = {p.Descriptor.ShaderRegister, p.Descriptor.RegisterSpace, D3D12_ROOT_DESCRIPTOR_FLAG_NONE}; + parameters[i].ShaderVisibility = p.ShaderVisibility; + } + D3D12_VERSIONED_ROOT_SIGNATURE_DESC versioned{D3D_ROOT_SIGNATURE_VERSION_1_1}; + versioned.Desc_1_1 = {desc.NumParameters, parameters.data(), 0, nullptr, desc.Flags}; + return D3D12SerializeVersionedRootSignature(&versioned, &blob, nullptr); +} } void* stream_root_signature() { return stream_root; } void* stream_alternate_root_signature() { return stream_alternate_root; } +const std::vector& stream_root_blob() { return stream_root_bytes; } int prepare_stream_pipeline(const char* vs_path, const char* ps_path, const char* root_path, bool hardware, bool textured, Microsoft::WRL::ComPtr& adapter, @@ -46,6 +66,15 @@ int prepare_stream_pipeline(const char* vs_path, const char* ps_path, const char std::vector vs{std::istreambuf_iterator(vs_file), {}}; std::vector ps{std::istreambuf_iterator(ps_file), {}}; if (vs.empty() || ps.empty()) return 3; + // X2W_TEST_DEBUG_LAYER=1 (startup_root_heap.cpp): the debug layer must be on before the first device exists. + if (GetEnvironmentVariableW(L"X2W_TEST_DEBUG_LAYER", nullptr, 0)) { + ComPtr debug; + if (FAILED(D3D12GetDebugInterface(IID_PPV_ARGS(&debug)))) { + std::printf("no debug layer: skipped\n"); + return 77; + } + debug->EnableDebugLayer(); + } ComPtr factory; if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory)))) return 4; @@ -95,21 +124,31 @@ int prepare_stream_pipeline(const char* vs_path, const char* ps_path, const char root_cbv.ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL; root_desc.NumParameters = 1; root_desc.pParameters = &root_cbv; + char flags[16]{}; + if (GetEnvironmentVariableA("X2W_TEST_ROOT_FLAGS", flags, sizeof(flags))) + root_desc.Flags = static_cast(std::strtoul(flags, nullptr, 0)); } + // A runtime or device that rejects the requested root signature flags is a capability skip. + const int rejected = root_desc.Flags ? 77 : 0; ComPtr blob; - if (FAILED(D3D12SerializeRootSignature(&root_desc, D3D_ROOT_SIGNATURE_VERSION_1, &blob, nullptr))) return 6; + if (FAILED(serialize_root(root_desc, blob))) return rejected ? rejected : 6; + stream_root_bytes.assign(static_cast(blob->GetBufferPointer()), + static_cast(blob->GetBufferPointer()) + blob->GetBufferSize()); std::ofstream(root_path, std::ios::binary).write(static_cast(blob->GetBufferPointer()), blob->GetBufferSize()); using CreateRoot = HRESULT (WINAPI*)(void*, UINT, const void*, SIZE_T, REFIID, void**); using CreateStream = HRESULT (WINAPI*)(void*, const D3D12_PIPELINE_STATE_STREAM_DESC*, REFIID, void**); auto** slots = *static_cast(device); ID3D12RootSignature* root = nullptr; if (FAILED(reinterpret_cast(slots[16])(device, 0, blob->GetBufferPointer(), blob->GetBufferSize(), - __uuidof(ID3D12RootSignature), reinterpret_cast(&root)))) return 7; + __uuidof(ID3D12RootSignature), reinterpret_cast(&root)))) { + if (rejected) std::printf("CreateRootSignature rejects flags 0x%x: skipped\n", static_cast(root_desc.Flags)); + return rejected ? rejected : 7; + } stream_root = root; if (std::strcmp(cbv_mode, "switch_root") == 0) { root_cbv.Descriptor.ShaderRegister = 1; ComPtr alternate; - if (FAILED(D3D12SerializeRootSignature(&root_desc, D3D_ROOT_SIGNATURE_VERSION_1, &alternate, nullptr)) || + if (FAILED(serialize_root(root_desc, alternate)) || FAILED(reinterpret_cast(slots[16])(device, 0, alternate->GetBufferPointer(), alternate->GetBufferSize(), __uuidof(ID3D12RootSignature), &stream_alternate_root))) return 7; diff --git a/tests/startup_stream_setup.h b/tests/startup_stream_setup.h index 03c573c046..d561dfd889 100644 --- a/tests/startup_stream_setup.h +++ b/tests/startup_stream_setup.h @@ -1,6 +1,7 @@ #pragma once #include #include +#include #include #include #include @@ -12,6 +13,8 @@ int prepare_stream_pipeline(const char* vs_path, const char* ps_path, const char // The guest root signature that prepare_stream_pipeline created (null before it ran). void* stream_root_signature(); void* stream_alternate_root_signature(); +// The serialized form of stream_root_signature(). +const std::vector& stream_root_blob(); struct StreamAttachment { Microsoft::WRL::ComPtr texture, readback;