1 /* Copyright (c) 2017-2018 Hans-Kristian Arntzen 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining 4 * a copy of this software and associated documentation files (the 5 * "Software"), to deal in the Software without restriction, including 6 * without limitation the rights to use, copy, modify, merge, publish, 7 * distribute, sublicense, and/or sell copies of the Software, and to 8 * permit persons to whom the Software is furnished to do so, subject to 9 * the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be 12 * included in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 23 #pragma once 24 25 #include "vulkan.hpp" 26 #include "vulkan_common.hpp" 27 #include "cookie.hpp" 28 #include "object_pool.hpp" 29 30 namespace Vulkan 31 { 32 class Device; 33 class EventHolder; 34 35 struct EventHolderDeleter 36 { 37 void operator()(EventHolder *event); 38 }; 39 40 class EventHolder : public Util::IntrusivePtrEnabled<EventHolder, EventHolderDeleter, HandleCounter>, 41 public InternalSyncEnabled 42 { 43 public: 44 friend struct EventHolderDeleter; 45 46 ~EventHolder(); 47 get_event() const48 const VkEvent &get_event() const 49 { 50 return event; 51 } 52 get_stages() const53 VkPipelineStageFlags get_stages() const 54 { 55 return stages; 56 } 57 set_stages(VkPipelineStageFlags stages)58 void set_stages(VkPipelineStageFlags stages) 59 { 60 this->stages = stages; 61 } 62 63 private: 64 friend class Util::ObjectPool<EventHolder>; EventHolder(Device * device,VkEvent event)65 EventHolder(Device *device, VkEvent event) 66 : device(device) 67 , event(event) 68 { 69 } 70 71 Device *device; 72 VkEvent event; 73 VkPipelineStageFlags stages = 0; 74 }; 75 76 using PipelineEvent = Util::IntrusivePtr<EventHolder>; 77 78 } 79