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
1 change: 1 addition & 0 deletions layer_gpu_profile/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ add_library(
layer_device_functions_command_buffer.cpp
layer_device_functions_command_pool.cpp
layer_device_functions_debug.cpp
layer_device_functions_dispatch_data_graph.cpp
layer_device_functions_dispatch.cpp
layer_device_functions_queue.cpp
layer_device_functions_render_pass.cpp
Expand Down
8 changes: 8 additions & 0 deletions layer_gpu_profile/source/layer_device_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ VKAPI_ATTR void VKAPI_CALL layer_vkCmdDispatchIndirect<user_tag>(VkCommandBuffer
VkBuffer buffer,
VkDeviceSize offset);

// Commands for data graph

/* See Vulkan API for documentation. */
template<>
VKAPI_ATTR void VKAPI_CALL layer_vkCmdDispatchDataGraphARM<user_tag>(VkCommandBuffer commandBuffer,
VkDataGraphPipelineSessionARM session,
const VkDataGraphPipelineDispatchInfoARM* pInfo);

// Commands for trace rays

/* See Vulkan API for documentation. */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* SPDX-License-Identifier: MIT
* ----------------------------------------------------------------------------
* Copyright (c) 2024-2025 Arm Limited
*
* 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.
* ----------------------------------------------------------------------------
*/

#include "device.hpp"
#include "device_utils.hpp"
#include "framework/device_dispatch_table.hpp"

#include <mutex>

extern std::mutex g_vulkanLock;

/**
* @brief Register a compute dispatch with the tracker.
*
* @param layer The layer context for the device.
* @param commandBuffer The command buffer we are recording.
*/
static void registerDispatchDataGraph(Device* layer,
VkCommandBuffer commandBuffer)
{
if (!layer->isFrameOfInterest)
{
return;
}

auto& tracker = layer->getStateTracker();
auto& cb = tracker.getCommandBuffer(commandBuffer);
cb.dispatchDataGraph();
}

/* See Vulkan API for documentation. */
template<>
VKAPI_ATTR void VKAPI_CALL layer_vkCmdDispatchDataGraphARM<user_tag>(VkCommandBuffer commandBuffer,
VkDataGraphPipelineSessionARM session,
const VkDataGraphPipelineDispatchInfoARM* pInfo)
{
LAYER_TRACE(__func__);

// Hold the lock to access layer-wide global store
std::unique_lock<std::mutex> lock {g_vulkanLock};
auto* layer = Device::retrieve(commandBuffer);

registerDispatchDataGraph(layer, commandBuffer);

// Release the lock to call into the driver
lock.unlock();
layer->driver.vkCmdDispatchDataGraphARM(commandBuffer, session, pInfo);
emitCPUTrap(*layer, commandBuffer);
}
14 changes: 12 additions & 2 deletions layer_gpu_profile/source/submit_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void ProfileSubmitVisitor::operator()(
) {
UNUSED(renderPass);

handleCPUTrap("renderpass", debugStack);
handleCPUTrap("render_pass", debugStack);
}

/* See header for documentation */
Expand All @@ -123,14 +123,24 @@ void ProfileSubmitVisitor::operator()(
handleCPUTrap("compute", debugStack);
}

/* See header for documentation */
void ProfileSubmitVisitor::operator()(
const Tracker::LCSDispatchDataGraph& dispatch,
const std::vector<std::string>& debugStack
) {
UNUSED(dispatch);

handleCPUTrap("data_graph", debugStack);
}

/* See header for documentation */
void ProfileSubmitVisitor::operator()(
const Tracker::LCSTraceRays& traceRays,
const std::vector<std::string>& debugStack
) {
UNUSED(traceRays);

handleCPUTrap("tracerays", debugStack);
handleCPUTrap("trace_rays", debugStack);
}

/* See header for documentation */
Expand Down
4 changes: 4 additions & 0 deletions layer_gpu_profile/source/submit_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class ProfileSubmitVisitor : public Tracker::SubmitCommandWorkloadVisitor
const Tracker::LCSDispatch& dispatch,
const std::vector<std::string>& debugStack) override;

void operator()(
const Tracker::LCSDispatchDataGraph& dispatch,
const std::vector<std::string>& debugStack) override;

