Hash :
80893f26
Author :
Date :
2023-11-30T16:57:15
OpenCL: Remove unneeded impl getters Some of the OpenCL backend (impl) getters are not needed. These are the size query for image creation, and CL source retrieval for program objects not created from source. Bug: angleproject:8438 Change-Id: I76b39b75f1ae76ec0c3c94d5715632cb9dd4900a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5078243 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
//
// 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.
//
// CLProgramCL.cpp: Implements the class methods for CLProgramCL.
#include "libANGLE/renderer/cl/CLProgramCL.h"
#include "libANGLE/renderer/cl/CLDeviceCL.h"
#include "libANGLE/renderer/cl/CLKernelCL.h"
#include "libANGLE/CLDevice.h"
#include "libANGLE/CLProgram.h"
#include "libANGLE/cl_utils.h"
namespace rx
{
CLProgramCL::CLProgramCL(const cl::Program &program, cl_program native)
: CLProgramImpl(program), mNative(native)
{}
CLProgramCL::~CLProgramCL()
{
if (mNative->getDispatch().clReleaseProgram(mNative) != CL_SUCCESS)
{
ERR() << "Error while releasing CL program";
}
}
angle::Result CLProgramCL::build(const cl::DevicePtrs &devices,
const char *options,
cl::Program *notify)
{
std::vector<cl_device_id> nativeDevices;
for (const cl::DevicePtr &device : devices)
{
nativeDevices.emplace_back(device->getImpl<CLDeviceCL>().getNative());
}
const cl_uint numDevices = static_cast<cl_uint>(nativeDevices.size());
const cl_device_id *const nativeDevicesPtr =
!nativeDevices.empty() ? nativeDevices.data() : nullptr;
const cl::ProgramCB callback = notify != nullptr ? Callback : nullptr;
ANGLE_CL_TRY(mNative->getDispatch().clBuildProgram(mNative, numDevices, nativeDevicesPtr,
options, callback, notify));
return angle::Result::Continue;
}
angle::Result CLProgramCL::compile(const cl::DevicePtrs &devices,
const char *options,
const cl::ProgramPtrs &inputHeaders,
const char **headerIncludeNames,
cl::Program *notify)
{
std::vector<cl_device_id> nativeDevices;
for (const cl::DevicePtr &device : devices)
{
nativeDevices.emplace_back(device->getImpl<CLDeviceCL>().getNative());
}
const cl_uint numDevices = static_cast<cl_uint>(nativeDevices.size());
const cl_device_id *const nativeDevicesPtr =
!nativeDevices.empty() ? nativeDevices.data() : nullptr;
std::vector<cl_program> nativePrograms;
for (const cl::ProgramPtr &program : inputHeaders)
{
nativePrograms.emplace_back(program->getImpl<CLProgramCL>().getNative());
}
const cl_uint numInputHeaders = static_cast<cl_uint>(nativePrograms.size());
const cl_program *const inputHeadersPtr =
!nativePrograms.empty() ? nativePrograms.data() : nullptr;
const cl::ProgramCB callback = notify != nullptr ? Callback : nullptr;
ANGLE_CL_TRY(mNative->getDispatch().clCompileProgram(mNative, numDevices, nativeDevicesPtr,
options, numInputHeaders, inputHeadersPtr,
headerIncludeNames, callback, notify));
return angle::Result::Continue;
}
angle::Result CLProgramCL::getInfo(cl::ProgramInfo name,
size_t valueSize,
void *value,
size_t *valueSizeRet) const
{
ANGLE_CL_TRY(mNative->getDispatch().clGetProgramInfo(mNative, cl::ToCLenum(name), valueSize,
value, valueSizeRet));
return angle::Result::Continue;
}
angle::Result CLProgramCL::getBuildInfo(const cl::Device &device,
cl::ProgramBuildInfo name,
size_t valueSize,
void *value,
size_t *valueSizeRet) const
{
ANGLE_CL_TRY(mNative->getDispatch().clGetProgramBuildInfo(
mNative, device.getImpl<CLDeviceCL>().getNative(), cl::ToCLenum(name), valueSize, value,
valueSizeRet));
return angle::Result::Continue;
}
angle::Result CLProgramCL::createKernel(const cl::Kernel &kernel,
const char *name,
CLKernelImpl::Ptr *kernelOut)
{
cl_int errorCode = CL_SUCCESS;
const cl_kernel nativeKernel = mNative->getDispatch().clCreateKernel(mNative, name, &errorCode);
ANGLE_CL_TRY(errorCode);
*kernelOut =
CLKernelImpl::Ptr(nativeKernel != nullptr ? new CLKernelCL(kernel, nativeKernel) : nullptr);
return angle::Result::Continue;
}
angle::Result CLProgramCL::createKernels(cl_uint numKernels,
CLKernelImpl::CreateFuncs &createFuncs,
cl_uint *numKernelsRet)
{
if (numKernels == 0u)
{
ANGLE_CL_TRY(
mNative->getDispatch().clCreateKernelsInProgram(mNative, 0u, nullptr, numKernelsRet));
}
std::vector<cl_kernel> nativeKernels(numKernels, nullptr);
ANGLE_CL_TRY(mNative->getDispatch().clCreateKernelsInProgram(
mNative, numKernels, nativeKernels.data(), numKernelsRet));
for (cl_kernel nativeKernel : nativeKernels)
{
createFuncs.emplace_back([nativeKernel](const cl::Kernel &kernel) {
return CLKernelImpl::Ptr(new CLKernelCL(kernel, nativeKernel));
});
}
return angle::Result::Continue;
}
void CLProgramCL::Callback(cl_program program, void *userData)
{
static_cast<cl::Program *>(userData)->callback();
}
} // namespace rx