Example Tweaks (#1987)

* Example Tweaks

* use released glium
This commit is contained in:
Austin Johnson 2022-09-17 10:37:22 -05:00 committed by GitHub
parent dc73acae5f
commit 8f99ceab32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 29 additions and 14 deletions

View File

@ -24,5 +24,4 @@ png = "0.17"
serde = { version = "1.0", features = ["derive"] }
ron = "0.7"
rand = "0.8.4"
glium = { git = "https://github.com/glium/glium.git", rev = "60889a2" }
glium = "0.32.1"

View File

@ -232,4 +232,6 @@ fn main() {
for n in 0..65536u32 {
assert_eq!(data_buffer_content[n as usize], n * 12);
}
println!("Success");
}

View File

@ -1,6 +1,8 @@
fn main() {
#[cfg(target_os = "linux")]
linux::main();
#[cfg(not(target_os = "linux"))]
println!("Not Implemented");
}
// TODO: Can this be demonstrated for other platforms as well?
@ -58,18 +60,18 @@ mod linux {
};
pub fn main() {
let event_loop_gl = glutin::event_loop::EventLoop::new();
let event_loop = EventLoop::new();
// For some reason, this must be created before the vulkan window
let hrb = glutin::ContextBuilder::new()
.with_gl_debug_flag(true)
.with_gl(glutin::GlRequest::Latest)
.build_surfaceless(&event_loop_gl)
.build_surfaceless(&event_loop)
.unwrap();
let hrb_vk = glutin::ContextBuilder::new()
.with_gl_debug_flag(true)
.with_gl(glutin::GlRequest::Latest)
.build_surfaceless(&event_loop_gl)
.build_surfaceless(&event_loop)
.unwrap();
let display = glium::HeadlessRenderer::with_debug(
@ -82,7 +84,6 @@ mod linux {
_instance,
mut swapchain,
surface,
event_loop,
mut viewport,
queue,
render_pass,
@ -90,7 +91,7 @@ mod linux {
sampler,
pipeline,
vertex_buffer,
) = vk_setup(display);
) = vk_setup(display, &event_loop);
let image = StorageImage::new_with_exportable_fd(
device.clone(),
@ -386,12 +387,12 @@ mod linux {
#[allow(clippy::type_complexity)]
fn vk_setup(
display: glium::HeadlessRenderer,
event_loop: &EventLoop<()>,
) -> (
Arc<vulkano::device::Device>,
Arc<vulkano::instance::Instance>,
Arc<Swapchain<winit::window::Window>>,
Arc<vulkano::swapchain::Surface<winit::window::Window>>,
winit::event_loop::EventLoop<()>,
vulkano::pipeline::graphics::viewport::Viewport,
Arc<Queue>,
Arc<RenderPass>,
@ -440,7 +441,6 @@ mod linux {
.unwrap()
};
let event_loop = EventLoop::new();
let surface = WindowBuilder::new()
.build_vk_surface(&event_loop, instance.clone())
.unwrap();
@ -628,7 +628,6 @@ mod linux {
instance,
swapchain,
surface,
event_loop,
viewport,
queue,
render_pass,

View File

@ -44,7 +44,7 @@ fn main() {
&context,
&WindowDescriptor {
title: "Fractal".to_string(),
present_mode: PresentMode::Immediate,
present_mode: PresentMode::Fifo,
..Default::default()
},
|_| {},

View File

@ -367,4 +367,8 @@ fn main() {
encoder.set_depth(png::BitDepth::Eight);
let mut writer = encoder.write_header().unwrap();
writer.write_image_data(&buffer_content).unwrap();
if let Ok(path) = path.canonicalize() {
println!("Saved to {}", path.display());
}
}

View File

@ -86,7 +86,7 @@ fn handle_events(
) -> bool {
let mut is_running = true;
event_loop.run_return(|event, _, control_flow| {
*control_flow = ControlFlow::Wait;
*control_flow = ControlFlow::Poll;
match &event {
Event::WindowEvent {
event, window_id, ..

View File

@ -387,4 +387,8 @@ fn write_image_buffer_to_file(
encoder.set_depth(png::BitDepth::Eight);
let mut writer = encoder.write_header().unwrap();
writer.write_image_data(&buffer_content).unwrap();
if let Ok(path) = path.canonicalize() {
println!("Saved to {}", path.display());
}
}

View File

@ -191,6 +191,9 @@ fn main() {
// in the byte blob here, but it should still work.
// If it doesn't, please check if there is an issue describing this problem, and if
// not open a new one, on the GitHub page.
println!("first : {:?}", pipeline_cache.get_data().unwrap());
println!("second: {:?}", second_cache.get_data().unwrap());
assert_eq!(
pipeline_cache.get_data().unwrap(),
second_cache.get_data().unwrap()
);
println!("Success");
}

View File

@ -183,4 +183,6 @@ fn main() {
assert_eq!(data_buffer_content[n as usize], n * 12);
assert_eq!(data_buffer_content[n as usize + 65536 / 2], n * 12);
}
println!("Success");
}

View File

@ -170,4 +170,6 @@ fn main() {
for n in 0..65536u32 {
assert_eq!(data_buffer_content[n as usize], n * 12);
}
println!("Success");
}