2017-10-10 23:32:13 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "dxvk_image.h"
|
|
|
|
#include "dxvk_renderpass.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Framebuffer size
|
|
|
|
*
|
|
|
|
* Stores the width, height and number of layers
|
|
|
|
* of a framebuffer. This can be used in case a
|
|
|
|
* framebuffer does not have any attachments.
|
|
|
|
*/
|
|
|
|
struct DxvkFramebufferSize {
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
uint32_t layers;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-02-06 17:31:23 +01:00
|
|
|
struct DxvkAttachment {
|
|
|
|
Rc<DxvkImageView> view = nullptr;
|
|
|
|
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-10-10 23:32:13 +02:00
|
|
|
/**
|
|
|
|
* \brief Render target description
|
|
|
|
*
|
|
|
|
* Stores render targets for a framebuffer object
|
|
|
|
* and provides methods to query the render pass
|
|
|
|
* format. Note that all render target views must
|
|
|
|
* have the same size and number of array layers.
|
|
|
|
*/
|
|
|
|
class DxvkRenderTargets {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
DxvkRenderTargets();
|
|
|
|
~DxvkRenderTargets();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Retrieves color target
|
|
|
|
*
|
|
|
|
* \param [in] id Color attachment ID
|
|
|
|
* \returns Render target view
|
|
|
|
*/
|
2018-02-06 17:31:23 +01:00
|
|
|
DxvkAttachment getColorTarget(uint32_t id) const {
|
2017-10-10 23:32:13 +02:00
|
|
|
return m_colorTargets.at(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Retrieves depth-stencil target
|
|
|
|
* \returns Depth-stencil target view
|
|
|
|
*/
|
2018-02-06 17:31:23 +01:00
|
|
|
DxvkAttachment getDepthTarget() const {
|
2017-10-10 23:32:13 +02:00
|
|
|
return m_depthTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Sets color target
|
|
|
|
*
|
|
|
|
* \param [in] id Color attachment ID
|
|
|
|
* \param [in] view Render target view
|
2018-02-06 17:31:23 +01:00
|
|
|
* \param [in] layout Layout to use for rendering
|
2017-10-10 23:32:13 +02:00
|
|
|
*/
|
2018-02-06 17:31:23 +01:00
|
|
|
void setColorTarget(
|
|
|
|
uint32_t id,
|
|
|
|
const Rc<DxvkImageView>& view,
|
|
|
|
VkImageLayout layout) {
|
|
|
|
m_colorTargets.at(id) = { view, layout };
|
2017-10-10 23:32:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Sets depth-stencil target
|
2018-02-06 17:31:23 +01:00
|
|
|
*
|
|
|
|
* \param [in] layout Layout to use for rendering
|
2017-10-10 23:32:13 +02:00
|
|
|
* \param [in] view Depth-stencil target view
|
|
|
|
*/
|
2018-02-06 17:31:23 +01:00
|
|
|
void setDepthTarget(
|
|
|
|
const Rc<DxvkImageView>& view,
|
|
|
|
VkImageLayout layout) {
|
|
|
|
m_depthTarget = { view, layout };
|
2017-10-10 23:32:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Render pass format
|
|
|
|
*
|
|
|
|
* Computes the render pass format based on
|
|
|
|
* the color and depth-stencil attachments.
|
|
|
|
* \returns Render pass format
|
|
|
|
*/
|
|
|
|
DxvkRenderPassFormat renderPassFormat() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Creates attachment list
|
2018-02-07 16:46:39 +01:00
|
|
|
*
|
|
|
|
* \param [out] viewHandles Attachment handles
|
|
|
|
* \returns Framebuffer attachment count
|
2017-10-10 23:32:13 +02:00
|
|
|
*/
|
2018-02-07 16:46:39 +01:00
|
|
|
uint32_t getAttachments(VkImageView* viewHandles) const;
|
2017-10-10 23:32:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Framebuffer size
|
|
|
|
*
|
|
|
|
* The width, height and layers
|
|
|
|
* of the attached render targets.
|
|
|
|
* \returns Framebuffer size
|
|
|
|
*/
|
|
|
|
DxvkFramebufferSize getImageSize() const;
|
|
|
|
|
2017-12-19 18:12:18 +01:00
|
|
|
/**
|
|
|
|
* \brief Checks whether any attachments are defined
|
|
|
|
* \returns \c false if no attachments are defined
|
|
|
|
*/
|
|
|
|
bool hasAttachments() const;
|
|
|
|
|
2018-04-15 03:01:52 +02:00
|
|
|
/**
|
|
|
|
* \brief Compares two sets of render targets
|
|
|
|
*
|
|
|
|
* Checks whether two sets of render targets
|
|
|
|
* are identical, including the image layout.
|
|
|
|
* \param [in] other Render target set to compare to
|
|
|
|
* \returns \c true if the render targets are the same
|
|
|
|
*/
|
|
|
|
bool matches(const DxvkRenderTargets& other) const;
|
|
|
|
|
2017-10-10 23:32:13 +02:00
|
|
|
private:
|
|
|
|
|
2018-02-06 17:31:23 +01:00
|
|
|
std::array<DxvkAttachment, MaxNumRenderTargets> m_colorTargets;
|
|
|
|
DxvkAttachment m_depthTarget;
|
2017-10-10 23:32:13 +02:00
|
|
|
|
|
|
|
DxvkFramebufferSize renderTargetSize(
|
|
|
|
const Rc<DxvkImageView>& renderTarget) const;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief DXVK framebuffer
|
|
|
|
*
|
|
|
|
* A framebuffer either stores a set of image views
|
|
|
|
* that will be used as render targets, or in case
|
|
|
|
* no render targets are being used, fixed viewport
|
|
|
|
* dimensions.
|
|
|
|
*/
|
|
|
|
class DxvkFramebuffer : public DxvkResource {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
DxvkFramebuffer(
|
|
|
|
const Rc<vk::DeviceFn>& vkd,
|
|
|
|
const Rc<DxvkRenderPass>& renderPass,
|
|
|
|
const DxvkRenderTargets& renderTargets);
|
|
|
|
~DxvkFramebuffer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Framebuffer handle
|
|
|
|
* \returns Framebuffer handle
|
|
|
|
*/
|
|
|
|
VkFramebuffer handle() const {
|
|
|
|
return m_framebuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Render pass handle
|
|
|
|
* \returns Render pass handle
|
|
|
|
*/
|
|
|
|
VkRenderPass renderPass() const {
|
|
|
|
return m_renderPass->handle();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Framebuffer size
|
|
|
|
* \returns Framebuffer size
|
|
|
|
*/
|
|
|
|
DxvkFramebufferSize size() const {
|
|
|
|
return m_framebufferSize;
|
|
|
|
}
|
|
|
|
|
2017-12-04 13:39:14 +01:00
|
|
|
/**
|
|
|
|
* \brief Render target info
|
|
|
|
* \returns Render target info
|
|
|
|
*/
|
|
|
|
const DxvkRenderTargets& renderTargets() const {
|
|
|
|
return m_renderTargets;
|
|
|
|
}
|
|
|
|
|
2017-12-12 00:27:49 +01:00
|
|
|
/**
|
|
|
|
* \brief Sample count
|
|
|
|
* \returns Sample count
|
|
|
|
*/
|
|
|
|
VkSampleCountFlagBits sampleCount() const {
|
|
|
|
return m_renderPass->sampleCount();
|
|
|
|
}
|
|
|
|
|
2018-03-17 17:59:43 +01:00
|
|
|
/**
|
|
|
|
* \brief Retrieves index of a given attachment
|
|
|
|
*
|
|
|
|
* \param [in] view The image view to look up
|
|
|
|
* \returns The attachment index, or \c 0 for a depth-stencil
|
|
|
|
* attachment, or \c MaxNumRenderTargets if the given
|
|
|
|
* view is not a framebuffer attachment.
|
|
|
|
*/
|
|
|
|
uint32_t findAttachment(
|
|
|
|
const Rc<DxvkImageView>& view) const;
|
|
|
|
|
2017-10-10 23:32:13 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
Rc<vk::DeviceFn> m_vkd;
|
|
|
|
Rc<DxvkRenderPass> m_renderPass;
|
2018-01-12 12:51:39 +01:00
|
|
|
|
2017-10-10 23:32:13 +02:00
|
|
|
DxvkRenderTargets m_renderTargets;
|
2018-01-12 12:51:39 +01:00
|
|
|
DxvkFramebufferSize m_framebufferSize = { 0, 0, 0 };
|
|
|
|
|
|
|
|
VkFramebuffer m_framebuffer = VK_NULL_HANDLE;
|
2017-10-10 23:32:13 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|