4 #include "module_backend.h"
12 VulkanSpirVModule::VulkanSpirVModule():
13 device(Device::get_current())
16 VulkanSpirVModule::VulkanSpirVModule(VulkanSpirVModule &&other):
23 VulkanSpirVModule::~VulkanSpirVModule()
25 const VulkanFunctions &vk = device.get_functions();
28 vk.DestroyShaderModule(handle);
31 void VulkanSpirVModule::create()
33 const vector<uint32_t> &code = static_cast<const SpirVModule *>(this)->code;
34 const VulkanFunctions &vk = device.get_functions();
36 VkShaderModuleCreateInfo module_info = { };
37 module_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
38 module_info.codeSize = code.size()*4;
39 module_info.pCode = code.data();
41 vk.CreateShaderModule(module_info, handle);
45 unsigned get_vulkan_stage(unsigned stage)
49 case SpirVModule::VERTEX: return VK_SHADER_STAGE_VERTEX_BIT;
50 case SpirVModule::GEOMETRY: return VK_SHADER_STAGE_GEOMETRY_BIT;
51 case SpirVModule::FRAGMENT: return VK_SHADER_STAGE_FRAGMENT_BIT;
52 default: throw invalid_argument("get_vulkan_stage");