void operator()(
const Tracker::LCSTraceRays& traceRays,
const std::vector<std::string>& debugStack) override;
Expand Down
1 change: 1 addition & 0 deletions layer_gpu_timeline/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ add_library(
layer_device_functions_command_buffer.cpp
layer_device_functions_command_pool.cpp
layer_device_functions_debug.cpp
layer_device_functions_dispatch_data_graph.cpp
layer_device_functions_dispatch.cpp
layer_device_functions_draw_call.cpp
layer_device_functions_queue.cpp
Expand Down
8 changes: 8 additions & 0 deletions layer_gpu_timeline/source/layer_device_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,14 @@ VKAPI_ATTR void VKAPI_CALL layer_vkCmdDispatchIndirect<user_tag>(VkCommandBuffer
VkBuffer buffer,
VkDeviceSize offset);

// Commands for data graph

/* See Vulkan API for documentation. */
template<>
VKAPI_ATTR void VKAPI_CALL layer_vkCmdDispatchDataGraphARM<user_tag>(VkCommandBuffer commandBuffer,
VkDataGraphPipelineSessionARM session,
const VkDataGraphPipelineDispatchInfoARM* pInfo);

// Commands for trace rays

/* See Vulkan API for documentation. */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* SPDX-License-Identifier: MIT
* ----------------------------------------------------------------------------
* Copyright (c) 2025 Arm Limited
*
* 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.
* ----------------------------------------------------------------------------
*/

#include "device.hpp"
#include "device_utils.hpp"
#include "framework/device_dispatch_table.hpp"

#include <mutex>

extern std::mutex g_vulkanLock;

/* See Vulkan API for documentation. */
template<>
VKAPI_ATTR void VKAPI_CALL layer_vkCmdDispatchDataGraphARM<user_tag>(VkCommandBuffer commandBuffer,
VkDataGraphPipelineSessionARM session,
const VkDataGraphPipelineDispatchInfoARM* pInfo)
{
LAYER_TRACE(__func__);

// Hold the lock to access layer-wide global store
std::unique_lock<std::mutex> lock {g_vulkanLock};
auto* layer = Device::retrieve(commandBuffer);

auto& tracker = layer->getStateTracker();
auto& cb = tracker.getCommandBuffer(commandBuffer);
uint64_t tagID = cb.dispatchDataGraph();

// Release the lock to call into the driver
lock.unlock();
emitStartTag(layer, commandBuffer, tagID);
layer->driver.vkCmdDispatchDataGraphARM(commandBuffer, session, pInfo);
emitEndTag(layer, commandBuffer);
}
33 changes: 32 additions & 1 deletion layer_gpu_timeline/source/timeline_protobuf_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ using Dispatch = pp::message<
/* Any user defined debug labels associated with the dispatch */
pp::string_field<"debug_label", 5, pp::repeated>>;

/* A dispatch data graph object submission */
using DispatchDataGraph = pp::message<
/* The unique identifier for this operation */
pp::uint64_field<"tag_id", 1>,
/* Any user defined debug labels associated with the dispatch */
pp::string_field<"debug_label", 2, pp::repeated>>;

/* A trace rays object submission */
using TraceRays = pp::message<
/* The unique identifier for this operation */
Expand Down Expand Up @@ -251,7 +258,8 @@ using TimelineRecord =
pp::message_field<"image_transfer", 9, ImageTransfer>,
pp::message_field<"buffer_transfer", 10, BufferTransfer>,
pp::message_field<"acceleration_structure_build", 11, AccelerationStructureBuild>,
pp::message_field<"acceleration_structure_transfer", 12, AccelerationStructureTransfer>>;
pp::message_field<"acceleration_structure_transfer", 12, AccelerationStructureTransfer>,
pp::message_field<"dispatch_data_graph", 13, DispatchDataGraph>>;

namespace
{
Expand Down Expand Up @@ -527,6 +535,23 @@ Comms::MessageData serialize(const Tracker::LCSDispatch& dispatch, const std::ve
});
}

/**
* @brief Get the metadata for this workload
*
* @param dispatch The dispatch data graph to serialize
* @param debugLabel The debug label stack for the VkQueue at submit time.
*/
Comms::MessageData serialize(const Tracker::LCSDispatchDataGraph& dispatch, const std::vector<std::string>& debugLabel)
{
using namespace pp;

return packBuffer("dispatch_data_graph"_f,
DispatchDataGraph {
dispatch.getTagID(),
debugLabel,
});
}

/**
* @brief Get the metadata for this workload
*
Expand Down Expand Up @@ -702,6 +727,12 @@ void TimelineProtobufEncoder::operator()(const Tracker::LCSDispatch& dispatch,
device.txMessage(serialize(dispatch, debugStack));
}

void TimelineProtobufEncoder::operator()(const Tracker::LCSDispatchDataGraph& dispatch,
const std::vector<std::string>& debugStack)
{
device.txMessage(serialize(dispatch, debugStack));
}

void TimelineProtobufEncoder::operator()(const Tracker::LCSTraceRays& traceRays,
const std::vector<std::string>& debugStack)
{
Expand Down
1 change: 1 addition & 0 deletions layer_gpu_timeline/source/timeline_protobuf_encoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class TimelineProtobufEncoder : public Tracker::SubmitCommandWorkloadVisitor
const std::vector<std::string>& debugStack,
uint64_t renderPassTagID) override;
void operator()(const Tracker::LCSDispatch& dispatch, const std::vector<std::string>& debugStack) override;
void operator()(const Tracker::LCSDispatchDataGraph& dispatch, const std::vector<std::string>& debugStack) override;
void operator()(const Tracker::LCSTraceRays& traceRays, const std::vector<std::string>& debugStack) override;
void operator()(const Tracker::LCSImageTransfer& imageTransfer,
const std::vector<std::string>& debugStack) override;
Expand Down
9 changes: 9 additions & 0 deletions layer_gpu_timeline/timeline.proto
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ message Dispatch {
repeated string debug_label = 5;
}

/* A dispatch data graph object submission */
message DispatchDataGraph {
/* The unique identifier for this operation */
uint64 tag_id = 1;
/* Any user defined debug labels associated with the dispatch */
repeated string debug_label = 2;
}

/* A trace rays object submission */
message TraceRays {
/* The unique identifier for this operation */
Expand Down Expand Up @@ -317,4 +325,5 @@ message TimelineRecord {
BufferTransfer buffer_transfer = 10;
AccelerationStructureBuild acceleration_structure_build = 11;
AccelerationStructureTransfer acceleration_structure_transfer = 12;
DispatchDataGraph dispatch_data_graph = 13;
}
15 changes: 15 additions & 0 deletions source_common/trackers/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ uint64_t CommandBuffer::dispatch(int64_t xGroups, int64_t yGroups, int64_t zGrou
return tagID;
}

/* See header for documentation. */
uint64_t CommandBuffer::dispatchDataGraph()
{
uint64_t tagID = Tracker::LCSWorkload::assignTagID();
stats.incDispatchDataGraphCount();

// Add a workload to the command stream
auto workload = std::make_shared<LCSDispatchDataGraph>(tagID);

// Add a command to the layer-side command stream
workloadCommandStream.emplace_back(LCSInstructionWorkload(workload));

return tagID;
}

/* See header for documentation. */
uint64_t CommandBuffer::traceRays(int64_t xItems, int64_t yItems, int64_t zItems)
{
Expand Down
7 changes: 7 additions & 0 deletions source_common/trackers/command_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ class CommandBuffer
*/
uint64_t dispatch(int64_t xGroups, int64_t yGroups, int64_t zGroups);

/**
* @brief Capture a data graph dispatch.
*
* @return Returns the tagID assigned to this workload.
*/
uint64_t dispatchDataGraph();

/**
* @brief Capture a trace rays dispatch.
*
Expand Down
6 changes: 6 additions & 0 deletions source_common/trackers/layer_command_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ LCSDispatch::LCSDispatch(uint64_t _tagID, int64_t _xGroups, int64_t _yGroups, in
{
}

/* See header for details. */
LCSDispatchDataGraph::LCSDispatchDataGraph(uint64_t _tagID)
: LCSWorkload(_tagID)
{
}

/* See header for details. */
LCSTraceRays::LCSTraceRays(uint64_t _tagID, int64_t _xItems, int64_t _yItems, int64_t _zItems)
: LCSWorkload(_tagID),
Expand Down
18 changes: 17 additions & 1 deletion source_common/trackers/layer_command_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,20 @@ class LCSDispatch : public LCSWorkload
int64_t zGroups;
};

/**
* @brief Class representing a data graph dispatch workload in the command stream.
*/
class LCSDispatchDataGraph : public LCSWorkload
{
public:
/**
* @brief Create a new data graph dispatch workload.
*
* @param tagID The assigned tagID.
*/
LCSDispatchDataGraph(uint64_t tagID);
};

/**
* @brief Class representing a trace rays workload in the command stream.
*/
Expand Down Expand Up @@ -586,8 +600,10 @@ using LCSInstruction = std::variant<
LCSInstructionWorkload<LCSRenderPass>,
// The instruction represents a continuation of a render pass workload operation
LCSInstructionWorkload<LCSRenderPassContinuation>,
// The instruction represents a dispatch workload operation
// The instruction represents a dispatch compute workload operation
LCSInstructionWorkload<LCSDispatch>,
// The instruction represents a dispatch data graph workload operation
LCSInstructionWorkload<LCSDispatchDataGraph>,
// The instruction represents a trace rays workload operation
LCSInstructionWorkload<LCSTraceRays>,
// The instruction represents an image transfer workload operation
Expand Down
Loading