Skip to content

Commit c95aec4

Browse files
Merge branch 'hash-checkers-keyboard' into 'main'
[REMIX-4642] [REMIX-4643] [REMIX-4643] Add components for detecting mesh hash, texture hash, and keyboard input See merge request lightspeedrtx/dxvk-remix-nv!1735
2 parents cda9f2e + 82f2ba3 commit c95aec4

21 files changed

+660
-31
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Keyboard Input
2+
3+
Checks the state of a keyboard key or key combination using the same format as RTX options\.
4+
5+
## Component Information
6+
7+
- **Name:** `KeyboardInput`
8+
- **UI Name:** Keyboard Input
9+
- **Version:** 1
10+
- **Categories:** Sense
11+
12+
## Input Properties
13+
14+
| Property | Display Name | Type | IO Type | Default Value | Optional |
15+
|----------|--------------|------|---------|---------------|----------|
16+
| keyString | Key String | String | Input | "A" | No |
17+
18+
### Key String
19+
20+
The key combination string \(e\.g\., 'A', 'CTRL,A', 'SHIFT,SPACE'\)\. Supports key names and combinations like RTX options\.
21+
22+
23+
## State Properties
24+
25+
| Property | Display Name | Type | IO Type | Default Value | Optional |
26+
|----------|--------------|------|---------|---------------|----------|
27+
| wasPressedLastFrame | | Bool | State | false | No |
28+
29+
###
30+
31+
Internal state to track if the key was pressed in the previous frame\.
32+
33+
34+
## Output Properties
35+
36+
| Property | Display Name | Type | IO Type | Default Value | Optional |
37+
|----------|--------------|------|---------|---------------|----------|
38+
| isPressed | Is Pressed | Bool | Output | false | No |
39+
| wasJustPressed | Was Just Pressed | Bool | Output | false | No |
40+
| wasClicked | Was Clicked | Bool | Output | false | No |
41+
42+
### Is Pressed
43+
44+
True if the key combination is currently being pressed\.
45+
46+
47+
### Was Just Pressed
48+
49+
True if the key combination was just pressed this frame\.
50+
51+
52+
### Was Clicked
53+
54+
True for one frame after the key combination is released \(press then release cycle\)\.
55+
56+
57+
## Usage Notes
58+
59+
This component is part of the RTX Remix graph system. It is intended for use in the Remix Toolkit and Runtime only.
60+
61+
---
62+
[← Back to Component Index](index.md)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Mesh Hash Checker
2+
3+
Checks if a specific mesh hash was processed in the current frame\.
4+
5+
## Component Information
6+
7+
- **Name:** `MeshHashChecker`
8+
- **UI Name:** Mesh Hash Checker
9+
- **Version:** 1
10+
- **Categories:** Sense
11+
12+
## Input Properties
13+
14+
| Property | Display Name | Type | IO Type | Default Value | Optional |
15+
|----------|--------------|------|---------|---------------|----------|
16+
| meshHash | Mesh Hash | Uint64 | Input | 0 | No |
17+
18+
### Mesh Hash
19+
20+
The mesh hash to check for usage in the current frame\.
21+
22+
23+
## Output Properties
24+
25+
| Property | Display Name | Type | IO Type | Default Value | Optional |
26+
|----------|--------------|------|---------|---------------|----------|
27+
| isUsed | Is Used | Bool | Output | false | No |
28+
| usageCount | Usage Count | Uint32 | Output | 0 | No |
29+
30+
### Is Used
31+
32+
True if the mesh hash was used in the current frame\.
33+
34+
35+
### Usage Count
36+
37+
Number of times the mesh hash was used in the current frame\.
38+
39+
40+
## Usage Notes
41+
42+
This component is part of the RTX Remix graph system. It is intended for use in the Remix Toolkit and Runtime only.
43+
44+
---
45+
[← Back to Component Index](index.md)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Texture Hash Checker
2+
3+
Checks if a specific hash was used for material replacement in the current frame\.
4+
5+
## Component Information
6+
7+
- **Name:** `TextureHashChecker`
8+
- **UI Name:** Texture Hash Checker
9+
- **Version:** 1
10+
- **Categories:** Sense
11+
12+
## Input Properties
13+
14+
| Property | Display Name | Type | IO Type | Default Value | Optional |
15+
|----------|--------------|------|---------|---------------|----------|
16+
| textureHash | Texture Hash | Uint64 | Input | 0 | No |
17+
18+
### Texture Hash
19+
20+
The texture hash to check for usage in the current frame\.
21+
22+
23+
## Output Properties
24+
25+
| Property | Display Name | Type | IO Type | Default Value | Optional |
26+
|----------|--------------|------|---------|---------------|----------|
27+
| isUsed | Is Used | Bool | Output | false | No |
28+
| usageCount | Usage Count | Uint32 | Output | 0 | No |
29+
30+
### Is Used
31+
32+
True if the texture hash was used in the current frame\.
33+
34+
35+
### Usage Count
36+
37+
Number of times the texture hash was used in the current frame\.
38+
39+
40+
## Usage Notes
41+
42+
This component is part of the RTX Remix graph system. It is intended for use in the Remix Toolkit and Runtime only.
43+
44+
---
45+
[← Back to Component Index](index.md)

