forked from KomputeProject/kompute
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShader.cpp
More file actions
43 lines (37 loc) · 1.13 KB
/
Shader.cpp
File metadata and controls
43 lines (37 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "kompute/Shader.hpp"
namespace kp {
Shader::Shader(const std::shared_ptr<vk::Device>& device,
const std::vector<uint32_t>& spv) :
mDevice(device)
{
KP_LOG_DEBUG("Kompute Module constructor started");
KP_LOG_DEBUG("Kompute Module Creating shader module. ShaderFileSize: {}",
spv.size());
vk::ShaderModuleCreateInfo shaderModuleInfo(vk::ShaderModuleCreateFlags(),
sizeof(uint32_t) * spv.size(), spv.data());
this->mDevice->createShaderModule(
&shaderModuleInfo, nullptr, &(this->mShaderModule) );
KP_LOG_DEBUG("Kompute Module constructor success");
}
const vk::ShaderModule& Shader::getShaderModule()
{
if (this->mDestroyed)
throw std::runtime_error("Attempting to get vk::ShaderModule from destroyed kp::Shader instance");
return this->mShaderModule;
}
void Shader::destroy()
{
KP_LOG_DEBUG("Kompute Module destructor started");
KP_LOG_DEBUG("Kompute Module Destroying shader module");
if (!this->mDestroyed)
{
this->mDestroyed = true;
this->mDevice->destroyShaderModule(this->mShaderModule);
}
KP_LOG_DEBUG("Kompute Module destructor success");
}
Shader::~Shader()
{
this->destroy();
}
} // end namespace kp