Kale
Loading...
Searching...
No Matches
Shader.hpp
Go to the documentation of this file.
1/*
2 Copyright 2022 Rishi Challa
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#pragma once
18
19#ifdef KALE_VULKAN
20
22
23#include <vulkan/vulkan.hpp>
24#include <string>
25#include <vector>
26
27namespace Kale::Vulkan {
28
32 class Device;
33
37 enum class ShaderType {
39 };
40
44 class Shader : public ChildResource<Device> {
45
52 std::vector<char> readFile(const std::string& filename) const;
53
58 void createShaderModule(const std::vector<char>& code);
59
60 public:
61
66
70 vk::UniqueShaderModule shader;
71
75 Shader();
76
84 Shader(const std::string& filename, ShaderType type, Device& device);
85
93 void init(const std::string& filename, ShaderType type, Device& device);
94
98 void freeResources(bool remove = true) override;
99
104 vk::ShaderStageFlagBits getShaderStage() const;
105
110 vk::PipelineShaderStageCreateInfo getShaderPipelineInfo() const;
111 };
112}
113
114#endif
ShaderType type
Definition Shader.hpp:65
vk::UniqueShaderModule shader
Definition Shader.hpp:70
std::vector< char > readFile(const std::string &filename) const
Definition Shader.cpp:69
vk::PipelineShaderStageCreateInfo getShaderPipelineInfo() const
Definition Shader.cpp:117
vk::ShaderStageFlagBits getShaderStage() const
Definition Shader.cpp:102
void freeResources(bool remove=true) override
Definition Shader.cpp:93
void createShaderModule(const std::vector< char > &code)
Definition Shader.cpp:84
void init(const std::string &filename, ShaderType type, Device &device)
Definition Shader.cpp:56