18 ShaderModule::ShaderModule(std::vector<uint8_t> code,
ShaderStageBit stage) {
19 VkDevice device = VulkanContext::getCurrent()->getDevice()->getHandle();
20 this->shaderStageBit = stage;
23 VkShaderModuleCreateInfo createInfo = {};
24 createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
25 createInfo.codeSize = code.size();
26 createInfo.pCode =
reinterpret_cast<const uint32_t*
> (code.data());
29 if (vkCreateShaderModule(device, &createInfo,
nullptr, &handle) != VK_SUCCESS) {
30 throw runtime_error(
"Could not create a shader module!");
34 ShaderModule::~ShaderModule(
void) {
35 VkDevice device = VulkanContext::getCurrent()->getDevice()->getHandle();
38 vkDestroyShaderModule(device, handle,
nullptr);
41 VkShaderModule ShaderModule::getHandle() {
45 VkShaderStageFlagBits ShaderModule::getShaderStageBit() {
47 VkShaderStageFlagBits stageFlagBit;
48 switch (shaderStageBit) {
49 case ShaderStageBit::VERTEX_BIT:
50 stageFlagBit = VK_SHADER_STAGE_VERTEX_BIT;
52 case ShaderStageBit::FRAGMENT_BIT:
53 stageFlagBit = VK_SHADER_STAGE_FRAGMENT_BIT;
Generic namespace for the SimpleGL framework.
ShaderStageBit
This enum stores supported shader stage flag bit.