MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / rebuild_pipelines

Method rebuild_pipelines

examples/runners/ash/src/main.rs:743–826  ·  view source on GitHub ↗
(&mut self, pipeline_cache: vk::PipelineCache)

Source from the content-addressed store, hash-verified

741 }
742
743 pub fn rebuild_pipelines(&mut self, pipeline_cache: vk::PipelineCache) {
744 // NOTE(eddyb) this acts like an integration test for specialization constants.
745 let spec_const_entries = [vk::SpecializationMapEntry::builder()
746 .constant_id(0x5007)
747 .offset(0)
748 .size(4)
749 .build()];
750 let spec_const_data =
751 u32::to_le_bytes(self.sky_fs_spec_id_0x5007_sun_intensity_extra_spec_const_factor);
752 let specialization_info = vk::SpecializationInfo::builder()
753 .map_entries(&spec_const_entries)
754 .data(&spec_const_data);
755
756 self.cleanup_pipelines();
757 let pipeline_layout = self.create_pipeline_layout();
758 let viewport = vk::PipelineViewportStateCreateInfo::builder()
759 .scissor_count(1)
760 .viewport_count(1);
761 let modules_names = self
762 .shader_set
763 .iter()
764 .map(|(vert, frag)| {
765 let vert_module = *self.shader_modules.get(&vert.module).unwrap();
766 let vert_name = CString::new(vert.entry_point.clone()).unwrap();
767 let frag_module = *self.shader_modules.get(&frag.module).unwrap();
768 let frag_name = CString::new(frag.entry_point.clone()).unwrap();
769 ((frag_module, frag_name), (vert_module, vert_name))
770 })
771 .collect::<Vec<_>>();
772 let descs = modules_names
773 .iter()
774 .map(|((frag_module, frag_name), (vert_module, vert_name))| {
775 PipelineDescriptor::new(Box::new([
776 vk::PipelineShaderStageCreateInfo {
777 module: *vert_module,
778 p_name: (*vert_name).as_ptr(),
779 stage: vk::ShaderStageFlags::VERTEX,
780 ..Default::default()
781 },
782 vk::PipelineShaderStageCreateInfo {
783 s_type: vk::StructureType::PIPELINE_SHADER_STAGE_CREATE_INFO,
784 module: *frag_module,
785 p_name: (*frag_name).as_ptr(),
786 stage: vk::ShaderStageFlags::FRAGMENT,
787 p_specialization_info: &*specialization_info,
788 ..Default::default()
789 },
790 ]))
791 })
792 .collect::<Vec<_>>();
793 let pipeline_info = descs
794 .iter()
795 .map(|desc| {
796 vk::GraphicsPipelineCreateInfo::builder()
797 .stages(&desc.shader_stages)
798 .vertex_input_state(&desc.vertex_input)
799 .input_assembly_state(&desc.input_assembly)
800 .rasterization_state(&desc.rasterization)

Callers 2

mainFunction · 0.80
build_pipelinesMethod · 0.80

Calls 8

dataMethod · 0.80
cleanup_pipelinesMethod · 0.80
iterMethod · 0.80
expectMethod · 0.80
buildMethod · 0.45
getMethod · 0.45
collectMethod · 0.45

Tested by

no test coverage detected