From: Jan Vesely <[email protected]> Check maximum size across all devices in the context
Signed-off-by: Jan Vesely <[email protected]> --- src/gallium/state_trackers/clover/api/memory.cpp | 2 +- src/gallium/state_trackers/clover/core/context.cpp | 11 +++++++++++ src/gallium/state_trackers/clover/core/context.hpp | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/clover/api/memory.cpp b/src/gallium/state_trackers/clover/api/memory.cpp index 15f5b7f..b5b75cd 100644 --- a/src/gallium/state_trackers/clover/api/memory.cpp +++ b/src/gallium/state_trackers/clover/api/memory.cpp @@ -35,7 +35,7 @@ clCreateBuffer(cl_context d_ctx, cl_mem_flags flags, size_t size, CL_MEM_COPY_HOST_PTR))) throw error(CL_INVALID_HOST_PTR); - if (!size) + if (!size || size > ctx.max_mem_alloc_size()) throw error(CL_INVALID_BUFFER_SIZE); if (flags & ~(CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | diff --git a/src/gallium/state_trackers/clover/core/context.cpp b/src/gallium/state_trackers/clover/core/context.cpp index e2658f2..d00c5b5 100644 --- a/src/gallium/state_trackers/clover/core/context.cpp +++ b/src/gallium/state_trackers/clover/core/context.cpp @@ -48,3 +48,14 @@ context::device_range context::devs() const { return map(derefs(), _devs); } + +static bool max_alloc_comp(const clover::device *a, const clover::device *b) +{ + return a->max_mem_alloc_size() < b->max_mem_alloc_size(); +} + +cl_ulong context::max_mem_alloc_size() const { + const clover::device *dev = + *(std::max_element(_devs.begin(), _devs.end(), max_alloc_comp)); + return dev->max_mem_alloc_size(); +} diff --git a/src/gallium/state_trackers/clover/core/context.hpp b/src/gallium/state_trackers/clover/core/context.hpp index 0b5cf8a..0bb5953 100644 --- a/src/gallium/state_trackers/clover/core/context.hpp +++ b/src/gallium/state_trackers/clover/core/context.hpp @@ -50,6 +50,8 @@ namespace clover { device_range devs() const; + + cl_ulong max_mem_alloc_size() const; private: property_list _props; -- 1.8.3.1 _______________________________________________ mesa-dev mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
