From 0fcbad33e66829aa61ca95c166c64f387e56fcd0 Mon Sep 17 00:00:00 2001 From: mchughalex <25671999+mchughalex@users.noreply.github.com> Date: Thu, 9 Jul 2026 00:29:16 +0100 Subject: [PATCH] D3D12: report fake occlusion results while emulated draws are suppressed --- cmake/rexglue_helpers.cmake | 8 +++++++- src/graphics/d3d12/command_processor.cpp | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/cmake/rexglue_helpers.cmake b/cmake/rexglue_helpers.cmake index 0255ac7..d26ad0e 100644 --- a/cmake/rexglue_helpers.cmake +++ b/cmake/rexglue_helpers.cmake @@ -74,7 +74,13 @@ function(rexglue_configure_target target_name) REXGLUE_BUILD_CONFIG="$") if(TARGET imgui::imgui) - target_link_libraries(${target_name} PRIVATE imgui::imgui) + # Headers only. The ImGui implementation lives inside the runtime + # library (which exports it); linking the object library here would + # give the host its own second copy of ImGui with a separate, + # never-initialized context (GImGui == nullptr), so any host-side + # ImGuiDialog subclass would crash on its first ImGui:: call. + target_include_directories(${target_name} PRIVATE + $) endif() target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/rexglue-sdk/include) diff --git a/src/graphics/d3d12/command_processor.cpp b/src/graphics/d3d12/command_processor.cpp index e8478c4..9818284 100644 --- a/src/graphics/d3d12/command_processor.cpp +++ b/src/graphics/d3d12/command_processor.cpp @@ -435,6 +435,27 @@ bool D3D12CommandProcessor::ExecutePacketType3_EVENT_WRITE_ZPD(memory::RingBuffe return write_fake_result(REXCVAR_GET(skate3_ultrawide_fake_occlusion_sample_count)); } + // Native guest-output renderer active: the framebuffer-sized draws between + // query begin/end are suppressed, so a real host occlusion query reports 0 + // samples. The game gates world rendering on these results; event-ad + // placements poll their poster quads' visibility and stop submitting the + // overlay geometry entirely (the native frame then shows the default poster + // art where the emulated frame shows the current ad). Report the fake + // positive count instead: the suppressed draws are exactly the ones the + // native renderer is drawing in their place. + if (ShouldSuppressEmulatedDraws()) { + if (active_occlusion_query_.valid) { + uint32_t host_index = active_occlusion_query_.host_index; + active_occlusion_query_ = {}; + if (occlusion_query_heap_ && BeginSubmission(true)) { + deferred_command_list_.D3DEndQuery(occlusion_query_heap_.Get(), D3D12_QUERY_TYPE_OCCLUSION, + host_index); + EndSubmission(false); + } + } + return write_fake_result(REXCVAR_GET(query_occlusion_fake_sample_count)); + } + if (!REXCVAR_GET(occlusion_query_enable) || !occlusion_query_resources_available_) { return CommandProcessor::ExecutePacketType3_EVENT_WRITE_ZPD(reader, packet, count); }