зеркало из https://github.com/AvaloniaUI/angle.git
Add support for OpenCL ICD Loader
Bug: angleproject:5908 Change-Id: Idafc0d15b69f9a21f2ab5e48c4c34f0dc0e0ee96 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2854598 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: John Plate <jplate@google.com>
This commit is contained in:
Родитель
bcae4fe182
Коммит
05fb22724f
3
BUILD.gn
3
BUILD.gn
|
@ -345,6 +345,9 @@ if (angle_has_build) {
|
|||
|
||||
angle_static_library("angle_common") {
|
||||
sources = libangle_common_sources
|
||||
if (angle_enable_cl) {
|
||||
sources += libangle_common_cl_sources
|
||||
}
|
||||
|
||||
configs += [
|
||||
":angle_common_config",
|
||||
|
|
|
@ -140,6 +140,11 @@ declare_args() {
|
|||
angle_enable_cl_passthrough = angle_enable_cl
|
||||
}
|
||||
|
||||
# OpenCL is not supported on Windows UWP, because the CL headers include DXD9, which is not
|
||||
# supported by UWP. A workaround might be possible if CL support on UWP is required.
|
||||
assert(!angle_is_winuwp || !angle_enable_cl,
|
||||
"OpenCL is not supported on Windows UWP")
|
||||
|
||||
if (!angle_enable_cl) {
|
||||
angle_enable_cl_passthrough = false
|
||||
}
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
// 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.
|
||||
//
|
||||
// angle_cl.h: Includes all necessary CL headers and definitions for ANGLE.
|
||||
|
||||
#ifndef ANGLECL_H_
|
||||
#define ANGLECL_H_
|
||||
|
@ -18,6 +16,91 @@
|
|||
#define CL_USE_DEPRECATED_OPENCL_2_1_APIS
|
||||
#define CL_USE_DEPRECATED_OPENCL_2_2_APIS
|
||||
|
||||
#include "CL/opencl.h"
|
||||
#include "CL/cl_icd.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
namespace cl
|
||||
{
|
||||
|
||||
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_
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"scripts/egl_angle_ext.xml":
|
||||
"5bcc01462b355d933cf3ada15198fb68",
|
||||
"scripts/generate_loader.py":
|
||||
"e24af68efd9f8149b53225e4b07a20aa",
|
||||
"5592f86f5841d24afa660c67330426d6",
|
||||
"scripts/gl.xml":
|
||||
"2a73a58a7e26d8676a2c0af6d528cae6",
|
||||
"scripts/gl_angle_ext.xml":
|
||||
|
@ -19,8 +19,6 @@
|
|||
"3740eb7bd4928f17c4239ab294930469",
|
||||
"src/libEGL/egl_loader_autogen.h":
|
||||
"9cbf4d491497058a32642865eb032276",
|
||||
"src/libOpenCL/cl_loader_autogen.cpp":
|
||||
"1251dfd7f095459ff076abb02a5bbf79",
|
||||
"src/tests/restricted_traces/trace_egl_loader_autogen.cpp":
|
||||
"ab1ce9e72e1e248b13302349f2228a89",
|
||||
"src/tests/restricted_traces/trace_egl_loader_autogen.h":
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"scripts/entry_point_packed_gl_enums.json":
|
||||
"4f7b43863a5e61991bba4010db463679",
|
||||
"scripts/generate_entry_points.py":
|
||||
"ce49f151aac3d4a163686d7e45bcb03e",
|
||||
"ef46ad67466c14b792ca7e9ac1cea8d7",
|
||||
"scripts/gl.xml":
|
||||
"2a73a58a7e26d8676a2c0af6d528cae6",
|
||||
"scripts/gl_angle_ext.xml":
|
||||
|
@ -130,9 +130,9 @@
|
|||
"src/libGLESv2/egl_stubs_autogen.h":
|
||||
"6439daa350c1663e71dd0af37dcc91df",
|
||||
"src/libGLESv2/entry_points_cl_autogen.cpp":
|
||||
"2c43ce51701c4499003638fa30de340e",
|
||||
"2de1fb4947c632a11803a459b3fc2b25",
|
||||
"src/libGLESv2/entry_points_cl_autogen.h":
|
||||
"129fa7936c8bc6a20de9269da0c3c7d3",
|
||||
"c53bd6b7025be98440ae9ca90161d550",
|
||||
"src/libGLESv2/entry_points_egl_autogen.cpp":
|
||||
"e7b708af1c8de435532058eb165d421e",
|
||||
"src/libGLESv2/entry_points_egl_autogen.h":
|
||||
|
@ -174,5 +174,5 @@
|
|||
"src/libGLESv2/libGLESv2_with_capture_autogen.def":
|
||||
"6b895f17f1a745f626a7534f14971fcd",
|
||||
"src/libOpenCL/libOpenCL_autogen.cpp":
|
||||
"be80b03e4d121921f4a27aba9ad16aa1"
|
||||
"06d55739c92ece6b669074451634b106"
|
||||
}
|
|
@ -58,9 +58,7 @@ TEMPLATE_ENTRY_POINT_HEADER = """\
|
|||
|
||||
{includes}
|
||||
|
||||
extern "C" {{
|
||||
{entry_points}
|
||||
}} // extern "C"
|
||||
|
||||
#endif // {lib}_ENTRY_POINTS_{annotation_upper}_AUTOGEN_H_
|
||||
"""
|
||||
|
@ -78,9 +76,7 @@ TEMPLATE_ENTRY_POINT_SOURCE = """\
|
|||
|
||||
{includes}
|
||||
|
||||
extern "C" {{
|
||||
{entry_points}
|
||||
}} // extern "C"
|
||||
"""
|
||||
|
||||
TEMPLATE_ENTRY_POINTS_ENUM_HEADER = """\
|
||||
|
@ -159,7 +155,7 @@ extern "C" {{
|
|||
}} // extern "C"
|
||||
"""
|
||||
|
||||
TEMPLATE_ENTRY_POINT_DECL = """ANGLE_EXPORT {return_type} {export_def} {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});"""
|
||||
TEMPLATE_ENTRY_POINT_DECL = """{angle_export}{return_type} {export_def} {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});"""
|
||||
|
||||
TEMPLATE_GLES_ENTRY_POINT_NO_RETURN = """\
|
||||
void GL_APIENTRY GL_{name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
|
||||
|
@ -247,7 +243,7 @@ TEMPLATE_EGL_ENTRY_POINT_WITH_RETURN = """\
|
|||
"""
|
||||
|
||||
TEMPLATE_CL_ENTRY_POINT_NO_RETURN = """\
|
||||
void CL_API_CALL CL_{name}({params})
|
||||
void CL_API_CALL cl{name}({params})
|
||||
{{
|
||||
CL_EVENT({name}, "{format_params}"{comma_if_needed}{pass_params});
|
||||
|
||||
|
@ -260,7 +256,7 @@ void CL_API_CALL CL_{name}({params})
|
|||
"""
|
||||
|
||||
TEMPLATE_CL_ENTRY_POINT_WITH_RETURN_ERROR = """\
|
||||
cl_int CL_API_CALL CL_{name}({params})
|
||||
cl_int CL_API_CALL cl{name}({params})
|
||||
{{
|
||||
CL_EVENT({name}, "{format_params}"{comma_if_needed}{pass_params});
|
||||
|
||||
|
@ -268,12 +264,12 @@ cl_int CL_API_CALL CL_{name}({params})
|
|||
|
||||
ANGLE_CL_VALIDATE_ERROR({name}{comma_if_needed}{internal_params});
|
||||
|
||||
return {return_cast}({name}({internal_params}));
|
||||
return {name}({internal_params});
|
||||
}}
|
||||
"""
|
||||
|
||||
TEMPLATE_CL_ENTRY_POINT_WITH_RETURN_POINTER = """\
|
||||
{return_type} CL_API_CALL CL_{name}({params})
|
||||
{return_type} CL_API_CALL cl{name}({params})
|
||||
{{
|
||||
CL_EVENT({name}, "{format_params}"{comma_if_needed}{pass_params});
|
||||
|
||||
|
@ -281,7 +277,7 @@ TEMPLATE_CL_ENTRY_POINT_WITH_RETURN_POINTER = """\
|
|||
|
||||
ANGLE_CL_VALIDATE_POINTER({name}{comma_if_needed}{internal_params});
|
||||
|
||||
return {return_cast}({name}({internal_params}));
|
||||
return {name}({internal_params});
|
||||
}}
|
||||
"""
|
||||
|
||||
|
@ -373,8 +369,7 @@ CONTEXT_DECL_FORMAT = """ {return_type} {name_lower_no_suffix}({internal_para
|
|||
TEMPLATE_CL_ENTRY_POINT_EXPORT = """\
|
||||
{return_type} CL_API_CALL cl{name}({params})
|
||||
{{
|
||||
EnsureCLLoaded();
|
||||
return cl_loader.cl{name}({internal_params});
|
||||
return cl::GetDispatch().cl{name}({internal_params});
|
||||
}}
|
||||
"""
|
||||
|
||||
|
@ -875,50 +870,8 @@ EGL_EXT_SOURCE_INCLUDES = """\
|
|||
using namespace egl;
|
||||
"""
|
||||
|
||||
LIBCL_EXPORT_INCLUDES_AND_PREAMBLE = """
|
||||
#include "cl_loader.h"
|
||||
|
||||
#include "anglebase/no_destructor.h"
|
||||
#include "common/system_utils.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
namespace
|
||||
{
|
||||
bool gLoaded = false;
|
||||
|
||||
std::unique_ptr<angle::Library> &EntryPointsLib()
|
||||
{
|
||||
static angle::base::NoDestructor<std::unique_ptr<angle::Library>> sEntryPointsLib;
|
||||
return *sEntryPointsLib;
|
||||
}
|
||||
|
||||
angle::GenericProc CL_API_CALL GlobalLoad(const char *symbol)
|
||||
{
|
||||
return reinterpret_cast<angle::GenericProc>(EntryPointsLib()->getSymbol(symbol));
|
||||
}
|
||||
|
||||
void EnsureCLLoaded()
|
||||
{
|
||||
if (gLoaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntryPointsLib().reset(
|
||||
angle::OpenSharedLibrary(ANGLE_GLESV2_LIBRARY_NAME, angle::SearchType::ApplicationDir));
|
||||
angle::LoadCL(GlobalLoad);
|
||||
if (!cl_loader.clGetDeviceIDs)
|
||||
{
|
||||
std::cerr << "Error loading CL entry points." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
gLoaded = true;
|
||||
}
|
||||
}
|
||||
} // anonymous namespace
|
||||
LIBCL_EXPORT_INCLUDES = """
|
||||
#include "libOpenCL/dispatch.h"
|
||||
"""
|
||||
|
||||
LIBGLESV2_EXPORT_INCLUDES = """
|
||||
|
@ -1000,23 +953,15 @@ void EnsureEGLLoaded() {}
|
|||
"""
|
||||
|
||||
LIBCL_HEADER_INCLUDES = """\
|
||||
#include "export.h"
|
||||
|
||||
#ifndef CL_API_ENTRY
|
||||
# define CL_API_ENTRY ANGLE_EXPORT
|
||||
#endif
|
||||
#include "angle_cl.h"
|
||||
"""
|
||||
|
||||
LIBCL_SOURCE_INCLUDES = """\
|
||||
#include "entry_points_cl_autogen.h"
|
||||
|
||||
#include "cl_stubs_autogen.h"
|
||||
#include "entry_points_cl_utils.h"
|
||||
#include "libGLESv2/entry_points_cl_autogen.h"
|
||||
|
||||
#include "libANGLE/validationCL_autogen.h"
|
||||
|
||||
using namespace cl;
|
||||
#include "libGLESv2/cl_stubs_autogen.h"
|
||||
#include "libGLESv2/entry_points_cl_utils.h"
|
||||
"""
|
||||
|
||||
TEMPLATE_EVENT_COMMENT = """\
|
||||
|
@ -1292,10 +1237,18 @@ def is_aliasing_excepted(api, cmd_name):
|
|||
return api == apis.GLES and cmd_name in ALIASING_EXCEPTIONS
|
||||
|
||||
|
||||
def entry_point_export(api):
|
||||
if api == apis.CL:
|
||||
return ""
|
||||
return "ANGLE_EXPORT "
|
||||
|
||||
|
||||
def entry_point_prefix(api):
|
||||
if api == apis.CL:
|
||||
return "cl"
|
||||
if api == apis.GLES:
|
||||
return "GL"
|
||||
return api
|
||||
return "GL_"
|
||||
return api + "_"
|
||||
|
||||
|
||||
def get_api_entry_def(api):
|
||||
|
@ -1320,8 +1273,9 @@ def format_entry_point_decl(api, cmd_name, proto, params, is_explicit_context):
|
|||
comma_if_needed = ", " if len(params) > 0 else ""
|
||||
stripped = strip_api_prefix(cmd_name)
|
||||
return TEMPLATE_ENTRY_POINT_DECL.format(
|
||||
angle_export=entry_point_export(api),
|
||||
export_def=get_api_entry_def(api),
|
||||
name="%s_%s" % (entry_point_prefix(api), stripped),
|
||||
name="%s%s" % (entry_point_prefix(api), stripped),
|
||||
return_type=proto[:-len(cmd_name)].strip(),
|
||||
params=", ".join(params),
|
||||
comma_if_needed=comma_if_needed,
|
||||
|
@ -1571,7 +1525,6 @@ def format_entry_point_def(api, command_node, cmd_name, proto, params, is_explic
|
|||
pass_params = [param_print_argument(command_node, param) for param in params]
|
||||
format_params = [param_format_string(param) for param in params]
|
||||
return_type = proto[:-len(cmd_name)].strip()
|
||||
return_cast = "UnpackParam<" + return_type + ">" if return_type in packed_param_types else ""
|
||||
default_return = default_return_value(cmd_name, return_type)
|
||||
event_comment = TEMPLATE_EVENT_COMMENT if cmd_name in NO_EVENT_MARKER_EXCEPTIONS_LIST else ""
|
||||
name_lower_no_suffix = strip_suffix(api, cmd_name[2:3].lower() + cmd_name[3:])
|
||||
|
@ -1583,8 +1536,6 @@ def format_entry_point_def(api, command_node, cmd_name, proto, params, is_explic
|
|||
name_lower_no_suffix,
|
||||
"return_type":
|
||||
return_type,
|
||||
"return_cast":
|
||||
return_cast,
|
||||
"params":
|
||||
", ".join(params),
|
||||
"internal_params":
|
||||
|
@ -2696,6 +2647,10 @@ def main():
|
|||
all_commands_with_suffix.extend(xml.commands[version])
|
||||
|
||||
eps = GLEntryPoints(apis.GLES, xml, version_commands)
|
||||
eps.decls.insert(0, "extern \"C\" {")
|
||||
eps.decls.append("} // extern \"C\"")
|
||||
eps.defs.insert(0, "extern \"C\" {")
|
||||
eps.defs.append("} // extern \"C\"")
|
||||
|
||||
# Write the version as a comment before the first EP.
|
||||
libgles_ep_exports.append("\n ; OpenGL ES %s" % comment)
|
||||
|
@ -2735,8 +2690,8 @@ def main():
|
|||
write_capture_source(version, validation_annotation, comment, eps.capture_methods)
|
||||
|
||||
# After we finish with the main entry points, we process the extensions.
|
||||
extension_defs = []
|
||||
extension_decls = []
|
||||
extension_decls = ["extern \"C\" {"]
|
||||
extension_defs = ["extern \"C\" {"]
|
||||
extension_commands = []
|
||||
|
||||
# Accumulated validation prototypes.
|
||||
|
@ -2862,8 +2817,8 @@ def main():
|
|||
set([major for (major, minor) in registry_xml.DESKTOP_GL_VERSIONS])):
|
||||
is_major = lambda ver: ver[0] == major_version
|
||||
|
||||
ver_decls = []
|
||||
ver_defs = []
|
||||
ver_decls = ["extern \"C\" {"]
|
||||
ver_defs = ["extern \"C\" {"]
|
||||
validation_protos = []
|
||||
|
||||
for _, minor_version in filter(is_major, registry_xml.DESKTOP_GL_VERSIONS):
|
||||
|
@ -2905,6 +2860,8 @@ def main():
|
|||
ver_decls += [cpp_comment] + eps.decls
|
||||
ver_defs += [cpp_comment] + eps.defs
|
||||
|
||||
ver_decls.append("} // extern \"C\"")
|
||||
ver_defs.append("} // extern \"C\"")
|
||||
annotation = "GL_%d" % major_version
|
||||
name = "Desktop GL %s.x" % major_version
|
||||
|
||||
|
@ -2924,8 +2881,8 @@ def main():
|
|||
clxml = registry_xml.RegistryXML('cl.xml')
|
||||
|
||||
cl_validation_protos = []
|
||||
cl_decls = []
|
||||
cl_defs = []
|
||||
cl_decls = ["namespace cl\n{"]
|
||||
cl_defs = ["namespace cl\n{"]
|
||||
libcl_ep_defs = []
|
||||
libcl_windows_def_exports = []
|
||||
cl_commands = []
|
||||
|
@ -2958,6 +2915,9 @@ def main():
|
|||
cl_validation_protos += [comment] + eps.validation_protos
|
||||
libcl_windows_def_exports += [win_def_comment] + get_exports(clxml.commands[version])
|
||||
|
||||
cl_decls.append("} // namespace cl")
|
||||
cl_defs.append("} // namespace cl")
|
||||
|
||||
write_file("cl", "CL", TEMPLATE_ENTRY_POINT_HEADER, "\n".join(cl_decls), "h",
|
||||
LIBCL_HEADER_INCLUDES, "libGLESv2", "cl.xml")
|
||||
write_file("cl", "CL", TEMPLATE_ENTRY_POINT_SOURCE, "\n".join(cl_defs), "cpp",
|
||||
|
@ -2971,8 +2931,8 @@ def main():
|
|||
eglxml = registry_xml.RegistryXML('egl.xml', 'egl_angle_ext.xml')
|
||||
|
||||
egl_validation_protos = []
|
||||
egl_decls = []
|
||||
egl_defs = []
|
||||
egl_decls = ["extern \"C\" {"]
|
||||
egl_defs = ["extern \"C\" {"]
|
||||
libegl_ep_defs = []
|
||||
libegl_windows_def_exports = []
|
||||
egl_commands = []
|
||||
|
@ -3005,6 +2965,9 @@ def main():
|
|||
egl_validation_protos += [comment] + eps.validation_protos
|
||||
libegl_windows_def_exports += [win_def_comment] + get_exports(eglxml.commands[version])
|
||||
|
||||
egl_decls.append("} // extern \"C\"")
|
||||
egl_defs.append("} // extern \"C\"")
|
||||
|
||||
write_file("egl", "EGL", TEMPLATE_ENTRY_POINT_HEADER, "\n".join(egl_decls), "h",
|
||||
EGL_HEADER_INCLUDES, "libGLESv2", "egl.xml")
|
||||
write_file("egl", "EGL", TEMPLATE_ENTRY_POINT_SOURCE, "\n".join(egl_defs), "cpp",
|
||||
|
@ -3013,8 +2976,8 @@ def main():
|
|||
egl_commands, EGLEntryPoints.get_packed_enums(), EGL_PACKED_TYPES)
|
||||
|
||||
eglxml.AddExtensionCommands(registry_xml.supported_egl_extensions, ['egl'])
|
||||
egl_ext_decls = []
|
||||
egl_ext_defs = []
|
||||
egl_ext_decls = ["extern \"C\" {"]
|
||||
egl_ext_defs = ["extern \"C\" {"]
|
||||
egl_ext_commands = []
|
||||
|
||||
for extension_name, ext_cmd_names in sorted(eglxml.ext_data.items()):
|
||||
|
@ -3042,6 +3005,9 @@ def main():
|
|||
msg = "// %s is already defined.\n" % strip_api_prefix(dupe)
|
||||
egl_ext_defs.append(msg)
|
||||
|
||||
egl_ext_decls.append("} // extern \"C\"")
|
||||
egl_ext_defs.append("} // extern \"C\"")
|
||||
|
||||
write_file("egl_ext", "EGL Extension", TEMPLATE_ENTRY_POINT_HEADER, "\n".join(egl_ext_decls),
|
||||
"h", EGL_EXT_HEADER_INCLUDES, "libGLESv2", "egl.xml and egl_angle_ext.xml")
|
||||
write_file("egl_ext", "EGL Extension", TEMPLATE_ENTRY_POINT_SOURCE, "\n".join(egl_ext_defs),
|
||||
|
@ -3072,6 +3038,8 @@ def main():
|
|||
wgl_commands.remove("wglUseFontOutlines")
|
||||
|
||||
libgl_ep_exports += get_exports(wgl_commands)
|
||||
extension_decls.append("} // extern \"C\"")
|
||||
extension_defs.append("} // extern \"C\"")
|
||||
|
||||
write_file("gles_ext", "GLES extension", TEMPLATE_ENTRY_POINT_HEADER,
|
||||
"\n".join([item for item in extension_decls]), "h", GLES_EXT_HEADER_INCLUDES,
|
||||
|
@ -3133,8 +3101,8 @@ def main():
|
|||
write_export_files("\n".join([item for item in libegl_ep_defs]),
|
||||
LIBEGL_EXPORT_INCLUDES_AND_PREAMBLE, "egl.xml and egl_angle_ext.xml",
|
||||
"libEGL", "EGL")
|
||||
write_export_files("\n".join([item for item in libcl_ep_defs]),
|
||||
LIBCL_EXPORT_INCLUDES_AND_PREAMBLE, "cl.xml", "libOpenCL", "CL")
|
||||
write_export_files("\n".join([item for item in libcl_ep_defs]), LIBCL_EXPORT_INCLUDES,
|
||||
"cl.xml", "libOpenCL", "CL")
|
||||
|
||||
libgles_ep_exports += get_egl_exports()
|
||||
|
||||
|
|
|
@ -102,32 +102,6 @@ def write_source(data_source_name,
|
|||
out.close()
|
||||
|
||||
|
||||
def gen_libcl_loader():
|
||||
|
||||
xml = registry_xml.RegistryXML("cl.xml")
|
||||
for major_version, minor_version in registry_xml.CL_VERSIONS:
|
||||
name_prefix = "CL_VERSION_"
|
||||
annotation = "%d_%d" % (major_version, minor_version)
|
||||
feature_name = "%s%s" % (name_prefix, annotation)
|
||||
xml.AddCommands(feature_name, annotation)
|
||||
all_cmds = xml.all_cmd_names.get_all_commands()
|
||||
|
||||
path = os.path.join("..", "src", "libOpenCL")
|
||||
source_path = registry_xml.path_to(path, "cl_loader_autogen.cpp")
|
||||
|
||||
with open(source_path, "w") as out:
|
||||
setter = " cl_loader.%s = reinterpret_cast<cl_api_%s>(loadProc(\"CL_%s\"));"
|
||||
setters = [setter % (cmd, cmd, cmd[2:]) for cmd in all_cmds]
|
||||
|
||||
loader_source = template_cl_loader_cpp.format(
|
||||
script_name=os.path.basename(sys.argv[0]),
|
||||
data_source_name="cl.xml",
|
||||
set_pointers="\n".join(setters))
|
||||
|
||||
out.write(loader_source)
|
||||
out.close()
|
||||
|
||||
|
||||
def gen_libegl_loader():
|
||||
|
||||
data_source_name = "egl.xml and egl_angle_ext.xml"
|
||||
|
@ -294,7 +268,6 @@ def main():
|
|||
if len(sys.argv) > 1:
|
||||
inputs = registry_xml.xml_inputs
|
||||
outputs = [
|
||||
'../src/libOpenCL/cl_loader_autogen.cpp',
|
||||
'../src/libEGL/egl_loader_autogen.cpp',
|
||||
'../src/libEGL/egl_loader_autogen.h',
|
||||
'../util/egl_loader_autogen.cpp',
|
||||
|
@ -318,7 +291,6 @@ def main():
|
|||
return 1
|
||||
return 0
|
||||
|
||||
gen_libcl_loader()
|
||||
gen_libegl_loader()
|
||||
gen_util_gles_and_egl_loaders()
|
||||
gen_util_wgl_loader()
|
||||
|
@ -418,28 +390,5 @@ void {load_fn_name}(LoadProc loadProc)
|
|||
}} // namespace angle
|
||||
"""
|
||||
|
||||
template_cl_loader_cpp = """// GENERATED FILE - DO NOT EDIT.
|
||||
// Generated by {script_name} using data from {data_source_name}.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// cl_loader_autogen.cpp:
|
||||
// Simple CL function loader.
|
||||
|
||||
#include "cl_loader.h"
|
||||
|
||||
cl_icd_dispatch cl_loader;
|
||||
|
||||
namespace angle
|
||||
{{
|
||||
void LoadCL(LoadProc loadProc)
|
||||
{{
|
||||
{set_pointers}
|
||||
}}
|
||||
}} // namespace angle
|
||||
"""
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLCommandQueue.cpp: Implements the cl::CommandQueue class.
|
||||
|
||||
#include "libANGLE/CLCommandQueue.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
// TODO
|
||||
|
||||
CommandQueue::CommandQueue(const cl_icd_dispatch &dispatch) : _cl_command_queue(dispatch) {}
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,21 +3,22 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLCommandQueue.h: Defines the cl::CommandQueue class, which can be used to queue a set of OpenCL
|
||||
// operations.
|
||||
|
||||
#ifndef LIBANGLE_CLCOMMANDQUEUE_H_
|
||||
#define LIBANGLE_CLCOMMANDQUEUE_H_
|
||||
|
||||
#include "libANGLE/CLtypes.h"
|
||||
#include "libANGLE/CLObject.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
class CommandQueue final
|
||||
|
||||
class CommandQueue final : public _cl_command_queue, public Object
|
||||
{
|
||||
public:
|
||||
using IsCLObjectType = std::true_type;
|
||||
CommandQueue(const cl_icd_dispatch &dispatch);
|
||||
~CommandQueue() = default;
|
||||
};
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLContext.cpp: Implements the cl::Context class.
|
||||
|
||||
#include "libANGLE/CLContext.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
// TODO
|
||||
|
||||
Context::Context(const cl_icd_dispatch &dispatch) : _cl_context(dispatch) {}
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,21 +3,22 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLContext.h: Defines the cl::Context class, which manages OpenCL objects such as command-queues,
|
||||
// memory, program and kernel objects and for executing kernels on one or more devices.
|
||||
|
||||
#ifndef LIBANGLE_CLCONTEXT_H_
|
||||
#define LIBANGLE_CLCONTEXT_H_
|
||||
|
||||
#include "libANGLE/CLtypes.h"
|
||||
#include "libANGLE/CLObject.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
class Context final
|
||||
|
||||
class Context final : public _cl_context, public Object
|
||||
{
|
||||
public:
|
||||
using IsCLObjectType = std::true_type;
|
||||
Context(const cl_icd_dispatch &dispatch);
|
||||
~Context() = default;
|
||||
};
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLDevice.cpp: Implements the cl::Device class.
|
||||
|
||||
#include "libANGLE/CLDevice.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
// TODO
|
||||
|
||||
Device::Device(const cl_icd_dispatch &dispatch) : _cl_device_id(dispatch) {}
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,21 +3,22 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLDevice.h: Defines the cl::Device class, which provides information about OpenCL device
|
||||
// configurations.
|
||||
|
||||
#ifndef LIBANGLE_CLDEVICE_H_
|
||||
#define LIBANGLE_CLDEVICE_H_
|
||||
|
||||
#include "libANGLE/CLtypes.h"
|
||||
#include "libANGLE/CLObject.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
class Device final
|
||||
|
||||
class Device final : public _cl_device_id, public Object
|
||||
{
|
||||
public:
|
||||
using IsCLObjectType = std::true_type;
|
||||
Device(const cl_icd_dispatch &dispatch);
|
||||
~Device() = default;
|
||||
};
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLEvent.cpp: Implements the cl::Event class.
|
||||
|
||||
#include "libANGLE/CLEvent.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
// TODO
|
||||
|
||||
Event::Event(const cl_icd_dispatch &dispatch) : _cl_event(dispatch) {}
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,21 +3,22 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLEvent.h: Defines the cl::Event class, which can be used to track the execution status of an
|
||||
// OpenCL command.
|
||||
|
||||
#ifndef LIBANGLE_CLEVENT_H_
|
||||
#define LIBANGLE_CLEVENT_H_
|
||||
|
||||
#include "libANGLE/CLtypes.h"
|
||||
#include "libANGLE/CLObject.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
class Event final
|
||||
|
||||
class Event final : public _cl_event, public Object
|
||||
{
|
||||
public:
|
||||
using IsCLObjectType = std::true_type;
|
||||
Event(const cl_icd_dispatch &dispatch);
|
||||
~Event() = default;
|
||||
};
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLKernel.cpp: Implements the cl::Kernel class.
|
||||
|
||||
#include "libANGLE/CLKernel.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
// TODO
|
||||
|
||||
Kernel::Kernel(const cl_icd_dispatch &dispatch) : _cl_kernel(dispatch) {}
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,20 +3,21 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLKernel.h: Defines the cl::Kernel class, which is a function declared in an OpenCL program.
|
||||
|
||||
#ifndef LIBANGLE_CLKERNEL_H_
|
||||
#define LIBANGLE_CLKERNEL_H_
|
||||
|
||||
#include "libANGLE/CLtypes.h"
|
||||
#include "libANGLE/CLObject.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
class Kernel final
|
||||
|
||||
class Kernel final : public _cl_kernel, public Object
|
||||
{
|
||||
public:
|
||||
using IsCLObjectType = std::true_type;
|
||||
Kernel(const cl_icd_dispatch &dispatch);
|
||||
~Kernel() = default;
|
||||
};
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLMemory.cpp: Implements the cl::Memory class.
|
||||
|
||||
#include "libANGLE/CLMemory.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
// TODO
|
||||
|
||||
Memory::Memory(const cl_icd_dispatch &dispatch) : _cl_mem(dispatch) {}
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,21 +3,22 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLMemory.h: Defines the cl::Memory class, which is a memory object and represents OpenCL objects
|
||||
// such as buffers, images and pipes.
|
||||
|
||||
#ifndef LIBANGLE_CLMEMORY_H_
|
||||
#define LIBANGLE_CLMEMORY_H_
|
||||
|
||||
#include "libANGLE/CLtypes.h"
|
||||
#include "libANGLE/CLObject.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
class Memory final
|
||||
|
||||
class Memory final : public _cl_mem, public Object
|
||||
{
|
||||
public:
|
||||
using IsCLObjectType = std::true_type;
|
||||
Memory(const cl_icd_dispatch &dispatch);
|
||||
~Memory() = default;
|
||||
};
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// 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.
|
||||
//
|
||||
// CLObject.h: Defines the cl::Object class, which is the base class of all ANGLE CL objects.
|
||||
|
||||
#ifndef LIBANGLE_CLOBJECT_H_
|
||||
#define LIBANGLE_CLOBJECT_H_
|
||||
|
||||
#include "libANGLE/CLtypes.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
constexpr Object() {}
|
||||
~Object() = default;
|
||||
};
|
||||
|
||||
} // namespace cl
|
||||
|
||||
#endif // LIBANGLE_CLCONTEXT_H_
|
|
@ -3,12 +3,13 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLPlatform.cpp: Implements the cl::Platform class.
|
||||
|
||||
#include "libANGLE/CLPlatform.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
// TODO
|
||||
|
||||
Platform::Platform(const cl_icd_dispatch &dispatch) : _cl_platform_id(dispatch) {}
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,21 +3,22 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLPlatform.h: Defines the cl::Platform class, which provides information about platform-specific
|
||||
// OpenCL features.
|
||||
|
||||
#ifndef LIBANGLE_CLPLATFORM_H_
|
||||
#define LIBANGLE_CLPLATFORM_H_
|
||||
|
||||
#include "libANGLE/CLtypes.h"
|
||||
#include "libANGLE/CLObject.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
class Platform final
|
||||
|
||||
class Platform final : public _cl_platform_id, public Object
|
||||
{
|
||||
public:
|
||||
using IsCLObjectType = std::true_type;
|
||||
Platform(const cl_icd_dispatch &dispatch);
|
||||
~Platform() = default;
|
||||
};
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLProgram.cpp: Implements the cl::Program class.
|
||||
|
||||
#include "libANGLE/CLProgram.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
// TODO
|
||||
|
||||
Program::Program(const cl_icd_dispatch &dispatch) : _cl_program(dispatch) {}
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,20 +3,21 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLProgram.h: Defines the cl::Program class, which consists of a set of OpenCL kernels.
|
||||
|
||||
#ifndef LIBANGLE_CLPROGRAM_H_
|
||||
#define LIBANGLE_CLPROGRAM_H_
|
||||
|
||||
#include "libANGLE/CLtypes.h"
|
||||
#include "libANGLE/CLObject.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
class Program final
|
||||
|
||||
class Program final : public _cl_program, public Object
|
||||
{
|
||||
public:
|
||||
using IsCLObjectType = std::true_type;
|
||||
Program(const cl_icd_dispatch &dispatch);
|
||||
~Program() = default;
|
||||
};
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLSampler.cpp: Implements the cl::Sampler class.
|
||||
|
||||
#include "libANGLE/CLSampler.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
// TODO
|
||||
|
||||
Sampler::Sampler(const cl_icd_dispatch &dispatch) : _cl_sampler(dispatch) {}
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,20 +3,21 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLSampler.h: Defines the cl::Sampler class, which describes how to sample an OpenCL Image.
|
||||
|
||||
#ifndef LIBANGLE_CLSAMPLER_H_
|
||||
#define LIBANGLE_CLSAMPLER_H_
|
||||
|
||||
#include "libANGLE/CLtypes.h"
|
||||
#include "libANGLE/CLObject.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
class Sampler final
|
||||
|
||||
class Sampler final : public _cl_sampler, public Object
|
||||
{
|
||||
public:
|
||||
using IsCLObjectType = std::true_type;
|
||||
Sampler(const cl_icd_dispatch &dispatch);
|
||||
~Sampler() = default;
|
||||
};
|
||||
|
||||
} // namespace cl
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// CLtypes.h: Defines common types for the OpenCL support in ANGLE.
|
||||
|
||||
#ifndef LIBANGLE_CLTYPES_H_
|
||||
|
@ -11,7 +10,7 @@
|
|||
|
||||
#include "angle_cl.h"
|
||||
|
||||
#include <type_traits>
|
||||
#include <memory>
|
||||
|
||||
namespace cl
|
||||
{
|
||||
|
@ -21,6 +20,7 @@ class Device;
|
|||
class Event;
|
||||
class Kernel;
|
||||
class Memory;
|
||||
class Object;
|
||||
class Platform;
|
||||
class Program;
|
||||
class Sampler;
|
||||
|
|
|
@ -11,8 +11,6 @@ libangle_common_sources = [
|
|||
"src/common/MemoryBuffer.cpp",
|
||||
"src/common/MemoryBuffer.h",
|
||||
"src/common/Optional.h",
|
||||
"src/common/PackedCLEnums_autogen.cpp",
|
||||
"src/common/PackedCLEnums_autogen.h",
|
||||
"src/common/PackedEGLEnums_autogen.cpp",
|
||||
"src/common/PackedEGLEnums_autogen.h",
|
||||
"src/common/PackedEnums.cpp",
|
||||
|
@ -67,6 +65,11 @@ libangle_common_sources = [
|
|||
"src/common/vector_utils.h",
|
||||
]
|
||||
|
||||
libangle_common_cl_sources = [
|
||||
"src/common/PackedCLEnums_autogen.cpp",
|
||||
"src/common/PackedCLEnums_autogen.h",
|
||||
]
|
||||
|
||||
xxhash_sources = [
|
||||
"src/common/third_party/xxhash/xxhash.c",
|
||||
"src/common/third_party/xxhash/xxhash.h",
|
||||
|
@ -456,6 +459,7 @@ libangle_cl_headers = [
|
|||
"src/libANGLE/CLEvent.h",
|
||||
"src/libANGLE/CLKernel.h",
|
||||
"src/libANGLE/CLMemory.h",
|
||||
"src/libANGLE/CLObject.h",
|
||||
"src/libANGLE/CLPlatform.h",
|
||||
"src/libANGLE/CLProgram.h",
|
||||
"src/libANGLE/CLSampler.h",
|
||||
|
@ -577,6 +581,8 @@ libglesv2_sources = [
|
|||
]
|
||||
|
||||
libglesv2_cl_sources = [
|
||||
"src/libGLESv2/cl_dispatch_table.cpp",
|
||||
"src/libGLESv2/cl_dispatch_table.h",
|
||||
"src/libGLESv2/cl_stubs.cpp",
|
||||
"src/libGLESv2/cl_stubs_autogen.h",
|
||||
"src/libGLESv2/entry_points_cl_autogen.cpp",
|
||||
|
|
|
@ -0,0 +1,197 @@
|
|||
//
|
||||
// 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.
|
||||
//
|
||||
// cl_dispatch_table_autogen.cpp: Dispatch table for CL ICD Loader.
|
||||
|
||||
#include "libGLESv2/cl_dispatch_table.h"
|
||||
|
||||
#include "libGLESv2/entry_points_cl_autogen.h"
|
||||
|
||||
// clang-format off
|
||||
|
||||
// The correct order is required as defined in 'include/CL/cl_icd.h'.
|
||||
cl_icd_dispatch gCLIcdDispatchTable = {
|
||||
|
||||
// OpenCL 1.0
|
||||
cl::clGetPlatformIDs,
|
||||
cl::clGetPlatformInfo,
|
||||
cl::clGetDeviceIDs,
|
||||
cl::clGetDeviceInfo,
|
||||
cl::clCreateContext,
|
||||
cl::clCreateContextFromType,
|
||||
cl::clRetainContext,
|
||||
cl::clReleaseContext,
|
||||
cl::clGetContextInfo,
|
||||
cl::clCreateCommandQueue,
|
||||
cl::clRetainCommandQueue,
|
||||
cl::clReleaseCommandQueue,
|
||||
cl::clGetCommandQueueInfo,
|
||||
cl::clSetCommandQueueProperty,
|
||||
cl::clCreateBuffer,
|
||||
cl::clCreateImage2D,
|
||||
cl::clCreateImage3D,
|
||||
cl::clRetainMemObject,
|
||||
cl::clReleaseMemObject,
|
||||
cl::clGetSupportedImageFormats,
|
||||
cl::clGetMemObjectInfo,
|
||||
cl::clGetImageInfo,
|
||||
cl::clCreateSampler,
|
||||
cl::clRetainSampler,
|
||||
cl::clReleaseSampler,
|
||||
cl::clGetSamplerInfo,
|
||||
cl::clCreateProgramWithSource,
|
||||
cl::clCreateProgramWithBinary,
|
||||
cl::clRetainProgram,
|
||||
cl::clReleaseProgram,
|
||||
cl::clBuildProgram,
|
||||
cl::clUnloadCompiler,
|
||||
cl::clGetProgramInfo,
|
||||
cl::clGetProgramBuildInfo,
|
||||
cl::clCreateKernel,
|
||||
cl::clCreateKernelsInProgram,
|
||||
cl::clRetainKernel,
|
||||
cl::clReleaseKernel,
|
||||
cl::clSetKernelArg,
|
||||
cl::clGetKernelInfo,
|
||||
cl::clGetKernelWorkGroupInfo,
|
||||
cl::clWaitForEvents,
|
||||
cl::clGetEventInfo,
|
||||
cl::clRetainEvent,
|
||||
cl::clReleaseEvent,
|
||||
cl::clGetEventProfilingInfo,
|
||||
cl::clFlush,
|
||||
cl::clFinish,
|
||||
cl::clEnqueueReadBuffer,
|
||||
cl::clEnqueueWriteBuffer,
|
||||
cl::clEnqueueCopyBuffer,
|
||||
cl::clEnqueueReadImage,
|
||||
cl::clEnqueueWriteImage,
|
||||
cl::clEnqueueCopyImage,
|
||||
cl::clEnqueueCopyImageToBuffer,
|
||||
cl::clEnqueueCopyBufferToImage,
|
||||
cl::clEnqueueMapBuffer,
|
||||
cl::clEnqueueMapImage,
|
||||
cl::clEnqueueUnmapMemObject,
|
||||
cl::clEnqueueNDRangeKernel,
|
||||
cl::clEnqueueTask,
|
||||
cl::clEnqueueNativeKernel,
|
||||
cl::clEnqueueMarker,
|
||||
cl::clEnqueueWaitForEvents,
|
||||
cl::clEnqueueBarrier,
|
||||
cl::clGetExtensionFunctionAddress,
|
||||
nullptr, // clCreateFromGLBuffer,
|
||||
nullptr, // clCreateFromGLTexture2D,
|
||||
nullptr, // clCreateFromGLTexture3D,
|
||||
nullptr, // clCreateFromGLRenderbuffer,
|
||||
nullptr, // clGetGLObjectInfo,
|
||||
nullptr, // clGetGLTextureInfo,
|
||||
nullptr, // clEnqueueAcquireGLObjects,
|
||||
nullptr, // clEnqueueReleaseGLObjects,
|
||||
nullptr, // clGetGLContextInfoKHR,
|
||||
|
||||
// cl_khr_d3d10_sharing
|
||||
nullptr, // clGetDeviceIDsFromD3D10KHR,
|
||||
nullptr, // clCreateFromD3D10BufferKHR,
|
||||
nullptr, // clCreateFromD3D10Texture2DKHR,
|
||||
nullptr, // clCreateFromD3D10Texture3DKHR,
|
||||
nullptr, // clEnqueueAcquireD3D10ObjectsKHR,
|
||||
nullptr, // clEnqueueReleaseD3D10ObjectsKHR,
|
||||
|
||||
// OpenCL 1.1
|
||||
cl::clSetEventCallback,
|
||||
cl::clCreateSubBuffer,
|
||||
cl::clSetMemObjectDestructorCallback,
|
||||
cl::clCreateUserEvent,
|
||||
cl::clSetUserEventStatus,
|
||||
cl::clEnqueueReadBufferRect,
|
||||
cl::clEnqueueWriteBufferRect,
|
||||
cl::clEnqueueCopyBufferRect,
|
||||
|
||||
// cl_ext_device_fission
|
||||
nullptr, // clCreateSubDevicesEXT,
|
||||
nullptr, // clRetainDeviceEXT,
|
||||
nullptr, // clReleaseDeviceEXT,
|
||||
|
||||
// cl_khr_gl_event
|
||||
nullptr, // clCreateEventFromGLsyncKHR,
|
||||
|
||||
// OpenCL 1.2
|
||||
cl::clCreateSubDevices,
|
||||
cl::clRetainDevice,
|
||||
cl::clReleaseDevice,
|
||||
cl::clCreateImage,
|
||||
cl::clCreateProgramWithBuiltInKernels,
|
||||
cl::clCompileProgram,
|
||||
cl::clLinkProgram,
|
||||
cl::clUnloadPlatformCompiler,
|
||||
cl::clGetKernelArgInfo,
|
||||
cl::clEnqueueFillBuffer,
|
||||
cl::clEnqueueFillImage,
|
||||
cl::clEnqueueMigrateMemObjects,
|
||||
cl::clEnqueueMarkerWithWaitList,
|
||||
cl::clEnqueueBarrierWithWaitList,
|
||||
cl::clGetExtensionFunctionAddressForPlatform,
|
||||
nullptr, // clCreateFromGLTexture,
|
||||
|
||||
// cl_khr_d3d11_sharing
|
||||
nullptr, // clGetDeviceIDsFromD3D11KHR,
|
||||
nullptr, // clCreateFromD3D11BufferKHR,
|
||||
nullptr, // clCreateFromD3D11Texture2DKHR,
|
||||
nullptr, // clCreateFromD3D11Texture3DKHR,
|
||||
nullptr, // clCreateFromDX9MediaSurfaceKHR,
|
||||
nullptr, // clEnqueueAcquireD3D11ObjectsKHR,
|
||||
nullptr, // clEnqueueReleaseD3D11ObjectsKHR,
|
||||
|
||||
// cl_khr_dx9_media_sharing
|
||||
nullptr, // clGetDeviceIDsFromDX9MediaAdapterKHR,
|
||||
nullptr, // clEnqueueAcquireDX9MediaSurfacesKHR,
|
||||
nullptr, // clEnqueueReleaseDX9MediaSurfacesKHR,
|
||||
|
||||
// cl_khr_egl_image
|
||||
nullptr, // clCreateFromEGLImageKHR,
|
||||
nullptr, // clEnqueueAcquireEGLObjectsKHR,
|
||||
nullptr, // clEnqueueReleaseEGLObjectsKHR,
|
||||
|
||||
// cl_khr_egl_event
|
||||
nullptr, // clCreateEventFromEGLSyncKHR,
|
||||
|
||||
// OpenCL 2.0
|
||||
cl::clCreateCommandQueueWithProperties,
|
||||
cl::clCreatePipe,
|
||||
cl::clGetPipeInfo,
|
||||
cl::clSVMAlloc,
|
||||
cl::clSVMFree,
|
||||
cl::clEnqueueSVMFree,
|
||||
cl::clEnqueueSVMMemcpy,
|
||||
cl::clEnqueueSVMMemFill,
|
||||
cl::clEnqueueSVMMap,
|
||||
cl::clEnqueueSVMUnmap,
|
||||
cl::clCreateSamplerWithProperties,
|
||||
cl::clSetKernelArgSVMPointer,
|
||||
cl::clSetKernelExecInfo,
|
||||
|
||||
// cl_khr_sub_groups
|
||||
nullptr, // clGetKernelSubGroupInfoKHR,
|
||||
|
||||
// OpenCL 2.1
|
||||
cl::clCloneKernel,
|
||||
cl::clCreateProgramWithIL,
|
||||
cl::clEnqueueSVMMigrateMem,
|
||||
cl::clGetDeviceAndHostTimer,
|
||||
cl::clGetHostTimer,
|
||||
cl::clGetKernelSubGroupInfo,
|
||||
cl::clSetDefaultDeviceCommandQueue,
|
||||
|
||||
// OpenCL 2.2
|
||||
cl::clSetProgramReleaseCallback,
|
||||
cl::clSetProgramSpecializationConstant,
|
||||
|
||||
// OpenCL 3.0
|
||||
cl::clCreateBufferWithProperties,
|
||||
cl::clCreateImageWithProperties,
|
||||
cl::clSetContextDestructorCallback
|
||||
};
|
||||
|
||||
// clang-format on
|
|
@ -0,0 +1,20 @@
|
|||
//
|
||||
// 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.
|
||||
//
|
||||
// cl_dispatch_table.h: Declares dispatch table for CL ICD Loader.
|
||||
|
||||
#ifndef LIBGLESV2_CL_DISPATCH_TABLE_H_
|
||||
#define LIBGLESV2_CL_DISPATCH_TABLE_H_
|
||||
|
||||
#include "angle_cl.h"
|
||||
#include "export.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
ANGLE_EXPORT extern cl_icd_dispatch gCLIcdDispatchTable;
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif // LIBGLESV2_CL_DISPATCH_TABLE_H_
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -23,6 +23,7 @@
|
|||
|
||||
namespace cl
|
||||
{
|
||||
|
||||
// First case: handling packed enums.
|
||||
template <typename PackedT, typename FromT>
|
||||
typename std::enable_if_t<std::is_enum<PackedT>::value, PackedT> PackParam(FromT from)
|
||||
|
@ -30,30 +31,16 @@ typename std::enable_if_t<std::is_enum<PackedT>::value, PackedT> PackParam(FromT
|
|||
return FromCLenum<PackedT>(from);
|
||||
}
|
||||
|
||||
// Cast CL object types to ANGLE types marked with 'using IsCLObjectType = std::true_type;'
|
||||
// Cast CL object types to ANGLE CL object types
|
||||
template <typename PackedT, typename FromT>
|
||||
inline std::enable_if_t<
|
||||
std::remove_pointer_t<std::remove_pointer_t<PackedT>>::IsCLObjectType::value,
|
||||
std::is_base_of<cl::Object, std::remove_pointer_t<std::remove_pointer_t<PackedT>>>::value,
|
||||
PackedT>
|
||||
PackParam(FromT from)
|
||||
{
|
||||
return reinterpret_cast<PackedT>(from);
|
||||
}
|
||||
|
||||
// First case: handling packed enums.
|
||||
template <typename UnpackedT, typename FromT>
|
||||
typename std::enable_if_t<std::is_enum<FromT>::value, UnpackedT> UnpackParam(FromT from)
|
||||
{
|
||||
return ToCLenum(from);
|
||||
}
|
||||
|
||||
// Cast ANGLE types marked with 'using IsCLObjectType = std::true_type;' to CL object types
|
||||
template <typename UnpackedT, typename FromT>
|
||||
inline typename std::enable_if_t<std::remove_pointer_t<FromT>::IsCLObjectType::value, UnpackedT>
|
||||
UnpackParam(FromT from)
|
||||
{
|
||||
return reinterpret_cast<UnpackedT>(from);
|
||||
}
|
||||
} // namespace cl
|
||||
|
||||
#endif // LIBGLESV2_ENTRY_POINTS_CL_UTILS_H_
|
||||
|
|
|
@ -8,12 +8,12 @@ import("../../gni/angle.gni")
|
|||
|
||||
assert(angle_enable_cl)
|
||||
|
||||
angle_shared_library("OpenCL") {
|
||||
angle_shared_library("OpenCL_ANGLE") {
|
||||
defines = [ "LIBCL_IMPLEMENTATION" ]
|
||||
|
||||
sources = [
|
||||
"cl_loader.h",
|
||||
"cl_loader_autogen.cpp",
|
||||
"dispatch.cpp",
|
||||
"dispatch.h",
|
||||
"libOpenCL_autogen.cpp",
|
||||
]
|
||||
|
||||
|
@ -28,6 +28,29 @@ angle_shared_library("OpenCL") {
|
|||
]
|
||||
}
|
||||
|
||||
group("angle_cl") {
|
||||
data_deps = [ ":OpenCL" ]
|
||||
angle_shared_library("OpenCL_ICD_ANGLE") {
|
||||
defines = [ "LIBCL_IMPLEMENTATION" ]
|
||||
|
||||
sources = [
|
||||
"dispatch.cpp",
|
||||
"dispatch.h",
|
||||
"libOpenCL_ICD.cpp",
|
||||
]
|
||||
|
||||
configs += [
|
||||
"$angle_root:debug_annotations_config",
|
||||
"$angle_root:library_name_config",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"$angle_root:angle_common",
|
||||
"$angle_root:cl_includes",
|
||||
]
|
||||
}
|
||||
|
||||
group("angle_cl") {
|
||||
data_deps = [
|
||||
":OpenCL_ANGLE",
|
||||
":OpenCL_ICD_ANGLE",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
//
|
||||
// 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.
|
||||
//
|
||||
// cl_loader.h:
|
||||
// Simple CL function loader.
|
||||
|
||||
#ifndef LIBCL_CL_LOADER_H_
|
||||
#define LIBCL_CL_LOADER_H_
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#ifndef CL_API_ENTRY
|
||||
# define CL_API_ENTRY ANGLE_EXPORT
|
||||
#endif
|
||||
#include "angle_cl.h"
|
||||
|
||||
// 'angle_cl.h' has to be included before this to enable CL defines
|
||||
#include "CL/cl_icd.h"
|
||||
|
||||
ANGLE_NO_EXPORT extern cl_icd_dispatch cl_loader;
|
||||
|
||||
namespace angle
|
||||
{
|
||||
using GenericProc = void (*)();
|
||||
using LoadProc = GenericProc(CL_API_CALL *)(const char *);
|
||||
ANGLE_NO_EXPORT void LoadCL(LoadProc loadProc);
|
||||
} // namespace angle
|
||||
|
||||
#endif // LIBCL_CL_LOADER_H_
|
|
@ -1,235 +0,0 @@
|
|||
// GENERATED FILE - DO NOT EDIT.
|
||||
// Generated by generate_loader.py using data from cl.xml.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// cl_loader_autogen.cpp:
|
||||
// Simple CL function loader.
|
||||
|
||||
#include "cl_loader.h"
|
||||
|
||||
cl_icd_dispatch cl_loader;
|
||||
|
||||
namespace angle
|
||||
{
|
||||
void LoadCL(LoadProc loadProc)
|
||||
{
|
||||
cl_loader.clGetPlatformIDs =
|
||||
reinterpret_cast<cl_api_clGetPlatformIDs>(loadProc("CL_GetPlatformIDs"));
|
||||
cl_loader.clGetPlatformInfo =
|
||||
reinterpret_cast<cl_api_clGetPlatformInfo>(loadProc("CL_GetPlatformInfo"));
|
||||
cl_loader.clGetDeviceIDs = reinterpret_cast<cl_api_clGetDeviceIDs>(loadProc("CL_GetDeviceIDs"));
|
||||
cl_loader.clGetDeviceInfo =
|
||||
reinterpret_cast<cl_api_clGetDeviceInfo>(loadProc("CL_GetDeviceInfo"));
|
||||
cl_loader.clCreateContext =
|
||||
reinterpret_cast<cl_api_clCreateContext>(loadProc("CL_CreateContext"));
|
||||
cl_loader.clCreateContextFromType =
|
||||
reinterpret_cast<cl_api_clCreateContextFromType>(loadProc("CL_CreateContextFromType"));
|
||||
cl_loader.clRetainContext =
|
||||
reinterpret_cast<cl_api_clRetainContext>(loadProc("CL_RetainContext"));
|
||||
cl_loader.clReleaseContext =
|
||||
reinterpret_cast<cl_api_clReleaseContext>(loadProc("CL_ReleaseContext"));
|
||||
cl_loader.clGetContextInfo =
|
||||
reinterpret_cast<cl_api_clGetContextInfo>(loadProc("CL_GetContextInfo"));
|
||||
cl_loader.clRetainCommandQueue =
|
||||
reinterpret_cast<cl_api_clRetainCommandQueue>(loadProc("CL_RetainCommandQueue"));
|
||||
cl_loader.clReleaseCommandQueue =
|
||||
reinterpret_cast<cl_api_clReleaseCommandQueue>(loadProc("CL_ReleaseCommandQueue"));
|
||||
cl_loader.clGetCommandQueueInfo =
|
||||
reinterpret_cast<cl_api_clGetCommandQueueInfo>(loadProc("CL_GetCommandQueueInfo"));
|
||||
cl_loader.clCreateBuffer = reinterpret_cast<cl_api_clCreateBuffer>(loadProc("CL_CreateBuffer"));
|
||||
cl_loader.clRetainMemObject =
|
||||
reinterpret_cast<cl_api_clRetainMemObject>(loadProc("CL_RetainMemObject"));
|
||||
cl_loader.clReleaseMemObject =
|
||||
reinterpret_cast<cl_api_clReleaseMemObject>(loadProc("CL_ReleaseMemObject"));
|
||||
cl_loader.clGetSupportedImageFormats = reinterpret_cast<cl_api_clGetSupportedImageFormats>(
|
||||
loadProc("CL_GetSupportedImageFormats"));
|
||||
cl_loader.clGetMemObjectInfo =
|
||||
reinterpret_cast<cl_api_clGetMemObjectInfo>(loadProc("CL_GetMemObjectInfo"));
|
||||
cl_loader.clGetImageInfo = reinterpret_cast<cl_api_clGetImageInfo>(loadProc("CL_GetImageInfo"));
|
||||
cl_loader.clRetainSampler =
|
||||
reinterpret_cast<cl_api_clRetainSampler>(loadProc("CL_RetainSampler"));
|
||||
cl_loader.clReleaseSampler =
|
||||
reinterpret_cast<cl_api_clReleaseSampler>(loadProc("CL_ReleaseSampler"));
|
||||
cl_loader.clGetSamplerInfo =
|
||||
reinterpret_cast<cl_api_clGetSamplerInfo>(loadProc("CL_GetSamplerInfo"));
|
||||
cl_loader.clCreateProgramWithSource =
|
||||
reinterpret_cast<cl_api_clCreateProgramWithSource>(loadProc("CL_CreateProgramWithSource"));
|
||||
cl_loader.clCreateProgramWithBinary =
|
||||
reinterpret_cast<cl_api_clCreateProgramWithBinary>(loadProc("CL_CreateProgramWithBinary"));
|
||||
cl_loader.clRetainProgram =
|
||||
reinterpret_cast<cl_api_clRetainProgram>(loadProc("CL_RetainProgram"));
|
||||
cl_loader.clReleaseProgram =
|
||||
reinterpret_cast<cl_api_clReleaseProgram>(loadProc("CL_ReleaseProgram"));
|
||||
cl_loader.clBuildProgram = reinterpret_cast<cl_api_clBuildProgram>(loadProc("CL_BuildProgram"));
|
||||
cl_loader.clGetProgramInfo =
|
||||
reinterpret_cast<cl_api_clGetProgramInfo>(loadProc("CL_GetProgramInfo"));
|
||||
cl_loader.clGetProgramBuildInfo =
|
||||
reinterpret_cast<cl_api_clGetProgramBuildInfo>(loadProc("CL_GetProgramBuildInfo"));
|
||||
cl_loader.clCreateKernel = reinterpret_cast<cl_api_clCreateKernel>(loadProc("CL_CreateKernel"));
|
||||
cl_loader.clCreateKernelsInProgram =
|
||||
reinterpret_cast<cl_api_clCreateKernelsInProgram>(loadProc("CL_CreateKernelsInProgram"));
|
||||
cl_loader.clRetainKernel = reinterpret_cast<cl_api_clRetainKernel>(loadProc("CL_RetainKernel"));
|
||||
cl_loader.clReleaseKernel =
|
||||
reinterpret_cast<cl_api_clReleaseKernel>(loadProc("CL_ReleaseKernel"));
|
||||
cl_loader.clSetKernelArg = reinterpret_cast<cl_api_clSetKernelArg>(loadProc("CL_SetKernelArg"));
|
||||
cl_loader.clGetKernelInfo =
|
||||
reinterpret_cast<cl_api_clGetKernelInfo>(loadProc("CL_GetKernelInfo"));
|
||||
cl_loader.clGetKernelWorkGroupInfo =
|
||||
reinterpret_cast<cl_api_clGetKernelWorkGroupInfo>(loadProc("CL_GetKernelWorkGroupInfo"));
|
||||
cl_loader.clWaitForEvents =
|
||||
reinterpret_cast<cl_api_clWaitForEvents>(loadProc("CL_WaitForEvents"));
|
||||
cl_loader.clGetEventInfo = reinterpret_cast<cl_api_clGetEventInfo>(loadProc("CL_GetEventInfo"));
|
||||
cl_loader.clRetainEvent = reinterpret_cast<cl_api_clRetainEvent>(loadProc("CL_RetainEvent"));
|
||||
cl_loader.clReleaseEvent = reinterpret_cast<cl_api_clReleaseEvent>(loadProc("CL_ReleaseEvent"));
|
||||
cl_loader.clGetEventProfilingInfo =
|
||||
reinterpret_cast<cl_api_clGetEventProfilingInfo>(loadProc("CL_GetEventProfilingInfo"));
|
||||
cl_loader.clFlush = reinterpret_cast<cl_api_clFlush>(loadProc("CL_Flush"));
|
||||
cl_loader.clFinish = reinterpret_cast<cl_api_clFinish>(loadProc("CL_Finish"));
|
||||
cl_loader.clEnqueueReadBuffer =
|
||||
reinterpret_cast<cl_api_clEnqueueReadBuffer>(loadProc("CL_EnqueueReadBuffer"));
|
||||
cl_loader.clEnqueueWriteBuffer =
|
||||
reinterpret_cast<cl_api_clEnqueueWriteBuffer>(loadProc("CL_EnqueueWriteBuffer"));
|
||||
cl_loader.clEnqueueCopyBuffer =
|
||||
reinterpret_cast<cl_api_clEnqueueCopyBuffer>(loadProc("CL_EnqueueCopyBuffer"));
|
||||
cl_loader.clEnqueueReadImage =
|
||||
reinterpret_cast<cl_api_clEnqueueReadImage>(loadProc("CL_EnqueueReadImage"));
|
||||
cl_loader.clEnqueueWriteImage =
|
||||
reinterpret_cast<cl_api_clEnqueueWriteImage>(loadProc("CL_EnqueueWriteImage"));
|
||||
cl_loader.clEnqueueCopyImage =
|
||||
reinterpret_cast<cl_api_clEnqueueCopyImage>(loadProc("CL_EnqueueCopyImage"));
|
||||
cl_loader.clEnqueueCopyImageToBuffer = reinterpret_cast<cl_api_clEnqueueCopyImageToBuffer>(
|
||||
loadProc("CL_EnqueueCopyImageToBuffer"));
|
||||
cl_loader.clEnqueueCopyBufferToImage = reinterpret_cast<cl_api_clEnqueueCopyBufferToImage>(
|
||||
loadProc("CL_EnqueueCopyBufferToImage"));
|
||||
cl_loader.clEnqueueMapBuffer =
|
||||
reinterpret_cast<cl_api_clEnqueueMapBuffer>(loadProc("CL_EnqueueMapBuffer"));
|
||||
cl_loader.clEnqueueMapImage =
|
||||
reinterpret_cast<cl_api_clEnqueueMapImage>(loadProc("CL_EnqueueMapImage"));
|
||||
cl_loader.clEnqueueUnmapMemObject =
|
||||
reinterpret_cast<cl_api_clEnqueueUnmapMemObject>(loadProc("CL_EnqueueUnmapMemObject"));
|
||||
cl_loader.clEnqueueNDRangeKernel =
|
||||
reinterpret_cast<cl_api_clEnqueueNDRangeKernel>(loadProc("CL_EnqueueNDRangeKernel"));
|
||||
cl_loader.clEnqueueNativeKernel =
|
||||
reinterpret_cast<cl_api_clEnqueueNativeKernel>(loadProc("CL_EnqueueNativeKernel"));
|
||||
cl_loader.clSetCommandQueueProperty =
|
||||
reinterpret_cast<cl_api_clSetCommandQueueProperty>(loadProc("CL_SetCommandQueueProperty"));
|
||||
cl_loader.clCreateImage2D =
|
||||
reinterpret_cast<cl_api_clCreateImage2D>(loadProc("CL_CreateImage2D"));
|
||||
cl_loader.clCreateImage3D =
|
||||
reinterpret_cast<cl_api_clCreateImage3D>(loadProc("CL_CreateImage3D"));
|
||||
cl_loader.clEnqueueMarker =
|
||||
reinterpret_cast<cl_api_clEnqueueMarker>(loadProc("CL_EnqueueMarker"));
|
||||
cl_loader.clEnqueueWaitForEvents =
|
||||
reinterpret_cast<cl_api_clEnqueueWaitForEvents>(loadProc("CL_EnqueueWaitForEvents"));
|
||||
cl_loader.clEnqueueBarrier =
|
||||
reinterpret_cast<cl_api_clEnqueueBarrier>(loadProc("CL_EnqueueBarrier"));
|
||||
cl_loader.clUnloadCompiler =
|
||||
reinterpret_cast<cl_api_clUnloadCompiler>(loadProc("CL_UnloadCompiler"));
|
||||
cl_loader.clGetExtensionFunctionAddress =
|
||||
reinterpret_cast<cl_api_clGetExtensionFunctionAddress>(
|
||||
loadProc("CL_GetExtensionFunctionAddress"));
|
||||
cl_loader.clCreateCommandQueue =
|
||||
reinterpret_cast<cl_api_clCreateCommandQueue>(loadProc("CL_CreateCommandQueue"));
|
||||
cl_loader.clCreateSampler =
|
||||
reinterpret_cast<cl_api_clCreateSampler>(loadProc("CL_CreateSampler"));
|
||||
cl_loader.clEnqueueTask = reinterpret_cast<cl_api_clEnqueueTask>(loadProc("CL_EnqueueTask"));
|
||||
cl_loader.clCreateSubBuffer =
|
||||
reinterpret_cast<cl_api_clCreateSubBuffer>(loadProc("CL_CreateSubBuffer"));
|
||||
cl_loader.clSetMemObjectDestructorCallback =
|
||||
reinterpret_cast<cl_api_clSetMemObjectDestructorCallback>(
|
||||
loadProc("CL_SetMemObjectDestructorCallback"));
|
||||
cl_loader.clCreateUserEvent =
|
||||
reinterpret_cast<cl_api_clCreateUserEvent>(loadProc("CL_CreateUserEvent"));
|
||||
cl_loader.clSetUserEventStatus =
|
||||
reinterpret_cast<cl_api_clSetUserEventStatus>(loadProc("CL_SetUserEventStatus"));
|
||||
cl_loader.clSetEventCallback =
|
||||
reinterpret_cast<cl_api_clSetEventCallback>(loadProc("CL_SetEventCallback"));
|
||||
cl_loader.clEnqueueReadBufferRect =
|
||||
reinterpret_cast<cl_api_clEnqueueReadBufferRect>(loadProc("CL_EnqueueReadBufferRect"));
|
||||
cl_loader.clEnqueueWriteBufferRect =
|
||||
reinterpret_cast<cl_api_clEnqueueWriteBufferRect>(loadProc("CL_EnqueueWriteBufferRect"));
|
||||
cl_loader.clEnqueueCopyBufferRect =
|
||||
reinterpret_cast<cl_api_clEnqueueCopyBufferRect>(loadProc("CL_EnqueueCopyBufferRect"));
|
||||
cl_loader.clCreateSubDevices =
|
||||
reinterpret_cast<cl_api_clCreateSubDevices>(loadProc("CL_CreateSubDevices"));
|
||||
cl_loader.clRetainDevice = reinterpret_cast<cl_api_clRetainDevice>(loadProc("CL_RetainDevice"));
|
||||
cl_loader.clReleaseDevice =
|
||||
reinterpret_cast<cl_api_clReleaseDevice>(loadProc("CL_ReleaseDevice"));
|
||||
cl_loader.clCreateImage = reinterpret_cast<cl_api_clCreateImage>(loadProc("CL_CreateImage"));
|
||||
cl_loader.clCreateProgramWithBuiltInKernels =
|
||||
reinterpret_cast<cl_api_clCreateProgramWithBuiltInKernels>(
|
||||
loadProc("CL_CreateProgramWithBuiltInKernels"));
|
||||
cl_loader.clCompileProgram =
|
||||
reinterpret_cast<cl_api_clCompileProgram>(loadProc("CL_CompileProgram"));
|
||||
cl_loader.clLinkProgram = reinterpret_cast<cl_api_clLinkProgram>(loadProc("CL_LinkProgram"));
|
||||
cl_loader.clUnloadPlatformCompiler =
|
||||
reinterpret_cast<cl_api_clUnloadPlatformCompiler>(loadProc("CL_UnloadPlatformCompiler"));
|
||||
cl_loader.clGetKernelArgInfo =
|
||||
reinterpret_cast<cl_api_clGetKernelArgInfo>(loadProc("CL_GetKernelArgInfo"));
|
||||
cl_loader.clEnqueueFillBuffer =
|
||||
reinterpret_cast<cl_api_clEnqueueFillBuffer>(loadProc("CL_EnqueueFillBuffer"));
|
||||
cl_loader.clEnqueueFillImage =
|
||||
reinterpret_cast<cl_api_clEnqueueFillImage>(loadProc("CL_EnqueueFillImage"));
|
||||
cl_loader.clEnqueueMigrateMemObjects = reinterpret_cast<cl_api_clEnqueueMigrateMemObjects>(
|
||||
loadProc("CL_EnqueueMigrateMemObjects"));
|
||||
cl_loader.clEnqueueMarkerWithWaitList = reinterpret_cast<cl_api_clEnqueueMarkerWithWaitList>(
|
||||
loadProc("CL_EnqueueMarkerWithWaitList"));
|
||||
cl_loader.clEnqueueBarrierWithWaitList = reinterpret_cast<cl_api_clEnqueueBarrierWithWaitList>(
|
||||
loadProc("CL_EnqueueBarrierWithWaitList"));
|
||||
cl_loader.clGetExtensionFunctionAddressForPlatform =
|
||||
reinterpret_cast<cl_api_clGetExtensionFunctionAddressForPlatform>(
|
||||
loadProc("CL_GetExtensionFunctionAddressForPlatform"));
|
||||
cl_loader.clCreateCommandQueueWithProperties =
|
||||
reinterpret_cast<cl_api_clCreateCommandQueueWithProperties>(
|
||||
loadProc("CL_CreateCommandQueueWithProperties"));
|
||||
cl_loader.clCreatePipe = reinterpret_cast<cl_api_clCreatePipe>(loadProc("CL_CreatePipe"));
|
||||
cl_loader.clGetPipeInfo = reinterpret_cast<cl_api_clGetPipeInfo>(loadProc("CL_GetPipeInfo"));
|
||||
cl_loader.clSVMAlloc = reinterpret_cast<cl_api_clSVMAlloc>(loadProc("CL_SVMAlloc"));
|
||||
cl_loader.clSVMFree = reinterpret_cast<cl_api_clSVMFree>(loadProc("CL_SVMFree"));
|
||||
cl_loader.clCreateSamplerWithProperties =
|
||||
reinterpret_cast<cl_api_clCreateSamplerWithProperties>(
|
||||
loadProc("CL_CreateSamplerWithProperties"));
|
||||
cl_loader.clSetKernelArgSVMPointer =
|
||||
reinterpret_cast<cl_api_clSetKernelArgSVMPointer>(loadProc("CL_SetKernelArgSVMPointer"));
|
||||
cl_loader.clSetKernelExecInfo =
|
||||
reinterpret_cast<cl_api_clSetKernelExecInfo>(loadProc("CL_SetKernelExecInfo"));
|
||||
cl_loader.clEnqueueSVMFree =
|
||||
reinterpret_cast<cl_api_clEnqueueSVMFree>(loadProc("CL_EnqueueSVMFree"));
|
||||
cl_loader.clEnqueueSVMMemcpy =
|
||||
reinterpret_cast<cl_api_clEnqueueSVMMemcpy>(loadProc("CL_EnqueueSVMMemcpy"));
|
||||
cl_loader.clEnqueueSVMMemFill =
|
||||
reinterpret_cast<cl_api_clEnqueueSVMMemFill>(loadProc("CL_EnqueueSVMMemFill"));
|
||||
cl_loader.clEnqueueSVMMap =
|
||||
reinterpret_cast<cl_api_clEnqueueSVMMap>(loadProc("CL_EnqueueSVMMap"));
|
||||
cl_loader.clEnqueueSVMUnmap =
|
||||
reinterpret_cast<cl_api_clEnqueueSVMUnmap>(loadProc("CL_EnqueueSVMUnmap"));
|
||||
cl_loader.clSetDefaultDeviceCommandQueue =
|
||||
reinterpret_cast<cl_api_clSetDefaultDeviceCommandQueue>(
|
||||
loadProc("CL_SetDefaultDeviceCommandQueue"));
|
||||
cl_loader.clGetDeviceAndHostTimer =
|
||||
reinterpret_cast<cl_api_clGetDeviceAndHostTimer>(loadProc("CL_GetDeviceAndHostTimer"));
|
||||
cl_loader.clGetHostTimer = reinterpret_cast<cl_api_clGetHostTimer>(loadProc("CL_GetHostTimer"));
|
||||
cl_loader.clCreateProgramWithIL =
|
||||
reinterpret_cast<cl_api_clCreateProgramWithIL>(loadProc("CL_CreateProgramWithIL"));
|
||||
cl_loader.clCloneKernel = reinterpret_cast<cl_api_clCloneKernel>(loadProc("CL_CloneKernel"));
|
||||
cl_loader.clGetKernelSubGroupInfo =
|
||||
reinterpret_cast<cl_api_clGetKernelSubGroupInfo>(loadProc("CL_GetKernelSubGroupInfo"));
|
||||
cl_loader.clEnqueueSVMMigrateMem =
|
||||
reinterpret_cast<cl_api_clEnqueueSVMMigrateMem>(loadProc("CL_EnqueueSVMMigrateMem"));
|
||||
cl_loader.clSetProgramSpecializationConstant =
|
||||
reinterpret_cast<cl_api_clSetProgramSpecializationConstant>(
|
||||
loadProc("CL_SetProgramSpecializationConstant"));
|
||||
cl_loader.clSetProgramReleaseCallback = reinterpret_cast<cl_api_clSetProgramReleaseCallback>(
|
||||
loadProc("CL_SetProgramReleaseCallback"));
|
||||
cl_loader.clSetContextDestructorCallback =
|
||||
reinterpret_cast<cl_api_clSetContextDestructorCallback>(
|
||||
loadProc("CL_SetContextDestructorCallback"));
|
||||
cl_loader.clCreateBufferWithProperties = reinterpret_cast<cl_api_clCreateBufferWithProperties>(
|
||||
loadProc("CL_CreateBufferWithProperties"));
|
||||
cl_loader.clCreateImageWithProperties = reinterpret_cast<cl_api_clCreateImageWithProperties>(
|
||||
loadProc("CL_CreateImageWithProperties"));
|
||||
}
|
||||
} // namespace angle
|
|
@ -0,0 +1,54 @@
|
|||
//
|
||||
// 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.
|
||||
//
|
||||
// dispatch.cpp: Implements a function to fetch the ANGLE OpenCL dispatch table.
|
||||
|
||||
#include "libOpenCL/dispatch.h"
|
||||
|
||||
#include "anglebase/no_destructor.h"
|
||||
#include "common/system_utils.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
namespace cl
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
std::unique_ptr<angle::Library> &EntryPointsLib()
|
||||
{
|
||||
static angle::base::NoDestructor<std::unique_ptr<angle::Library>> sEntryPointsLib;
|
||||
return *sEntryPointsLib;
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
cl_icd_dispatch &GetDispatch()
|
||||
{
|
||||
static cl_icd_dispatch *sDispatch = nullptr;
|
||||
|
||||
if (sDispatch == nullptr)
|
||||
{
|
||||
EntryPointsLib().reset(
|
||||
angle::OpenSharedLibrary(ANGLE_GLESV2_LIBRARY_NAME, angle::SearchType::ApplicationDir));
|
||||
if (EntryPointsLib())
|
||||
{
|
||||
sDispatch = reinterpret_cast<cl_icd_dispatch *>(
|
||||
EntryPointsLib()->getSymbol("gCLIcdDispatchTable"));
|
||||
if (sDispatch == nullptr)
|
||||
{
|
||||
std::cerr << "Error loading CL dispatch table." << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Error opening GLESv2 library." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return *sDispatch;
|
||||
}
|
||||
|
||||
} // namespace cl
|
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// 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.
|
||||
//
|
||||
// dispatch.h: Declares a function to fetch the ANGLE OpenCL dispatch table.
|
||||
|
||||
#ifndef LIBOPENCL_DISPATCH_H_
|
||||
#define LIBOPENCL_DISPATCH_H_
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#ifndef CL_API_ENTRY
|
||||
# define CL_API_ENTRY ANGLE_EXPORT
|
||||
#endif
|
||||
#include "angle_cl.h"
|
||||
|
||||
namespace cl
|
||||
{
|
||||
|
||||
cl_icd_dispatch &GetDispatch();
|
||||
|
||||
} // namespace cl
|
||||
|
||||
#endif // LIBOPENCL_DISPATCH_H_
|
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// 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.
|
||||
//
|
||||
// libOpenCL_ICD.cpp: Implements the CL entry points required for extension cl_khr_icd.
|
||||
|
||||
#include "libOpenCL/dispatch.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
cl_int CL_API_CALL clIcdGetPlatformIDsKHR(cl_uint num_entries,
|
||||
cl_platform_id *platforms,
|
||||
cl_uint *num_platforms)
|
||||
{
|
||||
return cl::GetDispatch().clGetPlatformIDs(num_entries, platforms, num_platforms);
|
||||
}
|
||||
|
||||
cl_int CL_API_CALL clGetPlatformInfo(cl_platform_id platform,
|
||||
cl_platform_info param_name,
|
||||
size_t param_value_size,
|
||||
void *param_value,
|
||||
size_t *param_value_size_ret)
|
||||
{
|
||||
return cl::GetDispatch().clGetPlatformInfo(platform, param_name, param_value_size, param_value,
|
||||
param_value_size_ret);
|
||||
}
|
||||
|
||||
void *CL_API_CALL clGetExtensionFunctionAddress(const char *func_name)
|
||||
{
|
||||
return cl::GetDispatch().clGetExtensionFunctionAddress(func_name);
|
||||
}
|
||||
|
||||
} // extern "C"
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче