2019-02-26 10:27:29 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "vulkan/system/vk_objects.h"
|
2019-02-28 23:42:51 +00:00
|
|
|
#include "r_data/renderstyle.h"
|
2019-03-01 14:37:13 +00:00
|
|
|
#include "hwrenderer/data/buffers.h"
|
2019-02-28 23:42:51 +00:00
|
|
|
#include <map>
|
2019-02-26 10:27:29 +00:00
|
|
|
|
|
|
|
class VKDataBuffer;
|
|
|
|
|
2019-02-28 23:42:51 +00:00
|
|
|
class VkRenderPassKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FRenderStyle RenderStyle;
|
2019-03-01 01:40:02 +00:00
|
|
|
int SpecialEffect;
|
|
|
|
int EffectState;
|
|
|
|
bool AlphaTest;
|
2019-03-01 14:37:13 +00:00
|
|
|
int VertexFormat;
|
2019-02-28 23:42:51 +00:00
|
|
|
|
|
|
|
bool operator<(const VkRenderPassKey &other) const
|
|
|
|
{
|
2019-03-01 14:37:13 +00:00
|
|
|
uint64_t a = RenderStyle.AsDWORD | (static_cast<uint64_t>(SpecialEffect) << 32) | (static_cast<uint64_t>(EffectState) << 40) | (static_cast<uint64_t>(AlphaTest) << 48) | (static_cast<uint64_t>(VertexFormat) << 56);
|
|
|
|
uint64_t b = other.RenderStyle.AsDWORD | (static_cast<uint64_t>(other.SpecialEffect) << 32) | (static_cast<uint64_t>(other.EffectState) << 40) | (static_cast<uint64_t>(other.AlphaTest) << 48) | (static_cast<uint64_t>(other.VertexFormat) << 56);
|
2019-03-01 01:40:02 +00:00
|
|
|
return a < b;
|
2019-02-28 23:42:51 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-02-26 10:27:29 +00:00
|
|
|
class VkRenderPassSetup
|
|
|
|
{
|
|
|
|
public:
|
2019-02-28 23:42:51 +00:00
|
|
|
VkRenderPassSetup(const VkRenderPassKey &key);
|
2019-02-26 10:27:29 +00:00
|
|
|
|
|
|
|
std::unique_ptr<VulkanRenderPass> RenderPass;
|
|
|
|
std::unique_ptr<VulkanPipeline> Pipeline;
|
|
|
|
std::unique_ptr<VulkanFramebuffer> Framebuffer;
|
|
|
|
|
|
|
|
private:
|
2019-02-28 23:42:51 +00:00
|
|
|
void CreatePipeline(const VkRenderPassKey &key);
|
2019-02-26 10:27:29 +00:00
|
|
|
void CreateRenderPass();
|
|
|
|
void CreateFramebuffer();
|
|
|
|
};
|
|
|
|
|
2019-03-01 14:37:13 +00:00
|
|
|
class VkVertexFormat
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int NumBindingPoints;
|
|
|
|
size_t Stride;
|
|
|
|
std::vector<FVertexBufferAttribute> Attrs;
|
|
|
|
};
|
|
|
|
|
2019-02-26 10:27:29 +00:00
|
|
|
class VkRenderPassManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VkRenderPassManager();
|
|
|
|
|
2019-03-01 14:37:13 +00:00
|
|
|
void Init();
|
2019-02-26 10:27:29 +00:00
|
|
|
void BeginFrame();
|
2019-02-28 23:42:51 +00:00
|
|
|
VkRenderPassSetup *GetRenderPass(const VkRenderPassKey &key);
|
2019-02-26 10:27:29 +00:00
|
|
|
|
2019-03-01 14:37:13 +00:00
|
|
|
int GetVertexFormat(int numBindingPoints, int numAttributes, size_t stride, const FVertexBufferAttribute *attrs);
|
|
|
|
|
2019-02-26 10:27:29 +00:00
|
|
|
std::unique_ptr<VulkanDescriptorSetLayout> DynamicSetLayout;
|
|
|
|
std::unique_ptr<VulkanDescriptorSetLayout> TextureSetLayout;
|
|
|
|
std::unique_ptr<VulkanPipelineLayout> PipelineLayout;
|
|
|
|
std::unique_ptr<VulkanDescriptorPool> DescriptorPool;
|
2019-02-28 23:42:51 +00:00
|
|
|
std::map<VkRenderPassKey, std::unique_ptr<VkRenderPassSetup>> RenderPassSetup;
|
2019-02-26 10:27:29 +00:00
|
|
|
|
|
|
|
std::unique_ptr<VulkanImage> SceneColor;
|
|
|
|
std::unique_ptr<VulkanImage> SceneDepthStencil;
|
|
|
|
std::unique_ptr<VulkanImageView> SceneColorView;
|
|
|
|
std::unique_ptr<VulkanImageView> SceneDepthStencilView;
|
|
|
|
std::unique_ptr<VulkanImageView> SceneDepthView;
|
|
|
|
|
|
|
|
std::unique_ptr<VulkanDescriptorSet> DynamicSet;
|
|
|
|
|
2019-03-01 14:37:13 +00:00
|
|
|
std::vector<VkVertexFormat> VertexFormats;
|
|
|
|
|
2019-02-26 10:27:29 +00:00
|
|
|
private:
|
|
|
|
void CreateDynamicSetLayout();
|
|
|
|
void CreateTextureSetLayout();
|
|
|
|
void CreatePipelineLayout();
|
|
|
|
void CreateDescriptorPool();
|
|
|
|
void CreateDynamicSet();
|
|
|
|
};
|