Hash :
cc50c75b
Author :
Date :
2024-04-19T16:40:26
CL/Vulkan: Fix missing kernel enqueue retain/release According to spec: https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#clReleaseKernel We also need to implicitly retain/release the Kernel object on Kernel enqueue APIs along with other kernel resource retain/release(s) (i.e. memobjs). Bug: angleproject:356328473 Change-Id: Ie6ca228ebece2988d511d9ffd2a617abdc057d0a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5753766 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Austin Annestrand <a.annestrand@samsung.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
//
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// CLKernelVk.h: Defines the class interface for CLKernelVk, implementing CLKernelImpl.
#ifndef LIBANGLE_RENDERER_VULKAN_CLKERNELVK_H_
#define LIBANGLE_RENDERER_VULKAN_CLKERNELVK_H_
#include "libANGLE/renderer/vulkan/cl_types.h"
#include "libANGLE/renderer/vulkan/vk_cache_utils.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h"
#include "libANGLE/renderer/vulkan/vk_utils.h"
#include "libANGLE/renderer/CLKernelImpl.h"
namespace rx
{
struct CLKernelArgument
{
CLKernelImpl::ArgInfo info{};
uint32_t type = 0;
uint32_t ordinal = 0;
size_t handleSize = 0;
void *handle = nullptr;
bool used = false;
// Shared operand words/regions for "OpExtInst" type spv instructions
// (starts from spv word index/offset 7 and onward)
// https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpExtInst
// https://github.com/google/clspv/blob/main/docs/OpenCLCOnVulkan.md#kernels
union
{
uint32_t op3;
uint32_t descriptorSet;
uint32_t pushConstOffset;
uint32_t workgroupSpecId;
};
union
{
uint32_t op4;
uint32_t descriptorBinding;
uint32_t pushConstantSize;
uint32_t workgroupSize;
};
union
{
uint32_t op5;
uint32_t podStorageBufferOffset;
uint32_t podUniformOffset;
uint32_t pointerUniformOffset;
};
union
{
uint32_t op6;
uint32_t podStorageBufferSize;
uint32_t podUniformSize;
uint32_t pointerUniformSize;
};
};
using CLKernelArguments = std::vector<CLKernelArgument>;
using CLKernelArgsMap = angle::HashMap<std::string, CLKernelArguments>;
class CLKernelVk : public CLKernelImpl
{
public:
using Ptr = std::unique_ptr<CLKernelVk>;
CLKernelVk(const cl::Kernel &kernel,
std::string &name,
std::string &attributes,
CLKernelArguments &args);
~CLKernelVk() override;
angle::Result setArg(cl_uint argIndex, size_t argSize, const void *argValue) override;
angle::Result createInfo(CLKernelImpl::Info *infoOut) const override;
CLProgramVk *getProgram() { return mProgram; }
const std::string &getKernelName() { return mName; }
const CLKernelArguments &getArgs() { return mArgs; }
vk::AtomicBindingPointer<vk::PipelineLayout> &getPipelineLayout() { return mPipelineLayout; }
vk::DescriptorSetLayoutPointerArray &getDescriptorSetLayouts() { return mDescriptorSetLayouts; }
cl::Kernel &getFrontendObject() { return const_cast<cl::Kernel &>(mKernel); }
angle::Result getOrCreateComputePipeline(vk::PipelineCacheAccess *pipelineCache,
const cl::NDRange &ndrange,
const cl::Device &device,
vk::PipelineHelper **pipelineOut,
cl::WorkgroupCount *workgroupCountOut);
private:
static constexpr std::array<size_t, 3> kEmptyWorkgroupSize = {0, 0, 0};
CLProgramVk *mProgram;
CLContextVk *mContext;
std::string mName;
std::string mAttributes;
CLKernelArguments mArgs;
vk::ShaderProgramHelper mShaderProgramHelper;
vk::ComputePipelineCache mComputePipelineCache;
vk::AtomicBindingPointer<vk::PipelineLayout> mPipelineLayout;
vk::DescriptorSetLayoutPointerArray mDescriptorSetLayouts{};
};
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_CLKERNELVK_H_