2018-02-21 01:04:28 +01:00
|
|
|
#pragma once
|
|
|
|
|
2018-06-23 13:07:11 +02:00
|
|
|
#include <mutex>
|
2018-02-21 01:04:28 +01:00
|
|
|
#include <unordered_map>
|
|
|
|
|
2018-06-23 13:07:11 +02:00
|
|
|
#include "../spirv/spirv_code_buffer.h"
|
|
|
|
|
2018-02-21 01:04:28 +01:00
|
|
|
#include "dxvk_barrier.h"
|
|
|
|
#include "dxvk_cmdlist.h"
|
|
|
|
#include "dxvk_resource.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
2018-06-23 13:07:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Resolve pipeline
|
|
|
|
*
|
|
|
|
* Stores the objects for a single pipeline
|
|
|
|
* that is used for fragment shader resolve.
|
|
|
|
*/
|
|
|
|
struct DxvkMetaResolvePipeline {
|
|
|
|
VkRenderPass renderPass;
|
|
|
|
VkDescriptorSetLayout dsetLayout;
|
|
|
|
VkPipelineLayout pipeLayout;
|
|
|
|
VkPipeline pipeHandle;
|
|
|
|
};
|
|
|
|
|
2019-04-07 20:19:34 +02:00
|
|
|
/**
|
|
|
|
* \brief Copy pipeline key
|
|
|
|
*
|
|
|
|
* Used to look up copy pipelines based
|
|
|
|
* on the copy operation they support.
|
|
|
|
*/
|
|
|
|
struct DxvkMetaResolvePipelineKey {
|
|
|
|
VkFormat format;
|
|
|
|
VkSampleCountFlagBits samples;
|
|
|
|
|
|
|
|
bool eq(const DxvkMetaResolvePipelineKey& other) const {
|
|
|
|
return this->format == other.format
|
|
|
|
&& this->samples == other.samples;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t hash() const {
|
|
|
|
return (uint32_t(format) << 4)
|
|
|
|
^ (uint32_t(samples) << 0);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-21 01:04:28 +01:00
|
|
|
/**
|
2018-06-23 13:07:11 +02:00
|
|
|
* \brief Meta resolve render pass
|
2018-02-21 01:04:28 +01:00
|
|
|
*
|
|
|
|
* Stores a framebuffer and image view objects
|
|
|
|
* for a meta resolve operation. Can be tracked.
|
|
|
|
*/
|
2018-06-23 13:07:11 +02:00
|
|
|
class DxvkMetaResolveRenderPass : public DxvkResource {
|
2018-02-21 01:04:28 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2018-06-23 13:07:11 +02:00
|
|
|
DxvkMetaResolveRenderPass(
|
|
|
|
const Rc<vk::DeviceFn>& vkd,
|
|
|
|
const Rc<DxvkImageView>& dstImageView,
|
2019-04-19 11:19:14 +02:00
|
|
|
const Rc<DxvkImageView>& srcImageView,
|
|
|
|
bool discardDst);
|
2018-02-21 01:04:28 +01:00
|
|
|
|
2018-06-23 13:07:11 +02:00
|
|
|
~DxvkMetaResolveRenderPass();
|
2018-02-21 01:04:28 +01:00
|
|
|
|
|
|
|
VkRenderPass renderPass() const {
|
|
|
|
return m_renderPass;
|
|
|
|
}
|
2018-06-23 13:07:11 +02:00
|
|
|
|
2018-02-21 01:04:28 +01:00
|
|
|
VkFramebuffer framebuffer() const {
|
|
|
|
return m_framebuffer;
|
|
|
|
}
|
2018-06-23 13:07:11 +02:00
|
|
|
|
|
|
|
private:
|
2018-02-21 01:04:28 +01:00
|
|
|
|
2018-06-23 13:07:11 +02:00
|
|
|
const Rc<vk::DeviceFn> m_vkd;
|
|
|
|
|
|
|
|
const Rc<DxvkImageView> m_dstImageView;
|
|
|
|
const Rc<DxvkImageView> m_srcImageView;
|
|
|
|
|
|
|
|
VkRenderPass m_renderPass = VK_NULL_HANDLE;
|
|
|
|
VkFramebuffer m_framebuffer = VK_NULL_HANDLE;
|
|
|
|
|
2019-04-19 11:19:14 +02:00
|
|
|
VkRenderPass createRenderPass(bool discard) const;
|
2018-06-23 13:07:11 +02:00
|
|
|
|
|
|
|
VkFramebuffer createFramebuffer() const;
|
|
|
|
|
|
|
|
};
|
2018-02-21 01:04:28 +01:00
|
|
|
|
2019-04-07 20:19:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Meta resolve objects
|
|
|
|
*
|
|
|
|
* Implements resolve operations in fragment
|
|
|
|
* shaders when using different formats.
|
|
|
|
*/
|
|
|
|
class DxvkMetaResolveObjects : public RcObject {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
DxvkMetaResolveObjects(DxvkDevice* device);
|
|
|
|
~DxvkMetaResolveObjects();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Creates pipeline for meta copy operation
|
|
|
|
*
|
|
|
|
* \param [in] format Destination image format
|
|
|
|
* \param [in] samples Destination sample count
|
|
|
|
* \returns Compatible pipeline for the operation
|
|
|
|
*/
|
|
|
|
DxvkMetaResolvePipeline getPipeline(
|
|
|
|
VkFormat format,
|
|
|
|
VkSampleCountFlagBits samples);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
Rc<vk::DeviceFn> m_vkd;
|
|
|
|
|
|
|
|
VkSampler m_sampler;
|
|
|
|
|
|
|
|
VkShaderModule m_shaderVert;
|
|
|
|
VkShaderModule m_shaderGeom;
|
|
|
|
VkShaderModule m_shaderFragF;
|
|
|
|
VkShaderModule m_shaderFragU;
|
|
|
|
VkShaderModule m_shaderFragI;
|
|
|
|
|
|
|
|
std::mutex m_mutex;
|
|
|
|
|
|
|
|
std::unordered_map<
|
|
|
|
DxvkMetaResolvePipelineKey,
|
|
|
|
DxvkMetaResolvePipeline,
|
|
|
|
DxvkHash, DxvkEq> m_pipelines;
|
|
|
|
|
|
|
|
VkSampler createSampler() const;
|
|
|
|
|
|
|
|
VkShaderModule createShaderModule(
|
|
|
|
const SpirvCodeBuffer& code) const;
|
|
|
|
|
|
|
|
DxvkMetaResolvePipeline createPipeline(
|
|
|
|
const DxvkMetaResolvePipelineKey& key);
|
|
|
|
|
|
|
|
VkRenderPass createRenderPass(
|
|
|
|
const DxvkMetaResolvePipelineKey& key);
|
|
|
|
|
|
|
|
VkDescriptorSetLayout createDescriptorSetLayout() const;
|
|
|
|
|
|
|
|
VkPipelineLayout createPipelineLayout(
|
|
|
|
VkDescriptorSetLayout descriptorSetLayout) const;
|
|
|
|
|
|
|
|
VkPipeline createPipelineObject(
|
|
|
|
const DxvkMetaResolvePipelineKey& key,
|
|
|
|
VkPipelineLayout pipelineLayout,
|
|
|
|
VkRenderPass renderPass);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-06-23 13:07:11 +02:00
|
|
|
}
|