Skip to content

Commit

Permalink
GameObjectsDisplay/ChainViewer: Only init D3D resources if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Nov 17, 2024
1 parent d12ffb2 commit 4805876
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/mods/tools/ChainViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ std::optional<std::string> ChainViewer::on_initialize_d3d_thread() {
}

std::optional<std::string> ChainViewer::initialize_d3d_resources() {
if (!m_enabled->value()) {
if (m_d3d12.initialized) {
m_d3d12 = {};
}

return std::nullopt;
}

if (g_framework->is_dx12()) {
m_d3d12 = {};

Expand All @@ -89,6 +97,7 @@ std::optional<std::string> ChainViewer::initialize_d3d_resources() {
m_d3d12.cylinder = DirectX::GeometricPrimitive::CreateCylinder();
m_d3d12.sphere = DirectX::GeometricPrimitive::CreateSphere();

m_d3d12.initialized = true;
spdlog::info("ChainViewer D3D12 initialized");
} else {
// TODO
Expand Down
2 changes: 2 additions & 0 deletions src/mods/tools/ChainViewer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class ChainViewer : public Tool {
std::unique_ptr<DirectX::DX12::BasicEffect> effect{};
std::unique_ptr<DirectX::DX12::GeometricPrimitive> cylinder{};
std::unique_ptr<DirectX::DX12::GeometricPrimitive> sphere{};

bool initialized{false};
} m_d3d12;

float m_effect_alpha{0.5f};
Expand Down
9 changes: 9 additions & 0 deletions src/mods/tools/GameObjectsDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ std::optional<std::string> GameObjectsDisplay::on_initialize() {
}

std::optional<std::string> GameObjectsDisplay::initialize_d3d_resources() {
if (!m_enabled->value()) {
if (m_d3d12.initialized) {
m_d3d12 = {};
}

return std::nullopt;
}

if (g_framework->is_dx12()) {
m_d3d12 = {};

Expand Down Expand Up @@ -105,6 +113,7 @@ std::optional<std::string> GameObjectsDisplay::initialize_d3d_resources() {

m_d3d12.effect->SetTexture(m_d3d12.text_texture->get_srv_gpu(), m_d3d12.states->LinearWrap());

m_d3d12.initialized = true;
spdlog::info("GameObjectsDisplay D3D12 initialized");
} else {
// TODO
Expand Down
2 changes: 2 additions & 0 deletions src/mods/tools/GameObjectsDisplay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class GameObjectsDisplay : public Tool {
std::unique_ptr<DirectX::DescriptorHeap> font_heap{};
std::unique_ptr<DirectX::DX12::SpriteBatch> sprite_batch{};
std::unique_ptr<DirectX::DX12::CommonStates> states{};

bool initialized{false};
} m_d3d12;

private:
Expand Down

0 comments on commit 4805876

Please sign in to comment.