Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions include/vsg/utils/Instrumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace vsg
# define VsgFunctionName __FUNCSIG__
#endif

class Device;
class Queue;
class CommandBuffer;

/// SourceLocation structs mark the location in a source file when instrumentation is placed.
Expand All @@ -44,6 +46,8 @@ namespace vsg
public:
Instrumentation();

// Conceived for the needs of Tracy
virtual void init(vsg::ref_ptr<Device> device, vsg::ref_ptr<Queue> queue, vsg::ref_ptr<CommandBuffer> cmd);
virtual void enter(const SourceLocation* sl, uint64_t& reference) const = 0;
virtual void leave(const SourceLocation* sl, uint64_t& reference) const = 0;

Expand Down Expand Up @@ -85,16 +89,16 @@ namespace vsg
}
};

#define SCOPED_INSTRUMENTASTION(instrumentation) \
#define SCOPED_INSTRUMENTATION(instrumentation) \
static constexpr SourceLocation s_source_location_##__LINE__{nullptr, VsgFunctionName, __FILE__, __LINE__, ubvec4(255, 255, 255, 255)}; \
ScopedInstrumentation __scoped_instrumentation(instrumentation, &(s_source_location_##__LINE__));
#define SCOPED_INSTRUMENTASTION_N(instrumentation, name) \
#define SCOPED_INSTRUMENTATION_N(instrumentation, name) \
static constexpr SourceLocation s_source_location_##__LINE__{name, VsgFunctionName, __FILE__, __LINE__, ubvec4(255, 255, 255, 255)}; \
ScopedInstrumentation __scoped_instrumentation(instrumentation, &(s_source_location_##__LINE__));
#define SCOPED_INSTRUMENTASTION_C(instrumentation, color) \
#define SCOPED_INSTRUMENTATION_C(instrumentation, color) \
static constexpr SourceLocation s_source_location_##__LINE__{nullptr, VsgFunctionName, __FILE__, __LINE__, color}; \
ScopedInstrumentation __scoped_instrumentation(instrumentation, &(s_source_location_##__LINE__));
#define SCOPED_INSTRUMENTASTION_NC(instrumentation, name, color) \
#define SCOPED_INSTRUMENTATION_NC(instrumentation, name, color) \
static constexpr SourceLocation s_source_location_##__LINE__{name, VsgFunctionName, __FILE__, __LINE__, color}; \
ScopedInstrumentation __scoped_instrumentation(instrumentation, &(s_source_location_##__LINE__));

Expand Down
12 changes: 6 additions & 6 deletions src/vsg/app/CommandGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ using namespace vsg;

CommandGraph::CommandGraph()
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);
}

CommandGraph::CommandGraph(ref_ptr<Device> in_device, int family) :
device(in_device),
queueFamily(family),
presentFamily(-1)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);
}

CommandGraph::CommandGraph(ref_ptr<Window> in_window, ref_ptr<Node> child) :
window(in_window),
device(in_window->getOrCreateDevice())
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

VkQueueFlags queueFlags = VK_QUEUE_GRAPHICS_BIT;
if (window->traits()) queueFlags = window->traits()->queueFlags;
Expand All @@ -49,7 +49,7 @@ CommandGraph::CommandGraph(ref_ptr<Window> in_window, ref_ptr<Node> child) :

CommandGraph::~CommandGraph()
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);
}

VkCommandBufferLevel CommandGraph::level() const
Expand All @@ -63,7 +63,7 @@ void CommandGraph::reset()

ref_ptr<RecordTraversal> CommandGraph::getOrCreateRecordTraversal()
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

if (!recordTraversal)
{
Expand All @@ -80,7 +80,7 @@ ref_ptr<RecordTraversal> CommandGraph::getOrCreateRecordTraversal()

void CommandGraph::record(ref_ptr<RecordedCommandBuffers> recordedCommandBuffers, ref_ptr<FrameStamp> frameStamp, ref_ptr<DatabasePager> databasePager)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

if (window && !window->visible())
{
Expand Down
12 changes: 6 additions & 6 deletions src/vsg/app/RecordAndSubmitTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using namespace vsg;
RecordAndSubmitTask::RecordAndSubmitTask(Device* in_device, uint32_t numBuffers) :
device(in_device)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

_currentFrameIndex = numBuffers; // numBuffers is used to signify unset value
for (uint32_t i = 0; i < numBuffers; ++i)
Expand All @@ -44,7 +44,7 @@ RecordAndSubmitTask::RecordAndSubmitTask(Device* in_device, uint32_t numBuffers)

void RecordAndSubmitTask::advance()
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

if (_currentFrameIndex >= _indices.size())
{
Expand Down Expand Up @@ -84,7 +84,7 @@ Fence* RecordAndSubmitTask::fence(size_t relativeFrameIndex)

VkResult RecordAndSubmitTask::submit(ref_ptr<FrameStamp> frameStamp)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

if (VkResult result = start(); result != VK_SUCCESS) return result;

Expand All @@ -102,7 +102,7 @@ VkResult RecordAndSubmitTask::submit(ref_ptr<FrameStamp> frameStamp)

VkResult RecordAndSubmitTask::start()
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

if (earlyTransferTask) earlyTransferTask->currentTransferCompletedSemaphore = {};
if (lateTransferTask) lateTransferTask->currentTransferCompletedSemaphore = {};
Expand All @@ -120,7 +120,7 @@ VkResult RecordAndSubmitTask::start()

VkResult RecordAndSubmitTask::record(ref_ptr<RecordedCommandBuffers> recordedCommandBuffers, ref_ptr<FrameStamp> frameStamp)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

for (auto& commandGraph : commandGraphs)
{
Expand All @@ -132,7 +132,7 @@ VkResult RecordAndSubmitTask::record(ref_ptr<RecordedCommandBuffers> recordedCom

VkResult RecordAndSubmitTask::finish(ref_ptr<RecordedCommandBuffers> recordedCommandBuffers)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

if (lateTransferTask)
{
Expand Down
48 changes: 24 additions & 24 deletions src/vsg/app/RecordTraversal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ RecordTraversal::RecordTraversal(uint32_t in_maxSlot, std::set<Bin*> in_bins) :
_state(new State(in_maxSlot))
{
// instrumentation = Instrumentation::create();
SCOPED_INSTRUMENTASTION_C(instrumentation, ubvec4(0, 0, 255, 255));
SCOPED_INSTRUMENTATION_C(instrumentation, ubvec4(0, 0, 255, 255));

_minimumBinNumber = 0;
int32_t maximumBinNumber = 0;
Expand All @@ -69,7 +69,7 @@ RecordTraversal::RecordTraversal(uint32_t in_maxSlot, std::set<Bin*> in_bins) :

RecordTraversal::~RecordTraversal()
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);
}

CommandBuffer* RecordTraversal::getCommandBuffer()
Expand Down Expand Up @@ -97,7 +97,7 @@ void RecordTraversal::setDatabasePager(DatabasePager* dp)

void RecordTraversal::clearBins()
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

for (auto& bin : _bins)
{
Expand All @@ -107,15 +107,15 @@ void RecordTraversal::clearBins()

void RecordTraversal::apply(const Object& object)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

//debug("Visiting Object");
object.traverse(*this);
}

void RecordTraversal::apply(const Group& group)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

//debug("Visiting Group");
#if INLINE_TRAVERSE
Expand All @@ -127,7 +127,7 @@ void RecordTraversal::apply(const Group& group)

void RecordTraversal::apply(const QuadGroup& quadGroup)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

//debug("Visiting QuadGroup");
#if INLINE_TRAVERSE
Expand All @@ -139,7 +139,7 @@ void RecordTraversal::apply(const QuadGroup& quadGroup)

void RecordTraversal::apply(const LOD& lod)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

const auto& sphere = lod.bound;

Expand All @@ -164,7 +164,7 @@ void RecordTraversal::apply(const LOD& lod)

void RecordTraversal::apply(const PagedLOD& plod)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

const auto& sphere = plod.bound;
auto frameCount = _frameStamp->frameCount;
Expand Down Expand Up @@ -244,7 +244,7 @@ void RecordTraversal::apply(const PagedLOD& plod)

void RecordTraversal::apply(const CullGroup& cullGroup)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

if (_state->intersect(cullGroup.bound))
{
Expand All @@ -255,7 +255,7 @@ void RecordTraversal::apply(const CullGroup& cullGroup)

void RecordTraversal::apply(const CullNode& cullNode)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

if (_state->intersect(cullNode.bound))
{
Expand All @@ -266,7 +266,7 @@ void RecordTraversal::apply(const CullNode& cullNode)

void RecordTraversal::apply(const DepthSorted& depthSorted)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

if (_state->intersect(depthSorted.bound))
{
Expand All @@ -280,7 +280,7 @@ void RecordTraversal::apply(const DepthSorted& depthSorted)

void RecordTraversal::apply(const Switch& sw)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

for (auto& child : sw.children)
{
Expand All @@ -293,46 +293,46 @@ void RecordTraversal::apply(const Switch& sw)

void RecordTraversal::apply(const Light& /*light*/)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

//debug("RecordTraversal::apply(Light) ", light.className());
}

void RecordTraversal::apply(const AmbientLight& light)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

//debug("RecordTraversal::apply(AmbientLight) ", light.className());
if (_viewDependentState) _viewDependentState->ambientLights.emplace_back(_state->modelviewMatrixStack.top(), &light);
}

void RecordTraversal::apply(const DirectionalLight& light)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

//debug("RecordTraversal::apply(DirectionalLight) ", light.className());
if (_viewDependentState) _viewDependentState->directionalLights.emplace_back(_state->modelviewMatrixStack.top(), &light);
}

void RecordTraversal::apply(const PointLight& light)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

//debug("RecordTraversal::apply(PointLight) ", light.className());
if (_viewDependentState) _viewDependentState->pointLights.emplace_back(_state->modelviewMatrixStack.top(), &light);
}

void RecordTraversal::apply(const SpotLight& light)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

//debug("RecordTraversal::apply(SpotLight) ", light.className());
if (_viewDependentState) _viewDependentState->spotLights.emplace_back(_state->modelviewMatrixStack.top(), &light);
}

void RecordTraversal::apply(const StateGroup& stateGroup)
{
SCOPED_INSTRUMENTASTION_C(instrumentation, ubvec4(255, 255, 0, 255));
SCOPED_INSTRUMENTATION_C(instrumentation, ubvec4(255, 255, 0, 255));

//debug("Visiting StateGroup");

Expand All @@ -353,7 +353,7 @@ void RecordTraversal::apply(const StateGroup& stateGroup)

void RecordTraversal::apply(const Transform& transform)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

_state->modelviewMatrixStack.push(transform);
_state->dirty = true;
Expand All @@ -375,7 +375,7 @@ void RecordTraversal::apply(const Transform& transform)

void RecordTraversal::apply(const MatrixTransform& mt)
{
SCOPED_INSTRUMENTASTION(instrumentation);
SCOPED_INSTRUMENTATION(instrumentation);

_state->modelviewMatrixStack.push(mt);
_state->dirty = true;
Expand All @@ -398,7 +398,7 @@ void RecordTraversal::apply(const MatrixTransform& mt)
// Vulkan nodes
void RecordTraversal::apply(const Commands& commands)
{
SCOPED_INSTRUMENTASTION_C(instrumentation, ubvec4(0, 255, 0, 255));
SCOPED_INSTRUMENTATION_C(instrumentation, ubvec4(0, 255, 0, 255));

_state->record();
for (auto& command : commands.children)
Expand All @@ -409,7 +409,7 @@ void RecordTraversal::apply(const Commands& commands)

void RecordTraversal::apply(const Command& command)
{
SCOPED_INSTRUMENTASTION_C(instrumentation, ubvec4(0, 255, 0, 255));
SCOPED_INSTRUMENTATION_C(instrumentation, ubvec4(0, 255, 0, 255));

//debug("Visiting Command");
_state->record();
Expand All @@ -418,7 +418,7 @@ void RecordTraversal::apply(const Command& command)

void RecordTraversal::apply(const View& view)
{
SCOPED_INSTRUMENTASTION_C(instrumentation, ubvec4(0, 0, 255, 255));
SCOPED_INSTRUMENTATION_C(instrumentation, ubvec4(0, 0, 255, 255));

// note, View::accept() updates the RecordTraversal's traversalMask
auto cached_traversalMask = _state->_commandBuffer->traversalMask;
Expand Down Expand Up @@ -507,7 +507,7 @@ void RecordTraversal::apply(const View& view)

void RecordTraversal::apply(const CommandGraph& commandGraph)
{
SCOPED_INSTRUMENTASTION_C(instrumentation, ubvec4(0, 0, 255, 255));
SCOPED_INSTRUMENTATION_C(instrumentation, ubvec4(0, 0, 255, 255));

if (recordedCommandBuffers)
{
Expand Down
Loading