diff options
author | Francisco Jerez <[email protected]> | 2013-10-06 13:52:02 -0700 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2013-10-21 10:47:03 -0700 |
commit | 6230f77232a4703c9f98f569104ac03430a5fb95 (patch) | |
tree | 4c07479cdec078d11618edcca5555d75cc49c9d3 /src/gallium/state_trackers/clover/core | |
parent | 9a5afd0dbd5cd7d45de926da2299b5a538b9b383 (diff) |
clover: Implement support for the ICD extension.
Tested-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/clover/core')
-rw-r--r-- | src/gallium/state_trackers/clover/core/object.hpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/gallium/state_trackers/clover/core/object.hpp b/src/gallium/state_trackers/clover/core/object.hpp index ea71879512c..b8b3da81eb7 100644 --- a/src/gallium/state_trackers/clover/core/object.hpp +++ b/src/gallium/state_trackers/clover/core/object.hpp @@ -31,6 +31,7 @@ #include "core/error.hpp" #include "core/property.hpp" +#include "api/dispatch.hpp" /// /// Main namespace of the CL state tracker. @@ -43,6 +44,13 @@ namespace clover { struct descriptor { typedef T object_type; typedef S descriptor_type; + + descriptor() : dispatch(&_dispatch) { + static_assert(std::is_standard_layout<descriptor_type>::value, + "ICD requires CL API objects to be standard layout."); + } + + const _cl_icd_dispatch *dispatch; }; struct default_tag; @@ -57,7 +65,8 @@ namespace clover { static void validate(D *d) { auto o = static_cast<typename D::object_type *>(d); - if (!o || !dynamic_cast<object_type *>(o)) + if (!o || o->dispatch != &_dispatch || + !dynamic_cast<object_type *>(o)) throw invalid_object_error<T>(); } @@ -74,7 +83,7 @@ namespace clover { static void validate(D *d) { - if (!d) + if (!d || d->dispatch != &_dispatch) throw invalid_object_error<object_type>(); } @@ -91,7 +100,7 @@ namespace clover { static void validate(D *d) { - if (!d) + if (!d || d->dispatch != &_dispatch) throw invalid_wait_list_error(); } |