Skip to content

Commit

Permalink
Store instance in Renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Zakor Gyula committed Nov 26, 2018
1 parent c17d936 commit 9b24bfb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions direct-composition/src/main_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ impl Rectangle {
gl: composition.gleam.clone(),
phantom_data: PhantomData,
},
Box::new(back::Instance {}),
notifier.clone(),
webrender::RendererOptions {
clear_color: Some(api::ColorF::new(0., 0., 0., 0.)),
Expand Down
6 changes: 3 additions & 3 deletions examples/common/boilerplate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn main_wrapper<E: Example>(
.with_dimensions(winit::dpi::LogicalSize::new(E::WIDTH as f64, E::HEIGHT as f64));

#[cfg(feature = "gl")]
let (gl, mut init, window) = {
let (gl, mut init, instance, window) = {
let context_builder = glutin::ContextBuilder::new()
.with_gl(glutin::GlRequest::GlThenGles {
opengl_version: (3, 2),
Expand Down Expand Up @@ -172,7 +172,7 @@ pub fn main_wrapper<E: Example>(
gl: gl.clone(),
phantom_data: PhantomData,
};
(gl, init, window)
(gl, init, back::Instance{}, window)
};

#[cfg(feature = "gfx-hal")]
Expand Down Expand Up @@ -220,7 +220,7 @@ pub fn main_wrapper<E: Example>(
DeviceUintSize::new(size.width as u32, size.height as u32)
};
let notifier = Box::new(Notifier::new(events_loop.create_proxy()));
let (mut renderer, sender) = webrender::Renderer::new(init, notifier, opts, None).unwrap();
let (mut renderer, sender) = webrender::Renderer::new(init, Box::new(instance), notifier, opts, None).unwrap();

let api = sender.create_api();
let document_id = api.add_document(framebuffer_size, 0);
Expand Down
10 changes: 3 additions & 7 deletions examples/multiwindow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ struct Window {
epoch: Epoch,
api: RenderApi,
font_instance_key: FontInstanceKey,
#[cfg(feature = "gfx-hal")]
instance: back::Instance,
}

#[cfg(any(feature = "gfx-hal", feature = "gl"))]
Expand All @@ -99,7 +97,7 @@ impl Window {
.with_dimensions(LogicalSize::new(800., 600.));

#[cfg(feature = "gl")]
let (init, window) = {
let (init, instance, window) = {
let context_builder = glutin::ContextBuilder::new()
.with_gl(glutin::GlRequest::GlThenGles {
opengl_version: (3, 2),
Expand All @@ -126,7 +124,7 @@ impl Window {
gl,
phantom_data: PhantomData,
};
(init, window)
(init, back::Instance{}, window)
};

#[cfg(feature = "gfx-hal")]
Expand Down Expand Up @@ -165,7 +163,7 @@ impl Window {
clear_color: Some(clear_color),
..webrender::RendererOptions::default()
};
webrender::Renderer::new(init, notifier, opts, None).unwrap()
webrender::Renderer::new(init, Box::new(instance), notifier, opts, None).unwrap()
};
let api = sender.create_api();
let document_id = api.add_document(framebuffer_size, 0);
Expand Down Expand Up @@ -193,8 +191,6 @@ impl Window {
document_id,
api,
font_instance_key,
#[cfg(feature = "gfx-hal")]
instance,
}
}

Expand Down
3 changes: 3 additions & 0 deletions webrender/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,7 @@ pub struct Renderer<B: hal::Backend> {
result_rx: Receiver<ResultMsg>,
debug_server: DebugServer,
pub device: Device<B>,
_instance: Box<hal::Instance<Backend=B>>,
pending_texture_updates: Vec<TextureUpdateList>,
pending_gpu_cache_updates: Vec<GpuCacheUpdateList>,
pending_shader_updates: Vec<PathBuf>,
Expand Down Expand Up @@ -1348,6 +1349,7 @@ impl<B: hal::Backend> Renderer<B>
/// [rendereroptions]: struct.RendererOptions.html
pub fn new(
init: DeviceInit<B>,
_instance: Box<hal::Instance<Backend=B>>,
notifier: Box<RenderNotifier>,
mut options: RendererOptions,
shaders: Option<&mut WrShaders<B>>
Expand Down Expand Up @@ -1689,6 +1691,7 @@ impl<B: hal::Backend> Renderer<B>
let mut renderer = Renderer {
result_rx,
debug_server,
_instance,
device,
active_documents: Vec::new(),
pending_texture_updates: Vec::new(),
Expand Down
4 changes: 4 additions & 0 deletions wrench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,9 @@ fn main() {
#[cfg(feature = "gfx")]
let instance = back::Instance::create("gfx-rs instance", 1);

#[cfg(not(feature = "gfx"))]
let instance = back::Instance{};

#[cfg(feature = "gfx")]
let init = webrender::DeviceInit {
adapter: instance.enumerate_adapters().remove(0),
Expand Down Expand Up @@ -588,6 +591,7 @@ fn main() {
chase_primitive,
notifier,
init,
instance,
);

if let Some(window_title) = wrench.take_title() {
Expand Down
3 changes: 2 additions & 1 deletion wrench/src/wrench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ impl Wrench {
chase_primitive: webrender::ChasePrimitive,
notifier: Option<Box<RenderNotifier>>,
init: webrender::DeviceInit<back::Backend>,
instance: back::Instance,
) -> Self {
println!("Shader override path: {:?}", shader_override_path);

Expand Down Expand Up @@ -239,7 +240,7 @@ impl Wrench {
Box::new(Notifier(data))
});

let (renderer, sender) = webrender::Renderer::new(init, notifier, opts, None).unwrap();
let (renderer, sender) = webrender::Renderer::new(init, Box::new(instance), notifier, opts, None).unwrap();
let api = sender.create_api();
let document_id = api.add_document(size, 0);

Expand Down

0 comments on commit 9b24bfb

Please sign in to comment.