mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2025-05-14 02:58:46 +00:00
parent
dc73acae5f
commit
8f99ceab32
@ -24,5 +24,4 @@ png = "0.17"
|
|||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
ron = "0.7"
|
ron = "0.7"
|
||||||
rand = "0.8.4"
|
rand = "0.8.4"
|
||||||
|
glium = "0.32.1"
|
||||||
glium = { git = "https://github.com/glium/glium.git", rev = "60889a2" }
|
|
||||||
|
@ -232,4 +232,6 @@ fn main() {
|
|||||||
for n in 0..65536u32 {
|
for n in 0..65536u32 {
|
||||||
assert_eq!(data_buffer_content[n as usize], n * 12);
|
assert_eq!(data_buffer_content[n as usize], n * 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("Success");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
linux::main();
|
linux::main();
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
println!("Not Implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Can this be demonstrated for other platforms as well?
|
// TODO: Can this be demonstrated for other platforms as well?
|
||||||
@ -58,18 +60,18 @@ mod linux {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub fn main() {
|
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
|
// For some reason, this must be created before the vulkan window
|
||||||
let hrb = glutin::ContextBuilder::new()
|
let hrb = glutin::ContextBuilder::new()
|
||||||
.with_gl_debug_flag(true)
|
.with_gl_debug_flag(true)
|
||||||
.with_gl(glutin::GlRequest::Latest)
|
.with_gl(glutin::GlRequest::Latest)
|
||||||
.build_surfaceless(&event_loop_gl)
|
.build_surfaceless(&event_loop)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let hrb_vk = glutin::ContextBuilder::new()
|
let hrb_vk = glutin::ContextBuilder::new()
|
||||||
.with_gl_debug_flag(true)
|
.with_gl_debug_flag(true)
|
||||||
.with_gl(glutin::GlRequest::Latest)
|
.with_gl(glutin::GlRequest::Latest)
|
||||||
.build_surfaceless(&event_loop_gl)
|
.build_surfaceless(&event_loop)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let display = glium::HeadlessRenderer::with_debug(
|
let display = glium::HeadlessRenderer::with_debug(
|
||||||
@ -82,7 +84,6 @@ mod linux {
|
|||||||
_instance,
|
_instance,
|
||||||
mut swapchain,
|
mut swapchain,
|
||||||
surface,
|
surface,
|
||||||
event_loop,
|
|
||||||
mut viewport,
|
mut viewport,
|
||||||
queue,
|
queue,
|
||||||
render_pass,
|
render_pass,
|
||||||
@ -90,7 +91,7 @@ mod linux {
|
|||||||
sampler,
|
sampler,
|
||||||
pipeline,
|
pipeline,
|
||||||
vertex_buffer,
|
vertex_buffer,
|
||||||
) = vk_setup(display);
|
) = vk_setup(display, &event_loop);
|
||||||
|
|
||||||
let image = StorageImage::new_with_exportable_fd(
|
let image = StorageImage::new_with_exportable_fd(
|
||||||
device.clone(),
|
device.clone(),
|
||||||
@ -386,12 +387,12 @@ mod linux {
|
|||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
fn vk_setup(
|
fn vk_setup(
|
||||||
display: glium::HeadlessRenderer,
|
display: glium::HeadlessRenderer,
|
||||||
|
event_loop: &EventLoop<()>,
|
||||||
) -> (
|
) -> (
|
||||||
Arc<vulkano::device::Device>,
|
Arc<vulkano::device::Device>,
|
||||||
Arc<vulkano::instance::Instance>,
|
Arc<vulkano::instance::Instance>,
|
||||||
Arc<Swapchain<winit::window::Window>>,
|
Arc<Swapchain<winit::window::Window>>,
|
||||||
Arc<vulkano::swapchain::Surface<winit::window::Window>>,
|
Arc<vulkano::swapchain::Surface<winit::window::Window>>,
|
||||||
winit::event_loop::EventLoop<()>,
|
|
||||||
vulkano::pipeline::graphics::viewport::Viewport,
|
vulkano::pipeline::graphics::viewport::Viewport,
|
||||||
Arc<Queue>,
|
Arc<Queue>,
|
||||||
Arc<RenderPass>,
|
Arc<RenderPass>,
|
||||||
@ -440,7 +441,6 @@ mod linux {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
let event_loop = EventLoop::new();
|
|
||||||
let surface = WindowBuilder::new()
|
let surface = WindowBuilder::new()
|
||||||
.build_vk_surface(&event_loop, instance.clone())
|
.build_vk_surface(&event_loop, instance.clone())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -628,7 +628,6 @@ mod linux {
|
|||||||
instance,
|
instance,
|
||||||
swapchain,
|
swapchain,
|
||||||
surface,
|
surface,
|
||||||
event_loop,
|
|
||||||
viewport,
|
viewport,
|
||||||
queue,
|
queue,
|
||||||
render_pass,
|
render_pass,
|
||||||
|
@ -44,7 +44,7 @@ fn main() {
|
|||||||
&context,
|
&context,
|
||||||
&WindowDescriptor {
|
&WindowDescriptor {
|
||||||
title: "Fractal".to_string(),
|
title: "Fractal".to_string(),
|
||||||
present_mode: PresentMode::Immediate,
|
present_mode: PresentMode::Fifo,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|_| {},
|
|_| {},
|
||||||
|
@ -367,4 +367,8 @@ fn main() {
|
|||||||
encoder.set_depth(png::BitDepth::Eight);
|
encoder.set_depth(png::BitDepth::Eight);
|
||||||
let mut writer = encoder.write_header().unwrap();
|
let mut writer = encoder.write_header().unwrap();
|
||||||
writer.write_image_data(&buffer_content).unwrap();
|
writer.write_image_data(&buffer_content).unwrap();
|
||||||
|
|
||||||
|
if let Ok(path) = path.canonicalize() {
|
||||||
|
println!("Saved to {}", path.display());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ fn handle_events(
|
|||||||
) -> bool {
|
) -> bool {
|
||||||
let mut is_running = true;
|
let mut is_running = true;
|
||||||
event_loop.run_return(|event, _, control_flow| {
|
event_loop.run_return(|event, _, control_flow| {
|
||||||
*control_flow = ControlFlow::Wait;
|
*control_flow = ControlFlow::Poll;
|
||||||
match &event {
|
match &event {
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
event, window_id, ..
|
event, window_id, ..
|
||||||
|
@ -387,4 +387,8 @@ fn write_image_buffer_to_file(
|
|||||||
encoder.set_depth(png::BitDepth::Eight);
|
encoder.set_depth(png::BitDepth::Eight);
|
||||||
let mut writer = encoder.write_header().unwrap();
|
let mut writer = encoder.write_header().unwrap();
|
||||||
writer.write_image_data(&buffer_content).unwrap();
|
writer.write_image_data(&buffer_content).unwrap();
|
||||||
|
|
||||||
|
if let Ok(path) = path.canonicalize() {
|
||||||
|
println!("Saved to {}", path.display());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,6 +191,9 @@ fn main() {
|
|||||||
// in the byte blob here, but it should still work.
|
// 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
|
// 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.
|
// not open a new one, on the GitHub page.
|
||||||
println!("first : {:?}", pipeline_cache.get_data().unwrap());
|
assert_eq!(
|
||||||
println!("second: {:?}", second_cache.get_data().unwrap());
|
pipeline_cache.get_data().unwrap(),
|
||||||
|
second_cache.get_data().unwrap()
|
||||||
|
);
|
||||||
|
println!("Success");
|
||||||
}
|
}
|
||||||
|
@ -183,4 +183,6 @@ fn main() {
|
|||||||
assert_eq!(data_buffer_content[n as usize], n * 12);
|
assert_eq!(data_buffer_content[n as usize], n * 12);
|
||||||
assert_eq!(data_buffer_content[n as usize + 65536 / 2], n * 12);
|
assert_eq!(data_buffer_content[n as usize + 65536 / 2], n * 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("Success");
|
||||||
}
|
}
|
||||||
|
@ -170,4 +170,6 @@ fn main() {
|
|||||||
for n in 0..65536u32 {
|
for n in 0..65536u32 {
|
||||||
assert_eq!(data_buffer_content[n as usize], n * 12);
|
assert_eq!(data_buffer_content[n as usize], n * 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("Success");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user