Skip to content

Commit 4e0526f

Browse files
committed
[REMIX-4106] Implement Option Layer
1 parent a8192ec commit 4e0526f

File tree

7 files changed

+697
-34
lines changed

7 files changed

+697
-34
lines changed

src/dxvk/dxvk_instance.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,9 @@ namespace dxvk {
642642
initConfig<Config::Type_RtxMod>();
643643

644644
RtxOption<bool>::initializeRtxOptions();
645+
for (const auto& optionLayer : RtxOptionImpl::getRtxOptionLayerMap()) {
646+
RtxOption<bool>::addRtxOptionLayer(optionLayer);
647+
}
645648

646649
m_config.logOptions("Effective (combined)");
647650

@@ -690,7 +693,7 @@ namespace dxvk {
690693
m_config.getOption<std::string>("rtx.baseGameModPathRegex", "", ""));
691694
if (baseGameModPath.empty()) {
692695
// Skip RtxMod if not present, as it may just pick up a different rtx.mod path
693-
Logger::info("No base game mod path found. Skipping initilization.");
696+
Logger::info("No base game mod path found. Skipping initialization.");
694697
return;
695698
} else {
696699
Logger::info(str::format("Found base game mod path: ", baseGameModPath));
@@ -704,11 +707,13 @@ namespace dxvk {
704707
// Set config so that any rtx option initialized later will use the value in that config object
705708
// The start-up config contains the values from the code and dxvk.conf, only.
706709
RtxOption<bool>::setStartupConfig(m_config);
710+
RtxOptionImpl::getRtxOptionLayerMap().insert(RtxOptionLayer(m_config, "dxvk.conf", 1, 1.0f, 1.0f));
707711
Logger::info("Set startup config.");
708712
} else if constexpr ((type == Config::Type_RtxUser) || (type == Config::Type_RtxMod)) {
709713
// Set custom config after the RTX user config has been merged into the config and
710714
// update the RTX options. Contains values from rtx.conf
711715
RtxOption<bool>::setCustomConfig(m_config);
716+
RtxOptionImpl::getRtxOptionLayerMap().insert(RtxOptionLayer(m_config, "rtx.conf", 2, 1.0f, 1.0f));
712717
Logger::info("Set custom config.");
713718
}
714719
}

src/dxvk/imgui/dxvk_imgui.cpp

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,9 @@ namespace dxvk {
11041104

11051105
ImGui::SameLine();
11061106
if (ImGui::Button("Reset Settings")) {
1107-
RtxOptions::reset();
1107+
for (auto& optionLayer : RtxOptionImpl::getRtxOptionLayerMap()) {
1108+
optionLayer.setEnabled(false);
1109+
}
11081110
}
11091111

11101112
ImGui::SameLine();
@@ -1975,6 +1977,54 @@ namespace dxvk {
19751977
ImGui::Unindent();
19761978
}
19771979
#endif
1980+
1981+
if (ImGui::CollapsingHeader("Option Layers")) {
1982+
ImGui::Indent();
1983+
1984+
if (ImGui::Button("Reset runtime settings")) {
1985+
// Remove all run-time changed settings
1986+
RtxOptionLayer::setResetSettings(true);
1987+
}
1988+
1989+
uint32_t optionLayerCounter = 1;
1990+
for (auto& optionLayer : RtxOptionImpl::getRtxOptionLayerMap()) {
1991+
// Runtime option layer priority is reserved for real-time user changes.
1992+
// These layers should not be modified through the GUI.
1993+
if (optionLayer.getPriority() != RtxOptionLayer::s_runtimeOptionLayerPriority) {
1994+
ImGui::Dummy(ImVec2(0.0f, 5.0f));
1995+
const std::string optionLayerText = std::to_string(optionLayerCounter++) + ". " + optionLayer.getName();
1996+
const std::string optionLayerStrengthText = optionLayer.getName() + " Strength";
1997+
if (ImGui::Checkbox(optionLayerText.c_str(), &optionLayer.isEnabledRef())) {
1998+
optionLayer.setDirty(true);
1999+
}
2000+
2001+
if (IMGUI_ADD_TOOLTIP(ImGui::SliderFloat(optionLayerStrengthText.c_str(), &optionLayer.getBlendStrengthRef(), 0.0f, 1.0f),
2002+
"Adjusts the blending strength of this option layer (0 = off, 1 = full effect).")) {
2003+
optionLayer.setBlendStrengthDirty(true);
2004+
}
2005+
2006+
if (ImGui::CollapsingHeader((optionLayer.getName() + " Details").c_str(), collapsingHeaderClosedFlags)) {
2007+
ImGui::Indent();
2008+
const std::string priorityText = "Priority: " + std::to_string(optionLayer.getPriority());
2009+
ImGui::Text(priorityText.c_str());
2010+
if (ImGui::IsItemHovered()) {
2011+
ImGui::SetTooltip(
2012+
"Layers are applied starting with the lowest priority layer, ending with the highest.\n"
2013+
"Each layer overrides the values written before it.\n"
2014+
"If a layer's blendWeight is not 1 and the option is a float or Vector type,\n"
2015+
"then the values will be calculated as LERP(previousValue, layerValue, blendWeight).");
2016+
}
2017+
for (const auto& option : optionLayer.getConfig().getOptions()) {
2018+
const std::string optionText = option.first + "=" + option.second;
2019+
ImGui::TextWrapped(optionText.c_str());
2020+
}
2021+
ImGui::Unindent();
2022+
}
2023+
}
2024+
}
2025+
2026+
ImGui::Unindent();
2027+
}
19782028
}
19792029

19802030
ImGui::PopItemWidth();

src/dxvk/rtx_render/rtx_context.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ namespace dxvk {
694694
getSceneManager().clearFogState();
695695

696696
// apply changes to RtxOptions after the frame has ended
697+
RtxOption<bool>::applyPendingValuesOptionLayers();
697698
RtxOption<bool>::applyPendingValues(m_device.ptr());
698699

699700
// Update stats

0 commit comments

Comments
 (0)