Commit 79927344 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: add wrapper for vkEvent

Bug: angleproject:2908 Change-Id: Id6c9326f85f9ff17b963078f82bcf486bae66a83 Reviewed-on: https://chromium-review.googlesource.com/c/1296951 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 27a472c6
......@@ -565,6 +565,35 @@ void CommandBuffer::pushConstants(const PipelineLayout &layout,
vkCmdPushConstants(mHandle, layout.getHandle(), flag, offset, size, data);
}
void CommandBuffer::setEvent(const vk::Event &event, VkPipelineStageFlags stageMask)
{
ASSERT(valid() && event.valid());
vkCmdSetEvent(mHandle, event.getHandle(), stageMask);
}
void CommandBuffer::resetEvent(const vk::Event &event, VkPipelineStageFlags stageMask)
{
ASSERT(valid() && event.valid());
vkCmdResetEvent(mHandle, event.getHandle(), stageMask);
}
void CommandBuffer::waitEvents(uint32_t eventCount,
const VkEvent *events,
VkPipelineStageFlags srcStageMask,
VkPipelineStageFlags dstStageMask,
uint32_t memoryBarrierCount,
const VkMemoryBarrier *memoryBarriers,
uint32_t bufferMemoryBarrierCount,
const VkBufferMemoryBarrier *bufferMemoryBarriers,
uint32_t imageMemoryBarrierCount,
const VkImageMemoryBarrier *imageMemoryBarriers)
{
ASSERT(valid());
vkCmdWaitEvents(mHandle, eventCount, events, srcStageMask, dstStageMask, memoryBarrierCount,
memoryBarriers, bufferMemoryBarrierCount, bufferMemoryBarriers,
imageMemoryBarrierCount, imageMemoryBarriers);
}
void CommandBuffer::resetQueryPool(VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
{
ASSERT(valid());
......@@ -1000,6 +1029,42 @@ angle::Result Sampler::init(Context *context, const VkSamplerCreateInfo &createI
vkCreateSampler(context->getDevice(), &createInfo, nullptr, &mHandle));
}
// Event implementation.
Event::Event()
{
}
void Event::destroy(VkDevice device)
{
if (valid())
{
vkDestroyEvent(device, mHandle, nullptr);
mHandle = VK_NULL_HANDLE;
}
}
angle::Result Event::init(Context *context, const VkEventCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkCreateEvent(context->getDevice(), &createInfo, nullptr, &mHandle));
}
angle::Result Event::getStatus(Context *context) const
{
ANGLE_VK_TRY_RETURN_EVENT_STATUS(context, vkGetEventStatus(context->getDevice(), mHandle));
}
angle::Result Event::set(Context *context) const
{
ANGLE_VK_TRY_RETURN(context, vkSetEvent(context->getDevice(), mHandle));
}
angle::Result Event::reset(Context *context) const
{
ANGLE_VK_TRY_RETURN(context, vkResetEvent(context->getDevice(), mHandle));
}
// Fence implementation.
Fence::Fence()
{
......@@ -1221,6 +1286,9 @@ void GarbageObject::destroy(VkDevice device)
// Command buffers are pool allocated.
UNREACHABLE();
break;
case HandleType::Event:
vkDestroyEvent(device, reinterpret_cast<VkEvent>(mHandle), nullptr);
break;
case HandleType::Fence:
vkDestroyFence(device, reinterpret_cast<VkFence>(mHandle), nullptr);
break;
......
......@@ -147,30 +147,29 @@ GetImplType<T> *GetImpl(const T *glObject)
// PhysicalDevice
// Device
// Queue
// Event
// QueryPool
// BufferView
// DescriptorSet
// PipelineCache
#define ANGLE_HANDLE_TYPES_X(FUNC) \
FUNC(Semaphore) \
FUNC(Buffer) \
FUNC(CommandBuffer) \
FUNC(Fence) \
FUNC(CommandPool) \
FUNC(DescriptorPool) \
FUNC(DescriptorSetLayout) \
FUNC(DeviceMemory) \
FUNC(Buffer) \
FUNC(Event) \
FUNC(Fence) \
FUNC(Framebuffer) \
FUNC(Image) \
FUNC(ImageView) \
FUNC(ShaderModule) \
FUNC(Pipeline) \
FUNC(PipelineCache) \
FUNC(PipelineLayout) \
FUNC(QueryPool) \
FUNC(RenderPass) \
FUNC(Pipeline) \
FUNC(DescriptorSetLayout) \
FUNC(Sampler) \
FUNC(DescriptorPool) \
FUNC(Framebuffer) \
FUNC(CommandPool) \
FUNC(QueryPool)
FUNC(Semaphore) \
FUNC(ShaderModule)
#define ANGLE_COMMA_SEP_FUNC(TYPE) TYPE,
......@@ -424,6 +423,19 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer>
uint32_t size,
const void *data);
void setEvent(const vk::Event &event, VkPipelineStageFlags stageMask);
void resetEvent(const vk::Event &event, VkPipelineStageFlags stageMask);
void waitEvents(uint32_t eventCount,
const VkEvent *events,
VkPipelineStageFlags srcStageMask,
VkPipelineStageFlags dstStageMask,
uint32_t memoryBarrierCount,
const VkMemoryBarrier *memoryBarriers,
uint32_t bufferMemoryBarrierCount,
const VkBufferMemoryBarrier *bufferMemoryBarriers,
uint32_t imageMemoryBarrierCount,
const VkImageMemoryBarrier *imageMemoryBarriers);
void resetQueryPool(VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount);
void beginQuery(VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags);
void endQuery(VkQueryPool queryPool, uint32_t query);
......@@ -602,6 +614,19 @@ class Sampler final : public WrappedObject<Sampler, VkSampler>
angle::Result init(Context *context, const VkSamplerCreateInfo &createInfo);
};
class Event final : public WrappedObject<Event, VkEvent>
{
public:
Event();
void destroy(VkDevice fence);
using WrappedObject::operator=;
angle::Result init(Context *context, const VkEventCreateInfo &createInfo);
angle::Result getStatus(Context *context) const;
angle::Result set(Context *context) const;
angle::Result reset(Context *context) const;
};
class Fence final : public WrappedObject<Fence, VkFence>
{
public:
......@@ -891,27 +916,30 @@ VkColorComponentFlags GetColorComponentFlags(bool red, bool green, bool blue, bo
return angle::Result::Continue(); \
} while (0)
#define ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, acceptable) \
#define ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, success, incomplete) \
do \
{ \
auto ANGLE_LOCAL_VAR = command; \
if (ANGLE_UNLIKELY(ANGLE_LOCAL_VAR != VK_SUCCESS && ANGLE_LOCAL_VAR != acceptable)) \
if (ANGLE_UNLIKELY(ANGLE_LOCAL_VAR != success && ANGLE_LOCAL_VAR != incomplete)) \
{ \
context->handleError(ANGLE_LOCAL_VAR, __FILE__, __LINE__); \
return angle::Result::Stop(); \
} \
return ANGLE_LOCAL_VAR == VK_SUCCESS ? angle::Result::Continue() \
return ANGLE_LOCAL_VAR == success ? angle::Result::Continue() \
: angle::Result::Incomplete(); \
} while (0)
#define ANGLE_VK_TRY_RETURN_ALLOW_INCOMPLETE(context, command) \
ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, VK_INCOMPLETE)
ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, VK_SUCCESS, VK_INCOMPLETE)
#define ANGLE_VK_TRY_RETURN_ALLOW_NOT_READY(context, command) \
ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, VK_NOT_READY)
ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, VK_SUCCESS, VK_NOT_READY)
#define ANGLE_VK_TRY_RETURN_ALLOW_TIMEOUT(context, command) \
ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, VK_TIMEOUT)
ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, VK_SUCCESS, VK_TIMEOUT)
#define ANGLE_VK_TRY_RETURN_EVENT_STATUS(context, command) \
ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, VK_EVENT_SET, VK_EVENT_RESET)
#define ANGLE_VK_UNREACHABLE(context) \
UNREACHABLE(); \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment