Path: blob/21.2-virgl/src/gallium/frontends/clover/core/queue.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_QUEUE_HPP23#define CLOVER_CORE_QUEUE_HPP2425#include <deque>26#include <mutex>2728#include "core/object.hpp"29#include "core/context.hpp"30#include "core/timestamp.hpp"31#include "pipe/p_context.h"3233namespace clover {34class resource;35class mapping;36class hard_event;3738class command_queue : public ref_counter, public _cl_command_queue {39public:40command_queue(clover::context &ctx, clover::device &dev,41std::vector<cl_queue_properties> properties);42command_queue(clover::context &ctx, clover::device &dev,43cl_command_queue_properties props);44~command_queue();4546command_queue(const command_queue &q) = delete;47command_queue &48operator=(const command_queue &q) = delete;4950void flush();51void svm_migrate(const std::vector<void const *> &svm_pointers,52const std::vector<size_t> &sizes, cl_mem_migration_flags flags);5354cl_command_queue_properties props() const;5556std::vector<cl_queue_properties> properties() const;57bool profiling_enabled() const;5859const intrusive_ref<clover::context> context;60const intrusive_ref<clover::device> device;6162friend class resource;63friend class root_resource;64friend class mapping;65friend class hard_event;66friend class sampler;67friend class kernel;68friend class clover::timestamp::query;69friend class clover::timestamp::current;7071private:72/// Serialize a hardware event with respect to the previous ones,73/// and push it to the pending list.74void sequence(hard_event &ev);75// Use this instead of flush() if `queued_events_mutex` is acquired.76void flush_unlocked();7778std::vector<cl_queue_properties> _properties;79cl_command_queue_properties _props;80pipe_context *pipe;81std::mutex queued_events_mutex;82std::deque<intrusive_ref<hard_event>> queued_events;83};84}8586#endif878889