-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added AnnotatedRecordTraversal class to enable reaching Vulkan debugging
- Loading branch information
1 parent
04ed4b8
commit 8671b7f
Showing
6 changed files
with
178 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#pragma once | ||
|
||
/* <editor-fold desc="MIT License"> | ||
Copyright(c) 2023 Robert Osfield | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
</editor-fold> */ | ||
|
||
#include <vsg/core/Inherit.h> | ||
#include <vsg/vk/CommandBuffer.h> | ||
#include <vsg/app/RecordTraversal.h> | ||
|
||
namespace vsg | ||
{ | ||
|
||
#if VSG_virtual_RecordTraversal_apply | ||
class VSG_DECLSPEC AnnotatedRecordTraversal : public Inherit<RecordTraversal, AnnotatedRecordTraversal> | ||
{ | ||
public: | ||
|
||
explicit AnnotatedRecordTraversal(uint32_t in_maxSlot = 2, std::set<Bin*> in_bins = {}); | ||
|
||
vec4 debugColor = {.8, .8, .8, 1.0}; | ||
|
||
template<class T> | ||
void annotate(const T& object) | ||
{ | ||
auto* commandBuffer = getCommandBuffer(); | ||
auto extensions = commandBuffer->getDevice()->getInstance()->getExtensions(); | ||
if (extensions->vkCmdBeginDebugUtilsLabelEXT) | ||
{ | ||
VkCommandBuffer cmdBuffer{*commandBuffer}; | ||
VkDebugUtilsLabelEXT markerInfo = {}; | ||
markerInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT; | ||
markerInfo.pLabelName = object.className(); | ||
std::copy(&debugColor.value[0], &debugColor.value[4], &markerInfo.color[0]); | ||
|
||
extensions->vkCmdBeginDebugUtilsLabelEXT(cmdBuffer, &markerInfo); | ||
|
||
RecordTraversal::apply(object); | ||
|
||
extensions->vkCmdEndDebugUtilsLabelEXT(cmdBuffer); | ||
} | ||
else | ||
{ | ||
RecordTraversal::apply(object); | ||
} | ||
} | ||
|
||
void apply(const Object& object) override; | ||
|
||
// scene graph nodes | ||
void apply(const Group& group) override; | ||
void apply(const QuadGroup& quadGroup) override; | ||
void apply(const LOD& lod) override; | ||
void apply(const PagedLOD& pagedLOD) override; | ||
void apply(const CullGroup& cullGroup) override; | ||
void apply(const CullNode& cullNode) override; | ||
void apply(const DepthSorted& depthSorted) override; | ||
void apply(const Switch& sw) override; | ||
|
||
// positional state | ||
void apply(const Light& light) override; | ||
void apply(const AmbientLight& light) override; | ||
void apply(const DirectionalLight& light) override; | ||
void apply(const PointLight& light) override; | ||
void apply(const SpotLight& light) override; | ||
|
||
// Vulkan nodes | ||
void apply(const Transform& transform) override; | ||
void apply(const MatrixTransform& mt) override; | ||
void apply(const StateGroup& sg) override; | ||
void apply(const Commands& commands) override; | ||
void apply(const Command& command) override; | ||
|
||
// Viewer level nodes | ||
void apply(const View& view) override; | ||
void apply(const CommandGraph& commandGraph) override; | ||
}; | ||
|
||
VSG_type_name(AnnotatedRecordTraversal); | ||
|
||
#endif | ||
|
||
} // namespace vsg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* <editor-fold desc="MIT License"> | ||
Copyright(c) 2023 Robert Osfield | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
</editor-fold> */ | ||
|
||
#include <vsg/app/AnnotatedRecordTraversal.h> | ||
#include <vsg/nodes/Group.h> | ||
#include <vsg/nodes/QuadGroup.h> | ||
#include <vsg/nodes/LOD.h> | ||
#include <vsg/nodes/PagedLOD.h> | ||
#include <vsg/nodes/MatrixTransform.h> | ||
#include <vsg/nodes/Switch.h> | ||
#include <vsg/nodes/Light.h> | ||
#include <vsg/nodes/StateGroup.h> | ||
#include <vsg/nodes/DepthSorted.h> | ||
#include <vsg/nodes/CullNode.h> | ||
#include <vsg/nodes/CullGroup.h> | ||
#include <vsg/app/CommandGraph.h> | ||
#include <vsg/app/View.h> | ||
#include <vsg/commands/Commands.h> | ||
#include <vsg/io/Options.h> | ||
|
||
using namespace vsg; | ||
|
||
#if VSG_virtual_RecordTraversal_apply | ||
|
||
AnnotatedRecordTraversal::AnnotatedRecordTraversal(uint32_t in_maxSlot, std::set<Bin*> in_bins) : | ||
Inherit(in_maxSlot, in_bins) | ||
{ | ||
} | ||
|
||
void AnnotatedRecordTraversal::apply(const vsg::Object& object) { annotate(object); } | ||
|
||
// scene graph nodes | ||
void AnnotatedRecordTraversal::apply(const vsg::Group& group) { annotate(group); } | ||
void AnnotatedRecordTraversal::apply(const vsg::QuadGroup& quadGroup) { annotate(quadGroup); } | ||
void AnnotatedRecordTraversal::apply(const vsg::LOD& lod) { annotate(lod); } | ||
void AnnotatedRecordTraversal::apply(const vsg::PagedLOD& pagedLOD) { annotate(pagedLOD); } | ||
void AnnotatedRecordTraversal::apply(const vsg::CullGroup& cullGroup) { annotate(cullGroup); } | ||
void AnnotatedRecordTraversal::apply(const vsg::CullNode& cullNode) { annotate(cullNode); } | ||
void AnnotatedRecordTraversal::apply(const vsg::DepthSorted& depthSorted) { annotate(depthSorted); } | ||
void AnnotatedRecordTraversal::apply(const vsg::Switch& sw) { annotate(sw); } | ||
|
||
// positional state | ||
void AnnotatedRecordTraversal::apply(const vsg::Light& light) { annotate(light); } | ||
void AnnotatedRecordTraversal::apply(const vsg::AmbientLight& light) { annotate(light); } | ||
void AnnotatedRecordTraversal::apply(const vsg::DirectionalLight& light) { annotate(light); } | ||
void AnnotatedRecordTraversal::apply(const vsg::PointLight& light) { annotate(light); } | ||
void AnnotatedRecordTraversal::apply(const vsg::SpotLight& light) { annotate(light); } | ||
|
||
// Vulkan nodes | ||
void AnnotatedRecordTraversal::apply(const vsg::Transform& transform) { annotate(transform); } | ||
void AnnotatedRecordTraversal::apply(const vsg::MatrixTransform& mt) { annotate(mt); } | ||
void AnnotatedRecordTraversal::apply(const vsg::StateGroup& sg) { annotate(sg); } | ||
void AnnotatedRecordTraversal::apply(const vsg::Commands& commands) { annotate(commands); } | ||
void AnnotatedRecordTraversal::apply(const vsg::Command& command) { annotate(command); } | ||
|
||
// Viewer level nodes | ||
void AnnotatedRecordTraversal::apply(const vsg::View& view) { annotate(view); } | ||
void AnnotatedRecordTraversal::apply(const vsg::CommandGraph& commandGraph) { annotate(commandGraph); } | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters