Hash :
76636ddb
Author :
Date :
2024-04-04T15:39:08
CL/VK: Update missing reflection ops & DS creation Adding CLProgramVk routine to allocate DS. Also adding reflection parsing support for WGS IDs and PushConstantGlobalSize. Additionally, we now check VK implementation if non-semantic reflection data (in SPIR-V) is supported. If not, we strip that data from binary (via vk_feature check). Bug: angleproject:8631 Change-Id: Ife02867c7c30b919abf663865adc92858e1bff8d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5421574 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@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
//
// 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.cpp: Implements the class methods for CLKernelVk.
#include "libANGLE/renderer/vulkan/CLKernelVk.h"
#include "libANGLE/renderer/vulkan/CLContextVk.h"
#include "libANGLE/renderer/vulkan/CLDeviceVk.h"
#include "libANGLE/renderer/vulkan/CLProgramVk.h"
#include "libANGLE/CLContext.h"
#include "libANGLE/CLKernel.h"
#include "libANGLE/CLProgram.h"
#include "libANGLE/cl_utils.h"
namespace rx
{
CLKernelVk::CLKernelVk(const cl::Kernel &kernel,
std::string &name,
std::string &attributes,
CLKernelArguments &args)
: CLKernelImpl(kernel),
mProgram(&kernel.getProgram().getImpl<CLProgramVk>()),
mContext(&kernel.getProgram().getContext().getImpl<CLContextVk>()),
mName(name),
mAttributes(attributes),
mArgs(args)
{}
CLKernelVk::~CLKernelVk()
{
for (auto &dsLayouts : mDescriptorSetLayouts)
{
dsLayouts.reset();
}
}
angle::Result CLKernelVk::setArg(cl_uint argIndex, size_t argSize, const void *argValue)
{
auto &arg = mArgs.at(argIndex);
if (arg.used)
{
arg.handle = const_cast<void *>(argValue);
arg.handleSize = argSize;
}
return angle::Result::Continue;
}
angle::Result CLKernelVk::createInfo(CLKernelImpl::Info *info) const
{
info->functionName = mName;
info->attributes = mAttributes;
info->numArgs = static_cast<cl_uint>(mArgs.size());
for (const auto &arg : mArgs)
{
ArgInfo argInfo;
argInfo.name = arg.info.name;
argInfo.typeName = arg.info.typeName;
argInfo.accessQualifier = arg.info.accessQualifier;
argInfo.addressQualifier = arg.info.addressQualifier;
argInfo.typeQualifier = arg.info.typeQualifier;
info->args.push_back(std::move(argInfo));
}
auto &ctx = mKernel.getProgram().getContext();
info->workGroups.resize(ctx.getDevices().size());
const CLProgramVk::DeviceProgramData *deviceProgramData = nullptr;
for (auto i = 0u; i < ctx.getDevices().size(); ++i)
{
auto &workGroup = info->workGroups[i];
const auto deviceVk = &ctx.getDevices()[i]->getImpl<CLDeviceVk>();
deviceProgramData = mProgram->getDeviceProgramData(ctx.getDevices()[i]->getNative());
if (deviceProgramData == nullptr)
{
continue;
}
// TODO: http://anglebug.com/8576
ANGLE_TRY(
deviceVk->getInfoSizeT(cl::DeviceInfo::MaxWorkGroupSize, &workGroup.workGroupSize));
// TODO: http://anglebug.com/8575
workGroup.privateMemSize = 0;
workGroup.localMemSize = 0;
workGroup.prefWorkGroupSizeMultiple = 16u;
workGroup.globalWorkSize = {0, 0, 0};
if (deviceProgramData->reflectionData.kernelCompileWGS.contains(mName))
{
workGroup.compileWorkGroupSize = {
deviceProgramData->reflectionData.kernelCompileWGS.at(mName)[0],
deviceProgramData->reflectionData.kernelCompileWGS.at(mName)[1],
deviceProgramData->reflectionData.kernelCompileWGS.at(mName)[2]};
}
else
{
workGroup.compileWorkGroupSize = {0, 0, 0};
}
}
return angle::Result::Continue;
}
} // namespace rx