Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow binding raw descriptor sets #2423

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions examples/async-update/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -843,14 +843,12 @@ impl Task for RenderTask {
0,
&[
// Bind the uniform buffer designated for this frame.
self.uniform_buffer_sets[frame_index as usize]
.clone()
.into(),
self.uniform_buffer_sets[frame_index as usize].as_raw(),
// Bind the currently most up-to-date texture.
self.sampler_sets[self.current_texture_index.load(Ordering::Relaxed) as usize]
.clone()
.into(),
.as_raw(),
],
&[],
)?;
cbf.bind_vertex_buffers(0, &[self.vertex_buffer_id], &[0], &[], &[])?;

Expand Down
7 changes: 4 additions & 3 deletions examples/bloom/bloom.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{App, RenderContext};
use std::{slice, sync::Arc};
use std::sync::Arc;
use vulkano::{
image::{mip_level_extent, Image},
pipeline::{
Expand Down Expand Up @@ -80,7 +80,8 @@ impl Task for BloomTask {
PipelineBindPoint::Compute,
&rcx.pipeline_layout,
0,
slice::from_ref(&rcx.descriptor_set),
&[&rcx.descriptor_set],
&[],
)?;

let bloom_image = tcx.image(self.bloom_image_id)?.image();
Expand Down Expand Up @@ -141,7 +142,7 @@ impl Task for BloomTask {
}

cbf.destroy_object(bloom_image.clone());
cbf.destroy_object(rcx.descriptor_set.as_ref().0.clone());
cbf.destroy_object(rcx.descriptor_set.clone());

Ok(())
}
Expand Down
54 changes: 28 additions & 26 deletions examples/bloom/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use vulkano::{
DescriptorSetLayout, DescriptorSetLayoutBinding, DescriptorSetLayoutCreateInfo,
DescriptorType,
},
DescriptorImageViewInfo, DescriptorSet, DescriptorSetWithOffsets, WriteDescriptorSet,
sys::RawDescriptorSet,
DescriptorImageViewInfo, WriteDescriptorSet,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, DeviceOwned,
Expand Down Expand Up @@ -80,7 +81,7 @@ pub struct RenderContext {
recreate_swapchain: bool,
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
sampler: Arc<Sampler>,
descriptor_set: DescriptorSetWithOffsets,
descriptor_set: Arc<RawDescriptorSet>,
task_graph: ExecutableTaskGraph<Self>,
scene_node_id: NodeId,
tonemap_node_id: NodeId,
Expand Down Expand Up @@ -500,7 +501,7 @@ fn window_size_dependent_setup(
pipeline_layout: &Arc<PipelineLayout>,
sampler: &Arc<Sampler>,
descriptor_set_allocator: &Arc<StandardDescriptorSetAllocator>,
) -> (Id<Image>, DescriptorSetWithOffsets) {
) -> (Id<Image>, Arc<RawDescriptorSet>) {
let device = resources.device();
let swapchain_state = resources.swapchain(swapchain_id).unwrap();
let images = swapchain_state.images();
Expand Down Expand Up @@ -570,30 +571,31 @@ fn window_size_dependent_setup(
.unwrap()
});

let descriptor_set = DescriptorSet::new(
let descriptor_set = RawDescriptorSet::new(
descriptor_set_allocator.clone(),
pipeline_layout.set_layouts()[0].clone(),
[
WriteDescriptorSet::sampler(0, sampler.clone()),
WriteDescriptorSet::image_view_with_layout(
1,
DescriptorImageViewInfo {
image_view: bloom_texture_view,
image_layout: ImageLayout::General,
},
),
WriteDescriptorSet::image_view_with_layout_array(
2,
0,
bloom_mip_chain_views.map(|image_view| DescriptorImageViewInfo {
image_view,
image_layout: ImageLayout::General,
}),
),
],
[],
&pipeline_layout.set_layouts()[0],
0,
)
.unwrap();

(bloom_image_id, descriptor_set.into())
let writes = &[
WriteDescriptorSet::sampler(0, sampler.clone()),
WriteDescriptorSet::image_view_with_layout(
1,
DescriptorImageViewInfo {
image_view: bloom_texture_view,
image_layout: ImageLayout::General,
},
),
WriteDescriptorSet::image_view_with_layout_array(
2,
0,
bloom_mip_chain_views.map(|image_view| DescriptorImageViewInfo {
image_view,
image_layout: ImageLayout::General,
}),
),
];
unsafe { descriptor_set.update(writes, &[]) }.unwrap();

(bloom_image_id, Arc::new(descriptor_set))
}
3 changes: 2 additions & 1 deletion examples/bloom/tonemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ impl Task for TonemapTask {
PipelineBindPoint::Graphics,
&rcx.pipeline_layout,
0,
slice::from_ref(&rcx.descriptor_set),
&[&rcx.descriptor_set],
&[],
)?;

let swapchain_state = tcx.swapchain(self.swapchain_id)?;
Expand Down
Loading