From 41847a1b9904e4978868166914ddbc0e1e590c00 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 18 Feb 2016 21:23:26 +0100 Subject: [PATCH] Correctly propagate errors when creating shader module --- vulkano-shaders/src/lib.rs | 10 ++++++---- vulkano/examples/triangle.rs | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/vulkano-shaders/src/lib.rs b/vulkano-shaders/src/lib.rs index 45f43223..f2b4c713 100644 --- a/vulkano-shaders/src/lib.rs +++ b/vulkano-shaders/src/lib.rs @@ -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)) + }}) }} }} diff --git a/vulkano/examples/triangle.rs b/vulkano/examples/triangle.rs index 845bd9a7..45df0045 100644 --- a/vulkano/examples/triangle.rs +++ b/vulkano/examples/triangle.rs @@ -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