Commit cddb2003 by John Plate Committed by Commit Bot

Stubs for CL validation entry points

Bug: angleproject:5775 Change-Id: Ic3b15efdf602bad8f5f170f03ba24b421a398ca8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2848504Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: John Plate <jplate@google.com>
parent e1201106
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"scripts/entry_point_packed_gl_enums.json": "scripts/entry_point_packed_gl_enums.json":
"4f7b43863a5e61991bba4010db463679", "4f7b43863a5e61991bba4010db463679",
"scripts/generate_entry_points.py": "scripts/generate_entry_points.py":
"992b715af193e3c5667e6c2b3240d4e6", "ce49f151aac3d4a163686d7e45bcb03e",
"scripts/gl.xml": "scripts/gl.xml":
"2a73a58a7e26d8676a2c0af6d528cae6", "2a73a58a7e26d8676a2c0af6d528cae6",
"scripts/gl_angle_ext.xml": "scripts/gl_angle_ext.xml":
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
"scripts/wgl.xml": "scripts/wgl.xml":
"c36001431919e1c435f1215a85f7e1db", "c36001431919e1c435f1215a85f7e1db",
"src/common/entry_points_enum_autogen.cpp": "src/common/entry_points_enum_autogen.cpp":
"8c07f579466a1a57fa6689f7ebc6dfae", "f44e96c3297ed6787434ae7ee02596af",
"src/common/entry_points_enum_autogen.h": "src/common/entry_points_enum_autogen.h":
"62145e8368def39a9c1dc26d000c9795", "9db537e91358777907a2bba88ee98be5",
"src/libANGLE/Context_gl_1_autogen.h": "src/libANGLE/Context_gl_1_autogen.h":
"6be1391ee21b3754d9e9c512255d4c5d", "6be1391ee21b3754d9e9c512255d4c5d",
"src/libANGLE/Context_gl_2_autogen.h": "src/libANGLE/Context_gl_2_autogen.h":
...@@ -73,6 +73,8 @@ ...@@ -73,6 +73,8 @@
"dfad80f141010395be7d0ca59ef8ee7a", "dfad80f141010395be7d0ca59ef8ee7a",
"src/libANGLE/capture/frame_capture_utils_autogen.h": "src/libANGLE/capture/frame_capture_utils_autogen.h":
"4405cac61b4f79b893bd40c7fc452397", "4405cac61b4f79b893bd40c7fc452397",
"src/libANGLE/validationCL_autogen.h":
"9b030d9bb634fdd7f38b28b2dc25e0f0",
"src/libANGLE/validationEGL_autogen.h": "src/libANGLE/validationEGL_autogen.h":
"3927fa260ad183fd9193d65b3f8d82c5", "3927fa260ad183fd9193d65b3f8d82c5",
"src/libANGLE/validationES1_autogen.h": "src/libANGLE/validationES1_autogen.h":
...@@ -120,7 +122,7 @@ ...@@ -120,7 +122,7 @@
"src/libGL/libGL_autogen.def": "src/libGL/libGL_autogen.def":
"2789d87b05eea9f53d52e2aff499b785", "2789d87b05eea9f53d52e2aff499b785",
"src/libGLESv2/cl_stubs_autogen.h": "src/libGLESv2/cl_stubs_autogen.h":
"3757cdaee900021bc14c21e97bd91d50", "93e4a07e582d3ee0955d1e82bc43dd9b",
"src/libGLESv2/egl_ext_stubs_autogen.h": "src/libGLESv2/egl_ext_stubs_autogen.h":
"2ef3b8d087f2a97f7270b96077c93856", "2ef3b8d087f2a97f7270b96077c93856",
"src/libGLESv2/egl_get_labeled_object_data.json": "src/libGLESv2/egl_get_labeled_object_data.json":
...@@ -128,7 +130,7 @@ ...@@ -128,7 +130,7 @@
"src/libGLESv2/egl_stubs_autogen.h": "src/libGLESv2/egl_stubs_autogen.h":
"6439daa350c1663e71dd0af37dcc91df", "6439daa350c1663e71dd0af37dcc91df",
"src/libGLESv2/entry_points_cl_autogen.cpp": "src/libGLESv2/entry_points_cl_autogen.cpp":
"e9310db2512fb91852dc8834717d4209", "2c43ce51701c4499003638fa30de340e",
"src/libGLESv2/entry_points_cl_autogen.h": "src/libGLESv2/entry_points_cl_autogen.h":
"129fa7936c8bc6a20de9269da0c3c7d3", "129fa7936c8bc6a20de9269da0c3c7d3",
"src/libGLESv2/entry_points_egl_autogen.cpp": "src/libGLESv2/entry_points_egl_autogen.cpp":
......
...@@ -253,22 +253,35 @@ void CL_API_CALL CL_{name}({params}) ...@@ -253,22 +253,35 @@ void CL_API_CALL CL_{name}({params})
{packed_gl_enum_conversions} {packed_gl_enum_conversions}
// TODO: validate ANGLE_CL_VALIDATE_VOID({name}{comma_if_needed}{internal_params});
cl::{name}({internal_params}); {name}({internal_params});
}} }}
""" """
TEMPLATE_CL_ENTRY_POINT_WITH_RETURN = """\ TEMPLATE_CL_ENTRY_POINT_WITH_RETURN_ERROR = """\
cl_int CL_API_CALL CL_{name}({params})
{{
CL_EVENT({name}, "{format_params}"{comma_if_needed}{pass_params});
{packed_gl_enum_conversions}
ANGLE_CL_VALIDATE_ERROR({name}{comma_if_needed}{internal_params});
return {return_cast}({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}); CL_EVENT({name}, "{format_params}"{comma_if_needed}{pass_params});
{packed_gl_enum_conversions} {packed_gl_enum_conversions}
// TODO: validate ANGLE_CL_VALIDATE_POINTER({name}{comma_if_needed}{internal_params});
return {return_cast}(cl::{name}({internal_params})); return {return_cast}({name}({internal_params}));
}} }}
""" """
...@@ -285,22 +298,12 @@ TEMPLATE_CL_STUBS_HEADER = """\ ...@@ -285,22 +298,12 @@ TEMPLATE_CL_STUBS_HEADER = """\
#ifndef LIBGLESV2_{annotation_upper}_STUBS_AUTOGEN_H_ #ifndef LIBGLESV2_{annotation_upper}_STUBS_AUTOGEN_H_
#define LIBGLESV2_{annotation_upper}_STUBS_AUTOGEN_H_ #define LIBGLESV2_{annotation_upper}_STUBS_AUTOGEN_H_
#include "angle_cl.h" #include "libANGLE/CLtypes.h"
#include "common/PackedCLEnums_autogen.h" #include "common/PackedCLEnums_autogen.h"
namespace cl namespace cl
{{ {{
class CommandQueue;
class Context;
class Device;
class Event;
class Kernel;
class Memory;
class Platform;
class Program;
class Sampler;
{stubs} {stubs}
}} // namespace cl }} // namespace cl
#endif // LIBGLESV2_{annotation_upper}_STUBS_AUTOGEN_H_ #endif // LIBGLESV2_{annotation_upper}_STUBS_AUTOGEN_H_
...@@ -436,6 +439,30 @@ class Context; ...@@ -436,6 +439,30 @@ class Context;
#endif // LIBANGLE_VALIDATION_{annotation}_AUTOGEN_H_ #endif // LIBANGLE_VALIDATION_{annotation}_AUTOGEN_H_
""" """
TEMPLATE_CL_VALIDATION_HEADER = """\
// 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.
//
// validation{annotation}_autogen.h:
// Validation functions for the {comment} entry points.
#ifndef LIBANGLE_VALIDATION_{annotation}_AUTOGEN_H_
#define LIBANGLE_VALIDATION_{annotation}_AUTOGEN_H_
#include "libANGLE/validationCL.h"
namespace cl
{{
{prototypes}
}} // namespace cl
#endif // LIBANGLE_VALIDATION_{annotation}_AUTOGEN_H_
"""
TEMPLATE_EGL_VALIDATION_HEADER = """\ TEMPLATE_EGL_VALIDATION_HEADER = """\
// GENERATED FILE - DO NOT EDIT. // GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}. // Generated by {script_name} using data from {data_source_name}.
...@@ -986,7 +1013,8 @@ LIBCL_SOURCE_INCLUDES = """\ ...@@ -986,7 +1013,8 @@ LIBCL_SOURCE_INCLUDES = """\
#include "cl_stubs_autogen.h" #include "cl_stubs_autogen.h"
#include "entry_points_cl_utils.h" #include "entry_points_cl_utils.h"
#include "validationCL.h"
#include "libANGLE/validationCL_autogen.h"
using namespace cl; using namespace cl;
""" """
...@@ -998,7 +1026,7 @@ TEMPLATE_EVENT_COMMENT = """\ ...@@ -998,7 +1026,7 @@ TEMPLATE_EVENT_COMMENT = """\
TEMPLATE_CAPTURE_PROTO = "angle::CallCapture Capture%s(%s);" TEMPLATE_CAPTURE_PROTO = "angle::CallCapture Capture%s(%s);"
TEMPLATE_VALIDATION_PROTO = "bool Validate%s(%s);" TEMPLATE_VALIDATION_PROTO = "%s Validate%s(%s);"
TEMPLATE_WINDOWS_DEF_FILE = """\ TEMPLATE_WINDOWS_DEF_FILE = """\
; GENERATED FILE - DO NOT EDIT. ; GENERATED FILE - DO NOT EDIT.
...@@ -1507,18 +1535,20 @@ def get_packed_enums(api, cmd_packed_gl_enums, cmd_name, packed_param_types, par ...@@ -1507,18 +1535,20 @@ def get_packed_enums(api, cmd_packed_gl_enums, cmd_name, packed_param_types, par
def get_def_template(api, return_type): def get_def_template(api, return_type):
if return_type.strip() == "void": if return_type == "void":
if api == apis.EGL: if api == apis.EGL:
return TEMPLATE_EGL_ENTRY_POINT_NO_RETURN return TEMPLATE_EGL_ENTRY_POINT_NO_RETURN
elif api == apis.CL: elif api == apis.CL:
return TEMPLATE_CL_ENTRY_POINT_NO_RETURN return TEMPLATE_CL_ENTRY_POINT_NO_RETURN
else: else:
return TEMPLATE_GLES_ENTRY_POINT_NO_RETURN return TEMPLATE_GLES_ENTRY_POINT_NO_RETURN
elif return_type == "cl_int":
return TEMPLATE_CL_ENTRY_POINT_WITH_RETURN_ERROR
else: else:
if api == apis.EGL: if api == apis.EGL:
return TEMPLATE_EGL_ENTRY_POINT_WITH_RETURN return TEMPLATE_EGL_ENTRY_POINT_WITH_RETURN
elif api == apis.CL: elif api == apis.CL:
return TEMPLATE_CL_ENTRY_POINT_WITH_RETURN return TEMPLATE_CL_ENTRY_POINT_WITH_RETURN_POINTER
else: else:
return TEMPLATE_GLES_ENTRY_POINT_WITH_RETURN return TEMPLATE_GLES_ENTRY_POINT_WITH_RETURN
...@@ -1675,10 +1705,12 @@ def format_capture_method(api, command, cmd_name, proto, params, all_param_types ...@@ -1675,10 +1705,12 @@ def format_capture_method(api, command, cmd_name, proto, params, all_param_types
def const_pointer_type(param, packed_gl_enums): def const_pointer_type(param, packed_gl_enums):
type = just_the_type_packed(param, packed_gl_enums) type = just_the_type_packed(param, packed_gl_enums)
if "**" in type and "const" not in type: if just_the_name(param) == "errcode_ret" or "(" in type:
return type
elif "**" in type and "const" not in type:
return type.replace("**", "* const *") return type.replace("**", "* const *")
elif "*" in type and "const" not in type: elif "*" in type and "const" not in type:
return "const " + type return type.replace("*", "*const ") if "[]" in type else "const " + type
else: else:
return type return type
...@@ -1736,7 +1768,11 @@ def format_entry_point_export(cmd_name, proto, params, is_explicit_context, temp ...@@ -1736,7 +1768,11 @@ def format_entry_point_export(cmd_name, proto, params, is_explicit_context, temp
explicit_context_internal_param="ctx" if is_explicit_context else "") explicit_context_internal_param="ctx" if is_explicit_context else "")
def format_validation_proto(api, cmd_name, params, cmd_packed_gl_enums, packed_param_types): def format_validation_proto(api, cmd_name, proto, params, cmd_packed_gl_enums, packed_param_types):
if api == apis.CL:
return_type = "cl_int" if proto[:-len(cmd_name)].strip() == "cl_int" else "bool"
else:
return_type = "bool"
if api in [apis.GL, apis.GLES]: if api in [apis.GL, apis.GLES]:
with_extra_params = ["Context *context"] + params with_extra_params = ["Context *context"] + params
elif api == apis.EGL: elif api == apis.EGL:
...@@ -1745,7 +1781,7 @@ def format_validation_proto(api, cmd_name, params, cmd_packed_gl_enums, packed_p ...@@ -1745,7 +1781,7 @@ def format_validation_proto(api, cmd_name, params, cmd_packed_gl_enums, packed_p
with_extra_params = params with_extra_params = params
internal_params = get_validation_params(api, cmd_name, with_extra_params, cmd_packed_gl_enums, internal_params = get_validation_params(api, cmd_name, with_extra_params, cmd_packed_gl_enums,
packed_param_types) packed_param_types)
return TEMPLATE_VALIDATION_PROTO % (strip_api_prefix(cmd_name), internal_params) return TEMPLATE_VALIDATION_PROTO % (return_type, strip_api_prefix(cmd_name), internal_params)
def format_capture_proto(api, cmd_name, proto, params, cmd_packed_gl_enums, packed_param_types): def format_capture_proto(api, cmd_name, proto, params, cmd_packed_gl_enums, packed_param_types):
...@@ -1798,8 +1834,8 @@ class ANGLEEntryPoints(registry_xml.EntryPoints): ...@@ -1798,8 +1834,8 @@ class ANGLEEntryPoints(registry_xml.EntryPoints):
export_template)) export_template))
self.validation_protos.append( self.validation_protos.append(
format_validation_proto(self.api, cmd_name, param_text, cmd_packed_enums, format_validation_proto(self.api, cmd_name, proto_text, param_text,
packed_param_types)) cmd_packed_enums, packed_param_types))
self.capture_protos.append( self.capture_protos.append(
format_capture_proto(self.api, cmd_name, proto_text, param_text, cmd_packed_enums, format_capture_proto(self.api, cmd_name, proto_text, param_text, cmd_packed_enums,
packed_param_types)) packed_param_types))
...@@ -2566,6 +2602,7 @@ def main(): ...@@ -2566,6 +2602,7 @@ def main():
'../src/libANGLE/capture/frame_capture_replay_autogen.cpp', '../src/libANGLE/capture/frame_capture_replay_autogen.cpp',
'../src/libANGLE/capture/frame_capture_utils_autogen.cpp', '../src/libANGLE/capture/frame_capture_utils_autogen.cpp',
'../src/libANGLE/capture/frame_capture_utils_autogen.h', '../src/libANGLE/capture/frame_capture_utils_autogen.h',
'../src/libANGLE/validationCL_autogen.h',
'../src/libANGLE/validationEGL_autogen.h', '../src/libANGLE/validationEGL_autogen.h',
'../src/libANGLE/validationES1_autogen.h', '../src/libANGLE/validationES1_autogen.h',
'../src/libANGLE/validationES2_autogen.h', '../src/libANGLE/validationES2_autogen.h',
...@@ -2925,6 +2962,8 @@ def main(): ...@@ -2925,6 +2962,8 @@ def main():
LIBCL_HEADER_INCLUDES, "libGLESv2", "cl.xml") LIBCL_HEADER_INCLUDES, "libGLESv2", "cl.xml")
write_file("cl", "CL", TEMPLATE_ENTRY_POINT_SOURCE, "\n".join(cl_defs), "cpp", write_file("cl", "CL", TEMPLATE_ENTRY_POINT_SOURCE, "\n".join(cl_defs), "cpp",
LIBCL_SOURCE_INCLUDES, "libGLESv2", "cl.xml") LIBCL_SOURCE_INCLUDES, "libGLESv2", "cl.xml")
write_validation_header("CL", "CL", cl_validation_protos, "cl.xml",
TEMPLATE_CL_VALIDATION_HEADER)
write_stubs_header("CL", "cl", "CL", "cl.xml", CL_STUBS_HEADER_PATH, clxml.all_commands, write_stubs_header("CL", "cl", "CL", "cl.xml", CL_STUBS_HEADER_PATH, clxml.all_commands,
cl_commands, CLEntryPoints.get_packed_enums(), CL_PACKED_TYPES) cl_commands, CLEntryPoints.get_packed_enums(), CL_PACKED_TYPES)
...@@ -3050,14 +3089,16 @@ def main(): ...@@ -3050,14 +3089,16 @@ def main():
write_context_api_decls(desktop_gl_decls, "gl") write_context_api_decls(desktop_gl_decls, "gl")
# Entry point enum # Entry point enum
cl_cmd_names = [strip_api_prefix(cmd) for cmd in clxml.all_cmd_names.get_all_commands()]
egl_cmd_names = [strip_api_prefix(cmd) for cmd in eglxml.all_cmd_names.get_all_commands()] egl_cmd_names = [strip_api_prefix(cmd) for cmd in eglxml.all_cmd_names.get_all_commands()]
gles_cmd_names = ["Invalid" gles_cmd_names = ["Invalid"
] + [strip_api_prefix(cmd) for cmd in xml.all_cmd_names.get_all_commands()] ] + [strip_api_prefix(cmd) for cmd in xml.all_cmd_names.get_all_commands()]
gl_cmd_names = [strip_api_prefix(cmd) for cmd in glxml.all_cmd_names.get_all_commands()] gl_cmd_names = [strip_api_prefix(cmd) for cmd in glxml.all_cmd_names.get_all_commands()]
wgl_cmd_names = [strip_api_prefix(cmd) for cmd in wglxml.all_cmd_names.get_all_commands()] wgl_cmd_names = [strip_api_prefix(cmd) for cmd in wglxml.all_cmd_names.get_all_commands()]
unsorted_enums = [("EGL%s" % cmd, "egl%s" % cmd) for cmd in egl_cmd_names] + [ unsorted_enums = [("CL%s" % cmd, "cl%s" % cmd) for cmd in cl_cmd_names] + [
("GL%s" % cmd, "gl%s" % cmd) for cmd in set(gles_cmd_names + gl_cmd_names) ("EGL%s" % cmd, "egl%s" % cmd) for cmd in egl_cmd_names
] + [("WGL%s" % cmd, "wgl%s" % cmd) for cmd in wgl_cmd_names] ] + [("GL%s" % cmd, "gl%s" % cmd) for cmd in set(gles_cmd_names + gl_cmd_names)
] + [("WGL%s" % cmd, "wgl%s" % cmd) for cmd in wgl_cmd_names]
all_enums = sorted(unsorted_enums) all_enums = sorted(unsorted_enums)
entry_points_enum_header = TEMPLATE_ENTRY_POINTS_ENUM_HEADER.format( entry_points_enum_header = TEMPLATE_ENTRY_POINTS_ENUM_HEADER.format(
......
...@@ -15,6 +15,120 @@ namespace angle ...@@ -15,6 +15,120 @@ namespace angle
{ {
enum class EntryPoint enum class EntryPoint
{ {
CLBuildProgram,
CLCloneKernel,
CLCompileProgram,
CLCreateBuffer,
CLCreateBufferWithProperties,
CLCreateCommandQueue,
CLCreateCommandQueueWithProperties,
CLCreateContext,
CLCreateContextFromType,
CLCreateImage,
CLCreateImage2D,
CLCreateImage3D,
CLCreateImageWithProperties,
CLCreateKernel,
CLCreateKernelsInProgram,
CLCreatePipe,
CLCreateProgramWithBinary,
CLCreateProgramWithBuiltInKernels,
CLCreateProgramWithIL,
CLCreateProgramWithSource,
CLCreateSampler,
CLCreateSamplerWithProperties,
CLCreateSubBuffer,
CLCreateSubDevices,
CLCreateUserEvent,
CLEnqueueBarrier,
CLEnqueueBarrierWithWaitList,
CLEnqueueCopyBuffer,
CLEnqueueCopyBufferRect,
CLEnqueueCopyBufferToImage,
CLEnqueueCopyImage,
CLEnqueueCopyImageToBuffer,
CLEnqueueFillBuffer,
CLEnqueueFillImage,
CLEnqueueMapBuffer,
CLEnqueueMapImage,
CLEnqueueMarker,
CLEnqueueMarkerWithWaitList,
CLEnqueueMigrateMemObjects,
CLEnqueueNDRangeKernel,
CLEnqueueNativeKernel,
CLEnqueueReadBuffer,
CLEnqueueReadBufferRect,
CLEnqueueReadImage,
CLEnqueueSVMFree,
CLEnqueueSVMMap,
CLEnqueueSVMMemFill,
CLEnqueueSVMMemcpy,
CLEnqueueSVMMigrateMem,
CLEnqueueSVMUnmap,
CLEnqueueTask,
CLEnqueueUnmapMemObject,
CLEnqueueWaitForEvents,
CLEnqueueWriteBuffer,
CLEnqueueWriteBufferRect,
CLEnqueueWriteImage,
CLFinish,
CLFlush,
CLGetCommandQueueInfo,
CLGetContextInfo,
CLGetDeviceAndHostTimer,
CLGetDeviceIDs,
CLGetDeviceInfo,
CLGetEventInfo,
CLGetEventProfilingInfo,
CLGetExtensionFunctionAddress,
CLGetExtensionFunctionAddressForPlatform,
CLGetHostTimer,
CLGetImageInfo,
CLGetKernelArgInfo,
CLGetKernelInfo,
CLGetKernelSubGroupInfo,
CLGetKernelWorkGroupInfo,
CLGetMemObjectInfo,
CLGetPipeInfo,
CLGetPlatformIDs,
CLGetPlatformInfo,
CLGetProgramBuildInfo,
CLGetProgramInfo,
CLGetSamplerInfo,
CLGetSupportedImageFormats,
CLLinkProgram,
CLReleaseCommandQueue,
CLReleaseContext,
CLReleaseDevice,
CLReleaseEvent,
CLReleaseKernel,
CLReleaseMemObject,
CLReleaseProgram,
CLReleaseSampler,
CLRetainCommandQueue,
CLRetainContext,
CLRetainDevice,
CLRetainEvent,
CLRetainKernel,
CLRetainMemObject,
CLRetainProgram,
CLRetainSampler,
CLSVMAlloc,
CLSVMFree,
CLSetCommandQueueProperty,
CLSetContextDestructorCallback,
CLSetDefaultDeviceCommandQueue,
CLSetEventCallback,
CLSetKernelArg,
CLSetKernelArgSVMPointer,
CLSetKernelExecInfo,
CLSetMemObjectDestructorCallback,
CLSetProgramReleaseCallback,
CLSetProgramSpecializationConstant,
CLSetUserEventStatus,
CLUnloadCompiler,
CLUnloadPlatformCompiler,
CLWaitForEvents,
EGLBindAPI, EGLBindAPI,
EGLBindTexImage, EGLBindTexImage,
EGLChooseConfig, EGLChooseConfig,
......
...@@ -10,11 +10,14 @@ ...@@ -10,11 +10,14 @@
#ifndef LIBANGLE_CLCOMMANDQUEUE_H_ #ifndef LIBANGLE_CLCOMMANDQUEUE_H_
#define LIBANGLE_CLCOMMANDQUEUE_H_ #define LIBANGLE_CLCOMMANDQUEUE_H_
#include "libANGLE/CLtypes.h"
namespace cl namespace cl
{ {
class CommandQueue final class CommandQueue final
{ {
public: public:
using IsCLObjectType = std::true_type;
}; };
} // namespace cl } // namespace cl
......
...@@ -10,11 +10,14 @@ ...@@ -10,11 +10,14 @@
#ifndef LIBANGLE_CLCONTEXT_H_ #ifndef LIBANGLE_CLCONTEXT_H_
#define LIBANGLE_CLCONTEXT_H_ #define LIBANGLE_CLCONTEXT_H_
#include "libANGLE/CLtypes.h"
namespace cl namespace cl
{ {
class Context final class Context final
{ {
public: public:
using IsCLObjectType = std::true_type;
}; };
} // namespace cl } // namespace cl
......
...@@ -10,11 +10,14 @@ ...@@ -10,11 +10,14 @@
#ifndef LIBANGLE_CLDEVICE_H_ #ifndef LIBANGLE_CLDEVICE_H_
#define LIBANGLE_CLDEVICE_H_ #define LIBANGLE_CLDEVICE_H_
#include "libANGLE/CLtypes.h"
namespace cl namespace cl
{ {
class Device final class Device final
{ {
public: public:
using IsCLObjectType = std::true_type;
}; };
} // namespace cl } // namespace cl
......
...@@ -10,11 +10,14 @@ ...@@ -10,11 +10,14 @@
#ifndef LIBANGLE_CLEVENT_H_ #ifndef LIBANGLE_CLEVENT_H_
#define LIBANGLE_CLEVENT_H_ #define LIBANGLE_CLEVENT_H_
#include "libANGLE/CLtypes.h"
namespace cl namespace cl
{ {
class Event final class Event final
{ {
public: public:
using IsCLObjectType = std::true_type;
}; };
} // namespace cl } // namespace cl
......
...@@ -9,11 +9,14 @@ ...@@ -9,11 +9,14 @@
#ifndef LIBANGLE_CLKERNEL_H_ #ifndef LIBANGLE_CLKERNEL_H_
#define LIBANGLE_CLKERNEL_H_ #define LIBANGLE_CLKERNEL_H_
#include "libANGLE/CLtypes.h"
namespace cl namespace cl
{ {
class Kernel final class Kernel final
{ {
public: public:
using IsCLObjectType = std::true_type;
}; };
} // namespace cl } // namespace cl
......
...@@ -4,17 +4,20 @@ ...@@ -4,17 +4,20 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// CLMemory.h: Defines the cl::Memory class, which is a memory object and the base class for OpenCL // CLMemory.h: Defines the cl::Memory class, which is a memory object and represents OpenCL objects
// objects such as Buffer, Image and Pipe. // such as buffers, images and pipes.
#ifndef LIBANGLE_CLMEMORY_H_ #ifndef LIBANGLE_CLMEMORY_H_
#define LIBANGLE_CLMEMORY_H_ #define LIBANGLE_CLMEMORY_H_
#include "libANGLE/CLtypes.h"
namespace cl namespace cl
{ {
class Memory final class Memory final
{ {
public: public:
using IsCLObjectType = std::true_type;
}; };
} // namespace cl } // namespace cl
......
...@@ -10,11 +10,14 @@ ...@@ -10,11 +10,14 @@
#ifndef LIBANGLE_CLPLATFORM_H_ #ifndef LIBANGLE_CLPLATFORM_H_
#define LIBANGLE_CLPLATFORM_H_ #define LIBANGLE_CLPLATFORM_H_
#include "libANGLE/CLtypes.h"
namespace cl namespace cl
{ {
class Platform final class Platform final
{ {
public: public:
using IsCLObjectType = std::true_type;
}; };
} // namespace cl } // namespace cl
......
...@@ -9,11 +9,14 @@ ...@@ -9,11 +9,14 @@
#ifndef LIBANGLE_CLPROGRAM_H_ #ifndef LIBANGLE_CLPROGRAM_H_
#define LIBANGLE_CLPROGRAM_H_ #define LIBANGLE_CLPROGRAM_H_
#include "libANGLE/CLtypes.h"
namespace cl namespace cl
{ {
class Program final class Program final
{ {
public: public:
using IsCLObjectType = std::true_type;
}; };
} // namespace cl } // namespace cl
......
...@@ -9,11 +9,14 @@ ...@@ -9,11 +9,14 @@
#ifndef LIBANGLE_CLSAMPLER_H_ #ifndef LIBANGLE_CLSAMPLER_H_
#define LIBANGLE_CLSAMPLER_H_ #define LIBANGLE_CLSAMPLER_H_
#include "libANGLE/CLtypes.h"
namespace cl namespace cl
{ {
class Sampler final class Sampler final
{ {
public: public:
using IsCLObjectType = std::true_type;
}; };
} // namespace cl } // namespace cl
......
//
// 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.
//
// CLtypes.h: Defines common types for the OpenCL support in ANGLE.
#ifndef LIBANGLE_CLTYPES_H_
#define LIBANGLE_CLTYPES_H_
#include "angle_cl.h"
#include <type_traits>
namespace cl
{
class CommandQueue;
class Context;
class Device;
class Event;
class Kernel;
class Memory;
class Platform;
class Program;
class Sampler;
} // namespace cl
#endif // LIBANGLE_CLTYPES_H_
//
// 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.
//
// validationCL.h: Validation functions for generic CL entry point parameters
#ifndef LIBANGLE_VALIDATIONCL_H_
#define LIBANGLE_VALIDATIONCL_H_
#include "libANGLE/CLCommandQueue.h"
#include "libANGLE/CLContext.h"
#include "libANGLE/CLDevice.h"
#include "libANGLE/CLEvent.h"
#include "libANGLE/CLKernel.h"
#include "libANGLE/CLMemory.h"
#include "libANGLE/CLPlatform.h"
#include "libANGLE/CLProgram.h"
#include "libANGLE/CLSampler.h"
#include "common/PackedCLEnums_autogen.h"
#define ANGLE_CL_VALIDATE_VOID(EP, ...) \
do \
{ \
if (!Validate##EP(__VA_ARGS__)) \
{ \
return; \
} \
} while (0)
#define ANGLE_CL_VALIDATE_ERROR(EP, ...) \
do \
{ \
cl_int errorCode = Validate##EP(__VA_ARGS__); \
if (errorCode != CL_SUCCESS) \
{ \
return errorCode; \
} \
} while (0)
#define ANGLE_CL_VALIDATE_POINTER(EP, ...) \
do \
{ \
if (!Validate##EP(__VA_ARGS__)) \
{ \
return nullptr; \
} \
} while (0)
#endif // LIBANGLE_VALIDATIONCL_H_
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// validationEGL.cpp: Validation functions for generic EGL entry point parameters // validationEGL.cpp: Validation functions for generic EGL entry point parameters
#include "libANGLE/validationEGL.h" #include "libANGLE/validationEGL_autogen.h"
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/Config.h" #include "libANGLE/Config.h"
......
...@@ -459,6 +459,9 @@ libangle_cl_headers = [ ...@@ -459,6 +459,9 @@ libangle_cl_headers = [
"src/libANGLE/CLPlatform.h", "src/libANGLE/CLPlatform.h",
"src/libANGLE/CLProgram.h", "src/libANGLE/CLProgram.h",
"src/libANGLE/CLSampler.h", "src/libANGLE/CLSampler.h",
"src/libANGLE/CLtypes.h",
"src/libANGLE/validationCL.h",
"src/libANGLE/validationCL_autogen.h",
] ]
libangle_cl_sources = [ libangle_cl_sources = [
...@@ -471,6 +474,7 @@ libangle_cl_sources = [ ...@@ -471,6 +474,7 @@ libangle_cl_sources = [
"src/libANGLE/CLPlatform.cpp", "src/libANGLE/CLPlatform.cpp",
"src/libANGLE/CLProgram.cpp", "src/libANGLE/CLProgram.cpp",
"src/libANGLE/CLSampler.cpp", "src/libANGLE/CLSampler.cpp",
"src/libANGLE/validationCL.cpp",
] ]
libangle_mac_sources = [ libangle_mac_sources = [
...@@ -575,7 +579,6 @@ libglesv2_cl_sources = [ ...@@ -575,7 +579,6 @@ libglesv2_cl_sources = [
"src/libGLESv2/entry_points_cl_autogen.cpp", "src/libGLESv2/entry_points_cl_autogen.cpp",
"src/libGLESv2/entry_points_cl_autogen.h", "src/libGLESv2/entry_points_cl_autogen.h",
"src/libGLESv2/entry_points_cl_utils.h", "src/libGLESv2/entry_points_cl_utils.h",
"src/libGLESv2/validationCL.h",
] ]
if (is_win) { if (is_win) {
......
...@@ -10,22 +10,12 @@ ...@@ -10,22 +10,12 @@
#ifndef LIBGLESV2_CL_STUBS_AUTOGEN_H_ #ifndef LIBGLESV2_CL_STUBS_AUTOGEN_H_
#define LIBGLESV2_CL_STUBS_AUTOGEN_H_ #define LIBGLESV2_CL_STUBS_AUTOGEN_H_
#include "angle_cl.h" #include "libANGLE/CLtypes.h"
#include "common/PackedCLEnums_autogen.h" #include "common/PackedCLEnums_autogen.h"
namespace cl namespace cl
{ {
class CommandQueue;
class Context;
class Device;
class Event;
class Kernel;
class Memory;
class Platform;
class Program;
class Sampler;
cl_int GetPlatformIDs(cl_uint num_entries, Platform **platformsPacked, cl_uint *num_platforms); cl_int GetPlatformIDs(cl_uint num_entries, Platform **platformsPacked, cl_uint *num_platforms);
cl_int GetPlatformInfo(Platform *platformPacked, cl_int GetPlatformInfo(Platform *platformPacked,
PlatformInfo param_namePacked, PlatformInfo param_namePacked,
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <cinttypes> #include <cinttypes>
#include <cstdio> #include <cstdio>
#include <type_traits>
#if defined(ANGLE_TRACE_ENABLED) #if defined(ANGLE_TRACE_ENABLED)
# define CL_EVENT(entryPoint, ...) \ # define CL_EVENT(entryPoint, ...) \
...@@ -20,4 +21,39 @@ ...@@ -20,4 +21,39 @@
# define CL_EVENT(entryPoint, ...) (void(0)) # define CL_EVENT(entryPoint, ...) (void(0))
#endif #endif
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)
{
return FromCLenum<PackedT>(from);
}
// Cast CL object types to ANGLE types marked with 'using IsCLObjectType = std::true_type;'
template <typename PackedT, typename FromT>
inline std::enable_if_t<
std::remove_pointer_t<std::remove_pointer_t<PackedT>>::IsCLObjectType::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_ #endif // LIBGLESV2_ENTRY_POINTS_CL_UTILS_H_
//
// 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.
//
// validationCL.h: Validation functions for generic CL entry point parameters
#ifndef LIBGLESV2_VALIDATIONCL_H_
#define LIBGLESV2_VALIDATIONCL_H_
#include "common/PackedCLEnums_autogen.h"
#include <type_traits>
namespace cl
{
// First case: handling packed enums.
template <typename PackedT, typename FromT>
typename std::enable_if<std::is_enum<PackedT>::value, PackedT>::type PackParam(FromT from)
{
return FromCLenum<PackedT>(from);
}
template <typename PackedT, typename FromT>
inline typename std::enable_if<!std::is_enum<PackedT>::value,
typename std::remove_reference<PackedT>::type>::type
PackParam(FromT from)
{
return reinterpret_cast<PackedT>(from);
}
// First case: handling packed enums.
template <typename UnpackedT, typename FromT>
typename std::enable_if<std::is_enum<FromT>::value, UnpackedT>::type UnpackParam(FromT from)
{
return ToCLenum(from);
}
template <typename UnpackedT, typename FromT>
inline typename std::enable_if<!std::is_enum<FromT>::value, UnpackedT>::type UnpackParam(FromT from)
{
return reinterpret_cast<UnpackedT>(from);
}
} // namespace cl
#endif // LIBGLESV2_VALIDATIONCL_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment