Skip to content

Commit

Permalink
WPI for manual initialization example.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerzywilczek committed Oct 7, 2024
1 parent fefb847 commit 7d3ff8c
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions integration_tests/examples/manual_graphics_initialization.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use compositor_pipeline::{
pipeline::{GraphicsContext, Options},
Pipeline,
};
use live_compositor::config::read_config;

// This example illustrates how to initialize a GraphicsContext separately to get access to a wgpu
// instance, adapter, queue and device.
fn main() {
let graphics_context =
GraphicsContext::new(false, wgpu::Features::default(), wgpu::Limits::default()).unwrap();

let _device = graphics_context.device.clone();
let _queue = graphics_context.queue.clone();

#[cfg(target_os = "linux")]
let _adapter = graphics_context
.vulkan_ctx
.as_ref()
.unwrap()
.wgpu_ctx
.adapter
.clone();

#[cfg(target_os = "linux")]
let _instance = graphics_context
.vulkan_ctx
.as_ref()
.unwrap()
.wgpu_ctx
.instance
.clone();

let config = read_config();

let _pipeline = Pipeline::new(Options {
wgpu_ctx: Some(graphics_context),
queue_options: config.queue_options,
stream_fallback_timeout: config.stream_fallback_timeout,
web_renderer: config.web_renderer,
force_gpu: config.force_gpu,
download_root: config.download_root,
output_sample_rate: config.output_sample_rate,
wgpu_features: config.required_wgpu_features,
load_system_fonts: Some(true),
})
.unwrap();
}

0 comments on commit 7d3ff8c

Please sign in to comment.