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

Method render

examples/runners/ash/src/main.rs:920–968  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

918 }
919
920 pub fn render(&mut self) {
921 let present_index = unsafe {
922 match self.base.swapchain_loader.acquire_next_image(
923 self.swapchain,
924 std::u64::MAX,
925 self.sync.present_complete_semaphore,
926 vk::Fence::null(),
927 ) {
928 Ok((idx, _)) => idx,
929 Err(vk::Result::ERROR_OUT_OF_DATE_KHR) => {
930 self.recreate_swapchain();
931 return;
932 }
933 Err(err) => panic!("failed to acquire next image: {err:?}"),
934 }
935 };
936
937 let framebuffer = self.framebuffers[present_index as usize];
938 let clear_values = [vk::ClearValue {
939 color: vk::ClearColorValue {
940 float32: [0.0, 0.0, 1.0, 0.0],
941 },
942 }];
943
944 // There should only be one pipeline because compile_shaders only loads the last spirv
945 // file it produced.
946 for pipeline in self.pipelines.iter() {
947 self.draw(pipeline, framebuffer, &clear_values);
948 }
949
950 let wait_semaphors = [self.sync.rendering_complete_semaphore];
951 let swapchains = [self.swapchain];
952 let image_indices = [present_index];
953 let present_info = vk::PresentInfoKHR::builder()
954 .wait_semaphores(&wait_semaphors)
955 .swapchains(&swapchains)
956 .image_indices(&image_indices);
957 unsafe {
958 match self
959 .base
960 .swapchain_loader
961 .queue_present(self.base.present_queue, &present_info)
962 {
963 Err(vk::Result::ERROR_OUT_OF_DATE_KHR) | Ok(true) => self.recreate_swapchain(),
964 Ok(false) => {}
965 Err(err) => panic!("failed to present queue: {err:?}"),
966 };
967 }
968 }
969
970 pub fn draw(
971 &self,

Callers 1

mainFunction · 0.80

Calls 3

recreate_swapchainMethod · 0.80
iterMethod · 0.80
drawMethod · 0.80

Tested by

no test coverage detected