Skip to content

Commit

Permalink
D3D12: Add 2D Screen/Cinema mode
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jun 10, 2023
1 parent 693891d commit b0fb18e
Show file tree
Hide file tree
Showing 14 changed files with 481 additions and 103 deletions.
3 changes: 3 additions & 0 deletions src/Framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,7 @@ bool Framework::init_d3d11() {

m_d3d11.rt_width = backbuffer_desc.Width;
m_d3d11.rt_height = backbuffer_desc.Height;
m_last_rt_size = {backbuffer_desc.Width, backbuffer_desc.Height};

spdlog::info("[D3D11] Initializing ImGui D3D11...");

Expand Down Expand Up @@ -1783,6 +1784,8 @@ bool Framework::init_d3d12() {

m_d3d12.rt_width = (uint32_t)desc.Width;
m_d3d12.rt_height = (uint32_t)desc.Height;

m_last_rt_size = {desc.Width, desc.Height};
}

spdlog::info("[D3D12] Initializing ImGui...");
Expand Down
5 changes: 3 additions & 2 deletions src/Framework.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ class Framework {
}

Vector2f get_d3d11_rt_size() const {
return Vector2f{(float)m_d3d11.rt_width, (float)m_d3d11.rt_height};
return m_last_rt_size;
}

Vector2f get_d3d12_rt_size() const {
return Vector2f{(float)m_d3d12.rt_width, (float)m_d3d12.rt_height};
return m_last_rt_size;
}

Vector2f get_rt_size() const {
Expand Down Expand Up @@ -218,6 +218,7 @@ class Framework {

ImVec2 m_last_window_pos{};
ImVec2 m_last_window_size{};
Vector2f m_last_rt_size{1920, 1080};

struct AdditionalFont {
std::filesystem::path filepath{};
Expand Down
17 changes: 17 additions & 0 deletions src/mods/VR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,22 @@ void VR::on_post_present() {
}
}

uint32_t VR::get_hmd_width() const {
if (m_2d_screen_mode->value()) {
return g_framework->get_rt_size().x;
}

return get_runtime()->get_width();
}

uint32_t VR::get_hmd_height() const {
if (m_2d_screen_mode->value()) {
return g_framework->get_rt_size().y;
}

return get_runtime()->get_height();
}

void VR::on_draw_ui() {
ZoneScopedN(__FUNCTION__);

Expand Down Expand Up @@ -1928,6 +1944,7 @@ void VR::on_draw_ui() {
}

m_desktop_fix->draw("Desktop Spectator View");
m_2d_screen_mode->draw("2D Screen Mode");

ImGui::TextWrapped("Render Resolution (per-eye): %d x %d", get_runtime()->get_width(), get_runtime()->get_height());
ImGui::TextWrapped("Total Render Resolution: %d x %d", get_runtime()->get_width() * 2, get_runtime()->get_height());
Expand Down
15 changes: 8 additions & 7 deletions src/mods/VR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,8 @@ class VR : public Mod {
return m_overlay_component;
}

auto get_hmd_width() const {
return get_runtime()->get_width();
}

auto get_hmd_height() const {
return get_runtime()->get_height();
}
uint32_t get_hmd_width() const;
uint32_t get_hmd_height() const;

const auto& get_eyes() const {
return get_runtime()->eyes;
Expand Down Expand Up @@ -448,6 +443,10 @@ class VR : public Mod {
return m_decoupled_pitch_data.pre_flattened_rotation;
}

bool is_using_2d_screen() const {
return m_2d_screen_mode->value();
}

private:
Vector4f get_position_unsafe(uint32_t index) const;
Vector4f get_velocity_unsafe(uint32_t index) const;
Expand Down Expand Up @@ -657,6 +656,7 @@ class VR : public Mod {
const ModToggle::Ptr m_decoupled_pitch{ ModToggle::create(generate_name("DecoupledPitch"), false) };
const ModToggle::Ptr m_decoupled_pitch_ui_adjust{ ModToggle::create(generate_name("DecoupledPitchUIAdjust"), true) };
const ModToggle::Ptr m_load_blueprint_code{ ModToggle::create(generate_name("LoadBlueprintCode"), false) };
const ModToggle::Ptr m_2d_screen_mode{ ModToggle::create(generate_name("2DScreenMode"), false) };

// Aim method and movement orientation are not the same thing, but they can both have the same options
const ModCombo::Ptr m_aim_method{ ModCombo::create(generate_name("AimMethod"), s_aim_method_names, AimMethod::GAME) };
Expand Down Expand Up @@ -719,6 +719,7 @@ class VR : public Mod {
*m_decoupled_pitch,
*m_decoupled_pitch_ui_adjust,
*m_load_blueprint_code,
*m_2d_screen_mode,
*m_aim_method,
*m_movement_orientation,
*m_aim_speed,
Expand Down
Loading

0 comments on commit b0fb18e

Please sign in to comment.