summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2013-09-16 18:26:04 -0700
committerFrancisco Jerez <[email protected]>2013-10-21 10:47:02 -0700
commit49a49e0742dde4aa6d0c870d795a480425e85f52 (patch)
treef3ff522988d409e697910a62b97916941ec85164
parentbff60c894a290260ab3dd2086445b44622a2800e (diff)
clover: Switch platform objects to the new model.
Tested-by: Tom Stellard <[email protected]>
-rw-r--r--src/gallium/state_trackers/clover/api/device.cpp9
-rw-r--r--src/gallium/state_trackers/clover/api/platform.cpp23
-rw-r--r--src/gallium/state_trackers/clover/core/device.hpp2
-rw-r--r--src/gallium/state_trackers/clover/core/error.hpp2
-rw-r--r--src/gallium/state_trackers/clover/core/object.hpp3
-rw-r--r--src/gallium/state_trackers/clover/core/platform.cpp2
-rw-r--r--src/gallium/state_trackers/clover/core/platform.hpp52
7 files changed, 47 insertions, 46 deletions
diff --git a/src/gallium/state_trackers/clover/api/device.cpp b/src/gallium/state_trackers/clover/api/device.cpp
index 495ac41f17e..9800779e81a 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -27,9 +27,10 @@
using namespace clover;
PUBLIC cl_int
-clGetDeviceIDs(cl_platform_id platform, cl_device_type device_type,
+clGetDeviceIDs(cl_platform_id d_platform, cl_device_type device_type,
cl_uint num_entries, cl_device_id *devices,
cl_uint *num_devices) {
+ auto &platform = obj(d_platform);
std::vector<cl_device_id> devs;
if ((!num_entries && devices) ||
@@ -37,9 +38,9 @@ clGetDeviceIDs(cl_platform_id platform, cl_device_type device_type,
return CL_INVALID_VALUE;
// Collect matching devices
- for (device &dev : *platform) {
+ for (device &dev : platform) {
if (((device_type & CL_DEVICE_TYPE_DEFAULT) &&
- &dev == &platform->front()) ||
+ &dev == &platform.front()) ||
(device_type & dev.type()))
devs.push_back(&dev);
}
@@ -254,7 +255,7 @@ clGetDeviceInfo(cl_device_id dev, cl_device_info param,
break;
case CL_DEVICE_PLATFORM:
- buf.as_scalar<cl_platform_id>() = &dev->platform;
+ buf.as_scalar<cl_platform_id>() = desc(dev->platform);
break;
case CL_DEVICE_HOST_UNIFIED_MEMORY:
diff --git a/src/gallium/state_trackers/clover/api/platform.cpp b/src/gallium/state_trackers/clover/api/platform.cpp
index 034bbef7777..985c2211027 100644
--- a/src/gallium/state_trackers/clover/api/platform.cpp
+++ b/src/gallium/state_trackers/clover/api/platform.cpp
@@ -30,29 +30,28 @@ namespace {
}
PUBLIC cl_int
-clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms,
- cl_uint *num_platforms) {
- if ((!num_entries && platforms) ||
- (!num_platforms && !platforms))
+clGetPlatformIDs(cl_uint num_entries, cl_platform_id *rd_platforms,
+ cl_uint *rnum_platforms) {
+ if ((!num_entries && rd_platforms) ||
+ (!rnum_platforms && !rd_platforms))
return CL_INVALID_VALUE;
- if (num_platforms)
- *num_platforms = 1;
- if (platforms)
- *platforms = &_clover_platform;
+ if (rnum_platforms)
+ *rnum_platforms = 1;
+ if (rd_platforms)
+ *rd_platforms = desc(_clover_platform);
return CL_SUCCESS;
}
PUBLIC cl_int
-clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name,
+clGetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
size_t size, void *r_buf, size_t *r_size) try {
property_buffer buf { r_buf, size, r_size };
- if (platform != &_clover_platform)
- return CL_INVALID_PLATFORM;
+ obj(d_platform);
- switch (param_name) {
+ switch (param) {
case CL_PLATFORM_PROFILE:
buf.as_string() = "FULL_PROFILE";
break;
diff --git a/src/gallium/state_trackers/clover/core/device.hpp b/src/gallium/state_trackers/clover/core/device.hpp
index 1dd47487ca5..8252c693f4b 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -32,7 +32,7 @@
namespace clover {
typedef struct _cl_device_id device;
- typedef struct _cl_platform_id platform;
+ struct platform;
class root_resource;
class hard_event;
}
diff --git a/src/gallium/state_trackers/clover/core/error.hpp b/src/gallium/state_trackers/clover/core/error.hpp
index 2b0b6c5e850..ab16a81b82c 100644
--- a/src/gallium/state_trackers/clover/core/error.hpp
+++ b/src/gallium/state_trackers/clover/core/error.hpp
@@ -42,7 +42,7 @@ namespace clover {
class image;
class image2d;
class image3d;
- typedef struct _cl_platform_id platform;
+ class platform;
typedef struct _cl_program program;
typedef struct _cl_sampler sampler;
diff --git a/src/gallium/state_trackers/clover/core/object.hpp b/src/gallium/state_trackers/clover/core/object.hpp
index 807e2f91fc7..00e94f9e895 100644
--- a/src/gallium/state_trackers/clover/core/object.hpp
+++ b/src/gallium/state_trackers/clover/core/object.hpp
@@ -179,4 +179,7 @@ namespace clover {
}
}
+struct _cl_platform_id :
+ public clover::descriptor<clover::platform, _cl_platform_id> {};
+
#endif
diff --git a/src/gallium/state_trackers/clover/core/platform.cpp b/src/gallium/state_trackers/clover/core/platform.cpp
index 6d002e7416d..31e88307605 100644
--- a/src/gallium/state_trackers/clover/core/platform.cpp
+++ b/src/gallium/state_trackers/clover/core/platform.cpp
@@ -24,7 +24,7 @@
using namespace clover;
-_cl_platform_id::_cl_platform_id() {
+platform::platform() {
int n = pipe_loader_probe(NULL, 0);
std::vector<pipe_loader_device *> ldevs(n);
diff --git a/src/gallium/state_trackers/clover/core/platform.hpp b/src/gallium/state_trackers/clover/core/platform.hpp
index af588cc5701..26c65c788bd 100644
--- a/src/gallium/state_trackers/clover/core/platform.hpp
+++ b/src/gallium/state_trackers/clover/core/platform.hpp
@@ -29,38 +29,36 @@
#include "core/device.hpp"
namespace clover {
- typedef struct _cl_platform_id platform;
-}
-
-struct _cl_platform_id {
-public:
- typedef std::vector<clover::device>::iterator iterator;
+ class platform : public _cl_platform_id {
+ public:
+ typedef std::vector<device>::iterator iterator;
- _cl_platform_id();
+ platform();
- ///
- /// Container of all compute devices that are available in the platform.
- ///
- /// @{
- iterator begin() {
- return devs.begin();
- }
+ ///
+ /// Container of all compute devices that are available in the platform.
+ ///
+ /// @{
+ iterator begin() {
+ return devs.begin();
+ }
- iterator end() {
- return devs.end();
- }
+ iterator end() {
+ return devs.end();
+ }
- clover::device &front() {
- return devs.front();
- }
+ device &front() {
+ return devs.front();
+ }
- clover::device &back() {
- return devs.back();
- }
- /// @}
+ device &back() {
+ return devs.back();
+ }
+ /// @}
-protected:
- std::vector<clover::device> devs;
-};
+ protected:
+ std::vector<device> devs;
+ };
+}
#endif