2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "vulkan/system/vk_objects.h"
|
|
|
|
#include "renderstyle.h"
|
|
|
|
#include "hwrenderer/data/buffers.h"
|
2022-07-02 08:09:59 +00:00
|
|
|
#include "hwrenderer/postprocessing/hw_postprocess.h"
|
2020-05-31 08:53:11 +00:00
|
|
|
#include "hw_renderstate.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <map>
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
class VulkanFrameBuffer;
|
|
|
|
class VkPPShader;
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
class VkPipelineKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FRenderStyle RenderStyle;
|
|
|
|
int SpecialEffect;
|
|
|
|
int EffectState;
|
|
|
|
int AlphaTest;
|
|
|
|
int DepthWrite;
|
|
|
|
int DepthTest;
|
|
|
|
int DepthFunc;
|
|
|
|
int DepthClamp;
|
|
|
|
int DepthBias;
|
|
|
|
int StencilTest;
|
|
|
|
int StencilPassOp;
|
|
|
|
int ColorMask;
|
|
|
|
int CullMode;
|
|
|
|
int VertexFormat;
|
|
|
|
int DrawType;
|
|
|
|
int NumTextureLayers;
|
|
|
|
|
|
|
|
bool operator<(const VkPipelineKey &other) const { return memcmp(this, &other, sizeof(VkPipelineKey)) < 0; }
|
|
|
|
bool operator==(const VkPipelineKey &other) const { return memcmp(this, &other, sizeof(VkPipelineKey)) == 0; }
|
|
|
|
bool operator!=(const VkPipelineKey &other) const { return memcmp(this, &other, sizeof(VkPipelineKey)) != 0; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class VkRenderPassKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int DepthStencil;
|
|
|
|
int Samples;
|
|
|
|
int DrawBuffers;
|
|
|
|
VkFormat DrawBufferFormat;
|
|
|
|
|
|
|
|
bool operator<(const VkRenderPassKey &other) const { return memcmp(this, &other, sizeof(VkRenderPassKey)) < 0; }
|
|
|
|
bool operator==(const VkRenderPassKey &other) const { return memcmp(this, &other, sizeof(VkRenderPassKey)) == 0; }
|
|
|
|
bool operator!=(const VkRenderPassKey &other) const { return memcmp(this, &other, sizeof(VkRenderPassKey)) != 0; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class VkRenderPassSetup
|
|
|
|
{
|
|
|
|
public:
|
2022-07-02 08:09:59 +00:00
|
|
|
VkRenderPassSetup(VulkanFrameBuffer* fb, const VkRenderPassKey &key);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
VulkanRenderPass *GetRenderPass(int clearTargets);
|
|
|
|
VulkanPipeline *GetPipeline(const VkPipelineKey &key);
|
|
|
|
|
|
|
|
VkRenderPassKey PassKey;
|
|
|
|
std::unique_ptr<VulkanRenderPass> RenderPasses[8];
|
|
|
|
std::map<VkPipelineKey, std::unique_ptr<VulkanPipeline>> Pipelines;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<VulkanRenderPass> CreateRenderPass(int clearTargets);
|
|
|
|
std::unique_ptr<VulkanPipeline> CreatePipeline(const VkPipelineKey &key);
|
2022-07-02 08:09:59 +00:00
|
|
|
|
|
|
|
VulkanFrameBuffer* fb = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class VkVertexFormat
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int NumBindingPoints;
|
|
|
|
size_t Stride;
|
|
|
|
std::vector<FVertexBufferAttribute> Attrs;
|
|
|
|
int UseVertexData;
|
|
|
|
};
|
|
|
|
|
2022-07-23 10:05:27 +00:00
|
|
|
enum class WhichDepthStencil;
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
class VkPPRenderPassKey
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VkPPShader* Shader;
|
|
|
|
int Uniforms;
|
|
|
|
int InputTextures;
|
|
|
|
PPBlendMode BlendMode;
|
|
|
|
VkFormat OutputFormat;
|
|
|
|
int SwapChain;
|
|
|
|
int ShadowMapBuffers;
|
2022-07-23 10:05:27 +00:00
|
|
|
WhichDepthStencil StencilTest;
|
2022-07-02 08:09:59 +00:00
|
|
|
VkSampleCountFlagBits Samples;
|
|
|
|
|
|
|
|
bool operator<(const VkPPRenderPassKey& other) const { return memcmp(this, &other, sizeof(VkPPRenderPassKey)) < 0; }
|
|
|
|
bool operator==(const VkPPRenderPassKey& other) const { return memcmp(this, &other, sizeof(VkPPRenderPassKey)) == 0; }
|
|
|
|
bool operator!=(const VkPPRenderPassKey& other) const { return memcmp(this, &other, sizeof(VkPPRenderPassKey)) != 0; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class VkPPRenderPassSetup
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VkPPRenderPassSetup(VulkanFrameBuffer* fb, const VkPPRenderPassKey& key);
|
|
|
|
|
|
|
|
std::unique_ptr<VulkanDescriptorSetLayout> DescriptorLayout;
|
|
|
|
std::unique_ptr<VulkanPipelineLayout> PipelineLayout;
|
|
|
|
std::unique_ptr<VulkanRenderPass> RenderPass;
|
|
|
|
std::unique_ptr<VulkanPipeline> Pipeline;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void CreateDescriptorLayout(const VkPPRenderPassKey& key);
|
|
|
|
void CreatePipelineLayout(const VkPPRenderPassKey& key);
|
|
|
|
void CreatePipeline(const VkPPRenderPassKey& key);
|
|
|
|
void CreateRenderPass(const VkPPRenderPassKey& key);
|
|
|
|
|
|
|
|
VulkanFrameBuffer* fb = nullptr;
|
|
|
|
};
|
|
|
|
|
2020-05-31 08:53:11 +00:00
|
|
|
class VkRenderPassManager
|
|
|
|
{
|
|
|
|
public:
|
2022-07-02 08:09:59 +00:00
|
|
|
VkRenderPassManager(VulkanFrameBuffer* fb);
|
2020-05-31 08:53:11 +00:00
|
|
|
~VkRenderPassManager();
|
|
|
|
|
|
|
|
void RenderBuffersReset();
|
|
|
|
|
|
|
|
VkRenderPassSetup *GetRenderPass(const VkRenderPassKey &key);
|
|
|
|
int GetVertexFormat(int numBindingPoints, int numAttributes, size_t stride, const FVertexBufferAttribute *attrs);
|
|
|
|
VkVertexFormat *GetVertexFormat(int index);
|
|
|
|
VulkanPipelineLayout* GetPipelineLayout(int numLayers);
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
VkPPRenderPassSetup* GetPPRenderPass(const VkPPRenderPassKey& key);
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
private:
|
2022-07-02 08:09:59 +00:00
|
|
|
VulkanFrameBuffer* fb = nullptr;
|
|
|
|
|
|
|
|
std::map<VkRenderPassKey, std::unique_ptr<VkRenderPassSetup>> RenderPassSetup;
|
2020-05-31 08:53:11 +00:00
|
|
|
std::vector<std::unique_ptr<VulkanPipelineLayout>> PipelineLayouts;
|
|
|
|
std::vector<VkVertexFormat> VertexFormats;
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
std::map<VkPPRenderPassKey, std::unique_ptr<VkPPRenderPassSetup>> PPRenderPassSetup;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|