QueueVk.h#

The Prank Queue class.

Includes#

  • PVRVk/DeviceVk.h

Included By#

Namespaces#

Classes#

Source Code#

#pragma once
#include "PVRVk/DeviceVk.h"

namespace pvrvk {

struct SparseMemoryBind
{
    uint64_t resourceOffset;
    uint64_t size;
    DeviceMemory memory;
    uint64_t memoryOffset;
    pvrvk::SparseMemoryBindFlags flags;
};

struct SparseImageMemoryBind
{
    ImageSubresource subresource;
    pvrvk::Offset3D offset;
    pvrvk::Extent3D extent;
    DeviceMemory memory;
    uint64_t memoryOffset;
    pvrvk::SparseMemoryBindFlags flags;
};

struct SparseBufferMemoryBindInfo
{
    Buffer buffer;
    std::vector<SparseMemoryBind> binds;
};

struct SparseImageOpaqueMemoryBindInfo
{
    Image image;
    std::vector<SparseMemoryBind> binds;
};

struct SparseImageMemoryBindInfo
{
    Image image;
    std::vector<SparseImageMemoryBind> binds;
};

struct BindSparseInfo
{
    std::vector<SparseBufferMemoryBindInfo> bufferBinds;
    std::vector<SparseImageOpaqueMemoryBindInfo> imageOpaqueBinds;
    std::vector<SparseImageMemoryBindInfo> imageBinds;
    std::vector<Semaphore> waitSemaphores;
    std::vector<Semaphore> signalSemaphore;
};

struct SubmitInfo
{
    const PipelineStageFlags* waitDstStageMask;
    const CommandBuffer* commandBuffers;
    uint32_t numCommandBuffers;
    const Semaphore* waitSemaphores;
    uint32_t numWaitSemaphores;
    const Semaphore* signalSemaphores;
    uint32_t numSignalSemaphores;
    TimelineSemaphoreSubmitInfo* timelineSemaphoreSubmitInfo;

    SubmitInfo()
        : waitDstStageMask(nullptr), commandBuffers(nullptr), numCommandBuffers(0), waitSemaphores(nullptr), numWaitSemaphores(0), signalSemaphores(nullptr),
          numSignalSemaphores(0), timelineSemaphoreSubmitInfo(nullptr)
    {}

    SubmitInfo(const pvrvk::PipelineStageFlags* waitDstStageMask, const CommandBuffer* commandBuffers, uint32_t numCommandBuffers, const Semaphore* waitSemaphores,
        uint32_t numWaitSemaphores, const Semaphore* signalSemaphores, uint32_t numSignalSemaphores)
        : waitDstStageMask(waitDstStageMask), commandBuffers(commandBuffers), numCommandBuffers(numCommandBuffers), waitSemaphores(waitSemaphores),
          numWaitSemaphores(numWaitSemaphores), signalSemaphores(signalSemaphores), numSignalSemaphores(numSignalSemaphores), timelineSemaphoreSubmitInfo(nullptr)
    {}
};

struct PresentInfo
{
    uint32_t numWaitSemaphores;
    Semaphore* waitSemaphores;
    uint32_t numSwapchains;
    const pvrvk::Swapchain* swapchains;
    const uint32_t* imageIndices;

    PresentInfo() : numWaitSemaphores(0), waitSemaphores(nullptr), numSwapchains(0), swapchains(nullptr), imageIndices(nullptr) {}

    PresentInfo(uint32_t numWaitSemaphores, Semaphore* waitSemaphores, uint32_t numSwapchains, const pvrvk::Swapchain* swapchains, const uint32_t* imageIndices)
        : numWaitSemaphores(numWaitSemaphores), waitSemaphores(waitSemaphores), numSwapchains(numSwapchains), swapchains(swapchains), imageIndices(imageIndices)
    {}
};

namespace impl {
class Queue_ : public PVRVkDeviceObjectBase<VkQueue, ObjectType::e_QUEUE>, public DeviceObjectDebugUtils<Queue_>
{
private:
    friend class Device_;

    class make_shared_enabler
    {
    protected:
        make_shared_enabler() {}
        friend class Queue_;
    };

    static Queue constructShared(const DeviceWeakPtr& device, VkQueue queue, pvrvk::QueueFlags flags, uint32_t familyIndex, float priority)
    {
        return std::make_shared<Queue_>(make_shared_enabler{}, device, queue, flags, familyIndex, priority);
    }

    pvrvk::QueueFlags _flags;
    uint32_t _familyIndex;
    float _priority;

public:
    DECLARE_NO_COPY_SEMANTICS(Queue_)
    Queue_(make_shared_enabler, const DeviceWeakPtr& device, VkQueue queue, pvrvk::QueueFlags flags, uint32_t familyIndex, float priority)
        : PVRVkDeviceObjectBase(device, queue), DeviceObjectDebugUtils(), _flags(flags), _familyIndex(familyIndex), _priority(priority)
    {}

    void submit(const SubmitInfo& queueSubmitInfo, Fence signalFence = Fence()) { submit(&queueSubmitInfo, 1, signalFence); }

    void submit(const SubmitInfo* queueSubmitInfo, uint32_t numSubmitInfos, Fence signalFence = Fence());

    void present(const PresentInfo& presentInfo, Result* const results = nullptr);

    void waitIdle();

    pvrvk::QueueFlags getFlags() const { return _flags; }

    float getPriority() const { return _priority; }

    void bindSparse(const BindSparseInfo* bindInfo, uint32_t numBindInfos, Fence& fenceSignal);

    uint32_t getFamilyIndex() const { return _familyIndex; }

    void beginDebugUtilsLabel(const pvrvk::DebugUtilsLabel& labelInfo);

    void endDebugUtilsLabel();

    void insertDebugUtilsLabel(const pvrvk::DebugUtilsLabel& labelInfo);
};
} // namespace impl
} // namespace pvrvk