From 4125a01ea164fc21abd89dfc1c2a8cadeb4198d9 Mon Sep 17 00:00:00 2001 From: Hal Gentz Date: Sun, 27 May 2018 18:17:06 -0600 Subject: [PATCH] Up Signed-off-by: Hal Gentz --- examples/hal/1-quad/main.rs | 4 ++-- examples/hal/2-compute/main.rs | 31 ++++++++++++++-------------- examples/hal/3-color_uniform/main.rs | 4 ++-- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/examples/hal/1-quad/main.rs b/examples/hal/1-quad/main.rs index d028f628e89..c6e93618ac4 100644 --- a/examples/hal/1-quad/main.rs +++ b/examples/hal/1-quad/main.rs @@ -710,7 +710,7 @@ fn swapchain_stuff( { spirv.push(byte.unwrap()) } - device.create_shader_module(&spirv).unwrap() + device.create_shader_module(&spirv, &pipeline_layout).unwrap() }; let fs_module = { let mut glsl = String::new(); @@ -726,7 +726,7 @@ fn swapchain_stuff( { spirv.push(byte.unwrap()) } - device.create_shader_module(&spirv).unwrap() + device.create_shader_module(&spirv, &pipeline_layout).unwrap() }; let pipeline = { diff --git a/examples/hal/2-compute/main.rs b/examples/hal/2-compute/main.rs index 08179655e4e..fa4f40a1f0e 100644 --- a/examples/hal/2-compute/main.rs +++ b/examples/hal/2-compute/main.rs @@ -51,20 +51,6 @@ fn main() { .open_with::<_, Compute>(1, |_family| true) .unwrap(); - let mut glsl = String::new(); - File::open("2-compute/shader/collatz.comp") - .unwrap() - .read_to_string(&mut glsl) - .unwrap(); - let mut spirv: Vec = vec![]; - for byte in glsl_to_spirv::compile(&glsl, glsl_to_spirv::ShaderType::Compute) - .unwrap() - .bytes() - { - spirv.push(byte.unwrap()) - } - let shader = device.create_shader_module(&spirv).unwrap(); - let (pipeline_layout, pipeline, set_layout, mut desc_pool) = { let set_layout = device.create_descriptor_set_layout(&[ pso::DescriptorSetLayoutBinding { @@ -77,11 +63,27 @@ fn main() { ); let pipeline_layout = device.create_pipeline_layout(Some(&set_layout), &[]); + + let mut glsl = String::new(); + File::open("2-compute/shader/collatz.comp") + .unwrap() + .read_to_string(&mut glsl) + .unwrap(); + let mut spirv: Vec = vec![]; + for byte in glsl_to_spirv::compile(&glsl, glsl_to_spirv::ShaderType::Compute) + .unwrap() + .bytes() + { + spirv.push(byte.unwrap()) + } + let shader = device.create_shader_module(&spirv, &pipeline_layout).unwrap(); + let entry_point = pso::EntryPoint { entry: "main", module: &shader, specialization: &[] }; let pipeline = device .create_compute_pipeline(&pso::ComputePipelineDesc::new(entry_point, &pipeline_layout)) .expect("Error creating compute pipeline!"); + device.destroy_shader_module(shader); let desc_pool = device.create_descriptor_pool( 1, &[ @@ -169,7 +171,6 @@ fn main() { device.destroy_command_pool(command_pool.into_raw()); device.destroy_descriptor_pool(desc_pool); device.destroy_descriptor_set_layout(set_layout); - device.destroy_shader_module(shader); device.destroy_buffer(device_buffer); device.destroy_buffer(staging_buffer); device.destroy_fence(fence); diff --git a/examples/hal/3-color_uniform/main.rs b/examples/hal/3-color_uniform/main.rs index 71c4dfdde2b..34881486652 100644 --- a/examples/hal/3-color_uniform/main.rs +++ b/examples/hal/3-color_uniform/main.rs @@ -1268,7 +1268,7 @@ impl PipelineState { { spirv.push(byte.unwrap()) } - device.create_shader_module(&spirv).unwrap() + device.create_shader_module(&spirv, &pipeline_layout).unwrap() }; let fs_module = { let mut glsl = String::new(); @@ -1284,7 +1284,7 @@ impl PipelineState { { spirv.push(byte.unwrap()) } - device.create_shader_module(&spirv).unwrap() + device.create_shader_module(&spirv, &pipeline_layout).unwrap() }; let pipeline = {