2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "vectors.h"
|
|
|
|
#include "matrix.h"
|
|
|
|
#include "name.h"
|
|
|
|
#include "hw_renderstate.h"
|
2022-07-02 08:09:59 +00:00
|
|
|
#include <list>
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
#define SHADER_MIN_REQUIRED_TEXTURE_LAYERS 8
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
class VulkanFrameBuffer;
|
2020-05-31 08:53:11 +00:00
|
|
|
class VulkanDevice;
|
|
|
|
class VulkanShader;
|
2022-07-02 08:09:59 +00:00
|
|
|
class VkPPShader;
|
|
|
|
class PPShader;
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
struct MatricesUBO
|
|
|
|
{
|
|
|
|
VSMatrix ModelMatrix;
|
|
|
|
VSMatrix NormalModelMatrix;
|
|
|
|
VSMatrix TextureMatrix;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_STREAM_DATA ((int)(65536 / sizeof(StreamData)))
|
|
|
|
|
|
|
|
struct StreamUBO
|
|
|
|
{
|
|
|
|
StreamData data[MAX_STREAM_DATA];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PushConstants
|
|
|
|
{
|
|
|
|
int uTextureMode;
|
|
|
|
float uAlphaThreshold;
|
|
|
|
FVector2 uClipSplit;
|
|
|
|
|
|
|
|
// Lighting + Fog
|
|
|
|
float uLightLevel;
|
|
|
|
float uFogDensity;
|
|
|
|
float uLightFactor;
|
|
|
|
float uLightDist;
|
|
|
|
int uFogEnabled;
|
|
|
|
|
|
|
|
// dynamic lights
|
|
|
|
int uLightIndex;
|
|
|
|
|
|
|
|
// Blinn glossiness and specular level
|
|
|
|
FVector2 uSpecularMaterial;
|
|
|
|
|
|
|
|
int uDataIndex;
|
|
|
|
int padding1, padding2, padding3;
|
|
|
|
};
|
|
|
|
|
|
|
|
class VkShaderProgram
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::unique_ptr<VulkanShader> vert;
|
|
|
|
std::unique_ptr<VulkanShader> frag;
|
|
|
|
};
|
|
|
|
|
|
|
|
class VkShaderManager
|
|
|
|
{
|
|
|
|
public:
|
2022-07-02 08:09:59 +00:00
|
|
|
VkShaderManager(VulkanFrameBuffer* fb);
|
2020-05-31 08:53:11 +00:00
|
|
|
~VkShaderManager();
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
void Deinit();
|
|
|
|
|
2020-05-31 08:53:11 +00:00
|
|
|
VkShaderProgram *GetEffect(int effect, EPassType passType);
|
|
|
|
VkShaderProgram *Get(unsigned int eff, bool alphateston, EPassType passType);
|
2022-06-06 09:45:02 +00:00
|
|
|
bool CompileNextShader();
|
2020-05-31 08:53:11 +00:00
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
VkPPShader* GetVkShader(PPShader* shader);
|
|
|
|
|
|
|
|
void AddVkPPShader(VkPPShader* shader);
|
|
|
|
void RemoveVkPPShader(VkPPShader* shader);
|
|
|
|
|
2020-05-31 08:53:11 +00:00
|
|
|
private:
|
|
|
|
std::unique_ptr<VulkanShader> LoadVertShader(FString shadername, const char *vert_lump, const char *defines);
|
|
|
|
std::unique_ptr<VulkanShader> LoadFragShader(FString shadername, const char *frag_lump, const char *material_lump, const char *light_lump, const char *defines, bool alphatest, bool gbufferpass);
|
|
|
|
|
|
|
|
FString GetTargetGlslVersion();
|
|
|
|
FString LoadPublicShaderLump(const char *lumpname);
|
|
|
|
FString LoadPrivateShaderLump(const char *lumpname);
|
|
|
|
|
2022-07-02 08:09:59 +00:00
|
|
|
VulkanFrameBuffer* fb = nullptr;
|
2020-05-31 08:53:11 +00:00
|
|
|
|
|
|
|
std::vector<VkShaderProgram> mMaterialShaders[MAX_PASS_TYPES];
|
|
|
|
std::vector<VkShaderProgram> mMaterialShadersNAT[MAX_PASS_TYPES];
|
|
|
|
std::vector<VkShaderProgram> mEffectShaders[MAX_PASS_TYPES];
|
2022-06-06 09:45:02 +00:00
|
|
|
uint8_t compilePass = 0, compileState = 0;
|
|
|
|
int compileIndex = 0;
|
2022-07-02 08:09:59 +00:00
|
|
|
|
|
|
|
std::list<VkPPShader*> PPShaders;
|
2020-05-31 08:53:11 +00:00
|
|
|
};
|