diff options
author | Francisco Jerez <[email protected]> | 2013-10-06 13:49:49 -0700 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2013-10-21 10:47:02 -0700 |
commit | d8b499428183178885bb182c898ee6f52e92ef03 (patch) | |
tree | c8b9ab03b332285576275f4d4e1a32fb5d0def5e /src/gallium/state_trackers/clover/api/util.hpp | |
parent | 7d61769e447e47022bea5e9fd415344b45a5a050 (diff) |
clover: Clean up property query functions by using a new property_buffer helper class.
Tested-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/clover/api/util.hpp')
-rw-r--r-- | src/gallium/state_trackers/clover/api/util.hpp | 71 |
1 files changed, 1 insertions, 70 deletions
diff --git a/src/gallium/state_trackers/clover/api/util.hpp b/src/gallium/state_trackers/clover/api/util.hpp index d9d9b7a73cb..e94b4b26a34 100644 --- a/src/gallium/state_trackers/clover/api/util.hpp +++ b/src/gallium/state_trackers/clover/api/util.hpp @@ -29,81 +29,12 @@ #include <map> #include "core/base.hpp" +#include "core/property.hpp" #include "util/algorithm.hpp" #include "pipe/p_compiler.h" namespace clover { /// - /// Return a matrix (a container of containers) in \a buf with - /// argument and bounds checking. Intended to be used by - /// implementations of \a clGetXXXInfo(). - /// - template<typename T, typename V> - cl_int - matrix_property(void *buf, size_t size, size_t *size_ret, const V& v) { - if (buf && size < sizeof(T *) * v.size()) - return CL_INVALID_VALUE; - - if (size_ret) - *size_ret = sizeof(T *) * v.size(); - - if (buf) - for_each([](typename V::value_type src, T *dst) { - if (dst) - copy(src, dst); - }, - v, range((T **)buf, v.size())); - - return CL_SUCCESS; - } - - /// - /// Return a vector in \a buf with argument and bounds checking. - /// Intended to be used by implementations of \a clGetXXXInfo(). - /// - template<typename T, typename V> - cl_int - vector_property(void *buf, size_t size, size_t *size_ret, const V& v) { - if (buf && size < sizeof(T) * v.size()) - return CL_INVALID_VALUE; - - if (size_ret) - *size_ret = sizeof(T) * v.size(); - if (buf) - copy(v, (T *)buf); - - return CL_SUCCESS; - } - - /// - /// Return a scalar in \a buf with argument and bounds checking. - /// Intended to be used by implementations of \a clGetXXXInfo(). - /// - template<typename T> - cl_int - scalar_property(void *buf, size_t size, size_t *size_ret, T v) { - return vector_property<T>(buf, size, size_ret, std::vector<T>(1, v)); - } - - /// - /// Return a string in \a buf with argument and bounds checking. - /// Intended to be used by implementations of \a clGetXXXInfo(). - /// - inline cl_int - string_property(void *buf, size_t size, size_t *size_ret, - const std::string &v) { - if (buf && size < v.size() + 1) - return CL_INVALID_VALUE; - - if (size_ret) - *size_ret = v.size() + 1; - if (buf) - std::strcpy((char *)buf, v.c_str()); - - return CL_SUCCESS; - } - - /// /// Convert a NULL-terminated property list into an std::map. /// template<typename T> |