Skip to content

Commit ed25bbd

Browse files
committed
Merge branch 'xbei/option_layers_fix' into 'main'
Fix virtual key binding issue and optimize option queue See merge request lightspeedrtx/dxvk-remix-nv!1749
2 parents c95aec4 + cd21a8c commit ed25bbd

File tree

4 files changed

+48
-7
lines changed

4 files changed

+48
-7
lines changed

RtxOptions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ Tables below enumerate all the options and their defaults set by RTX Remix. Note
894894
|rtx.baseGameModRegex|string||||Regex used to determine if the base game is running a mod, like a sourcemod\.|
895895
|rtx.beamTextures|hash set||||Textures on draw calls that are already particles or emissively blended and have beam\-like geometry\.<br>Typically objects marked as particles or objects using emissive blending will be rendered with a special method which allows re\-orientation of the billboard geometry assumed to make up the draw call in indirect rays \(reflections for example\)\.<br>This method works fine for typical particles, but some \(e\.g\. a laser beam\) may not be well\-represented with the typical billboard assumption of simply needing to rotate around its centroid to face the view direction\.<br>To handle such cases a different beam mode is used to treat objects as more of a cylindrical beam and re\-orient around its main spanning axis, allowing for better rendering of these beam\-like effect objects\.|
896896
|rtx.cameraSequence.filePath|string||||File path\.|
897-
|rtx.captureHotKey|virtual keys|CTRL + SHFT + Q|||Hotkey to trigger a capture without bringing up the menu\.<br>example override: 'rtx\.captureHotKey = CTRL, SHIFT, P'\.<br>Full list of key names available in \`src/util/util\_keybind\.h\`\.|
897+
|rtx.captureHotKey|virtual keys|CTRL,SHFT,Q|||Hotkey to trigger a capture without bringing up the menu\.<br>example override: 'rtx\.captureHotKey = CTRL, SHIFT, P'\.<br>Full list of key names available in \`src/util/util\_keybind\.h\`\.|
898898
|rtx.captureInstanceStageName|string|capture_{timestamp}.usd|||Name of the 'instance' stage \(see: 'rtx\.captureInstances'\)\.|
899899
|rtx.captureTimestampReplacement|string|{timestamp}|||String that can be used for auto\-replacing current time stamp in instance stage name\.<br>Note: Changing this value does not change the default value for rtx\.captureInstanceStageName\.|
900900
|rtx.decalTextures|hash set||||Textures on draw calls used for static geometric decals or decals with complex topology\.<br>These materials will be blended over the materials underneath them when decal material blending is enabled\.<br>A small configurable offset is applied to each flat/co\-planar part of these decals to prevent coplanar geometric cases \(which poses problems for ray tracing\)\.|
@@ -930,7 +930,7 @@ Tables below enumerate all the options and their defaults set by RTX Remix. Note
930930
|rtx.postfx.motionBlurMaskOutTextures|hash set||||Disable motion blur for meshes with specific texture\.|
931931
|rtx.rayPortalModelTextureHashes|hash vector||||Texture hashes identifying ray portals\. Allowed number of hashes: \{0, 2\}\.|
932932
|rtx.raytracedRenderTargetTextures|hash set||||DescriptorHashes for Render Targets\. \(Screens that should display the output of another camera\)\.|
933-
|rtx.remixMenuKeyBinds|virtual keys|ALT + X|||Hotkey to open the Remix menu\.<br>example override: 'rtx\.remixMenuKeyBinds = CTRL, SHIFT, Z'\.<br>Full list of key names available in \`src/util/util\_keybind\.h\`\.|
933+
|rtx.remixMenuKeyBinds|virtual keys|ALT,X|||Hotkey to open the Remix menu\.<br>example override: 'rtx\.remixMenuKeyBinds = CTRL, SHIFT, Z'\.<br>Full list of key names available in \`src/util/util\_keybind\.h\`\.|
934934
|rtx.singleOffsetDecalTextures|hash set||||Warning: This option is deprecated, please use rtx\.decalTextures instead\.<br>Textures on draw calls used for geometric decals that don't inter\-overlap for a given texture hash\. Textures must be tagged as "Decal Texture" or "Dynamic Decal Texture" to apply\.<br>Applies a single shared offset to all the batched decal geometry rendered in a given draw call, rather than increasing offset per decal within the batch \(i\.e\. a quad in case of "Dynamic Decal Texture"\)\.<br>Note, the offset adds to the global offset among all decals drawn with different draw calls\.<br>The decal textures tagged this way must not inter\-overlap within a batch / single draw call since the same offset is applied to all of them\.<br>Applying a single offset is useful for stabilizing decal offsets when a game dynamically batches decals together\.<br>In addition, it makes the global decal offset index grow slower and thus it minimizes a chance of hitting the "rtx\.decals\.maxOffsetIndex limit"\.|
935935
|rtx.skyBoxGeometries|hash set||||Geometries from draw calls used for the sky or are otherwise intended to be very far away from the camera at all times \(no parallax\)\.<br>Any draw calls using a geometry hash in this list will be treated as sky and rendered as such in a manner different from typical geometry\.<br>The geometry hash being used for sky detection is based off of the asset hash rule, see: "rtx\.geometryAssetHashRuleString"\.|
936936
|rtx.skyBoxTextures|hash set||||Textures on draw calls used for the sky or are otherwise intended to be very far away from the camera at all times \(no parallax\)\.<br>Any draw calls using a texture in this list will be treated as sky and rendered as such in a manner different from typical geometry\.|

src/dxvk/rtx_render/rtx_option.cpp

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,11 +775,17 @@ namespace dxvk {
775775
*/
776776
GenericValueWrapper optionValue(type);
777777
float throughput = 1.0f;
778+
bool layerMatchingRuntimePriorityFound = false;
778779
// Loop layers from highest priority to lowest to lerp the value across layers base on the blend strength of layers
779780
for (const auto& optionLayer : optionLayerValueQueue) {
780-
// Skip options with runtime priority when ignoreChangedOption is true
781-
if (ignoreChangedOption && optionLayer.second.priority == RtxOptionLayer::s_runtimeOptionLayerPriority) {
782-
continue;
781+
if (optionLayer.second.priority == RtxOptionLayer::s_runtimeOptionLayerPriority) {
782+
if (ignoreChangedOption) {
783+
// Skip options with runtime priority when ignoreChangedOption is true
784+
continue;
785+
}
786+
787+
// Changing this flag must happen after checking ignoreChangedOption, or the real-time changes will be mistakenly removed.
788+
layerMatchingRuntimePriorityFound = true;
783789
}
784790

785791
if (type == OptionType::Float || type == OptionType::Vector2 || type == OptionType::Vector3 || type == OptionType::Vector4) {
@@ -799,6 +805,39 @@ namespace dxvk {
799805
}
800806
}
801807

808+
// If a runtime option layer exists, recompute the resolved value without it
809+
// to check whether the layer actually changes the final result. If the recomputed value
810+
// matches the current resolved value, it means the real-time layer is redundant,
811+
// so we remove (disable) it to avoid unnecessary layers and redundant blending.
812+
if (layerMatchingRuntimePriorityFound) {
813+
GenericValueWrapper originalResolvedValue(type);
814+
for (const auto& optionLayer : optionLayerValueQueue) {
815+
if (optionLayer.second.priority == RtxOptionLayer::s_runtimeOptionLayerPriority) {
816+
continue;
817+
}
818+
819+
if (type == OptionType::Float || type == OptionType::Vector2 || type == OptionType::Vector3 || type == OptionType::Vector4) {
820+
// Stop when the blend strength is larger than 1, because lerp(a, b, 1.0f) => b, we don't need to loop lower priority values
821+
if (optionLayer.second.blendStrength >= 1.0f) {
822+
addWeightedValue(optionLayer.second.value, throughput, originalResolvedValue.data);
823+
break;
824+
}
825+
826+
addWeightedValue(optionLayer.second.value, optionLayer.second.blendStrength * throughput, originalResolvedValue.data);
827+
throughput *= (1.0f - optionLayer.second.blendStrength);
828+
} else {
829+
if (optionLayer.second.blendStrength >= optionLayer.second.blendThreshold || optionLayer.second.priority == 0) {
830+
addWeightedValue(optionLayer.second.value, throughput, originalResolvedValue.data);
831+
break;
832+
}
833+
}
834+
}
835+
836+
if (isEqual(originalResolvedValue.data, optionValue.data)) {
837+
disableTopLayer();
838+
}
839+
}
840+
802841
// Copy to resolvedValue
803842
copyValue(optionValue.data, value);
804843
}

src/util/config/config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ namespace dxvk {
13621362
std::string s;
13631363
bool bFoundValidConfig = false;
13641364
VirtualKeys virtKeys;
1365-
while (std::getline(ss, s, ',')) {
1365+
while (std::getline(ss, s, kVirtualKeyDelimiter)) {
13661366
VirtualKey vk;
13671367
try {
13681368
// Strip whitespace from s

src/util/util_keybind.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ struct VirtualKey {
4343
};
4444
using VirtualKeys = std::vector<VirtualKey>;
4545

46+
constexpr const char kVirtualKeyDelimiter = ',';
47+
4648
class KeyBind {
4749
public:
4850
static std::string getName(const VirtualKey vk) {
@@ -346,7 +348,7 @@ static std::string buildKeyBindDescriptorString(const VirtualKeys& virtKeys) {
346348
bool bIsFirst = true;
347349
for(const auto& virtKey : virtKeys) {
348350
if(!bIsFirst) {
349-
ss << " + ";
351+
ss << kVirtualKeyDelimiter;
350352
}
351353
ss << KeyBind::getName(virtKey);
352354
bIsFirst = false;

0 commit comments

Comments
 (0)