PipelineVk.h#

Includes#

  • PVRVk/DeviceVk.h

  • PVRVk/HeadersVk.h

  • PVRVk/PipelineConfigVk.h

Included By#

Namespaces#

Classes#

Source Code#

#pragma once
#include "PVRVk/PipelineConfigVk.h"
#include "PVRVk/HeadersVk.h"
#include "PVRVk/DeviceVk.h"
namespace pvrvk {
template<class PVRVkPipeline>
struct PipelineCreateInfo
{
public:
    PipelineLayout pipelineLayout;
    pvrvk::PipelineCreateFlags flags;
    PVRVkPipeline basePipeline;
    int32_t basePipelineIndex;

    virtual ~PipelineCreateInfo() {}

protected:
    PipelineCreateInfo() : flags(pvrvk::PipelineCreateFlags(0)), basePipelineIndex(-1) {}
};

namespace impl {
template<class PVRVkPipeline, class PVRVkPipelineCreateInfo>
class Pipeline : public PVRVkDeviceObjectBase<VkPipeline, ObjectType::e_PIPELINE>, public DeviceObjectDebugUtils<Pipeline<PVRVkPipeline, PVRVkPipelineCreateInfo>>
{
public:
    DECLARE_NO_COPY_SEMANTICS(Pipeline)
    const PipelineLayout& getPipelineLayout() const { return _createInfo.pipelineLayout; }

    const PVRVkPipelineCreateInfo& getCreateInfo() const { return _createInfo; }

protected:
    ~Pipeline()
    {
        if (_vkHandle != VK_NULL_HANDLE || _pipeCache != VK_NULL_HANDLE)
        {
            if (!_device.expired())
            {
                if (_vkHandle != VK_NULL_HANDLE)
                {
                    getDevice()->getVkBindings().vkDestroyPipeline(getDevice()->getVkHandle(), _vkHandle, nullptr);
                    _vkHandle = VK_NULL_HANDLE;
                }
                if (_pipeCache != VK_NULL_HANDLE)
                {
                    getDevice()->getVkBindings().vkDestroyPipelineCache(getDevice()->getVkHandle(), _pipeCache, nullptr);
                    _pipeCache = VK_NULL_HANDLE;
                }
            }
            else
            {
                reportDestroyedAfterDevice();
            }
        }
        _parent.reset();
    }

    Pipeline(const DeviceWeakPtr& device, VkPipeline vkPipeline, const PVRVkPipelineCreateInfo& desc)
        : PVRVkDeviceObjectBase<VkPipeline, ObjectType::e_PIPELINE>(device), DeviceObjectDebugUtils<Pipeline<PVRVkPipeline, PVRVkPipelineCreateInfo>>(), _pipeCache(VK_NULL_HANDLE)
    {
        _vkHandle = vkPipeline;
        _createInfo = desc;
    }

    PVRVkPipelineCreateInfo _createInfo;

    VkPipelineCache _pipeCache;

    PVRVkPipeline _parent;
};
} // namespace impl
} // namespace pvrvk