Hash :
c2fd3388
Author :
Date :
2021-05-15T22:28:27
CL: Add front end object references to back end objects Add front end object references to back end objects, which requires a significant amount of refactoring, because the back end objects have to be constructed during the construction of the front end objects, so that the references can be passed to the back end objects, which then can be passed to the front end member initialization. That would have been easier with inheritance than with PImpl. Bug: angleproject:5904 Change-Id: Ib58e6a698e76987bdd63cd8088f923424d6c622b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2897249 Commit-Queue: John Plate <jplate@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.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 110 111
//
// 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.
//
// angle_cl.h: Includes all necessary CL headers and definitions for ANGLE.
#ifndef ANGLECL_H_
#define ANGLECL_H_
#define CL_TARGET_OPENCL_VERSION 300
#define CL_USE_DEPRECATED_OPENCL_1_0_APIS
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
#define CL_USE_DEPRECATED_OPENCL_2_1_APIS
#define CL_USE_DEPRECATED_OPENCL_2_2_APIS
#include "CL/cl_icd.h"
#include <cstddef>
#include <type_traits>
namespace cl
{
using ContextErrorCB = void(CL_CALLBACK *)(const char *errinfo,
const void *private_info,
size_t cb,
void *user_data);
template <typename CLObjectType>
struct Dispatch
{
constexpr Dispatch(const cl_icd_dispatch &dispatch) : mDispatch(&dispatch)
{
static_assert(
std::is_standard_layout<CLObjectType>::value && offsetof(CLObjectType, mDispatch) == 0u,
"Not ICD compatible");
}
~Dispatch() = default;
constexpr const cl_icd_dispatch &getDispatch() { return *mDispatch; }
private:
// This has to be the first member to be OpenCL ICD compatible
const cl_icd_dispatch *const mDispatch;
};
} // namespace cl
struct _cl_platform_id : public cl::Dispatch<_cl_platform_id>
{
constexpr _cl_platform_id(const cl_icd_dispatch &dispatch)
: cl::Dispatch<_cl_platform_id>(dispatch)
{}
~_cl_platform_id() = default;
};
struct _cl_device_id : public cl::Dispatch<_cl_device_id>
{
constexpr _cl_device_id(const cl_icd_dispatch &dispatch) : cl::Dispatch<_cl_device_id>(dispatch)
{}
~_cl_device_id() = default;
};
struct _cl_context : public cl::Dispatch<_cl_context>
{
constexpr _cl_context(const cl_icd_dispatch &dispatch) : cl::Dispatch<_cl_context>(dispatch) {}
~_cl_context() = default;
};
struct _cl_command_queue : public cl::Dispatch<_cl_command_queue>
{
constexpr _cl_command_queue(const cl_icd_dispatch &dispatch)
: cl::Dispatch<_cl_command_queue>(dispatch)
{}
~_cl_command_queue() = default;
};
struct _cl_mem : public cl::Dispatch<_cl_mem>
{
constexpr _cl_mem(const cl_icd_dispatch &dispatch) : cl::Dispatch<_cl_mem>(dispatch) {}
~_cl_mem() = default;
};
struct _cl_program : public cl::Dispatch<_cl_program>
{
constexpr _cl_program(const cl_icd_dispatch &dispatch) : cl::Dispatch<_cl_program>(dispatch) {}
~_cl_program() = default;
};
struct _cl_kernel : public cl::Dispatch<_cl_kernel>
{
constexpr _cl_kernel(const cl_icd_dispatch &dispatch) : cl::Dispatch<_cl_kernel>(dispatch) {}
~_cl_kernel() = default;
};
struct _cl_event : public cl::Dispatch<_cl_event>
{
constexpr _cl_event(const cl_icd_dispatch &dispatch) : cl::Dispatch<_cl_event>(dispatch) {}
~_cl_event() = default;
};
struct _cl_sampler : public cl::Dispatch<_cl_sampler>
{
constexpr _cl_sampler(const cl_icd_dispatch &dispatch) : cl::Dispatch<_cl_sampler>(dispatch) {}
~_cl_sampler() = default;
};
#endif // ANGLECL_H_