diff --git a/src/startup_stubs/clear_census.h b/src/startup_stubs/clear_census.h new file mode 100644 index 0000000000..77b726fcfe --- /dev/null +++ b/src/startup_stubs/clear_census.h @@ -0,0 +1,84 @@ +#pragma once + +#include +#include +#include +#include + +namespace x2w_startup { + +enum class ClearKind { rtv, dsv, uav_uint, uav_float }; + +struct ClearKey { + ClearKind kind; + unsigned format, dimension, width_class, height_class, depth_class; + std::array bits{}; + + bool operator==(const ClearKey& other) const + { + return kind == other.kind && format == other.format && dimension == other.dimension && + width_class == other.width_class && height_class == other.height_class && + depth_class == other.depth_class && bits == other.bits; + } +}; + +// Classes round up to a power of two, represented by its exponent. +inline unsigned clear_size_class(std::uint64_t size) +{ + unsigned result = 0; + for (auto n = size ? size - 1 : 0; n; n >>= 1) ++result; + return result; +} + +class ClearCensus { + struct Entry { + ClearKey key; + long first_frame; + unsigned long long calls = 1, reported = 0; + }; + std::mutex mutex_; + std::array entries_{}; + unsigned used_ = 0; + unsigned long long total_ = 0, overflow_ = 0, reported_ = 0; + +public: + void note(const ClearKey& key, long frame) + { + std::lock_guard lock(mutex_); + ++total_; + for (unsigned i = 0; i < used_; ++i) { + if (entries_[i].key == key) { + ++entries_[i].calls; + return; + } + } + if (used_ == entries_.size()) ++overflow_; + else entries_[used_++] = {key, frame}; + } + + template + void report(Emit emit, bool only_if_changed) + { + std::lock_guard lock(mutex_); + if (!total_ || (only_if_changed && total_ == reported_)) return; + if (only_if_changed) reported_ = total_; + char line[256]; + std::snprintf(line, sizeof(line), "x2w-render clear census: total %llu; shapes %u (overflow calls %llu)", + total_, used_, overflow_); + emit(line); + constexpr const char* names[] = {"rtv", "dsv", "uav_uint", "uav_float"}; + for (unsigned i = 0; i < used_; ++i) { + auto& entry = entries_[i]; + if (only_if_changed && entry.calls == entry.reported) continue; + if (only_if_changed) entry.reported = entry.calls; + const auto& k = entry.key; + std::snprintf(line, sizeof(line), "x2w-render clear %s fmt=%u dim=%u size_log2=%ux%ux%u " + "value_bits=%08x,%08x,%08x,%08x calls=%llu first_seen_frame=%ld", + names[static_cast(k.kind)], k.format, k.dimension, k.width_class, k.height_class, + k.depth_class, k.bits[0], k.bits[1], k.bits[2], k.bits[3], entry.calls, entry.first_frame); + emit(line); + } + } +}; + +} // namespace x2w_startup diff --git a/src/startup_stubs/d3d12_draw.inl b/src/startup_stubs/d3d12_draw.inl index f6e88d4e4f..6410e35d28 100644 --- a/src/startup_stubs/d3d12_draw.inl +++ b/src/startup_stubs/d3d12_draw.inl @@ -2958,7 +2958,7 @@ bool fixed_vertex_view(Wrapper* self, const Pass& pass, const Translation& tr, b // X2W_PIPELINE_COLOUR=1 (pipeline_colour.h), a debug switch read once. last_draw_refusal: why the last // draw_translated on this thread drew nothing, and its pipeline key (0 when the draw stopped before a translation -// was found). Only written while the switch is on. +// was found). The prose is only written while the switch is on. bool pipeline_colour_enabled() { static const bool enabled = x2w_local::env_on("X2W_PIPELINE_COLOUR"); @@ -2967,14 +2967,16 @@ bool pipeline_colour_enabled() struct DrawRefusal { u64 key = 0; + const char* code = nullptr; char why[192] = ""; }; thread_local DrawRefusal last_draw_refusal; -void note_draw_refusal(u64 key, const char* why, const char* detail = nullptr) +void note_draw_refusal(u64 key, const char* code, const char* why, const char* detail = nullptr) { - if (!pipeline_colour_enabled()) return; last_draw_refusal.key = key; + last_draw_refusal.code = code; + if (!pipeline_colour_enabled()) return; if (detail) std::snprintf(last_draw_refusal.why, sizeof(last_draw_refusal.why), "%s: %s", why, detail); else std::snprintf(last_draw_refusal.why, sizeof(last_draw_refusal.why), "%s", why); } @@ -3108,6 +3110,7 @@ void draw_pipeline_colour(Wrapper* self, u64 key, const char* why) bool draw_translated(Wrapper* self, bool indexed, UINT count, UINT instances, UINT start, INT base_vertex, UINT start_instance, TranslatedIndirectDraw* indirect, bool* used_fallback = nullptr) { + last_draw_refusal.code = nullptr; if (pipeline_colour_enabled()) last_draw_refusal = {}; auto* list = recording(self); Pass& pass = pass_of(self); @@ -3115,14 +3118,17 @@ bool draw_translated(Wrapper* self, bool indexed, UINT count, UINT instances, UI const bool indexed_rect = rect && indexed && indirect; if (!list || !pass.pipeline || !pass.targets_bound || !(rect || pass.topology == 4 || pass.topology == 5) || (rect && indexed && !indexed_rect)) { - note_draw_refusal(0, !list ? "no recording list" : !pass.pipeline ? "no pipeline bound" + note_draw_refusal(0, !list ? "no_recording_list" : !pass.pipeline ? "no_pipeline_bound" + : !pass.targets_bound ? "render_targets_not_bound" : "topology_not_translated", + !list ? "no recording list" : !pass.pipeline ? "no pipeline bound" : !pass.targets_bound ? "render targets not bound" : "topology not translated"); return false; } AcquireSRWLockExclusive(&draw_lock); BoundPipeline* bound = translation_for(pass.pipeline); Translation* tr = bound ? translation_for_targets(bound->translation, pass) : nullptr; - if (!tr) note_draw_refusal(0, bound ? "no translation for the bound targets" : "pipeline description not decoded"); + if (!tr) note_draw_refusal(0, bound ? "no_target_translation" : "pipeline_not_decoded", + bound ? "no translation for the bound targets" : "pipeline description not decoded"); if (used_fallback && tr && tr->manifest_retry.pending() && draw_missing_translation(device_of(self->own().list_device), list, pass, count, instances, start, start_instance)) { *used_fallback = true; @@ -3145,7 +3151,10 @@ bool draw_translated(Wrapper* self, bool indexed, UINT count, UINT instances, UI #ifdef X2W_NATIVE_SHADERS if (!tr->native_refusal.empty()) native = tr->native_refusal.c_str(); #endif - note_draw_refusal(tr->key, translation_ok ? (!d16_ok ? "d16 texture view not ready" : "formatted buffer not ready") + const char* code = translation_ok ? (!d16_ok ? "d16_view_not_ready" : "formatted_buffer_not_ready") + : native ? "native_graphics_refused" + : tr->manifest_retry.pending() ? "manifest_absent" : "manifest_refused"; + note_draw_refusal(tr->key, code, translation_ok ? (!d16_ok ? "d16 texture view not ready" : "formatted buffer not ready") : native ? "native graphics refused" : tr->manifest_retry.pending() ? "no translation (manifest absent)" : "translation unusable (manifest refused)", @@ -3160,7 +3169,7 @@ bool draw_translated(Wrapper* self, bool indexed, UINT count, UINT instances, UI if (fixed_stream && (indirect || !fixed_vertex_view(self, pass, *tr, indexed, start, count, fixed_view, fixed_resource))) { if (indirect) indirect->set_refusal("fixed vertex stream indirect arguments are unsupported", indirect_refusal_code::unsupported_resource_or_entry); - note_draw_refusal(tr->key, "fixed vertex stream refused"); + note_draw_refusal(tr->key, "fixed_vertex_stream_refused", "fixed vertex stream refused"); static LONG refused; if (first_calls(refused, 16)) log("x2w-draw %016llx fixed vertex stream refused: rect=%u indirect=%u vb=%llx bytes=%u", @@ -3228,7 +3237,8 @@ bool draw_translated(Wrapper* self, bool indexed, UINT count, UINT instances, UI if (indirect && !(indexed_rect && !pipeline)) indirect->refusal_code = !pipeline ? indirect_refusal_code::pipeline_unavailable : indirect_refusal_code::sampler_heap_unavailable; - note_draw_refusal(tr->key, !pipeline ? "pipeline state unavailable" : "sampler heap unavailable"); + note_draw_refusal(tr->key, !pipeline ? "pipeline_state_unavailable" : "sampler_heap_unavailable", + !pipeline ? "pipeline state unavailable" : "sampler heap unavailable"); ReleaseSRWLockExclusive(&draw_lock); return false; } @@ -3237,12 +3247,12 @@ bool draw_translated(Wrapper* self, bool indexed, UINT count, UINT instances, UI // draws can alias it through guest addresses, so do not guess their independence. if (raw_uav && (indexed || indirect || tr->uavs.size() != 1 || !tr->srvs.empty())) { log("x2w-draw %016llx raw UAV requires one writable view and a direct non-indexed draw without SRVs", tr->key); - note_draw_refusal(tr->key, "raw UAV draw shape unsupported"); + note_draw_refusal(tr->key, "raw_uav_shape_unsupported", "raw UAV draw shape unsupported"); ReleaseSRWLockExclusive(&draw_lock); return false; } // Every later refusal (views, buffer copies, index data, default scissor) shares one reason. - note_draw_refusal(tr->key, "resource binding refused after the pipeline was created"); + note_draw_refusal(tr->key, "resource_binding_refused", "resource binding refused after the pipeline was created"); PixelUavBinding uav_bindings[pixel_uav_limit]; if (!resolve_pixel_uavs(*tr, pass, uav_bindings) || (raw_uav && !retain_with_recording(self, x2w_startup::ComPtr(uav_bindings[0].resource)))) { @@ -3788,6 +3798,16 @@ bool draw_translated(Wrapper* self, bool indexed, UINT count, UINT instances, UI LONG missing_shader_fallback_draws; +void count_direct_draw(Wrapper* self, bool drawn) +{ + InterlockedIncrement(drawn ? &translated_draws : &untranslated_draws); + if (drawn) return; + const auto& refusal = last_draw_refusal; + const u64 key = refusal.code && refusal.key ? refusal.key : known_pipeline_key(pass_of(self).pipeline); + direct_draw_refusal_census.note(key, refusal.code, InterlockedCompareExchange(&frame_number, 0, 0)); + if (pipeline_colour_enabled()) draw_pipeline_colour(self, refusal.key, refusal.why); +} + void draw_startup_direct(Wrapper* self, UINT count, UINT instances, UINT start, UINT start_instance) { bool used_fallback = false; @@ -3796,8 +3816,7 @@ void draw_startup_direct(Wrapper* self, UINT count, UINT instances, UINT start, const LONG n = InterlockedIncrement(&missing_shader_fallback_draws); if (n == 1) log("x2w-draw recorded first missing shader fallback"); } else { - InterlockedIncrement(drawn ? &translated_draws : &untranslated_draws); - if (!drawn && pipeline_colour_enabled()) draw_pipeline_colour(self, last_draw_refusal.key, last_draw_refusal.why); + count_direct_draw(self, drawn); } } @@ -3969,6 +3988,5 @@ void __stdcall list_vertex_buffers(Wrapper* self, UINT start, UINT count, const void __stdcall list_draw_indexed(Wrapper* self, UINT count, UINT instances, UINT start, INT base_vertex, UINT start_instance) { const bool drawn = draw_translated(self, true, count, instances, start, base_vertex, start_instance); - InterlockedIncrement(drawn ? &translated_draws : &untranslated_draws); - if (!drawn && pipeline_colour_enabled()) draw_pipeline_colour(self, last_draw_refusal.key, last_draw_refusal.why); + count_direct_draw(self, drawn); } diff --git a/src/startup_stubs/d3d12_xs_device.cpp b/src/startup_stubs/d3d12_xs_device.cpp index cc1f9abc54..5cd43a994c 100644 --- a/src/startup_stubs/d3d12_xs_device.cpp +++ b/src/startup_stubs/d3d12_xs_device.cpp @@ -57,6 +57,7 @@ #include "startup_stubs/memory_srv_census.h" #include "startup_stubs/memory_srv_as.h" #include "startup_stubs/per_reason_refusal_census.h" +#include "startup_stubs/clear_census.h" #include "startup_stubs/buffer_format_word3.h" #include "startup_stubs/memory_srv_buffer.h" #include "startup_stubs/single_element_srv.h" @@ -130,8 +131,7 @@ namespace { using u64 = std::uint64_t; constexpr int slot_count = 512; -// Refused slot 70 calls, "token" texture nulls (memory_srv_census.h), and indirect refusal censuses -// per (pipeline key, reason) (per_reason_refusal_census.h), printed with the five-second report. +// Render diagnostics printed with the five-second report. x2w_startup::MemorySrvCensus memory_srv_census; x2w_startup::TokenNullCensus token_null_census; x2w_startup::MemorySrvWrites memory_srv_writes; @@ -140,6 +140,16 @@ x2w_startup::PerReasonRefusalCensus indirect_other_refusal_census{"indirect-othe // Graphics-pipeline, compute-pipeline and placeholder-signature refusals, by pipeline key. // Acceptance is unchanged; this census only names the cause. x2w_startup::PerReasonRefusalCensus indirect_pipeline_refusal_census{"indirect-pipeline"}; +x2w_startup::PerReasonRefusalCensus direct_draw_refusal_census{"direct-draw"}; +x2w_startup::ClearCensus clear_census; + +template +void report_draw_and_clear_censuses(Emit emit, bool only_if_changed) +{ + if (only_if_changed || direct_draw_refusal_census.total()) + direct_draw_refusal_census.report(emit, only_if_changed); + clear_census.report(emit, only_if_changed); +} enum Kind : int { device_kind, queue_kind, fence_kind, allocator_kind, list_kind, descriptor_heap_kind, root_signature_kind, @@ -4325,9 +4335,8 @@ void __stdcall list_graphics_root(Wrapper* self, void* root) 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) +DXGI_FORMAT view_format_of(u64 desktop_handle, DXGI_FORMAT format) { - DXGI_FORMAT format = target->GetDesc().Format; if (const std::uint32_t id = shadow_id(desktop_handle)) { AcquireSRWLockShared(¬e_lock); DXGI_FORMAT view_format = DXGI_FORMAT_UNKNOWN; @@ -4338,6 +4347,20 @@ DXGI_FORMAT view_format_of(u64 desktop_handle, ID3D12Resource* target) } return format; } +DXGI_FORMAT view_format_of(u64 desktop_handle, ID3D12Resource* target) +{ + return view_format_of(desktop_handle, target->GetDesc().Format); +} + +void note_clear(x2w_startup::ClearKind kind, u64 handle, ID3D12Resource* target, const void* values) +{ + using namespace x2w_startup; + const auto desc = target->GetDesc(); + ClearKey key{kind, static_cast(view_format_of(handle, desc.Format)), static_cast(desc.Dimension), + clear_size_class(desc.Width), clear_size_class(desc.Height), clear_size_class(desc.DepthOrArraySize)}; + std::memcpy(key.bits.data(), values, 4 * sizeof(std::uint32_t)); + clear_census.note(key, InterlockedCompareExchange(&frame_number, 0, 0)); +} // The view a descriptor holds now, read from its shadow record so copies are followed. A record of the // other kind is wrong_kind; a handle with no record falls back to the creation-time map (render targets only). struct ResolvedView { @@ -4451,6 +4474,12 @@ void __stdcall list_clear_depth_stencil(Wrapper* self, u64 handle, D3D12_CLEAR_F list->ClearDepthStencilView(D3D12_CPU_DESCRIPTOR_HANDLE{static_cast(desktop)}, flags, depth, stencil, rect_count, rect_count ? rects : nullptr); red_producers().after(self, red_sample); + // The four census words are depth bits, stencil, effective clear flags and zero. + const float cleared_depth = flags & D3D12_CLEAR_FLAG_DEPTH ? depth : 0.0f; + std::uint32_t values[] = {0, flags & D3D12_CLEAR_FLAG_STENCIL ? static_cast(stencil) : 0u, + static_cast(flags), 0}; + std::memcpy(values, &cleared_depth, sizeof(cleared_depth)); + note_clear(x2w_startup::ClearKind::dsv, desktop, target, values); InterlockedIncrement(&render_clears); } // List slot 52 (desktop 48 + 4), ClearRenderTargetView(view, colour, rect count, rects). Desktop @@ -4482,6 +4511,7 @@ void __stdcall list_clear_target(Wrapper* self, u64 handle, const float* colour, list->ClearRenderTargetView(D3D12_CPU_DESCRIPTOR_HANDLE{static_cast(desktop)}, colour, rect_count, rect_count ? rects : nullptr); red_producers().after(self, red_sample); + note_clear(x2w_startup::ClearKind::rtv, desktop, target, colour); InterlockedIncrement(&render_clears); } // The desktop shader-visible CBV/SRV/UAV heap that owns the GPU handle's descriptor, or null. @@ -4548,6 +4578,7 @@ void __stdcall list_clear_uav(Wrapper* self, u64 gpu_handle, u64 cpu_handle, u64 const D3D12_CPU_DESCRIPTOR_HANDLE cpu{static_cast(desktop)}; if (Float) list->ClearUnorderedAccessViewFloat(gpu, cpu, target, static_cast(values), rect_count, rect_count ? rects : nullptr); else list->ClearUnorderedAccessViewUint(gpu, cpu, target, static_cast(values), rect_count, rect_count ? rects : nullptr); + note_clear(Float ? x2w_startup::ClearKind::uav_float : x2w_startup::ClearKind::uav_uint, desktop, target, values); InterlockedIncrement(&render_clears); } // List slot 55 (desktop 51 + 4), DiscardResource(resource, region). Discard is only a hint, so a resource @@ -7901,7 +7932,7 @@ HRESULT __stdcall queue_present(Wrapper* self, UINT planes, const void* plane_pa static LONG frames; static ULONGLONG started, last_report; const LONG frame = InterlockedIncrement(&frames); - frame_number = frame; + InterlockedExchange(&frame_number, frame); draw_dump_flush(); red_producers().flush(); { @@ -8112,6 +8143,7 @@ HRESULT __stdcall queue_present(Wrapper* self, UINT planes, const void* plane_pa indirect_other_refusal_census.report([](const char* line) { log("%s", line); }, true); indirect_pipeline_refusal_census.report([](const char* line) { log("%s", line); }, true); emit_pipeline_refusal_counts([](const char* line) { log("%s", line); }); + report_draw_and_clear_censuses([](const char* line) { log("%s", line); }, true); log("x2w-d3d12 heartbeat: %ld frames presented in %.1f s (%.1f fps overall); frame waits by type %ld/%ld/%ld/%ld, " "%lld ms slept", frame, (now - started) / 1000.0, frame * 1000.0 / (now - started ? now - started : 1), frame_waits[0], frame_waits[1], frame_waits[2], frame_waits[3], static_cast(frame_wait_ms)); @@ -8141,6 +8173,7 @@ extern "C" __declspec(dllexport) std::size_t x2w_d3d12_census_report(char* out, if (indirect_other_refusal_census.total()) indirect_other_refusal_census.report(emit, false); if (indirect_pipeline_refusal_census.total()) indirect_pipeline_refusal_census.report(emit, false); emit_pipeline_refusal_counts(emit); + report_draw_and_clear_censuses(emit, false); if (out && capacity) out[length < capacity ? length : capacity - 1] = 0; return length; } diff --git a/src/startup_stubs/per_reason_refusal_census.h b/src/startup_stubs/per_reason_refusal_census.h index 0adbd468bc..cc334fcdf5 100644 --- a/src/startup_stubs/per_reason_refusal_census.h +++ b/src/startup_stubs/per_reason_refusal_census.h @@ -33,7 +33,7 @@ class PerReasonRefusalCensus { // Counts one refusal for (key, reason_name). Returns true on the first insertion of one of // the first detail_entries distinct (key, reason) pairs so callers can budget detail logs. - bool note(std::uint64_t key, const char* reason_name) + bool note(std::uint64_t key, const char* reason_name, std::int64_t frame = -1) { char reason[max_reason_bytes] = {}; copy_sanitized(reason, sizeof(reason), reason_name, "unknown"); @@ -72,6 +72,7 @@ class PerReasonRefusalCensus { std::memcpy(entry.reason, reason, sizeof(reason)); entry.calls = 1; entry.reported_calls = 0; + entry.first_frame = frame; const bool detail = entry_count_ < detail_entries; ++entry_count_; return detail; @@ -96,10 +97,13 @@ class PerReasonRefusalCensus { Entry& entry = entries_[i]; if (only_if_changed && entry.calls == entry.reported_calls) continue; if (only_if_changed) entry.reported_calls = entry.calls; - std::snprintf(line, sizeof(line), + const int used = std::snprintf(line, sizeof(line), "x2w-d3d12 %s refusal %u: key=%016llx reason=%s calls=%llu", label_, i + 1, static_cast(entry.key), entry.reason, static_cast(entry.calls)); + if (entry.first_frame >= 0 && used > 0 && static_cast(used) < sizeof(line)) + std::snprintf(line + used, sizeof(line) - used, " first_seen_frame=%lld", + static_cast(entry.first_frame)); emit(static_cast(line)); } emit_key_totals_locked(emit, only_if_changed, line, sizeof(line)); @@ -136,6 +140,7 @@ class PerReasonRefusalCensus { char reason[max_reason_bytes] = {}; std::uint64_t calls = 0; std::uint64_t reported_calls = 0; + std::int64_t first_frame = -1; }; static void copy_sanitized(char* out, std::size_t out_size, const char* src, const char* fallback) diff --git a/tests/cmake/startup_draw_clear_census.cmake b/tests/cmake/startup_draw_clear_census.cmake new file mode 100644 index 0000000000..cf8b537cbc --- /dev/null +++ b/tests/cmake/startup_draw_clear_census.cmake @@ -0,0 +1,3 @@ +add_test(NAME startup_draw_clear_census_warp COMMAND startup_clear_depth_stencil warp census) +set_tests_properties(startup_draw_clear_census_warp PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77 + ENVIRONMENT "X2W_D3D12_PERMISSIVE=1;X2W_D3D12_LIST_NOOP=1;X2W_D3D12_RENDER=1;X2W_D3D12_DEBUG=1;X2W_PIPELINE_COLOUR=0") diff --git a/tests/startup_clear_depth_stencil.cpp b/tests/startup_clear_depth_stencil.cpp index 091a7e25cf..e74d769a26 100644 --- a/tests/startup_clear_depth_stencil.cpp +++ b/tests/startup_clear_depth_stencil.cpp @@ -31,6 +31,7 @@ using Microsoft::WRL::ComPtr; extern "C" __declspec(dllimport) HRESULT WINAPI D3D12XboxCreateDevice(IUnknown*, const void*, REFIID, void**); extern "C" __declspec(dllimport) void x2w_d3d12_render_target_stats(unsigned* binds, unsigned* unresolved); +extern "C" __declspec(dllimport) std::size_t x2w_d3d12_census_report(char*, std::size_t); namespace { using Word = std::uint64_t; @@ -178,7 +179,8 @@ bool check_count(const char* name, unsigned& before, unsigned expected_added) int main(int argc, char** argv) { - if (argc != 2) return 2; + const bool census = argc == 3 && std::strcmp(argv[2], "census") == 0; + if (argc != 2 && !census) return 2; ComPtr factory; if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory)))) return 3; ComPtr adapter; @@ -346,6 +348,28 @@ int main(int argc, char** argv) clear_dsv(list, handle_d, D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL, 0.5f, 0x5a, 0, nullptr); if (!check_count("7 mapped depth/stencil clear", seen, 0)) return 22; + if (census) { + invoke(list, 12, 3, 1); + for (unsigned i = 0; i < 5; ++i) invoke(list, 52, rtv_cpu, arg(rtv_clear.Color)); + if (!ok(invoke(probe.queue, 32))) return 24; + invoke(list, 13, 3, 1); + for (unsigned i = 1; i <= 125; ++i) { + const float colour[] = {i / 128.0f, 0, 0, 0}; + invoke(list, 52, rtv_cpu, arg(colour)); + } + invoke(list, 52, rtv_cpu, arg(rtv_clear.Color)); + std::array report{}; + if (x2w_d3d12_census_report(report.data(), report.size()) >= report.size() || + !std::strstr(report.data(), "key=0000000000000000 reason=no_pipeline_bound calls=2 first_seen_frame=0") || + !std::strstr(report.data(), "clear census: total 134; shapes 128 (overflow calls 1)") || + !std::strstr(report.data(), "clear dsv fmt=40 dim=3 size_log2=1x1x0 value_bits=3f400000,00000000,00000001,00000000") || + !std::strstr(report.data(), "clear rtv fmt=28 dim=3 size_log2=0x0x0 value_bits=00000000,00000000,00000000,00000000 calls=6 first_seen_frame=0") || + !std::strstr(report.data(), "value_bits=3c000000,00000000,00000000,00000000 calls=1 first_seen_frame=1")) { + std::fputs(report.data(), stderr); + return 25; + } + } + // Close and submit invoke(list, 9); if (!probe.submit(list)) return 16; diff --git a/tests/startup_clear_uav.cpp b/tests/startup_clear_uav.cpp index 2367e52508..5ee05a0be5 100644 --- a/tests/startup_clear_uav.cpp +++ b/tests/startup_clear_uav.cpp @@ -31,6 +31,7 @@ using Microsoft::WRL::ComPtr; extern "C" __declspec(dllimport) HRESULT WINAPI D3D12XboxCreateDevice(IUnknown*, const void*, REFIID, void**); extern "C" __declspec(dllimport) void x2w_d3d12_render_target_stats(unsigned* binds, unsigned* unresolved); +extern "C" __declspec(dllimport) std::size_t x2w_d3d12_census_report(char*, std::size_t); namespace { using Word = std::uint64_t; @@ -245,6 +246,14 @@ int main(int argc, char** argv) if (!check_count("5 clear through a CPU handle holding no view", seen, 1)) return 14; invoke(list, 53, gpu_start, plain_cpu, arg(a.Get()), 0, 0, 0); if (!check_count("6 clear with no values", seen, 1)) return 15; + std::array report{}; + x2w_d3d12_census_report(report.data(), report.size()); + if (!std::strstr(report.data(), "clear census: total 3; shapes 3 (overflow calls 0)") || + !std::strstr(report.data(), "clear uav_uint fmt=42 dim=3 size_log2=0x0x0 value_bits=12345678,12345678,12345678,12345678") || + !std::strstr(report.data(), "clear uav_float fmt=41 dim=3 size_log2=0x0x0 value_bits=3fc00000,3fc00000,3fc00000,3fc00000")) { + std::fputs(report.data(), stderr); + return 21; + } const D3D12_DISCARD_REGION region{1, &whole, 0, 1}; invoke(list, 55, arg(e.Get()), 0);