Created
June 17, 2021 11:14
-
-
Save xenobrain/37a953da7ebba65e96ec8e74f7a90aa2 to your computer and use it in GitHub Desktop.
shaderc create_shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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