diff --git a/include/vsg/app/RecordTraversal.h b/include/vsg/app/RecordTraversal.h index 3479c26ef1..225f0445bb 100644 --- a/include/vsg/app/RecordTraversal.h +++ b/include/vsg/app/RecordTraversal.h @@ -183,6 +183,9 @@ namespace vsg int32_t _minimumBinNumber = 0; std::vector> _bins; ref_ptr _viewDependentState; + + // Increment and decrement the view counter so we know if we are traversing a top-level view. + int32_t _viewCounter = 0; }; } // namespace vsg diff --git a/src/vsg/app/RecordTraversal.cpp b/src/vsg/app/RecordTraversal.cpp index 19854d141b..457bf1cb27 100644 --- a/src/vsg/app/RecordTraversal.cpp +++ b/src/vsg/app/RecordTraversal.cpp @@ -556,8 +556,9 @@ void RecordTraversal::apply(const View& view) { GPU_INSTRUMENTATION_L1_NCO(instrumentation, *getCommandBuffer(), "View", COLOR_RECORD_L1, &view); - // Reset the state at the start of a new view traversal. - _state->reset(); + // Reset the state at the start of a new top-level view traversal. + if(_viewCounter == 0) _state->reset(); + ++_viewCounter; // note, View::accept() updates the RecordTraversal's traversalMask auto cached_traversalMask = _state->_commandBuffer->traversalMask; @@ -659,6 +660,8 @@ void RecordTraversal::apply(const View& view) cached_regionsOfInterest.swap(regionsOfInterest); _state->_commandBuffer->traversalMask = cached_traversalMask; _viewDependentState = cached_viewDependentState; + + --_viewCounter; } void RecordTraversal::apply(const CommandGraph& commandGraph)