Files
Seele/src/Engine/Graphics/Vulkan/Shader.h
T

67 lines
1.8 KiB
C++
Raw Normal View History

2020-05-05 01:51:13 +02:00
#pragma once
2023-10-26 18:37:29 +02:00
#include "Resources.h"
#include "Enums.h"
#include "Graphics/Shader.h"
2020-05-05 01:51:13 +02:00
namespace Seele
{
namespace Vulkan
{
2021-04-01 16:40:14 +02:00
DECLARE_REF(Graphics)
DECLARE_REF(DescriptorLayout)
2020-05-05 01:51:13 +02:00
class Shader
{
public:
Shader(PGraphics graphics, ShaderType shaderType, VkShaderStageFlags stage);
virtual ~Shader();
2020-06-02 11:46:18 +02:00
void create(const ShaderCreateInfo& createInfo);
2020-05-05 01:51:13 +02:00
VkShaderModule getModuleHandle() const
{
return module;
}
const char* getEntryPointName() const
{
2020-10-03 11:00:10 +02:00
//SLang renames all entry points to main, so we dont need that
return "main";//entryPointName.c_str();
2020-05-05 01:51:13 +02:00
}
2020-06-02 11:46:18 +02:00
Map<uint32, PDescriptorLayout> getDescriptorLayouts();
uint32 getShaderHash() const;
2020-05-05 01:51:13 +02:00
private:
2020-06-02 11:46:18 +02:00
PGraphics graphics;
Map<uint32, PDescriptorLayout> descriptorSets;
2020-05-05 01:51:13 +02:00
VkShaderModule module;
2020-06-02 11:46:18 +02:00
ShaderType type;
2021-04-01 16:40:14 +02:00
VkShaderStageFlags stage;
2020-05-05 01:51:13 +02:00
std::string entryPointName;
uint32 hash;
2020-05-05 01:51:13 +02:00
};
2021-04-01 16:40:14 +02:00
DEFINE_REF(Shader)
2020-05-05 01:51:13 +02:00
2020-06-02 11:46:18 +02:00
template <typename Base, ShaderType shaderType, VkShaderStageFlags stageFlags>
2020-05-05 01:51:13 +02:00
class ShaderBase : public Base, public Shader
{
public:
ShaderBase(PGraphics graphics)
2020-06-02 11:46:18 +02:00
: Shader(graphics, shaderType, stageFlags)
2020-05-05 01:51:13 +02:00
{
}
virtual ~ShaderBase()
{
}
};
typedef ShaderBase<Gfx::VertexShader, ShaderType::VERTEX, VK_SHADER_STAGE_VERTEX_BIT> VertexShader;
typedef ShaderBase<Gfx::FragmentShader, ShaderType::FRAGMENT, VK_SHADER_STAGE_FRAGMENT_BIT> FragmentShader;
typedef ShaderBase<Gfx::ComputeShader, ShaderType::COMPUTE, VK_SHADER_STAGE_COMPUTE_BIT> ComputeShader;
2023-10-26 18:37:29 +02:00
typedef ShaderBase<Gfx::TaskShader, ShaderType::TASK, VK_SHADER_STAGE_TASK_BIT_EXT> TaskShader;
typedef ShaderBase<Gfx::MeshShader, ShaderType::MESH, VK_SHADER_STAGE_MESH_BIT_EXT> MeshShader;
2020-05-05 01:51:13 +02:00
2021-04-01 16:40:14 +02:00
DEFINE_REF(VertexShader)
DEFINE_REF(FragmentShader)
DEFINE_REF(ComputeShader)
2023-10-26 18:37:29 +02:00
DEFINE_REF(TaskShader)
DEFINE_REF(MeshShader)
2020-05-05 01:51:13 +02:00
} // namespace Vulkan
}