MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / bloom_init_window

Function bloom_init_window

native/linux/src/lib.rs:493–618  ·  view source on GitHub ↗
(width: f64, height: f64, title_ptr: *const u8, fullscreen: f64)

Source from the content-addressed store, hash-verified

491
492#[no_mangle]
493pub extern "C" fn bloom_init_window(width: f64, height: f64, title_ptr: *const u8, fullscreen: f64) {
494 let title = str_from_header(title_ptr);
495
496 #[cfg(target_os = "linux")]
497 {
498 // Headless mode: BLOOM_HEADLESS=1 keeps the X11 window + Vulkan
499 // surface alive (wgpu requires a real surface) but never maps
500 // the window so it's invisible and never steals focus. Lets an
501 // agent spin up the renderer in a batch loop without disturbing
502 // the user's desktop.
503 let headless = std::env::var("BLOOM_HEADLESS")
504 .map(|v| v == "1" || v.eq_ignore_ascii_case("true"))
505 .unwrap_or(false);
506 // BLOOM_NO_FULLSCREEN=1 hard-disables fullscreen capability for
507 // benchmark harnesses where a 4K-display fullscreen path would
508 // silently quadruple render cost.
509 let no_fullscreen = std::env::var("BLOOM_NO_FULLSCREEN")
510 .map(|v| v == "1" || v.eq_ignore_ascii_case("true"))
511 .unwrap_or(false);
512 x11_impl::set_no_fullscreen(no_fullscreen);
513
514 let (phys_w, phys_h) = x11_impl::create_window(width, height, title, headless);
515
516 let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
517 backends: wgpu::Backends::VULKAN | wgpu::Backends::GL,
518 ..wgpu::InstanceDescriptor::new_without_display_handle()
519 });
520
521 let surface = unsafe {
522 let raw_window = raw_window_handle::RawWindowHandle::Xlib(
523 raw_window_handle::XlibWindowHandle::new(x11_impl::window())
524 );
525 let raw_display = raw_window_handle::RawDisplayHandle::Xlib(
526 raw_window_handle::XlibDisplayHandle::new(
527 std::ptr::NonNull::new(x11_impl::display() as *mut _),
528 0,
529 )
530 );
531 instance.create_surface_unsafe(wgpu::SurfaceTargetUnsafe::RawHandle {
532 raw_display_handle: Some(raw_display),
533 raw_window_handle: raw_window,
534 }).expect("Failed to create surface")
535 };
536
537 let adapter = pollster_block_on(instance.request_adapter(&wgpu::RequestAdapterOptions {
538 compatible_surface: Some(&surface),
539 ..Default::default()
540 })).expect("No adapter found");
541
542 // Ticket 007b: HW ray-query via VK_KHR_ray_query on RT-capable
543 // desktop Linux GPUs. Older integrated GPUs will fall back to
544 // the SW path through this gate.
545 let supported = adapter.features();
546 let force_sw_gi = std::env::var("BLOOM_FORCE_SW_GI")
547 .map(|v| v == "1" || v.eq_ignore_ascii_case("true"))
548 .unwrap_or(false);
549 let rt_mask = wgpu::Features::EXPERIMENTAL_RAY_QUERY;
550 let mut required_features = wgpu::Features::empty();

Callers

nothing calls this directly

Calls 8

str_from_headerFunction · 0.85
set_no_fullscreenFunction · 0.85
windowFunction · 0.85
displayFunction · 0.85
create_windowFunction · 0.70
pollster_block_onFunction · 0.70
set_fullscreenFunction · 0.70

Tested by

no test coverage detected