Path: blob/21.2-virgl/src/gallium/frontends/clover/core/context.hpp
4572 views
//1// Copyright 2012 Francisco Jerez2//3// Permission is hereby granted, free of charge, to any person obtaining a4// copy of this software and associated documentation files (the "Software"),5// to deal in the Software without restriction, including without limitation6// the rights to use, copy, modify, merge, publish, distribute, sublicense,7// and/or sell copies of the Software, and to permit persons to whom the8// Software is furnished to do so, subject to the following conditions:9//10// The above copyright notice and this permission notice shall be included in11// all copies or substantial portions of the Software.12//13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR17// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19// OTHER DEALINGS IN THE SOFTWARE.20//2122#ifndef CLOVER_CORE_CONTEXT_HPP23#define CLOVER_CORE_CONTEXT_HPP2425#include <map>26#include <stack>2728#include "core/object.hpp"29#include "core/device.hpp"30#include "core/property.hpp"3132namespace clover {33class context : public ref_counter, public _cl_context {34private:35typedef adaptor_range<36evals, const std::vector<intrusive_ref<device>> &37> device_range;38typedef clover::property_list<cl_context_properties> property_list;3940public:41~context();4243typedef std::function<void (const char *)> notify_action;44typedef std::map<const void *, size_t> svm_pointer_map;4546context(const property_list &props, const ref_vector<device> &devs,47const notify_action ¬ify);4849context(const context &ctx) = delete;50context &51operator=(const context &ctx) = delete;5253bool54operator==(const context &ctx) const;55bool56operator!=(const context &ctx) const;5758void destroy_notify(std::function<void ()> f);5960const property_list &61properties() const;6263device_range64devices() const;6566void67add_svm_allocation(const void *ptr, size_t size);6869void70remove_svm_allocation(const void *ptr);7172svm_pointer_map::value_type73find_svm_allocation(const void *ptr) const;7475const notify_action notify;7677private:78property_list props;79const std::vector<intrusive_ref<device>> devs;80std::stack<std::function<void ()>> _destroy_notify;81svm_pointer_map svm_ptrs;82};83}8485#endif868788