mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
172 lines
3.7 KiB
C++
172 lines
3.7 KiB
C++
#pragma once
|
|
|
|
#include <mutex>
|
|
#include <unordered_map>
|
|
|
|
#include "dxvk_hash.h"
|
|
#include "dxvk_include.h"
|
|
#include "dxvk_limits.h"
|
|
|
|
namespace dxvk {
|
|
|
|
/**
|
|
* \brief Render pass format
|
|
*
|
|
* Stores the formats of all render targets
|
|
* that are used by a framebuffer object.
|
|
*/
|
|
class DxvkRenderPassFormat {
|
|
|
|
public:
|
|
|
|
DxvkRenderPassFormat();
|
|
|
|
/**
|
|
* \brief Retrieves color target format
|
|
*
|
|
* If the color target has not been defined,
|
|
* this will return \c VK_FORMAT_UNDEFINED.
|
|
* \param [in] id Color target index
|
|
* \returns Color target format
|
|
*/
|
|
VkFormat getColorFormat(uint32_t id) const {
|
|
return m_color.at(id);
|
|
}
|
|
|
|
/**
|
|
* \brief Retrieves depth-stencil format
|
|
*
|
|
* If the color target has not been defined,
|
|
* this will return \c VK_FORMAT_UNDEFINED.
|
|
*/
|
|
VkFormat getDepthFormat() const {
|
|
return m_depth;
|
|
}
|
|
|
|
/**
|
|
* \brief Retrieves sample count
|
|
*
|
|
* If no sample count has been explicitly specitied,
|
|
* this will return \c VK_SAMPLE_COUNT_1_BIT.
|
|
* \returns Sample count
|
|
*/
|
|
VkSampleCountFlagBits getSampleCount() const {
|
|
return m_samples;
|
|
}
|
|
|
|
/**
|
|
* \brief Sets color target format
|
|
*
|
|
* \param [in] id Color target index
|
|
* \param [in] fmt Color target format
|
|
*/
|
|
void setColorFormat(uint32_t id, VkFormat fmt) {
|
|
m_color.at(id) = fmt;
|
|
}
|
|
|
|
/**
|
|
* \brief Sets depth-stencil format
|
|
* \param [in] fmt Depth-stencil format
|
|
*/
|
|
void setDepthFormat(VkFormat fmt) {
|
|
m_depth = fmt;
|
|
}
|
|
|
|
/**
|
|
* \brief Sets sample count
|
|
* \param [in] samples Sample count
|
|
*/
|
|
void setSampleCount(VkSampleCountFlagBits samples) {
|
|
m_samples = samples;
|
|
}
|
|
|
|
/**
|
|
* \brief Computes the hash
|
|
* \returns Resulting hash
|
|
*/
|
|
size_t hash() const;
|
|
|
|
bool operator == (const DxvkRenderPassFormat& other) const;
|
|
bool operator != (const DxvkRenderPassFormat& other) const;
|
|
|
|
private:
|
|
|
|
std::array<VkFormat, MaxNumRenderTargets> m_color;
|
|
VkFormat m_depth;
|
|
VkSampleCountFlagBits m_samples;
|
|
|
|
};
|
|
|
|
|
|
/**
|
|
* \brief DXVK render pass
|
|
*
|
|
* Render pass objects are used internally to identify render
|
|
* target formats and
|
|
*/
|
|
class DxvkRenderPass : public RcObject {
|
|
|
|
public:
|
|
|
|
DxvkRenderPass(
|
|
const Rc<vk::DeviceFn>& vkd,
|
|
const DxvkRenderPassFormat& fmt);
|
|
~DxvkRenderPass();
|
|
|
|
/**
|
|
* \brief Render pass handle
|
|
*
|
|
* Internal use only.
|
|
* \returns Render pass handle
|
|
*/
|
|
VkRenderPass handle() const {
|
|
return m_renderPass;
|
|
}
|
|
|
|
private:
|
|
|
|
Rc<vk::DeviceFn> m_vkd;
|
|
DxvkRenderPassFormat m_format;
|
|
VkRenderPass m_renderPass;
|
|
|
|
};
|
|
|
|
|
|
/**
|
|
* \brief Render pass pool
|
|
*
|
|
* Thread-safe class that manages the render pass
|
|
* objects that are used within an application.
|
|
*/
|
|
class DxvkRenderPassPool : public RcObject {
|
|
|
|
public:
|
|
|
|
DxvkRenderPassPool(const Rc<vk::DeviceFn>& vkd);
|
|
~DxvkRenderPassPool();
|
|
|
|
/**
|
|
* \brief Retrieves a render pass object
|
|
*
|
|
* \param [in] fmt Render target formats
|
|
* \returns Compatible render pass object
|
|
*/
|
|
Rc<DxvkRenderPass> getRenderPass(
|
|
const DxvkRenderPassFormat& fmt);
|
|
|
|
private:
|
|
|
|
Rc<vk::DeviceFn> m_vkd;
|
|
|
|
std::mutex m_mutex;
|
|
std::unordered_map<
|
|
DxvkRenderPassFormat,
|
|
Rc<DxvkRenderPass>,
|
|
DxvkHash> m_renderPasses;
|
|
|
|
Rc<DxvkRenderPass> createRenderPass(
|
|
const DxvkRenderPassFormat& fmt);
|
|
|
|
};
|
|
|
|
} |