Skip to content

Instantly share code, notes, and snippets.

@xenobrain
Created June 17, 2021 11:14
Show Gist options
  • Save xenobrain/37a953da7ebba65e96ec8e74f7a90aa2 to your computer and use it in GitHub Desktop.
Save xenobrain/37a953da7ebba65e96ec8e74f7a90aa2 to your computer and use it in GitHub Desktop.
shaderc create_shader
auto create_shader(vk::raii::Device const& device, std::string const& source) {
auto static compiler = shaderc::Compiler{};
auto result{compiler.CompileGlslToSpv(source, shaderc_glsl_infer_from_source, "", {})};
if (result.GetCompilationStatus()) throw std::runtime_error(result.GetErrorMessage());
auto code = std::vector<std::uint32_t>(result.begin(), result.end());
return std::make_unique<vk::raii::ShaderModule>(device, vk::ShaderModuleCreateInfo{{}, code});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment