2 // Copyright 2012 Francisco Jerez
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 // OTHER DEALINGS IN THE SOFTWARE.
23 #include "api/util.hpp"
24 #include "core/platform.hpp"
26 #include "util/u_debug.h"
28 using namespace clover
;
31 platform _clover_platform
;
35 clGetPlatformIDs(cl_uint num_entries
, cl_platform_id
*rd_platforms
,
36 cl_uint
*rnum_platforms
) {
37 if ((!num_entries
&& rd_platforms
) ||
38 (!rnum_platforms
&& !rd_platforms
))
39 return CL_INVALID_VALUE
;
44 *rd_platforms
= desc(_clover_platform
);
50 clover::GetPlatformInfo(cl_platform_id d_platform
, cl_platform_info param
,
51 size_t size
, void *r_buf
, size_t *r_size
) try {
52 property_buffer buf
{ r_buf
, size
, r_size
};
57 case CL_PLATFORM_PROFILE
:
58 buf
.as_string() = "FULL_PROFILE";
61 case CL_PLATFORM_VERSION
: {
62 static const std::string version_string
=
63 debug_get_option("CLOVER_PLATFORM_VERSION_OVERRIDE", "1.1");
65 buf
.as_string() = "OpenCL " + version_string
+ " Mesa " PACKAGE_VERSION MESA_GIT_SHA1
;
68 case CL_PLATFORM_NAME
:
69 buf
.as_string() = "Clover";
72 case CL_PLATFORM_VENDOR
:
73 buf
.as_string() = "Mesa";
76 case CL_PLATFORM_EXTENSIONS
:
77 buf
.as_string() = "cl_khr_icd";
80 case CL_PLATFORM_ICD_SUFFIX_KHR
:
81 buf
.as_string() = "MESA";
85 throw error(CL_INVALID_VALUE
);
95 clover::GetExtensionFunctionAddressForPlatform(cl_platform_id d_platform
,
96 const char *p_name
) try {
98 return GetExtensionFunctionAddress(p_name
);
105 clover::GetExtensionFunctionAddress(const char *p_name
) {
106 std::string name
{ p_name
};
108 if (name
== "clIcdGetPlatformIDsKHR")
109 return reinterpret_cast<void *>(IcdGetPlatformIDsKHR
);
115 clover::IcdGetPlatformIDsKHR(cl_uint num_entries
, cl_platform_id
*rd_platforms
,
116 cl_uint
*rnum_platforms
) {
117 return clGetPlatformIDs(num_entries
, rd_platforms
, rnum_platforms
);
120 CLOVER_ICD_API cl_int
121 clGetPlatformInfo(cl_platform_id d_platform
, cl_platform_info param
,
122 size_t size
, void *r_buf
, size_t *r_size
) {
123 return GetPlatformInfo(d_platform
, param
, size
, r_buf
, r_size
);
126 CLOVER_ICD_API
void *
127 clGetExtensionFunctionAddress(const char *p_name
) {
128 return GetExtensionFunctionAddress(p_name
);
131 CLOVER_ICD_API
void *
132 clGetExtensionFunctionAddressForPlatform(cl_platform_id d_platform
,
133 const char *p_name
) {
134 return GetExtensionFunctionAddressForPlatform(d_platform
, p_name
);
137 CLOVER_ICD_API cl_int
138 clIcdGetPlatformIDsKHR(cl_uint num_entries
, cl_platform_id
*rd_platforms
,
139 cl_uint
*rnum_platforms
) {
140 return IcdGetPlatformIDsKHR(num_entries
, rd_platforms
, rnum_platforms
);