FramebufferVk.h#
PVRVk Framebuffer Object class.
Includes#
ImageVk.h
(ImageVk.h)
Included By#
Namespaces#
Classes#
Source Code#
#pragma once
#include "ImageVk.h"
namespace pvrvk {
struct FramebufferCreateInfo
{
public:
friend class impl::Framebuffer_;
void clear()
{
_width = 0;
_height = 0;
_layers = 1;
_renderPass.reset();
for (uint32_t i = 0; i < total_max_attachments; ++i) { _attachments[i].reset(); }
}
FramebufferCreateInfo() : _numAttachments(0), _layers(1), _width(0), _height(0) {}
FramebufferCreateInfo(uint32_t width, uint32_t height, uint32_t layers, const RenderPass& renderPass, uint32_t numAttachments = 0, ImageView* attachments = nullptr)
: _numAttachments(numAttachments), _layers(layers), _width(width), _height(height), _renderPass(renderPass)
{
for (uint32_t i = 0; i < numAttachments; ++i) { _attachments[i] = attachments[i]; }
}
uint32_t getNumAttachments() const { return _numAttachments; }
const ImageView& getAttachment(uint32_t index) const
{
assert(index < _numAttachments && "Invalid attachment index");
return _attachments[index];
}
ImageView& getAttachment(uint32_t index)
{
assert(index < _numAttachments && "Invalid attachment index");
return _attachments[index];
}
const RenderPass& getRenderPass() const { return _renderPass; }
RenderPass& getRenderPass() { return _renderPass; }
Extent2D getDimensions() const { return Extent2D(_width, _height); }
FramebufferCreateInfo& setDimensions(uint32_t inWidth, uint32_t inHeight)
{
this->_width = inWidth;
this->_height = inHeight;
return *this;
}
FramebufferCreateInfo& setDimensions(const Extent2D& extent)
{
_width = extent.getWidth();
_height = extent.getHeight();
return *this;
}
FramebufferCreateInfo& setAttachment(uint32_t index, const ImageView& colorView)
{
assert(index < total_max_attachments && "Index out-of-bound");
if (index >= _numAttachments) { _numAttachments = index + 1; }
this->_attachments[index] = colorView;
return *this;
}
inline uint32_t getLayers() const { return _layers; }
FramebufferCreateInfo& setNumLayers(uint32_t numLayers)
{
_layers = numLayers;
return *this;
}
FramebufferCreateInfo& setRenderPass(const RenderPass& renderPass)
{
this->_renderPass = renderPass;
return *this;
}
private:
enum
{
total_max_attachments = FrameworkCaps::MaxColorAttachments + FrameworkCaps::MaxDepthStencilAttachments
};
ImageView _attachments[total_max_attachments];
uint32_t _numAttachments;
uint32_t _layers;
uint32_t _width;
uint32_t _height;
RenderPass _renderPass;
};
namespace impl {
class Framebuffer_ : public PVRVkDeviceObjectBase<VkFramebuffer, ObjectType::e_FRAMEBUFFER>, public DeviceObjectDebugUtils<Framebuffer_>
{
private:
friend class Device_;
class make_shared_enabler
{
protected:
make_shared_enabler() {}
friend class Framebuffer_;
};
static Framebuffer constructShared(const DeviceWeakPtr& device, const FramebufferCreateInfo& createInfo)
{
return std::make_shared<Framebuffer_>(make_shared_enabler{}, device, createInfo);
}
FramebufferCreateInfo _createInfo;
public:
DECLARE_NO_COPY_SEMANTICS(Framebuffer_)
Framebuffer_(make_shared_enabler, const DeviceWeakPtr& device, const FramebufferCreateInfo& createInfo);
~Framebuffer_();
const RenderPass& getRenderPass() const { return _createInfo._renderPass; }
const FramebufferCreateInfo& getCreateInfo() const { return _createInfo; }
Extent2D getDimensions() const { return _createInfo.getDimensions(); }
const ImageView& getAttachment(uint32_t index) const { return _createInfo.getAttachment(index); }
ImageView& getAttachment(uint32_t index) { return _createInfo.getAttachment(index); }
uint32_t getNumAttachments() const { return _createInfo.getNumAttachments(); }
};
} // namespace impl
} // namespace pvrvk