summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2014-06-14 20:53:35 +0200
committerFrancisco Jerez <[email protected]>2014-06-19 20:17:08 +0200
commitab023c27a374bb69bd7300b5b6f0789844fc8ba9 (patch)
treef204edd4b1bcd52d3813aa16f6ef22e55394769b /src/gallium/state_trackers
parentcad60420d5ea36a4b6fa2e6c91317f71423aa63e (diff)
clover: Optimize module serialization for vectors of fundamental types.
Tested-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/clover/core/module.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/clover/core/module.cpp b/src/gallium/state_trackers/clover/core/module.cpp
index 3e3ad99e450..41de7344203 100644
--- a/src/gallium/state_trackers/clover/core/module.cpp
+++ b/src/gallium/state_trackers/clover/core/module.cpp
@@ -69,7 +69,9 @@ namespace {
/// (De)serialize a vector.
template<typename T>
- struct _serializer<compat::vector<T>> {
+ struct _serializer<compat::vector<T>,
+ typename std::enable_if<
+ !std::is_scalar<T>::value>::type> {
static void
proc(compat::ostream &os, const compat::vector<T> &v) {
_proc<uint32_t>(os, v.size());
@@ -87,6 +89,25 @@ namespace {
}
};
+ template<typename T>
+ struct _serializer<compat::vector<T>,
+ typename std::enable_if<
+ std::is_scalar<T>::value>::type> {
+ static void
+ proc(compat::ostream &os, const compat::vector<T> &v) {
+ _proc<uint32_t>(os, v.size());
+ os.write(reinterpret_cast<const char *>(v.begin()),
+ v.size() * sizeof(T));
+ }
+
+ static void
+ proc(compat::istream &is, compat::vector<T> &v) {
+ v.reserve(_proc<uint32_t>(is));
+ is.read(reinterpret_cast<char *>(v.begin()),
+ v.size() * sizeof(T));
+ }
+ };
+
/// (De)serialize a module::section.
template<>
struct _serializer<module::section> {