RenderPassVk.h#

The PVRVk RenderPass class.

Includes#

Included By#

Namespaces#

Classes#

Source Code#

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

namespace pvrvk {

struct RenderPassCreateInfo
{
private:
    friend class impl::RenderPass_;
    std::vector<AttachmentDescription> _attachmentDescriptions;
    std::vector<SubpassDescription> _subpasses;
    std::vector<SubpassDependency> _subpassDependencies;

public:
    RenderPassCreateInfo() {}

    void clear()
    {
        _attachmentDescriptions.clear();
        _subpasses.clear();
        _subpassDependencies.clear();
    }

    uint32_t getNumSubpasses() const { return static_cast<uint32_t>(_subpasses.size()); }

    const SubpassDescription& getSubpass(uint32_t index) const
    {
        assert(index < getNumSubpasses() && "Invalid subpass index");
        return _subpasses[index];
    }

    uint32_t getNumSubpassDependencies() const { return static_cast<uint32_t>(_subpassDependencies.size()); }

    const SubpassDependency& getSubpassDependency(uint32_t index) const
    {
        assert(index < getNumSubpassDependencies() && "Invalid subpass dependency index");
        return _subpassDependencies[index];
    }

    uint32_t getNumAttachmentDescription() const { return static_cast<uint32_t>(_attachmentDescriptions.size()); }

    const AttachmentDescription& getAttachmentDescription(uint32_t index) const
    {
        assert(index < getNumAttachmentDescription() && "Invalid color info index");
        return _attachmentDescriptions[index];
    }

    RenderPassCreateInfo& setAttachmentDescription(uint32_t index, const AttachmentDescription& attachmentDescription)
    {
        setElementAtIndex<AttachmentDescription>(index, attachmentDescription, _attachmentDescriptions);
        return *this;
    }

    RenderPassCreateInfo& setSubpass(uint32_t index, const SubpassDescription& subpass)
    {
        setElementAtIndex<SubpassDescription>(index, subpass, _subpasses);
        return *this;
    }

    RenderPassCreateInfo& addSubpassDependency(const SubpassDependency& subPassDependency)
    {
        if ((subPassDependency.getSrcSubpass() != pvrvk::SubpassExternal) && (subPassDependency.getSrcSubpass() > subPassDependency.getDstSubpass()))
        { assert(false && " Source Sub pass must be less than or equal to destination Sub pass"); }
        _subpassDependencies.emplace_back(subPassDependency);
        return *this;
    }

    RenderPassCreateInfo& addSubpassDependencies(const SubpassDependency* subPassDependencies, uint32_t numDependencies)
    {
        for (uint32_t i = 0; i < numDependencies; ++i) { addSubpassDependency(subPassDependencies[i]); }
        return *this;
    }

    bool extendedSupportRequired() const {
        for (const SubpassDescription& subpass : _subpasses)
        {
            if (subpass.getFragmentShadingRateAttachment().getEnabled())
            { return true; }
        }
        return false;
    }
};

namespace impl {

class RenderPass_ : public PVRVkDeviceObjectBase<VkRenderPass, ObjectType::e_RENDER_PASS>, public DeviceObjectDebugUtils<RenderPass_>
{
private:
    friend class Device_;

    class make_shared_enabler
    {
    protected:
        make_shared_enabler() = default;
        friend class RenderPass_;
    };

    static RenderPass constructShared(const DeviceWeakPtr& device, const RenderPassCreateInfo& createInfo)
    {
        return std::make_shared<RenderPass_>(make_shared_enabler{}, device, createInfo);
    }

    void createRenderPass(const RenderPassCreateInfo& createInfo);
    void createRenderPass2(const RenderPassCreateInfo& createInfo);

    RenderPassCreateInfo _createInfo;

public:
    DECLARE_NO_COPY_SEMANTICS(RenderPass_)
    RenderPass_(make_shared_enabler, const DeviceWeakPtr& device, const RenderPassCreateInfo& createInfo);

    ~RenderPass_();

    const RenderPassCreateInfo& getCreateInfo() const { return _createInfo; }
};
} // namespace impl
} // namespace pvrvk