Skip to content

Commit 2ea85c0

Browse files
committed
D3D12: Harden last commit
1 parent b9ce85a commit 2ea85c0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/mods/vr/D3D12Component.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ vr::EVRCompositorError D3D12Component::on_frame(VR* vr) {
351351

352352
// Draws the spectator view
353353
auto clear_rt = [&](d3d12::CommandContext& commands) {
354+
if (m_game_ui_tex.texture.Get() == nullptr) {
355+
return;
356+
}
357+
354358
const float ui_clear_color[] = { 0.0f, 0.0f, 0.0f, ui_should_invert_alpha ? 1.0f : 0.0f };
355359
commands.clear_rtv(m_game_ui_tex, (float*)&ui_clear_color, ENGINE_SRC_COLOR);
356360
};
@@ -392,7 +396,7 @@ vr::EVRCompositorError D3D12Component::on_frame(VR* vr) {
392396
}
393397
} else if (is_2d_screen) {
394398
m_openxr.copy((uint32_t)runtimes::OpenXR::SwapchainIndex::UI, m_2d_screen_tex[0].texture.Get(), draw_2d_view, clear_rt, ENGINE_SRC_COLOR);
395-
} else {
399+
} else if (m_game_ui_tex.commands.ready()) {
396400
m_game_ui_tex.commands.wait(INFINITE);
397401
draw_2d_view(m_game_ui_tex.commands, nullptr);
398402
clear_rt(m_game_ui_tex.commands);

src/mods/vr/d3d12/CommandContext.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ struct CommandContext {
3535
void clear_rtv(TextureContext& tex, const float* color, D3D12_RESOURCE_STATES dst_state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
3636
void execute();
3737

38+
bool ready() const {
39+
return this->cmd_list != nullptr && this->cmd_allocator != nullptr && this->fence != nullptr;
40+
}
41+
3842
ComPtr<ID3D12CommandAllocator> cmd_allocator{};
3943
ComPtr<ID3D12GraphicsCommandList> cmd_list{};
4044
ComPtr<ID3D12Fence> fence{};

0 commit comments

Comments
 (0)