Skip to content

Commit

Permalink
fix(swapchain): don't restore RTV on swapchain proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
clshortfuse committed Jan 5, 2025
1 parent ec3ed1c commit 231584c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/mods/swapchain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,8 @@ static void DrawSwapChainProxy(reshade::api::swapchain* swapchain, reshade::api:
queue->flush_immediate_command_list();

if (previous_state.has_value()) {
// Don't restore RTVs for now (crashes DX11)
previous_state->render_targets.clear();
previous_state->Apply(cmd_list);
}

Expand Down
16 changes: 4 additions & 12 deletions src/utils/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#pragma once

#include <algorithm>
#include <include/reshade.hpp>
#include <memory>
#include <optional>
Expand All @@ -29,17 +28,10 @@ struct CommandListState {

void Apply(reshade::api::command_list* cmd_list) const {
if (!render_targets.empty() || depth_stencil != 0) {
bool has_rtv = std::ranges::any_of(render_targets, [](auto rtv) {
return rtv.handle != 0u;
});
if (has_rtv) {
cmd_list->bind_render_targets_and_depth_stencil(
static_cast<uint32_t>(render_targets.size()),
render_targets.data(),
depth_stencil);
} else if (depth_stencil != 0) {
cmd_list->bind_render_targets_and_depth_stencil(0, nullptr, depth_stencil);
}
cmd_list->bind_render_targets_and_depth_stencil(
static_cast<uint32_t>(render_targets.size()),
render_targets.data(),
depth_stencil);
}

for (const auto& [stages, pipeline] : pipelines) {
Expand Down

0 comments on commit 231584c

Please sign in to comment.