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

Function main

examples/runners/ash/src/main.rs:110–213  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

108}
109
110pub fn main() {
111 let options = Options::from_args();
112 let shaders = compile_shaders();
113
114 // runtime setup
115 let event_loop = EventLoop::new();
116 let window = winit::window::WindowBuilder::new()
117 .with_title("Rust GPU - ash")
118 .with_inner_size(winit::dpi::LogicalSize::new(
119 f64::from(1280),
120 f64::from(720),
121 ))
122 .build(&event_loop)
123 .unwrap();
124 let mut ctx = RenderBase::new(window, &options).into_ctx();
125
126 // Create shader module and pipelines
127 for SpvFile { name, data } in shaders {
128 ctx.insert_shader_module(name, &data);
129 }
130 ctx.build_pipelines(
131 vk::PipelineCache::null(),
132 vec![(
133 // HACK(eddyb) used to be `module: "sky_shader"` but we need `multimodule`
134 // for `debugPrintf` instrumentation to work (see `compile_shaders`).
135 VertexShaderEntryPoint {
136 module: "sky_shader::main_vs".into(),
137 entry_point: "main_vs".into(),
138 },
139 FragmentShaderEntryPoint {
140 module: "sky_shader::main_fs".into(),
141 entry_point: "main_fs".into(),
142 },
143 )],
144 );
145
146 let (compiler_sender, compiler_reciever) = sync_channel(1);
147
148 event_loop.run(move |event, _window_target, control_flow| match event {
149 Event::RedrawEventsCleared { .. } => {
150 match compiler_reciever.try_recv() {
151 Err(TryRecvError::Empty) => {
152 if ctx.rendering_paused {
153 let vk::Extent2D { width, height } = ctx.base.surface_resolution();
154 if height > 0 && width > 0 {
155 ctx.recreate_swapchain();
156 ctx.render();
157 }
158 } else {
159 ctx.render();
160 }
161 }
162 Ok(new_shaders) => {
163 for SpvFile { name, data } in new_shaders {
164 ctx.insert_shader_module(name, &data);
165 }
166 ctx.recompiling_shaders = false;
167 ctx.rebuild_pipelines(vk::PipelineCache::null());

Callers

nothing calls this directly

Calls 9

compile_shadersFunction · 0.85
into_ctxMethod · 0.80
insert_shader_moduleMethod · 0.80
build_pipelinesMethod · 0.80
surface_resolutionMethod · 0.80
recreate_swapchainMethod · 0.80
renderMethod · 0.80
rebuild_pipelinesMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected