mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-21 22:34:43 +00:00
Correctly propagate errors when creating shader module
This commit is contained in:
parent
bbda9a98d4
commit
41847a1b99
@ -32,7 +32,9 @@ pub struct {name} {{
|
||||
impl {name} {{
|
||||
/// Loads the shader in Vulkan as a `ShaderModule`.
|
||||
#[inline]
|
||||
pub fn load(device: &::std::sync::Arc<::vulkano::device::Device>) -> {name} {{
|
||||
pub fn load(device: &::std::sync::Arc<::vulkano::device::Device>)
|
||||
-> Result<{name}, ::vulkano::OomError>
|
||||
{{
|
||||
|
||||
"#, name = name));
|
||||
|
||||
@ -54,9 +56,9 @@ impl {name} {{
|
||||
unsafe {{
|
||||
let data = [{spirv_data}];
|
||||
|
||||
{name} {{
|
||||
shader: ::vulkano::shader::ShaderModule::new(device, &data).unwrap() // FIXME: try!()
|
||||
}}
|
||||
Ok({name} {{
|
||||
shader: try!(::vulkano::shader::ShaderModule::new(device, &data))
|
||||
}})
|
||||
}}
|
||||
}}
|
||||
|
||||
|
@ -130,9 +130,9 @@ fn main() {
|
||||
//
|
||||
// Because of some restrictions with the `include!` macro, we need to use a module.
|
||||
mod vs { include!{concat!(env!("OUT_DIR"), "/examples-triangle_vs.rs")} }
|
||||
let vs = vs::TriangleShader::load(&device);
|
||||
let vs = vs::TriangleShader::load(&device).expect("failed to create shader module");
|
||||
mod fs { include!{concat!(env!("OUT_DIR"), "/examples-triangle_fs.rs")} }
|
||||
let fs = fs::TriangleShader::load(&device);
|
||||
let fs = fs::TriangleShader::load(&device).expect("failed to create shader module");
|
||||
|
||||
// At this point, OpenGL initialization would be finished. However in Vulkan it is not. OpenGL
|
||||
// implicitely does a lot of computation whenever you draw. In Vulkan, you have to do all this
|
||||
|
Loading…
Reference in New Issue
Block a user