Skip to content

Commit cc96378

Browse files
committed
Timeline layer: Add VK_ARM_data_graph support
1 parent 0c6389c commit cc96378

13 files changed

+189
-15
lines changed

layer_gpu_timeline/source/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ add_library(
4747
layer_device_functions_command_buffer.cpp
4848
layer_device_functions_command_pool.cpp
4949
layer_device_functions_debug.cpp
50+
layer_device_functions_dispatch_data_graph.cpp
5051
layer_device_functions_dispatch.cpp
5152
layer_device_functions_draw_call.cpp
5253
layer_device_functions_queue.cpp

layer_gpu_timeline/source/layer_device_functions.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,14 @@ VKAPI_ATTR void VKAPI_CALL layer_vkCmdDispatchIndirect<user_tag>(VkCommandBuffer
279279
VkBuffer buffer,
280280
VkDeviceSize offset);
281281

282+
// Commands for data graph
283+
284+
/* See Vulkan API for documentation. */
285+
template<>
286+
VKAPI_ATTR void VKAPI_CALL layer_vkCmdDispatchDataGraphARM<user_tag>(VkCommandBuffer commandBuffer,
287+
VkDataGraphPipelineSessionARM session,
288+
const VkDataGraphPipelineDispatchInfoARM* pInfo);
289+
282290
// Commands for trace rays
283291

284292
/* See Vulkan API for documentation. */
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* SPDX-License-Identifier: MIT
3+
* ----------------------------------------------------------------------------
4+
* Copyright (c) 2025 Arm Limited
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to
8+
* deal in the Software without restriction, including without limitation the
9+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
* sell copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22+
* IN THE SOFTWARE.
23+
* ----------------------------------------------------------------------------
24+
*/
25+
26+
#include "device.hpp"
27+
#include "device_utils.hpp"
28+
#include "framework/device_dispatch_table.hpp"
29+
30+
#include <mutex>
31+
32+
extern std::mutex g_vulkanLock;
33+
34+
/* See Vulkan API for documentation. */
35+
template<>
36+
VKAPI_ATTR void VKAPI_CALL layer_vkCmdDispatchDataGraphARM<user_tag>(VkCommandBuffer commandBuffer,
37+
VkDataGraphPipelineSessionARM session,
38+
const VkDataGraphPipelineDispatchInfoARM* pInfo)
39+
{
40+
LAYER_TRACE(__func__);
41+
42+
// Hold the lock to access layer-wide global store
43+
std::unique_lock<std::mutex> lock {g_vulkanLock};
44+
auto* layer = Device::retrieve(commandBuffer);
45+
46+
auto& tracker = layer->getStateTracker();
47+
auto& cb = tracker.getCommandBuffer(commandBuffer);
48+
uint64_t tagID = cb.dispatchDataGraph();
49+
50+
// Release the lock to call into the driver
51+
lock.unlock();
52+
emitStartTag(layer, commandBuffer, tagID);
53+
layer->driver.vkCmdDispatchDataGraphARM(commandBuffer, session, pInfo);
54+
emitEndTag(layer, commandBuffer);
55+
}

layer_gpu_timeline/source/timeline_protobuf_encoder.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ using Dispatch = pp::message<
148148
/* Any user defined debug labels associated with the dispatch */
149149
pp::string_field<"debug_label", 5, pp::repeated>>;
150150

151+
/* A dispatch data graph object submission */
152+
using DispatchDataGraph = pp::message<
153+
/* The unique identifier for this operation */
154+
pp::uint64_field<"tag_id", 1>,
155+
/* Any user defined debug labels associated with the dispatch */
156+
pp::string_field<"debug_label", 2, pp::repeated>>;
157+
151158
/* A trace rays object submission */
152159
using TraceRays = pp::message<
153160
/* The unique identifier for this operation */
@@ -251,7 +258,8 @@ using TimelineRecord =
251258
pp::message_field<"image_transfer", 9, ImageTransfer>,
252259
pp::message_field<"buffer_transfer", 10, BufferTransfer>,
253260
pp::message_field<"acceleration_structure_build", 11, AccelerationStructureBuild>,
254-
pp::message_field<"acceleration_structure_transfer", 12, AccelerationStructureTransfer>>;
261+
pp::message_field<"acceleration_structure_transfer", 12, AccelerationStructureTransfer>,
262+
pp::message_field<"dispatch_data_graph", 13, DispatchDataGraph>>;
255263

256264
namespace
257265
{
@@ -527,6 +535,23 @@ Comms::MessageData serialize(const Tracker::LCSDispatch& dispatch, const std::ve
527535
});
528536
}
529537

538+
/**
539+
* @brief Get the metadata for this workload
540+
*
541+
* @param dispatch The dispatch data graph to serialize
542+
* @param debugLabel The debug label stack for the VkQueue at submit time.
543+
*/
544+
Comms::MessageData serialize(const Tracker::LCSDispatchDataGraph& dispatch, const std::vector<std::string>& debugLabel)
545+
{
546+
using namespace pp;
547+
548+
return packBuffer("dispatch_data_graph"_f,
549+
DispatchDataGraph {
550+
dispatch.getTagID(),
551+
debugLabel,
552+
});
553+
}
554+
530555
/**
531556
* @brief Get the metadata for this workload
532557
*
@@ -702,6 +727,12 @@ void TimelineProtobufEncoder::operator()(const Tracker::LCSDispatch& dispatch,
702727
device.txMessage(serialize(dispatch, debugStack));
703728
}
704729

730+
void TimelineProtobufEncoder::operator()(const Tracker::LCSDispatchDataGraph& dispatch,
731+
const std::vector<std::string>& debugStack)
732+
{
733+
device.txMessage(serialize(dispatch, debugStack));
734+
}
735+
705736
void TimelineProtobufEncoder::operator()(const Tracker::LCSTraceRays& traceRays,
706737
const std::vector<std::string>& debugStack)
707738
{

layer_gpu_timeline/source/timeline_protobuf_encoder.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class TimelineProtobufEncoder : public Tracker::SubmitCommandWorkloadVisitor
112112
const std::vector<std::string>& debugStack,
113113
uint64_t renderPassTagID) override;
114114
void operator()(const Tracker::LCSDispatch& dispatch, const std::vector<std::string>& debugStack) override;
115+
void operator()(const Tracker::LCSDispatchDataGraph& dispatch, const std::vector<std::string>& debugStack) override;
115116
void operator()(const Tracker::LCSTraceRays& traceRays, const std::vector<std::string>& debugStack) override;
116117
void operator()(const Tracker::LCSImageTransfer& imageTransfer,
117118
const std::vector<std::string>& debugStack) override;

layer_gpu_timeline/timeline.proto

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ message Dispatch {
209209
repeated string debug_label = 5;
210210
}
211211

212+
/* A dispatch data graph object submission */
213+
message DispatchDataGraph {
214+
/* The unique identifier for this operation */
215+
uint64 tag_id = 1;
216+
/* Any user defined debug labels associated with the dispatch */
217+
repeated string debug_label = 2;
218+
}
219+
212220
/* A trace rays object submission */
213221
message TraceRays {
214222
/* The unique identifier for this operation */
@@ -317,4 +325,5 @@ message TimelineRecord {
317325
BufferTransfer buffer_transfer = 10;
318326
AccelerationStructureBuild acceleration_structure_build = 11;
319327
AccelerationStructureTransfer acceleration_structure_transfer = 12;
328+
DispatchDataGraph dispatch_data_graph = 13;
320329
}

source_common/trackers/command_buffer.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ uint64_t CommandBuffer::dispatch(int64_t xGroups, int64_t yGroups, int64_t zGrou
144144
return tagID;
145145
}
146146

147+
/* See header for documentation. */
148+
uint64_t CommandBuffer::dispatchDataGraph()
149+
{
150+
uint64_t tagID = Tracker::LCSWorkload::assignTagID();
151+
stats.incDispatchDataGraphCount();
152+
153+
// Add a workload to the command stream
154+
auto workload = std::make_shared<LCSDispatchDataGraph>(tagID);
155+
156+
// Add a command to the layer-side command stream
157+
workloadCommandStream.emplace_back(LCSInstructionWorkload(workload));
158+
159+
return tagID;
160+
}
161+
147162
/* See header for documentation. */
148163
uint64_t CommandBuffer::traceRays(int64_t xItems, int64_t yItems, int64_t zItems)
149164
{

source_common/trackers/command_buffer.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ class CommandBuffer
116116
*/
117117
uint64_t dispatch(int64_t xGroups, int64_t yGroups, int64_t zGroups);
118118

119+
/**
120+
* @brief Capture a data graph dispatch.
121+
*
122+
* @return Returns the tagID assigned to this workload.
123+
*/
124+
uint64_t dispatchDataGraph();
125+
119126
/**
120127
* @brief Capture a trace rays dispatch.
121128
*

source_common/trackers/layer_command_stream.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ LCSDispatch::LCSDispatch(uint64_t _tagID, int64_t _xGroups, int64_t _yGroups, in
7171
{
7272
}
7373

74+
/* See header for details. */
75+
LCSDispatchDataGraph::LCSDispatchDataGraph(uint64_t _tagID)
76+
: LCSWorkload(_tagID)
77+
{
78+
}
79+
7480
/* See header for details. */
7581
LCSTraceRays::LCSTraceRays(uint64_t _tagID, int64_t _xItems, int64_t _yItems, int64_t _zItems)
7682
: LCSWorkload(_tagID),

source_common/trackers/layer_command_stream.hpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,20 @@ class LCSDispatch : public LCSWorkload
272272
int64_t zGroups;
273273
};
274274

275+
/**
276+
* @brief Class representing a data graph dispatch workload in the command stream.
277+
*/
278+
class LCSDispatchDataGraph : public LCSWorkload
279+
{
280+
public:
281+
/**
282+
* @brief Create a new data graph dispatch workload.
283+
*
284+
* @param tagID The assigned tagID.
285+
*/
286+
LCSDispatchDataGraph(uint64_t tagID);
287+
};
288+
275289
/**
276290
* @brief Class representing a trace rays workload in the command stream.
277291
*/
@@ -586,8 +600,10 @@ using LCSInstruction = std::variant<
586600
LCSInstructionWorkload<LCSRenderPass>,
587601
// The instruction represents a continuation of a render pass workload operation
588602
LCSInstructionWorkload<LCSRenderPassContinuation>,
589-
// The instruction represents a dispatch workload operation
603+
// The instruction represents a dispatch compute workload operation
590604
LCSInstructionWorkload<LCSDispatch>,
605+
// The instruction represents a dispatch data graph workload operation
606+
LCSInstructionWorkload<LCSDispatchDataGraph>,
591607
// The instruction represents a trace rays workload operation
592608
LCSInstructionWorkload<LCSTraceRays>,
593609
// The instruction represents an image transfer workload operation

0 commit comments

Comments
 (0)