Skip to content

Commit

Permalink
Add UnsafeImageCreateInfo and ImageViewCreateInfo (#1844)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rua authored Feb 27, 2022
1 parent 9abe092 commit 9e8682f
Show file tree
Hide file tree
Showing 43 changed files with 1,919 additions and 1,650 deletions.
2 changes: 1 addition & 1 deletion examples/src/bin/buffer-pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();
Framebuffer::new(
render_pass.clone(),
FramebufferCreateInfo {
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/clear_attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();
Framebuffer::new(
render_pass.clone(),
FramebufferCreateInfo {
Expand Down
12 changes: 6 additions & 6 deletions examples/src/bin/deferred/frame/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl FrameSystem {
input_attachment: true,
..ImageUsage::none()
};
let diffuse_buffer = ImageView::new(
let diffuse_buffer = ImageView::new_default(
AttachmentImage::with_usage(
gfx_queue.device().clone(),
[1, 1],
Expand All @@ -163,7 +163,7 @@ impl FrameSystem {
.unwrap(),
)
.unwrap();
let normals_buffer = ImageView::new(
let normals_buffer = ImageView::new_default(
AttachmentImage::with_usage(
gfx_queue.device().clone(),
[1, 1],
Expand All @@ -173,7 +173,7 @@ impl FrameSystem {
.unwrap(),
)
.unwrap();
let depth_buffer = ImageView::new(
let depth_buffer = ImageView::new_default(
AttachmentImage::with_usage(
gfx_queue.device().clone(),
[1, 1],
Expand Down Expand Up @@ -248,7 +248,7 @@ impl FrameSystem {
// image is only defined when within a render pass. In other words you can draw to
// them in a subpass then read them in another subpass, but as soon as you leave the
// render pass their content becomes undefined.
self.diffuse_buffer = ImageView::new(
self.diffuse_buffer = ImageView::new_default(
AttachmentImage::with_usage(
self.gfx_queue.device().clone(),
img_dims,
Expand All @@ -258,7 +258,7 @@ impl FrameSystem {
.unwrap(),
)
.unwrap();
self.normals_buffer = ImageView::new(
self.normals_buffer = ImageView::new_default(
AttachmentImage::with_usage(
self.gfx_queue.device().clone(),
img_dims,
Expand All @@ -268,7 +268,7 @@ impl FrameSystem {
.unwrap(),
)
.unwrap();
self.depth_buffer = ImageView::new(
self.depth_buffer = ImageView::new_default(
AttachmentImage::with_usage(
self.gfx_queue.device().clone(),
img_dims,
Expand Down
4 changes: 2 additions & 2 deletions examples/src/bin/deferred/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fn main() {
.unwrap();
let images = images
.into_iter()
.map(|image| ImageView::new(image.clone()).unwrap())
.map(|image| ImageView::new_default(image.clone()).unwrap())
.collect::<Vec<_>>();
(swapchain, images)
};
Expand Down Expand Up @@ -173,7 +173,7 @@ fn main() {
};
let new_images = new_images
.into_iter()
.map(|image| ImageView::new(image.clone()).unwrap())
.map(|image| ImageView::new_default(image.clone()).unwrap())
.collect::<Vec<_>>();

swapchain = new_swapchain;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/dynamic-local-size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn main() {
Some(queue.family()),
)
.unwrap();
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();

let layout = pipeline.layout().set_layouts().get(0).unwrap();
let set = PersistentDescriptorSet::new(
Expand Down
4 changes: 2 additions & 2 deletions examples/src/bin/gl-interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn main() {

let image_fd = image.export_posix_fd().unwrap();

let image_view = ImageView::new(image.clone()).unwrap();
let image_view = ImageView::new_default(image.clone()).unwrap();

let barrier = Arc::new(Barrier::new(2));
let barrier_2 = Arc::new(Barrier::new(2));
Expand Down Expand Up @@ -605,7 +605,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| -> Arc<Framebuffer> {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();

Framebuffer::new(
render_pass.clone(),
Expand Down
4 changes: 2 additions & 2 deletions examples/src/bin/image-self-copy-blit/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ fn main() {
let command_buffer = builder.build().unwrap();

(
ImageView::new(image).unwrap(),
ImageView::new_default(image).unwrap(),
command_buffer.execute(queue.clone()).unwrap(),
)
};
Expand Down Expand Up @@ -421,7 +421,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();
Framebuffer::new(
render_pass.clone(),
FramebufferCreateInfo {
Expand Down
4 changes: 2 additions & 2 deletions examples/src/bin/image/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ fn main() {
queue.clone(),
)
.unwrap();
(ImageView::new(image).unwrap(), future)
(ImageView::new_default(image).unwrap(), future)
};

let sampler = Sampler::new(
Expand Down Expand Up @@ -355,7 +355,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();
Framebuffer::new(
render_pass.clone(),
FramebufferCreateInfo {
Expand Down
4 changes: 2 additions & 2 deletions examples/src/bin/immutable-sampler/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ fn main() {
queue.clone(),
)
.unwrap();
(ImageView::new(image).unwrap(), future)
(ImageView::new_default(image).unwrap(), future)
};

let sampler = Sampler::new(
Expand Down Expand Up @@ -364,7 +364,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();
Framebuffer::new(
render_pass.clone(),
FramebufferCreateInfo {
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/indirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();
Framebuffer::new(
render_pass.clone(),
FramebufferCreateInfo {
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/instancing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();
Framebuffer::new(
render_pass.clone(),
FramebufferCreateInfo {
Expand Down
10 changes: 5 additions & 5 deletions examples/src/bin/interactive_fractal/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Renderer {
);
let previous_frame_end = Some(sync::now(device.clone()).boxed());
let is_full_screen = swapchain.surface().window().fullscreen().is_some();
let image_format = final_images.first().unwrap().format();
let image_format = final_images.first().unwrap().format().unwrap();
let render_passes = RenderPasses {
place_over_frame: RenderPassPlaceOverFrame::new(queue.clone(), image_format),
};
Expand Down Expand Up @@ -226,7 +226,7 @@ impl Renderer {
.unwrap();
let images = images
.into_iter()
.map(|image| ImageView::new(image).unwrap())
.map(|image| ImageView::new_default(image).unwrap())
.collect::<Vec<_>>();
(swapchain, images)
}
Expand All @@ -239,7 +239,7 @@ impl Renderer {
/// Return swapchain image format
#[allow(unused)]
pub fn swapchain_format(&self) -> Format {
self.final_views[self.image_index].format()
self.final_views[self.image_index].format().unwrap()
}

/// Returns the index of last swapchain image that is the next render target
Expand Down Expand Up @@ -305,7 +305,7 @@ impl Renderer {
view_size: Option<[u32; 2]>,
format: Format,
) {
let image = ImageView::new(
let image = ImageView::new_default(
AttachmentImage::multisampled_with_usage(
self.device(),
if view_size.is_some() {
Expand Down Expand Up @@ -436,7 +436,7 @@ impl Renderer {
self.swapchain = new_swapchain;
let new_images = new_images
.into_iter()
.map(|image| ImageView::new(image).unwrap())
.map(|image| ImageView::new_default(image).unwrap())
.collect::<Vec<_>>();
self.final_views = new_images;
// Resize images that follow swapchain size
Expand Down
4 changes: 2 additions & 2 deletions examples/src/bin/msaa-renderpass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn main() {
//
// As explained in the introduction, we pass the same dimensions and format as for the final
// image. But we also pass the number of samples-per-pixel, which is 4 here.
let intermediary = ImageView::new(
let intermediary = ImageView::new_default(
AttachmentImage::transient_multisampled(
device.clone(),
[1024, 1024],
Expand All @@ -161,7 +161,7 @@ fn main() {
Some(queue.family()),
)
.unwrap();
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();

// In this example, we are going to perform the *resolve* (ie. turning a multisampled image
// into a non-multisampled one) as part of the render pass. This is the preferred method of
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/multi-window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();
Framebuffer::new(
render_pass.clone(),
FramebufferCreateInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl VulkanoContext {
.unwrap();
let images = images
.into_iter()
.map(|image| ImageView::new(image).unwrap())
.map(|image| ImageView::new_default(image).unwrap())
.collect::<Vec<_>>();
(swapchain, images)
}
Expand Down
10 changes: 5 additions & 5 deletions examples/src/bin/multi_window_game_of_life/vulkano_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl VulkanoWindow {

/// Return swapchain image format
pub fn swapchain_format(&self) -> Format {
self.final_views[self.image_index].format()
self.final_views[self.image_index].format().unwrap()
}

/// Return default image format for images
Expand Down Expand Up @@ -255,7 +255,7 @@ impl VulkanoWindow {
self.swapchain = new_swapchain;
let new_images = new_images
.into_iter()
.map(|image| ImageView::new(image).unwrap())
.map(|image| ImageView::new_default(image).unwrap())
.collect::<Vec<_>>();
self.final_views = new_images;
// Resize images that follow swapchain size
Expand All @@ -266,7 +266,7 @@ impl VulkanoWindow {
.map(|c| *c.0)
.collect::<Vec<usize>>();
for i in resizable_views {
let format = self.get_image_target(i).format();
let format = self.get_image_target(i).format().unwrap();
self.remove_image_target(i);
self.add_image_target(i, None, format);
}
Expand All @@ -282,7 +282,7 @@ pub fn create_device_image(queue: Arc<Queue>, size: [u32; 2], format: Format) ->
array_layers: 1,
};
let flags = ImageCreateFlags::none();
ImageView::new(
ImageView::new_default(
StorageImage::with_usage(
queue.device().clone(),
dims,
Expand Down Expand Up @@ -315,7 +315,7 @@ pub fn create_device_image_with_usage(
array_layers: 1,
};
let flags = ImageCreateFlags::none();
ImageView::new(
ImageView::new_default(
StorageImage::with_usage(
queue.device().clone(),
dims,
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/multiview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn main() {
)
.unwrap();

let image_view = ImageView::new(image.clone()).unwrap();
let image_view = ImageView::new_default(image.clone()).unwrap();

#[repr(C)]
#[derive(Default, Debug, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions examples/src/bin/occlusion-query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ fn window_size_dependent_setup(
let dimensions = images[0].dimensions().width_height();
viewport.dimensions = [dimensions[0] as f32, dimensions[1] as f32];

let depth_attachment = ImageView::new(
let depth_attachment = ImageView::new_default(
AttachmentImage::with_usage(
render_pass.device().clone(),
dimensions,
Expand All @@ -491,7 +491,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();
Framebuffer::new(
render_pass.clone(),
FramebufferCreateInfo {
Expand Down
4 changes: 2 additions & 2 deletions examples/src/bin/push-descriptors/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn main() {
queue.clone(),
)
.unwrap();
(ImageView::new(image).unwrap(), future)
(ImageView::new_default(image).unwrap(), future)
};

let sampler = Sampler::new(
Expand Down Expand Up @@ -347,7 +347,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();
Framebuffer::new(
render_pass.clone(),
FramebufferCreateInfo {
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/runtime-shader/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();
Framebuffer::new(
render_pass.clone(),
FramebufferCreateInfo {
Expand Down
6 changes: 3 additions & 3 deletions examples/src/bin/runtime_array/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ fn main() {
.unwrap()
.0;

ImageView::new(image).unwrap()
ImageView::new_default(image).unwrap()
};

let vulkano_texture = {
Expand Down Expand Up @@ -284,7 +284,7 @@ fn main() {
.unwrap()
.0;

ImageView::new(image).unwrap()
ImageView::new_default(image).unwrap()
};

let sampler = Sampler::new(
Expand Down Expand Up @@ -482,7 +482,7 @@ fn window_size_dependent_setup(
images
.iter()
.map(|image| {
let view = ImageView::new(image.clone()).unwrap();
let view = ImageView::new_default(image.clone()).unwrap();
Framebuffer::new(
render_pass.clone(),
FramebufferCreateInfo {
Expand Down
Loading

0 comments on commit 9e8682f

Please sign in to comment.