Skip to content

Commit

Permalink
D3D11: Fix 2D screen not working with synced/AFR
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Oct 20, 2023
1 parent 7042872 commit 53fc792
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/mods/vr/D3D11Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,25 @@ vr::EVRCompositorError D3D11Component::on_frame(VR* vr) {
context->ClearRenderTargetView(m_engine_tex_ref, clear_color);
};

if (is_2d_screen) {
draw_2d_view();
}

// Duplicate frames can sometimes cause the UI to get stuck on the screen.
// and can lock up the compositor.
if (is_right_eye_frame) {
if (runtime->is_openvr() && get_ui_tex().Get() != nullptr && m_engine_ui_ref.has_texture()) {
copy_tex(m_engine_ui_ref, get_ui_tex().Get());
} else if (runtime->is_openxr() && vr->m_openxr->frame_began) {
if (runtime->is_openvr() && get_ui_tex().Get() != nullptr) {
if (is_right_eye_frame) {
if (is_2d_screen) {
copy_tex(m_2d_screen_tex[0], get_ui_tex().Get());
} else if (m_engine_ui_ref.has_texture()) {
copy_tex(m_engine_ui_ref, get_ui_tex().Get());
}
} else if (is_2d_screen) {
copy_tex(m_2d_screen_tex[0], get_ui_tex().Get());
}
} else if (runtime->is_openxr() && vr->m_openxr->frame_began) {
if (is_right_eye_frame) {
if (is_2d_screen) {
draw_2d_view();

if (is_afr) {
m_openxr.copy((uint32_t)runtimes::OpenXR::SwapchainIndex::UI_RIGHT, m_2d_screen_tex[0]);
} else {
Expand All @@ -415,6 +425,8 @@ vr::EVRCompositorError D3D11Component::on_frame(VR* vr) {
if (fw_rt != nullptr && g_framework->is_drawing_anything()) {
m_openxr.copy((uint32_t)runtimes::OpenXR::SwapchainIndex::FRAMEWORK_UI, fw_rt.Get());
}
} else if (is_2d_screen) {
m_openxr.copy((uint32_t)runtimes::OpenXR::SwapchainIndex::UI, m_2d_screen_tex[0]);
}
}

Expand Down

0 comments on commit 53fc792

Please sign in to comment.