Skip to content

Commit

Permalink
Descriptor set revamp (#2404)
Browse files Browse the repository at this point in the history
* Descriptor set revamp

* Fix tests

* Fix examples

* Add `DescriptorSet::update_unchecked`

* Fix docs

* Add `Debug` impls

* Add `DescriptorSet::update_by_ref[_unchecked]`

* Rename `UnsafeDescriptorSet` to `RawDescriptorSet`

* Fix outdated docs for `DescriptorPool`
  • Loading branch information
marc0246 authored Nov 12, 2023
1 parent 6b95170 commit 63a53f1
Show file tree
Hide file tree
Showing 36 changed files with 343 additions and 323 deletions.
6 changes: 3 additions & 3 deletions examples/async-update/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use vulkano::{
PrimaryCommandBufferAbstract, RenderPassBeginInfo,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Queue,
Expand Down Expand Up @@ -486,7 +486,7 @@ fn main() -> Result<(), impl Error> {
let uniform_buffer_sets = uniform_buffers
.iter()
.map(|buffer| {
PersistentDescriptorSet::new(
DescriptorSet::new(
descriptor_set_allocator.clone(),
pipeline.layout().set_layouts()[0].clone(),
[WriteDescriptorSet::buffer(0, buffer.clone())],
Expand All @@ -499,7 +499,7 @@ fn main() -> Result<(), impl Error> {
// Create the descriptor sets for sampling the textures.
let sampler = Sampler::new(device.clone(), SamplerCreateInfo::simple_repeat_linear()).unwrap();
let sampler_sets = textures.map(|texture| {
PersistentDescriptorSet::new(
DescriptorSet::new(
descriptor_set_allocator.clone(),
pipeline.layout().set_layouts()[1].clone(),
[
Expand Down
4 changes: 2 additions & 2 deletions examples/basic-compute-shader/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use vulkano::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
Expand Down Expand Up @@ -184,7 +184,7 @@ fn main() {
// If you want to run the pipeline on multiple different buffers, you need to create multiple
// descriptor sets that each contain the buffer you want to run the shader on.
let layout = pipeline.layout().set_layouts().get(0).unwrap();
let set = PersistentDescriptorSet::new(
let set = DescriptorSet::new(
descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::buffer(0, data_buffer.clone())],
Expand Down
4 changes: 2 additions & 2 deletions examples/deferred/frame/ambient_lighting_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use vulkano::{
CommandBufferInheritanceInfo, CommandBufferUsage, SecondaryAutoCommandBuffer,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::Queue,
image::view::ImageView,
Expand Down Expand Up @@ -168,7 +168,7 @@ impl AmbientLightingSystem {
};

let layout = self.pipeline.layout().set_layouts().get(0).unwrap();
let descriptor_set = PersistentDescriptorSet::new(
let descriptor_set = DescriptorSet::new(
self.descriptor_set_allocator.clone(),
layout.clone(),
[WriteDescriptorSet::image_view(0, color_input)],
Expand Down
4 changes: 2 additions & 2 deletions examples/deferred/frame/directional_lighting_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use vulkano::{
CommandBufferInheritanceInfo, CommandBufferUsage, SecondaryAutoCommandBuffer,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::Queue,
image::view::ImageView,
Expand Down Expand Up @@ -179,7 +179,7 @@ impl DirectionalLightingSystem {
};

let layout = self.pipeline.layout().set_layouts().get(0).unwrap();
let descriptor_set = PersistentDescriptorSet::new(
let descriptor_set = DescriptorSet::new(
self.descriptor_set_allocator.clone(),
layout.clone(),
[
Expand Down
4 changes: 2 additions & 2 deletions examples/deferred/frame/point_lighting_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use vulkano::{
CommandBufferInheritanceInfo, CommandBufferUsage, SecondaryAutoCommandBuffer,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::Queue,
image::view::ImageView,
Expand Down Expand Up @@ -191,7 +191,7 @@ impl PointLightingSystem {
};

let layout = self.pipeline.layout().set_layouts().get(0).unwrap();
let descriptor_set = PersistentDescriptorSet::new(
let descriptor_set = DescriptorSet::new(
self.descriptor_set_allocator.clone(),
layout.clone(),
[
Expand Down
4 changes: 2 additions & 2 deletions examples/dynamic-buffers/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use vulkano::{
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, layout::DescriptorType, DescriptorBufferInfo,
DescriptorSet, PersistentDescriptorSet, WriteDescriptorSet,
DescriptorSet, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
Expand Down Expand Up @@ -212,7 +212,7 @@ fn main() {
.unwrap();

let layout = pipeline.layout().set_layouts().get(0).unwrap();
let set = PersistentDescriptorSet::new(
let set = DescriptorSet::new(
descriptor_set_allocator,
layout.clone(),
[
Expand Down
4 changes: 2 additions & 2 deletions examples/dynamic-local-size/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use vulkano::{
CopyImageToBufferInfo,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
Expand Down Expand Up @@ -224,7 +224,7 @@ fn main() {
let view = ImageView::new_default(image.clone()).unwrap();

let layout = pipeline.layout().set_layouts().get(0).unwrap();
let set = PersistentDescriptorSet::new(
let set = DescriptorSet::new(
descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::image_view(0, view)],
Expand Down
4 changes: 2 additions & 2 deletions examples/gl-interop/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod linux {
CommandBufferUsage, RenderPassBeginInfo, SemaphoreSubmitInfo, SubmitInfo,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Queue,
Expand Down Expand Up @@ -278,7 +278,7 @@ mod linux {

let layout = pipeline.layout().set_layouts().get(0).unwrap();

let set = PersistentDescriptorSet::new(
let set = DescriptorSet::new(
descriptor_set_allocator,
layout.clone(),
[
Expand Down
4 changes: 2 additions & 2 deletions examples/image-self-copy-blit/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use vulkano::{
CopyImageInfo, ImageBlit, ImageCopy, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
Expand Down Expand Up @@ -380,7 +380,7 @@ fn main() -> Result<(), impl Error> {
};

let layout = pipeline.layout().set_layouts().get(0).unwrap();
let set = PersistentDescriptorSet::new(
let set = DescriptorSet::new(
descriptor_set_allocator,
layout.clone(),
[
Expand Down
4 changes: 2 additions & 2 deletions examples/image/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use vulkano::{
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
Expand Down Expand Up @@ -328,7 +328,7 @@ fn main() -> Result<(), impl Error> {
};

let layout = pipeline.layout().set_layouts().get(0).unwrap();
let set = PersistentDescriptorSet::new(
let set = DescriptorSet::new(
descriptor_set_allocator,
layout.clone(),
[
Expand Down
4 changes: 2 additions & 2 deletions examples/immutable-sampler/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use vulkano::{
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
Expand Down Expand Up @@ -349,7 +349,7 @@ fn main() -> Result<(), impl Error> {

// Use `image_view` instead of `image_view_sampler`, since the sampler is already in the
// layout.
let set = PersistentDescriptorSet::new(
let set = DescriptorSet::new(
descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::image_view(1, texture)],
Expand Down
4 changes: 2 additions & 2 deletions examples/indirect/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use vulkano::{
DrawIndirectCommand, RenderPassBeginInfo,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
Expand Down Expand Up @@ -454,7 +454,7 @@ fn main() -> Result<(), impl Error> {

// Pass the two buffers to the compute shader.
let layout = compute_pipeline.layout().set_layouts().get(0).unwrap();
let cs_desciptor_set = PersistentDescriptorSet::new(
let cs_desciptor_set = DescriptorSet::new(
descriptor_set_allocator.clone(),
layout.clone(),
[
Expand Down
4 changes: 2 additions & 2 deletions examples/interactive-fractal/fractal_compute_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use vulkano::{
PrimaryCommandBufferAbstract,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::Queue,
image::view::ImageView,
Expand Down Expand Up @@ -138,7 +138,7 @@ impl FractalComputePipeline {
let image_extent = image_view.image().extent();
let pipeline_layout = self.pipeline.layout();
let desc_layout = pipeline_layout.set_layouts().get(0).unwrap();
let set = PersistentDescriptorSet::new(
let set = DescriptorSet::new(
self.descriptor_set_allocator.clone(),
desc_layout.clone(),
[
Expand Down
6 changes: 3 additions & 3 deletions examples/interactive-fractal/pixels_draw_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use vulkano::{
CommandBufferInheritanceInfo, CommandBufferUsage, SecondaryAutoCommandBuffer,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::Queue,
image::{
Expand Down Expand Up @@ -172,7 +172,7 @@ impl PixelsDrawPipeline {
}
}

fn create_descriptor_set(&self, image: Arc<ImageView>) -> Arc<PersistentDescriptorSet> {
fn create_descriptor_set(&self, image: Arc<ImageView>) -> Arc<DescriptorSet> {
let layout = self.pipeline.layout().set_layouts().get(0).unwrap();
let sampler = Sampler::new(
self.gfx_queue.device().clone(),
Expand All @@ -186,7 +186,7 @@ impl PixelsDrawPipeline {
)
.unwrap();

PersistentDescriptorSet::new(
DescriptorSet::new(
self.descriptor_set_allocator.clone(),
layout.clone(),
[
Expand Down
4 changes: 2 additions & 2 deletions examples/multi-window-game-of-life/game_of_life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use vulkano::{
PrimaryAutoCommandBuffer,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::Queue,
format::Format,
Expand Down Expand Up @@ -173,7 +173,7 @@ impl GameOfLifeComputePipeline {
let image_extent = self.image.image().extent();
let pipeline_layout = self.compute_life_pipeline.layout();
let desc_layout = pipeline_layout.set_layouts().get(0).unwrap();
let set = PersistentDescriptorSet::new(
let set = DescriptorSet::new(
self.descriptor_set_allocator.clone(),
desc_layout.clone(),
[
Expand Down
6 changes: 3 additions & 3 deletions examples/multi-window-game-of-life/pixels_draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use vulkano::{
CommandBufferInheritanceInfo, CommandBufferUsage, SecondaryAutoCommandBuffer,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::Queue,
image::{
Expand Down Expand Up @@ -168,7 +168,7 @@ impl PixelsDrawPipeline {
}
}

fn create_image_sampler_nearest(&self, image: Arc<ImageView>) -> Arc<PersistentDescriptorSet> {
fn create_image_sampler_nearest(&self, image: Arc<ImageView>) -> Arc<DescriptorSet> {
let layout = self.pipeline.layout().set_layouts().get(0).unwrap();
let sampler = Sampler::new(
self.gfx_queue.device().clone(),
Expand All @@ -182,7 +182,7 @@ impl PixelsDrawPipeline {
)
.unwrap();

PersistentDescriptorSet::new(
DescriptorSet::new(
self.descriptor_set_allocator.clone(),
layout.clone(),
[
Expand Down
4 changes: 2 additions & 2 deletions examples/push-constants/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use vulkano::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
Expand Down Expand Up @@ -156,7 +156,7 @@ fn main() {
.unwrap();

let layout = pipeline.layout().set_layouts().get(0).unwrap();
let set = PersistentDescriptorSet::new(
let set = DescriptorSet::new(
descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::buffer(0, data_buffer.clone())],
Expand Down
6 changes: 3 additions & 3 deletions examples/runtime-array/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use vulkano::{
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, layout::DescriptorBindingFlags,
PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, layout::DescriptorBindingFlags, DescriptorSet,
WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Features,
Expand Down Expand Up @@ -448,7 +448,7 @@ fn main() -> Result<(), impl Error> {
};

let layout = pipeline.layout().set_layouts().get(0).unwrap();
let set = PersistentDescriptorSet::new_variable(
let set = DescriptorSet::new_variable(
descriptor_set_allocator,
layout.clone(),
2,
Expand Down
4 changes: 2 additions & 2 deletions examples/self-copy-buffer/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use vulkano::{
CommandBufferUsage, CopyBufferInfoTyped,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
Expand Down Expand Up @@ -152,7 +152,7 @@ fn main() {
.unwrap();

let layout = pipeline.layout().set_layouts().get(0).unwrap();
let set = PersistentDescriptorSet::new(
let set = DescriptorSet::new(
descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::buffer(0, data_buffer.clone())],
Expand Down
4 changes: 2 additions & 2 deletions examples/shader-include/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use vulkano::{
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, PersistentDescriptorSet, WriteDescriptorSet,
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
Expand Down Expand Up @@ -156,7 +156,7 @@ fn main() {
.unwrap();

let layout = pipeline.layout().set_layouts().get(0).unwrap();
let set = PersistentDescriptorSet::new(
let set = DescriptorSet::new(
descriptor_set_allocator,
layout.clone(),
[WriteDescriptorSet::buffer(0, data_buffer.clone())],
Expand Down
Loading

0 comments on commit 63a53f1

Please sign in to comment.