documentation/components/index.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ This documentation provides detailed information about all available components
1010

1111
| Component | Description | Version |
1212
|-----------|-------------|---------|
13+
| [Texture Hash Checker](TextureHashChecker.md) | Checks if a specific hash was used for material replacement in the current frame\. | 1 |
14+
| [Keyboard Input](KeyboardInput.md) | Checks the state of a keyboard key or key combination using the same format as RTX options\. | 1 |
15+
| [Mesh Hash Checker](MeshHashChecker.md) | Checks if a specific mesh hash was processed in the current frame\. | 1 |
1316
| [Time](Time.md) | Outputs the time in seconds since the component was created\. Can be paused and speed\-adjusted\. | 1 |
1417

1518
### Logic
@@ -28,8 +31,8 @@ This documentation provides detailed information about all available components
2831

2932
## Statistics
3033

31-
- **Total Components:** 5
32-
- **Categorized Components:** 5
34+
- **Total Components:** 8
35+
- **Categorized Components:** 8
3336
- **Categories:** 3
3437

3538
---
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
* DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#pragma once
24+
25+
#include "../rtx_graph_component_macros.h"
26+
#include "../../imgui/dxvk_imgui.h"
27+
#include "../../../util/util_keybind.h"
28+
#include "../../../util/config/config.h"
29+
30+
namespace dxvk {
31+
namespace components {
32+
33+
#define LIST_INPUTS(X) \
34+
X(RtComponentPropertyType::String, std::string("A"), keyString, "Key String", "The key combination string (e.g., 'A', 'CTRL,A', 'SHIFT,SPACE'). Supports key names and combinations like RTX options.")
35+
36+
#define LIST_STATES(X) \
37+
X(RtComponentPropertyType::Bool, false, wasPressedLastFrame, "", "Internal state to track if the key was pressed in the previous frame.")
38+
39+
#define LIST_OUTPUTS(X) \
40+
X(RtComponentPropertyType::Bool, false, isPressed, "Is Pressed", "True if the key combination is currently being pressed.") \
41+
X(RtComponentPropertyType::Bool, false, wasJustPressed, "Was Just Pressed", "True if the key combination was just pressed this frame.") \
42+
X(RtComponentPropertyType::Bool, false, wasClicked, "Was Clicked", "True for one frame after the key combination is released (press then release cycle).")
43+
44+
REMIX_COMPONENT( \
45+
/* the Component name */ KeyboardInput, \
46+
/* the UI name */ "Keyboard Input", \
47+
/* the UI categories */ "Sense", \
48+
/* the doc string */ "Checks the state of a keyboard key or key combination using the same format as RTX options.", \
49+
/* the version number */ 1, \
50+
LIST_INPUTS, LIST_STATES, LIST_OUTPUTS);
51+
52+
#undef LIST_INPUTS
53+
#undef LIST_STATES
54+
#undef LIST_OUTPUTS
55+
56+
void KeyboardInput::updateRange(const Rc<DxvkContext>& context, const size_t start, const size_t end) {
57+
for (size_t i = start; i < end; i++) {
58+
// Parse the key string into VirtualKeys
59+
VirtualKeys virtualKeys;
60+
const bool parseSuccess = Config::parseOptionValue(m_keyString[i], virtualKeys);
61+
62+
if (parseSuccess && !virtualKeys.empty()) {
63+
// Check if the key combination is currently pressed (continuous press)
64+
const bool currentlyPressed = ImGUI::checkHotkeyState(virtualKeys, true);
65+
66+
// Check if the key combination was just pressed this frame (single press)
67+
const bool justPressed = ImGUI::checkHotkeyState(virtualKeys, false);
68+
69+
// Check if the key was clicked (pressed last frame, released this frame)
70+
const bool wasClicked = m_wasPressedLastFrame[i] && !currentlyPressed;
71+
72+
// Update outputs
73+
m_isPressed[i] = currentlyPressed;
74+
m_wasJustPressed[i] = justPressed;
75+
m_wasClicked[i] = wasClicked;
76+
77+
// Update state for next frame
78+
m_wasPressedLastFrame[i] = currentlyPressed;
79+
} else {
80+
ONCE(Logger::err(str::format("Failed to parse key string: '", m_keyString[i], "'")));
81+
// Invalid key string - default to false
82+
m_isPressed[i] = false;
83+
m_wasJustPressed[i] = false;
84+
m_wasClicked[i] = false;
85+
m_wasPressedLastFrame[i] = false;
86+
}
87+
}
88+
}
89+
90+
} // namespace components
91+
} // namespace dxvk
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
* DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#pragma once
24+
25+
#include "../rtx_graph_component_macros.h"
26+
#include "../../rtx_scene_manager.h"
27+
28+
namespace dxvk {
29+
namespace components {
30+
31+
#define LIST_INPUTS(X) \
32+
X(RtComponentPropertyType::Uint64, 0, meshHash, "Mesh Hash", "The mesh hash to check for usage in the current frame.")
33+
34+
#define LIST_STATES(X)
35+
36+
#define LIST_OUTPUTS(X) \
37+
X(RtComponentPropertyType::Bool, false, isUsed, "Is Used", "True if the mesh hash was used in the current frame.") \
38+
X(RtComponentPropertyType::Uint32, 0, usageCount, "Usage Count", "Number of times the mesh hash was used in the current frame.")
39+
40+
REMIX_COMPONENT( \
41+
/* the Component name */ MeshHashChecker, \
42+
/* the UI name */ "Mesh Hash Checker", \
43+
/* the UI categories */ "Sense", \
44+
/* the doc string */ "Checks if a specific mesh hash was processed in the current frame.", \
45+
/* the version number */ 1, \
46+
LIST_INPUTS, LIST_STATES, LIST_OUTPUTS);
47+
48+
#undef LIST_INPUTS
49+
#undef LIST_STATES
50+
#undef LIST_OUTPUTS
51+
52+
void MeshHashChecker::updateRange(const Rc<DxvkContext>& context, const size_t start, const size_t end) {
53+
// Get the scene manager from context
54+
RtxContext* rtxContext = dynamic_cast<RtxContext*>(context.ptr());
55+
assert(rtxContext != nullptr && "Components must be run within a valid RtxContext.");
56+
const SceneManager& sceneManager = rtxContext->getSceneManager();
57+
58+
for (size_t i = start; i < end; i++) {
59+
const uint64_t targetHash = m_meshHash[i];
60+
61+
// Check if the mesh hash was used in the current frame
62+
uint32_t count = sceneManager.getMeshHashUsageCount(targetHash);
63+
bool isUsed = count > 0;
64+
65+
m_isUsed[i] = isUsed;
66+
m_usageCount[i] = count;
67+
}
68+
}
69+
70+
} // namespace components
71+
} // namespace dxvk

0 commit comments

Comments
 (0)