Skip to content

Commit

Permalink
Up
Browse files Browse the repository at this point in the history
Signed-off-by: Hal Gentz <[email protected]>
  • Loading branch information
goddessfreya committed May 28, 2018
1 parent 45a9dde commit 4125a01
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions examples/hal/1-quad/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 = {
Expand Down
31 changes: 16 additions & 15 deletions examples/hal/2-compute/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> = 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 {
Expand All @@ -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<u8> = 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,
&[
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions examples/hal/3-color_uniform/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ impl<B: Backend> PipelineState<B> {
{
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();
Expand All @@ -1284,7 +1284,7 @@ impl<B: Backend> PipelineState<B> {
{
spirv.push(byte.unwrap())
}
device.create_shader_module(&spirv).unwrap()
device.create_shader_module(&spirv, &pipeline_layout).unwrap()
};

let pipeline = {
Expand Down

0 comments on commit 4125a01

Please sign in to comment.