Skip to content
Snippets Groups Projects
Commit cebcad5e authored by Hadrien Grasland's avatar Hadrien Grasland
Browse files

Small corrections from writing the solution

parent 98201f36
No related branches found
No related tags found
No related merge requests found
......@@ -375,7 +375,7 @@ pub fn create_parameters(
## Concentration images
### Setting the stage
### Did you say images?
As previously mentioned, Vulkan images give us access to the power of GPU
texturing units, which were designed to speed up and simplify the chore of
......@@ -684,32 +684,33 @@ use vulkano::{
Validated, VulkanError,
};
|[in_u, in_v, out_u, out_v]: [Arc<Image>; 4]| -> Result<_, Validated<VulkanError>> {
let layout = pipeline.layout().set_layouts()[IMAGES_SET as usize].clone();
let binding =
|binding, image: Arc<Image>, usage| -> Result<_, Validated<VulkanError>> {
let view_info = ImageViewCreateInfo {
usage,
..ImageViewCreateInfo::from_image(&image)
let create_set =
|[in_u, in_v, out_u, out_v]: [Arc<Image>; 4]| -> Result<_, Validated<VulkanError>> {
let layout = pipeline.layout().set_layouts()[IMAGES_SET as usize].clone();
let binding =
|binding, image: Arc<Image>, usage| -> Result<_, Validated<VulkanError>> {
let view_info = ImageViewCreateInfo {
usage,
..ImageViewCreateInfo::from_image(&image)
};
Ok(WriteDescriptorSet::image_view(
binding,
ImageView::new(image, view_info)?,
))
};
Ok(WriteDescriptorSet::image_view(
binding,
ImageView::new(image, view_info)?,
))
};
let descriptor_set = PersistentDescriptorSet::new(
&context.descriptor_alloc,
layout,
[
binding(IN_U, in_u, ImageUsage::SAMPLED)?,
binding(IN_V, in_v, ImageUsage::SAMPLED)?,
binding(OUT_U, out_u, ImageUsage::STORAGE)?,
binding(OUT_V, out_v, ImageUsage::STORAGE)?,
],
[],
)?;
Ok(descriptor_set)
};
let descriptor_set = PersistentDescriptorSet::new(
&context.descriptor_alloc,
layout,
[
binding(IN_U, in_u, ImageUsage::SAMPLED)?,
binding(IN_V, in_v, ImageUsage::SAMPLED)?,
binding(OUT_U, out_u, ImageUsage::STORAGE)?,
binding(OUT_V, out_v, ImageUsage::STORAGE)?,
],
[],
)?;
Ok(descriptor_set)
};
```
...and then we will use it to build our double-buffered descriptor set
......@@ -721,11 +722,11 @@ fn create_concentration_sets(
pipeline: &ComputePipeline,
images: &[Arc<Image>],
) -> Result<[Arc<PersistentDescriptorSet>; 2], Validated<VulkanError>> {
let new_images_set = /* ... as above ... */;
let create_set = /* ... as above ... */;
let [u1, v1, u2, v2] = [&images[0], &images[1], &images[2], &images[3]];
let descriptor_sets = [
new_images_set([u1.clone(), v1.clone(), u2.clone(), v2.clone()])?,
new_images_set([u2.clone(), v2.clone(), u1.clone(), v1.clone()])?,
create_set([u1.clone(), v1.clone(), u2.clone(), v2.clone()])?,
create_set([u2.clone(), v2.clone(), u1.clone(), v1.clone()])?,
];
Ok(descriptor_sets)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment