|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: MIT |
| 3 | + * ---------------------------------------------------------------------------- |
| 4 | + * Copyright (c) 2024-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 | +/** |
| 35 | + * @brief Register a compute dispatch with the tracker. |
| 36 | + * |
| 37 | + * @param layer The layer context for the device. |
| 38 | + * @param commandBuffer The command buffer we are recording. |
| 39 | + */ |
| 40 | +static void registerDispatchDataGraph(Device* layer, |
| 41 | + VkCommandBuffer commandBuffer) |
| 42 | +{ |
| 43 | + if (!layer->isFrameOfInterest) |
| 44 | + { |
| 45 | + return; |
| 46 | + } |
| 47 | + |
| 48 | + auto& tracker = layer->getStateTracker(); |
| 49 | + auto& cb = tracker.getCommandBuffer(commandBuffer); |
| 50 | + cb.dispatchDataGraph(); |
| 51 | +} |
| 52 | + |
| 53 | +/* See Vulkan API for documentation. */ |
| 54 | +template<> |
| 55 | +VKAPI_ATTR void VKAPI_CALL layer_vkCmdDispatchDataGraphARM<user_tag>(VkCommandBuffer commandBuffer, |
| 56 | + VkDataGraphPipelineSessionARM session, |
| 57 | + const VkDataGraphPipelineDispatchInfoARM* pInfo) |
| 58 | +{ |
| 59 | + LAYER_TRACE(__func__); |
| 60 | + |
| 61 | + // Hold the lock to access layer-wide global store |
| 62 | + std::unique_lock<std::mutex> lock {g_vulkanLock}; |
| 63 | + auto* layer = Device::retrieve(commandBuffer); |
| 64 | + |
| 65 | + registerDispatchDataGraph(layer, commandBuffer); |
| 66 | + |
| 67 | + // Release the lock to call into the driver |
| 68 | + lock.unlock(); |
| 69 | + layer->driver.vkCmdDispatchDataGraphARM(commandBuffer, session, pInfo); |
| 70 | + emitCPUTrap(*layer, commandBuffer); |
| 71 | +} |
0 commit comments