Skip to content

Commit f7256b0

Browse files
Merge branch 'PrimTargetFix' into 'main'
[REMIX-4845] properly handle unset target properties in components See merge request lightspeedrtx/dxvk-remix-nv!1850
2 parents cded4b9 + d194aa1 commit f7256b0

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

src/dxvk/rtx_render/graph/rtx_graph_batch.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,18 @@ void RtGraphBatch::Initialize(const RtGraphTopology& topology) {
120120
m_graphHash = topology.graphHash;
121121
}
122122

123-
void RtGraphBatch::addInstance(Rc<DxvkContext> context, const RtGraphState& initialGraphState, GraphInstance* graphInstance) {
123+
bool RtGraphBatch::addInstance(Rc<DxvkContext> context, const RtGraphState& initialGraphState, GraphInstance* graphInstance) {
124124
ScopedCpuProfileZone();
125125
if (graphInstance == nullptr) {
126126
Logger::err("Cannot add null GraphInstance");
127-
return;
127+
return false;
128128
}
129129

130130
if (initialGraphState.values.size() != m_properties.size()) {
131131
Logger::err(str::format("RtGraphState had the wrong number of values. Expected: ",
132132
m_properties.size(), " got: ", initialGraphState.values.size()));
133133
assert(false && "RtGraphState had the wrong number of values.");
134-
return;
134+
return false;
135135
}
136136

137137
graphInstance->setBatchIndex(m_graphInstances.size());
@@ -150,10 +150,10 @@ void RtGraphBatch::addInstance(Rc<DxvkContext> context, const RtGraphState& init
150150
}, initialGraphState.values[i]);
151151
}
152152
catch (const std::bad_variant_access& e) {
153-
Logger::err(str::format("Type mismatch when adding instance to property ", i, ": ", e.what()));
153+
Logger::err(str::format("Graph ", initialGraphState.primPath, " had a type mismatch when adding instance to property ", i, ": ", e.what()));
154154
// Remove the instance we just added
155155
m_graphInstances.pop_back();
156-
return;
156+
return false;
157157
}
158158
}
159159

@@ -167,6 +167,7 @@ void RtGraphBatch::addInstance(Rc<DxvkContext> context, const RtGraphState& init
167167
}
168168
batch->updateRange(context, newInstanceIndex, newInstanceIndex + 1);
169169
}
170+
return true;
170171
}
171172

172173
void RtGraphBatch::removeInstance(GraphInstance* graphInstance) {

src/dxvk/rtx_render/graph/rtx_graph_batch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class RtGraphBatch {
4444

4545
void Initialize(const RtGraphTopology& topology);
4646

47-
void addInstance(Rc<DxvkContext> context, const RtGraphState& graphState, GraphInstance* replacementInstance);
47+
bool addInstance(Rc<DxvkContext> context, const RtGraphState& graphState, GraphInstance* replacementInstance);
4848

4949
void removeInstance(GraphInstance* graphInstance);
5050

src/dxvk/rtx_render/graph/rtx_graph_gui.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,13 @@ std::string RtxGraphGUI::formatPropertyValue(const RtComponentPropertyValue& val
450450
} else if constexpr (std::is_same_v<T, std::string>) {
451451
return "\"" + v + "\"";
452452
} else if constexpr (std::is_same_v<T, PrimTarget>) {
453-
return "instance: " + std::to_string(v.instanceId) + ", index: " + std::to_string(v.replacementIndex);
453+
if (v.instanceId == kInvalidInstanceId) {
454+
return "Invalid instance";
455+
} else if (v.replacementIndex == ReplacementInstance::kInvalidReplacementIndex) {
456+
return "Invalid replacement index";
457+
} else {
458+
return "instance: " + std::to_string(v.instanceId) + ", index: " + std::to_string(v.replacementIndex);
459+
}
454460
} else {
455461
return "Unknown";
456462
}

src/dxvk/rtx_render/graph/rtx_graph_manager.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,14 @@ class GraphManager {
7171
uint64_t instanceId = m_nextInstanceId++;
7272
auto pair = m_graphInstances.try_emplace(instanceId, this, graphState.topology.graphHash, 0, instanceId, graphState);
7373
if (!pair.second) {
74-
Logger::err(str::format("GraphInstance already exists. Instance: ", instanceId));
74+
Logger::err(str::format("GraphInstance already exists. Instance: ", instanceId, " Prim path: ", graphState.primPath));
75+
return nullptr;
76+
}
77+
if (!iter->second.addInstance(context, graphState, &pair.first->second)) {
78+
m_graphInstances.erase(instanceId);
79+
Logger::err(str::format("Failed to add GraphInstance to GraphBatch. Instance: ", instanceId, " Prim path: ", graphState.primPath));
7580
return nullptr;
7681
}
77-
iter->second.addInstance(context, graphState, &pair.first->second);
7882
return &pair.first->second;
7983
}
8084

src/dxvk/rtx_render/graph/rtx_graph_usd_parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,13 +764,13 @@ RtComponentPropertyValue GraphUsdParser::getPropertyValue(const pxr::UsdRelation
764764
}
765765
}
766766
return propertyValueForceType<PrimTarget>(result);
767-
} else {
767+
} else if (targets.size() > 1) {
768768
Logger::err(str::format("Relationship ", rel.GetPath().GetString(), " has multiple targets, which is not supported."));
769769
}
770770
}
771771
// Note: this intentionally ignores the default value - if the relationship isn't connected,
772772
// we need to use kInvalidReplacementIndex.
773-
return ReplacementInstance::kInvalidReplacementIndex;
773+
return PrimTarget{ ReplacementInstance::kInvalidReplacementIndex, kInvalidInstanceId };
774774
}
775775

776776
RtComponentPropertyValue GraphUsdParser::getPropertyValue(const pxr::UsdAttribute& attr, const RtComponentPropertySpec& spec, PathToOffsetMap& pathToOffsetMap) {

0 commit comments

Comments
 (0)