From 45a9dded05d49b4fe4219d2ce5fba521c71bd861 Mon Sep 17 00:00:00 2001 From: Hal Gentz Date: Sun, 27 May 2018 15:52:30 -0600 Subject: [PATCH] Updated func signatures Signed-off-by: Hal Gentz --- src/backend/dx12/src/device.rs | 17 ++++++++++++----- src/backend/empty/src/lib.rs | 12 +++++++++--- src/backend/gl/src/device.rs | 7 +++++-- src/backend/metal/src/device.rs | 14 ++++++++++---- src/backend/vulkan/src/device.rs | 14 ++++++++++---- src/hal/src/device.rs | 18 ++++++++++++++---- 6 files changed, 60 insertions(+), 22 deletions(-) diff --git a/src/backend/dx12/src/device.rs b/src/backend/dx12/src/device.rs index 0462d6ae2a8..305f519d325 100644 --- a/src/backend/dx12/src/device.rs +++ b/src/backend/dx12/src/device.rs @@ -1262,14 +1262,16 @@ impl d::Device for Device { rp } - fn create_pipeline_layout( + fn create_pipeline_layout( &self, sets: IS, push_constant_ranges: IR, ) -> n::PipelineLayout where IS: IntoIterator, - IS::Item: Borrow, + IS::Item: Borrow<(n::DescriptorSetLayout, IB)>, + IB: IntoIterator, + IB::Item: Borrow, IR: IntoIterator, IR::Item: Borrow<(pso::ShaderStageFlags, Range)>, { @@ -1331,6 +1333,7 @@ impl d::Device for Device { let mut sum = 0; let bindings = &desc_set .borrow() + .0 .bindings; for binding in bindings { @@ -1348,7 +1351,7 @@ impl d::Device for Device { let mut set_tables = Vec::with_capacity(sets.len()); for (i, set) in sets.iter().enumerate() { - let set = set.borrow(); + let set = set.borrow().0; let mut table_type = n::SetTableTypes::empty(); let mut param = d3d12::D3D12_ROOT_PARAMETER { @@ -1728,7 +1731,11 @@ impl d::Device for Device { }) } - fn create_shader_module(&self, raw_data: &[u8]) -> Result { + fn create_shader_module( + &self, + raw_data: &[u8], + _pipeline_layout: &n::PipelineLayout, + ) -> Result { Ok(n::ShaderModule::Spirv(raw_data.into())) } @@ -2925,7 +2932,7 @@ impl d::Device for Device { unsafe { self.raw.clone().CreateRenderTargetView(resource, &rtv_desc, rtv_handle); } - + resources.push(resource); let surface_type = config diff --git a/src/backend/empty/src/lib.rs b/src/backend/empty/src/lib.rs index 239d9490b65..dd85c148531 100644 --- a/src/backend/empty/src/lib.rs +++ b/src/backend/empty/src/lib.rs @@ -139,10 +139,12 @@ impl hal::Device for Device { unimplemented!() } - fn create_pipeline_layout(&self, _: IS, _: IR) -> () + fn create_pipeline_layout(&self, _: IS, _: IR) -> () where IS: IntoIterator, - IS::Item: Borrow<()>, + IS::Item: Borrow<((), IB)>, + IB: IntoIterator, + IB::Item: Borrow, IR: IntoIterator, IR::Item: Borrow<(pso::ShaderStageFlags, Range)>, { @@ -159,7 +161,11 @@ impl hal::Device for Device { unimplemented!() } - fn create_shader_module(&self, _: &[u8]) -> Result<(), device::ShaderError> { + fn create_shader_module( + &self, + _: &[u8], + _: &(), + ) -> Result<(), device::ShaderError> { unimplemented!() } diff --git a/src/backend/gl/src/device.rs b/src/backend/gl/src/device.rs index 90a262db897..d0da89c2d9d 100644 --- a/src/backend/gl/src/device.rs +++ b/src/backend/gl/src/device.rs @@ -383,10 +383,12 @@ impl d::Device for Device { } } - fn create_pipeline_layout(&self, _: IS, _: IR) -> n::PipelineLayout + fn create_pipeline_layout(&self, _: IS, _: IR) -> n::PipelineLayout where IS: IntoIterator, - IS::Item: Borrow, + IS::Item: Borrow<(n::DescriptorSetLayout, IB)>, + IB: IntoIterator, + IB::Item: Borrow, IR: IntoIterator, IR::Item: Borrow<(pso::ShaderStageFlags, Range)>, { @@ -603,6 +605,7 @@ impl d::Device for Device { fn create_shader_module( &self, raw_data: &[u8], + _pipeline_layout: &n::PipelineLayout, ) -> Result { Ok(n::ShaderModule::Spirv(raw_data.into())) } diff --git a/src/backend/metal/src/device.rs b/src/backend/metal/src/device.rs index cb420a7acd6..cd13a04ae78 100644 --- a/src/backend/metal/src/device.rs +++ b/src/backend/metal/src/device.rs @@ -569,14 +569,16 @@ impl hal::Device for Device { } } - fn create_pipeline_layout( + fn create_pipeline_layout( &self, set_layouts: IS, _push_constant_ranges: IR, ) -> n::PipelineLayout where IS: IntoIterator, - IS::Item: Borrow, + IS::Item: Borrow<(n::DescriptorSetLayout, IB)>, + IB: IntoIterator, + IB::Item: Borrow, IR: IntoIterator, IR::Item: Borrow<(pso::ShaderStageFlags, Range)> { @@ -595,7 +597,7 @@ impl hal::Device for Device { let mut res_overrides = HashMap::new(); for (set_index, set_layout) in set_layouts.into_iter().enumerate() { - match set_layout.borrow() { + match set_layout.borrow().0 { &n::DescriptorSetLayout::Emulated(ref set_bindings) => { for set_binding in set_bindings { for &mut(stage_bit, stage, ref mut counters) in stage_infos.iter_mut() { @@ -920,7 +922,11 @@ impl hal::Device for Device { Ok(n::FrameBuffer(descriptor)) } - fn create_shader_module(&self, raw_data: &[u8]) -> Result { + fn create_shader_module( + &self, + raw_data: &[u8], + _pipeline_layout: &n::PipelineLayout, + ) -> Result { //TODO: we can probably at least parse here and save the `Ast` let depends_on_pipeline_layout = true; //TODO: !self.private_caps.argument_buffers Ok(if depends_on_pipeline_layout { diff --git a/src/backend/vulkan/src/device.rs b/src/backend/vulkan/src/device.rs index bcff268b189..be3bcaee195 100644 --- a/src/backend/vulkan/src/device.rs +++ b/src/backend/vulkan/src/device.rs @@ -224,17 +224,19 @@ impl d::Device for Device { n::RenderPass { raw: renderpass } } - fn create_pipeline_layout(&self, sets: IS, push_constant_ranges: IR) -> n::PipelineLayout + fn create_pipeline_layout(&self, sets: IS, push_constant_ranges: IR) -> n::PipelineLayout where IS: IntoIterator, - IS::Item: Borrow, + IS::Item: Borrow<(n::DescriptorSetLayout, IB)>, + IB: IntoIterator, + IB::Item: Borrow, IR: IntoIterator, IR::Item: Borrow<(pso::ShaderStageFlags, Range)>, { let set_layouts = sets .into_iter() .map(|set| { - set.borrow().raw + set.borrow().0.raw }).collect::>(); debug!("create_pipeline_layout {:?}", set_layouts); @@ -811,7 +813,11 @@ impl d::Device for Device { Ok(n::Framebuffer { raw: framebuffer }) } - fn create_shader_module(&self, spirv_data: &[u8]) -> Result { + fn create_shader_module( + &self, + spirv_data: &[u8], + _pipeline_layout: &n::PipelineLayout, + ) -> Result { // spec requires "codeSize must be a multiple of 4" assert_eq!(spirv_data.len() & 3, 0); diff --git a/src/hal/src/device.rs b/src/hal/src/device.rs index 1c16f57f564..0db74e61b16 100644 --- a/src/hal/src/device.rs +++ b/src/hal/src/device.rs @@ -185,18 +185,20 @@ pub trait Device: Any + Send + Sync { /// /// # Arguments /// - /// * `set_layouts` - Descriptor set layouts + /// * `set_layouts` - The descriptor layouts and the sets which will use that layout. /// * `push_constants` - Ranges of push constants. A shader stage may only contain one push /// constant block. The length of the range indicates the number of u32 constants occupied /// by the push constant block. - fn create_pipeline_layout( + fn create_pipeline_layout( &self, set_layouts: IS, push_constant: IR, ) -> B::PipelineLayout where IS: IntoIterator, - IS::Item: Borrow, + IS::Item: Borrow<(B::DescriptorSetLayout, IB)>, + IB: IntoIterator, + IB::Item: Borrow, IR: IntoIterator, IR::Item: Borrow<(pso::ShaderStageFlags, Range)>; @@ -270,9 +272,17 @@ pub trait Device: Any + Send + Sync { /// which references the framebuffer, has finished execution. fn destroy_framebuffer(&self, buf: B::Framebuffer); + /// Creates a shader module /// + /// Creating a shader module requires passing in both the spirv for the + /// shader and the pipeline layout that will be used with this shader. + /// + /// Shader modules should not be passed to pipelines who's pipeline layout + /// was diffrent then the one the shader module was created with. fn create_shader_module( - &self, spirv_data: &[u8] + &self, + spirv_data: &[u8], + pipeline_layout: &B::PipelineLayout, ) -> Result; ///