SleakEngine
0.1.0
C++23 multi-backend game engine
Toggle main menu visibility
Loading...
Searching...
No Matches
VulkanShader.hpp
Go to the documentation of this file.
1
#ifndef _VULKANSHADER_H_
2
#define _VULKANSHADER_H_
3
4
#include <vector>
5
#include "
Graphics/Common/Shader.hpp
"
6
#include "vulkan/vulkan_core.h"
7
8
namespace
Sleak
{
9
namespace
RenderEngine
{
10
11
/// Vulkan vertex+fragment shader pair, loaded from precompiled SPIR-V modules.
12
class
ENGINE_API
VulkanShader
:
public
Shader
{
13
public
:
14
VulkanShader
(VkDevice dev) : device(dev) {}
15
~VulkanShader
();
16
17
/// Loads the combined-path convention's .vert.spv/.frag.spv pair.
18
virtual
bool
compile(
const
std::string& shaderPath)
override
;
19
/// Loads separate vertex and fragment SPIR-V modules.
20
virtual
bool
compile(
const
std::string& vert,
const
std::string& frag)
override
;
21
/// Loads only the vertex stage (used for depth-only/shadow pipelines with no fragment shader).
22
bool
compileVertexOnly(
const
std::string& vertPath);
23
/// Reads a .spv file and creates a VkShaderModule from it.
24
VkShaderModule LoadSPIRV(
const
char
* path);
25
/// No-op: Vulkan binds shader stages via pipeline creation, not a runtime bind call.
26
virtual
void
bind()
override
;
27
28
inline
VkShaderModule
GetVertexShader
() {
return
vertShader; }
29
inline
VkShaderModule
GetFragmentShader
() {
return
fragShader; }
30
31
inline
VkPipelineShaderStageCreateInfo
GetVertexInfo
() {
return
vertexInfo;}
32
inline
VkPipelineShaderStageCreateInfo
GetFragInfo
() {
return
fragmentInfo;}
33
34
private
:
35
VkDevice device =
nullptr
;
36
VkShaderModule vertShader =
nullptr
;
37
VkShaderModule fragShader =
nullptr
;
38
39
VkPipelineShaderStageCreateInfo vertexInfo{};
40
VkPipelineShaderStageCreateInfo fragmentInfo{};
41
42
/// Wraps compiled SPIR-V bytecode in a VkShaderModule.
43
VkShaderModule createShaderModule(
const
std::vector<char>& code);
44
/// Reads a binary file's full contents (used for .spv loading).
45
std::vector<char> ReadFile(
const
std::string& path);
46
47
};
48
49
}
50
}
51
52
#endif
Shader.hpp
Sleak::RenderEngine::Shader
Backend-agnostic compiled shader program.
Definition
Shader.hpp:11
Sleak::RenderEngine::VulkanShader
Vulkan vertex+fragment shader pair, loaded from precompiled SPIR-V modules.
Definition
VulkanShader.hpp:12
Sleak::RenderEngine::VulkanShader::VulkanShader
VulkanShader(VkDevice dev)
Definition
VulkanShader.hpp:14
Sleak::RenderEngine::VulkanShader::GetFragInfo
VkPipelineShaderStageCreateInfo GetFragInfo()
Definition
VulkanShader.hpp:32
Sleak::RenderEngine::VulkanShader::GetVertexShader
VkShaderModule GetVertexShader()
Definition
VulkanShader.hpp:28
Sleak::RenderEngine::VulkanShader::GetVertexInfo
VkPipelineShaderStageCreateInfo GetVertexInfo()
Definition
VulkanShader.hpp:31
Sleak::RenderEngine::VulkanShader::GetFragmentShader
VkShaderModule GetFragmentShader()
Definition
VulkanShader.hpp:29
Sleak::RenderEngine
Backend-facing rendering layer shared by the four graphics backends.
Definition
Application.hpp:60
Sleak
Root namespace for everything the engine exposes.
Definition
Camera.hpp:10
include
private
Graphics
Vulkan
VulkanShader.hpp
Generated on
for SleakEngine by
1.18.0