Stronger typing for descriptor sets and draft for proper barriers handling

This commit is contained in:
Pierre Krieger 2016-03-28 11:11:59 +02:00
parent 50b19b4fec
commit 5f81147eff
9 changed files with 325 additions and 72 deletions

View File

@ -21,11 +21,17 @@ pub fn write_descriptor_sets(doc: &parse::Spirv) -> String {
name: String,
desc_ty: String,
bind_ty: String,
bind_template_params: Vec<String>,
bind_where_clauses: String,
bind: String,
set: u32,
binding: u32,
}
// template parameter names that are available for the purpose of the code below
// TODO: better system
let mut template_params = vec!["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M"].into_iter();
// looping to find all the elements that have the `DescriptorSet` decoration
for instruction in doc.instructions.iter() {
let (variable_id, descriptor_set) = match instruction {
@ -51,42 +57,58 @@ pub fn write_descriptor_sets(doc: &parse::Spirv) -> String {
}).next().expect(&format!("Uniform `{}` is missing a binding", name));
// find informations about the kind of binding for this descriptor
let (desc_ty, bind_ty, bind) = doc.instructions.iter().filter_map(|i| {
let (desc_ty, bind_template_params, bind_where_clauses, bind_ty, bind) = doc.instructions.iter().filter_map(|i| {
match i {
&parse::Instruction::TypeStruct { result_id, .. } if result_id == pointed_ty => {
let tp_buffer = template_params.next().unwrap();
Some((
"::vulkano::descriptor_set::DescriptorType::UniformBuffer",
"::std::sync::Arc<::vulkano::buffer::Buffer>",
"::vulkano::descriptor_set::DescriptorBind::UniformBuffer { buffer: data, offset: 0, size: 128 /* FIXME */ }"
vec![tp_buffer.to_owned()],
format!("{}: 'static + ::vulkano::buffer::Buffer", tp_buffer),
format!("&'a ::std::sync::Arc<{}>", tp_buffer),
"unsafe { ::vulkano::descriptor_set::DescriptorBind::unchecked_uniform_buffer(data, 0 .. data.size()) }"
))
},
&parse::Instruction::TypeImage { result_id, sampled_type_id, ref dim, arrayed, ms,
sampled, ref format, ref access, .. }
if result_id == pointed_ty && sampled == Some(true) =>
{
let img = template_params.next().unwrap();
Some((
"::vulkano::descriptor_set::DescriptorType::SampledImage",
"::std::sync::Arc<::vulkano::image::ImageView>",
"::vulkano::descriptor_set::DescriptorBind::SampledImage(data)"
vec![img.to_owned()],
format!("{}: 'static + ::vulkano::image::ImageView", img),
format!("&'a ::std::sync::Arc<{}>", img),
"::vulkano::descriptor_set::DescriptorBind::sampled_image(data)"
))
},
&parse::Instruction::TypeImage { result_id, sampled_type_id, ref dim, arrayed, ms,
sampled, ref format, ref access, .. }
if result_id == pointed_ty && sampled == Some(false) =>
{
let img = template_params.next().unwrap();
Some((
"::vulkano::descriptor_set::DescriptorType::InputAttachment", // FIXME: can be `StorageImage`
"::std::sync::Arc<::vulkano::image::ImageView>",
"::vulkano::descriptor_set::DescriptorBind::InputAttachment(data)"
vec![img.to_owned()],
format!("{}: 'static + ::vulkano::image::ImageView", img),
format!("&'a ::std::sync::Arc<{}>", img),
"::vulkano::descriptor_set::DescriptorBind::input_attachment(data)"
))
},
&parse::Instruction::TypeSampledImage { result_id, image_type_id }
if result_id == pointed_ty =>
{
let img = template_params.next().unwrap();
Some((
"::vulkano::descriptor_set::DescriptorType::CombinedImageSampler",
"(::std::sync::Arc<::vulkano::sampler::Sampler>, ::std::sync::Arc<::vulkano::image::ImageView>)",
"::vulkano::descriptor_set::DescriptorBind::CombinedImageSampler(data.0, data.1)"
vec![img.to_owned()],
format!("{}: 'static + ::vulkano::image::ImageView", img),
format!("(&'a ::std::sync::Arc<::vulkano::sampler::Sampler>, &'a ::std::sync::Arc<{}>)", img),
"::vulkano::descriptor_set::DescriptorBind::combined_image_sampler(data.0, data.1)"
))
},
_ => None, // TODO: other types
@ -96,7 +118,9 @@ pub fn write_descriptor_sets(doc: &parse::Spirv) -> String {
descriptors.push(Descriptor {
name: name,
desc_ty: desc_ty.to_owned(),
bind_ty: bind_ty.to_owned(),
bind_ty: bind_ty,
bind_template_params: bind_template_params,
bind_where_clauses: bind_where_clauses,
bind: bind.to_owned(),
set: descriptor_set,
binding: binding,
@ -113,6 +137,20 @@ pub fn write_descriptor_sets(doc: &parse::Spirv) -> String {
.map(|d| d.bind_ty.clone())
.collect::<Vec<_>>();
let write_tp = {
let v = descriptors.iter().filter(|d| d.set == *set)
.map(|d| d.bind_template_params.join(", "))
.collect::<Vec<_>>().join(", ");
if v.is_empty() { v } else { ", ".to_owned() + &v }
};
let write_where = {
let v = descriptors.iter().filter(|d| d.set == *set)
.map(|d| d.bind_where_clauses.clone())
.collect::<Vec<_>>().join(", ");
if v.is_empty() { v } else { "where ".to_owned() + &v }
};
let writes = descriptors.iter().enumerate().filter(|&(_, d)| d.set == *set)
.map(|(entry, d)| {
let entry = if write_ty.len() == 1 {
@ -160,7 +198,9 @@ unsafe impl ::vulkano::descriptor_set::SetLayout for Set{set} {{
}}
}}
unsafe impl ::vulkano::descriptor_set::SetLayoutWrite<{write_ty}> for Set{set} {{
unsafe impl<'a {write_tp}> ::vulkano::descriptor_set::SetLayoutWrite<{write_ty}> for Set{set}
{write_where}
{{
fn decode(&self, data: {write_ty}) -> Vec<::vulkano::descriptor_set::DescriptorWrite> {{
vec![
{writes}
@ -168,13 +208,16 @@ unsafe impl ::vulkano::descriptor_set::SetLayoutWrite<{write_ty}> for Set{set} {
}}
}}
unsafe impl ::vulkano::descriptor_set::SetLayoutInit<{write_ty}> for Set{set} {{
unsafe impl<'a {write_tp}> ::vulkano::descriptor_set::SetLayoutInit<{write_ty}> for Set{set}
{write_where}
{{
fn decode(&self, data: {write_ty}) -> Vec<::vulkano::descriptor_set::DescriptorWrite> {{
::vulkano::descriptor_set::SetLayoutWrite::decode(self, data)
}}
}}
"#, set = set, write_ty = write_ty, writes = writes.join(","), descr = descr.join(",")));
"#, set = set, write_ty = write_ty, writes = writes.join(","), write_tp = write_tp,
write_where = write_where, descr = descr.join(",")));
}
let max_set = sets_list.iter().cloned().max().map(|v| v + 1).unwrap_or(0);

View File

@ -172,7 +172,7 @@ fn main() {
let pipeline_layout = vulkano::descriptor_set::PipelineLayout::new(&device, vulkano::descriptor_set::RuntimeDesc, vec![descriptor_set_layout.clone()]).unwrap();
let set = vulkano::descriptor_set::DescriptorSet::new(&descriptor_pool, &descriptor_set_layout,
vec![(0, vulkano::descriptor_set::DescriptorBind::CombinedImageSampler(sampler.clone(), texture.clone(), vulkano::image::Layout::ShaderReadOnlyOptimal))]).unwrap();
vec![(0, vulkano::descriptor_set::DescriptorBind::combined_image_sampler(&sampler, &texture))]).unwrap();
let pipeline = {

View File

@ -165,7 +165,7 @@ fn main() {
mod pipeline_layout { pipeline_from_sets!(::vs::Set0); }
let pipeline_layout = vulkano::descriptor_set::PipelineLayout::new(&device, pipeline_layout::Layout, (descriptor_set_layout.clone(),)).unwrap();
let set = vulkano::descriptor_set::DescriptorSet::new(&descriptor_pool, &descriptor_set_layout,
uniform_buffer.clone() as std::sync::Arc<_>).unwrap();
&uniform_buffer).unwrap();
let pipeline = {

View File

@ -7,13 +7,15 @@
// notice may not be copied, modified, or distributed except
// according to those terms.
use std::ops::Range;
use std::sync::Arc;
use buffer::Buffer;
use buffer::BufferSlice;
use descriptor_set::AbstractDescriptorSet;
use descriptor_set::AbstractDescriptorSetLayout;
use image::Image;
use image::ImageView;
use image::Layout as ImageLayout;
use sampler::Sampler;
use vk;
@ -84,40 +86,209 @@ pub struct DescriptorWrite {
pub content: DescriptorBind,
}
pub struct DescriptorBind {
inner: DescriptorBindInner
}
// FIXME: incomplete
// TODO: hacky visibility
#[derive(Clone)] // TODO: Debug
pub enum DescriptorBind {
StorageImage(Arc<ImageView>),
#[doc(hidden)]
pub enum DescriptorBindInner {
StorageImage(Arc<ImageView>, Arc<Image>, Vec<(u32, u32)>),
Sampler(Arc<Sampler>),
SampledImage(Arc<ImageView>),
CombinedImageSampler(Arc<Sampler>, Arc<ImageView>),
SampledImage(Arc<ImageView>, Arc<Image>, Vec<(u32, u32)>),
CombinedImageSampler(Arc<Sampler>, Arc<ImageView>, Arc<Image>, Vec<(u32, u32)>),
//UniformTexelBuffer(Arc<Buffer>), // FIXME: requires buffer views
//StorageTexelBuffer(Arc<Buffer>), // FIXME: requires buffer views
UniformBuffer { buffer: Arc<Buffer>, offset: usize, size: usize },
StorageBuffer { buffer: Arc<Buffer>, offset: usize, size: usize },
DynamicUniformBuffer { buffer: Arc<Buffer>, offset: usize, size: usize },
DynamicStorageBuffer { buffer: Arc<Buffer>, offset: usize, size: usize },
InputAttachment(Arc<ImageView>),
InputAttachment(Arc<ImageView>, Arc<Image>, Vec<(u32, u32)>),
}
impl DescriptorBind {
#[inline]
pub fn storage_image<I>(image: &Arc<I>) -> DescriptorBind
where I: ImageView + 'static
{
DescriptorBind {
inner: DescriptorBindInner::StorageImage(image.clone(), ImageView::parent_arc(image), image.blocks())
}
}
#[inline]
pub fn sampler(sampler: &Arc<Sampler>) -> DescriptorBind {
DescriptorBind {
inner: DescriptorBindInner::Sampler(sampler.clone())
}
}
#[inline]
pub fn sampled_image<I>(image: &Arc<I>) -> DescriptorBind
where I: ImageView + 'static
{
DescriptorBind {
inner: DescriptorBindInner::SampledImage(image.clone(), ImageView::parent_arc(image), image.blocks())
}
}
#[inline]
pub fn combined_image_sampler<I>(sampler: &Arc<Sampler>, image: &Arc<I>) -> DescriptorBind
where I: ImageView + 'static
{
DescriptorBind {
inner: DescriptorBindInner::CombinedImageSampler(sampler.clone(), image.clone(), ImageView::parent_arc(image), image.blocks())
}
}
#[inline]
pub fn uniform_buffer<'a, S, T: ?Sized, B>(buffer: S) -> DescriptorBind
where S: Into<BufferSlice<'a, T, B>>, B: Buffer + 'static
{
let buffer = buffer.into();
DescriptorBind {
inner: DescriptorBindInner::UniformBuffer {
buffer: buffer.buffer().clone(),
offset: buffer.offset(),
size: buffer.size(),
}
}
}
#[inline]
pub unsafe fn unchecked_uniform_buffer<B>(buffer: &Arc<B>, range: Range<usize>)
-> DescriptorBind
where B: Buffer + 'static
{
DescriptorBind {
inner: DescriptorBindInner::UniformBuffer {
buffer: buffer.clone(),
offset: range.start,
size: range.end - range.start,
}
}
}
#[inline]
pub fn storage_buffer<'a, S, T: ?Sized, B>(buffer: S) -> DescriptorBind
where S: Into<BufferSlice<'a, T, B>>, B: Buffer + 'static
{
let buffer = buffer.into();
DescriptorBind {
inner: DescriptorBindInner::StorageBuffer {
buffer: buffer.buffer().clone(),
offset: buffer.offset(),
size: buffer.size(),
}
}
}
#[inline]
pub unsafe fn unchecked_storage_buffer<B>(buffer: &Arc<B>, range: Range<usize>)
-> DescriptorBind
where B: Buffer + 'static
{
DescriptorBind {
inner: DescriptorBindInner::StorageBuffer {
buffer: buffer.clone(),
offset: range.start,
size: range.end - range.start,
}
}
}
#[inline]
pub fn dynamic_uniform_buffer<'a, S, T: ?Sized, B>(buffer: S) -> DescriptorBind
where S: Into<BufferSlice<'a, T, B>>, B: Buffer + 'static
{
let buffer = buffer.into();
DescriptorBind {
inner: DescriptorBindInner::DynamicUniformBuffer {
buffer: buffer.buffer().clone(),
offset: buffer.offset(),
size: buffer.size(),
}
}
}
#[inline]
pub unsafe fn unchecked_dynamic_uniform_buffer<B>(buffer: &Arc<B>, range: Range<usize>)
-> DescriptorBind
where B: Buffer + 'static
{
DescriptorBind {
inner: DescriptorBindInner::DynamicUniformBuffer {
buffer: buffer.clone(),
offset: range.start,
size: range.end - range.start,
}
}
}
#[inline]
pub fn dynamic_storage_buffer<'a, S, T: ?Sized, B>(buffer: S) -> DescriptorBind
where S: Into<BufferSlice<'a, T, B>>, B: Buffer + 'static
{
let buffer = buffer.into();
DescriptorBind {
inner: DescriptorBindInner::DynamicStorageBuffer {
buffer: buffer.buffer().clone(),
offset: buffer.offset(),
size: buffer.size(),
}
}
}
#[inline]
pub unsafe fn unchecked_dynamic_storage_buffer<B>(buffer: &Arc<B>, range: Range<usize>)
-> DescriptorBind
where B: Buffer + 'static
{
DescriptorBind {
inner: DescriptorBindInner::DynamicStorageBuffer {
buffer: buffer.clone(),
offset: range.start,
size: range.end - range.start,
}
}
}
#[inline]
pub fn input_attachment<I>(image: &Arc<I>) -> DescriptorBind
where I: ImageView + 'static
{
DescriptorBind {
inner: DescriptorBindInner::InputAttachment(image.clone(), ImageView::parent_arc(image), image.blocks())
}
}
/// Returns the type corresponding to this bind.
#[inline]
pub fn ty(&self) -> DescriptorType {
match *self {
DescriptorBind::Sampler(_) => DescriptorType::Sampler,
DescriptorBind::CombinedImageSampler(_, _) => DescriptorType::CombinedImageSampler,
DescriptorBind::SampledImage(_) => DescriptorType::SampledImage,
DescriptorBind::StorageImage(_) => DescriptorType::StorageImage,
//DescriptorBind::UniformTexelBuffer(_) => DescriptorType::UniformTexelBuffer,
//DescriptorBind::StorageTexelBuffer(_) => DescriptorType::StorageTexelBuffer,
DescriptorBind::UniformBuffer { .. } => DescriptorType::UniformBuffer,
DescriptorBind::StorageBuffer { .. } => DescriptorType::StorageBuffer,
DescriptorBind::DynamicUniformBuffer { .. } => DescriptorType::UniformBufferDynamic,
DescriptorBind::DynamicStorageBuffer { .. } => DescriptorType::StorageBufferDynamic,
DescriptorBind::InputAttachment(_) => DescriptorType::InputAttachment,
match self.inner {
DescriptorBindInner::Sampler(_) => DescriptorType::Sampler,
DescriptorBindInner::CombinedImageSampler(_, _, _, _) => DescriptorType::CombinedImageSampler,
DescriptorBindInner::SampledImage(_, _, _) => DescriptorType::SampledImage,
DescriptorBindInner::StorageImage(_, _, _) => DescriptorType::StorageImage,
//DescriptorBindInner::UniformTexelBuffer(_) => DescriptorType::UniformTexelBuffer,
//DescriptorBindInner::StorageTexelBuffer(_) => DescriptorType::StorageTexelBuffer,
DescriptorBindInner::UniformBuffer { .. } => DescriptorType::UniformBuffer,
DescriptorBindInner::StorageBuffer { .. } => DescriptorType::StorageBuffer,
DescriptorBindInner::DynamicUniformBuffer { .. } => DescriptorType::UniformBufferDynamic,
DescriptorBindInner::DynamicStorageBuffer { .. } => DescriptorType::StorageBufferDynamic,
DescriptorBindInner::InputAttachment(_, _, _) => DescriptorType::InputAttachment,
}
}
// TODO: hacky visibility
#[doc(hidden)]
pub fn inner(&self) -> &DescriptorBindInner { &self.inner }
}
/// Describes a single descriptor.

View File

@ -18,10 +18,12 @@ use descriptor_set::layout_def::SetLayout;
use descriptor_set::layout_def::SetLayoutWrite;
use descriptor_set::layout_def::SetLayoutInit;
use descriptor_set::layout_def::DescriptorWrite;
use descriptor_set::layout_def::DescriptorBind;
use descriptor_set::layout_def::DescriptorBindInner;
use descriptor_set::pool::DescriptorPool;
use device::Device;
use image::ImageView;
use image::sys::Layout as ImageLayout;
use image::traits::Image;
use image::traits::ImageView;
use sampler::Sampler;
use OomError;
@ -40,6 +42,7 @@ pub struct DescriptorSet<S> {
// Here we store the resources used by the descriptor set.
// TODO: for the moment even when a resource is overwritten it stays in these lists
resources_samplers: Vec<Arc<Sampler>>,
resources_images: Vec<(Arc<Image>, (u32, u32), ImageLayout)>,
resources_image_views: Vec<Arc<ImageView>>,
resources_buffers: Vec<Arc<Buffer>>,
}
@ -97,6 +100,7 @@ impl<S> DescriptorSet<S> where S: SetLayout {
layout: layout.clone(),
resources_samplers: Vec::new(),
resources_images: Vec::new(),
resources_image_views: Vec::new(),
resources_buffers: Vec::new(),
}))
@ -125,13 +129,14 @@ impl<S> DescriptorSet<S> where S: SetLayout {
// borrow checker, we extract references to the members here.
let ref mut self_resources_buffers = self.resources_buffers;
let ref mut self_resources_samplers = self.resources_samplers;
let ref mut self_resources_images = self.resources_images;
let ref mut self_resources_image_views = self.resources_image_views;
let self_set = self.set;
let buffer_descriptors = write.iter().filter_map(|write| {
match write.content {
DescriptorBind::UniformBuffer { ref buffer, offset, size } |
DescriptorBind::DynamicUniformBuffer { ref buffer, offset, size } => {
match *write.content.inner() {
DescriptorBindInner::UniformBuffer { ref buffer, offset, size } |
DescriptorBindInner::DynamicUniformBuffer { ref buffer, offset, size } => {
assert!(buffer.inner_buffer().usage_uniform_buffer());
self_resources_buffers.push(buffer.clone());
Some(vk::DescriptorBufferInfo {
@ -140,8 +145,8 @@ impl<S> DescriptorSet<S> where S: SetLayout {
range: size as u64,
})
},
DescriptorBind::StorageBuffer { ref buffer, offset, size } |
DescriptorBind::DynamicStorageBuffer { ref buffer, offset, size } => {
DescriptorBindInner::StorageBuffer { ref buffer, offset, size } |
DescriptorBindInner::DynamicStorageBuffer { ref buffer, offset, size } => {
assert!(buffer.inner_buffer().usage_storage_buffer());
self_resources_buffers.push(buffer.clone());
Some(vk::DescriptorBufferInfo {
@ -155,8 +160,8 @@ impl<S> DescriptorSet<S> where S: SetLayout {
}).collect::<SmallVec<[_; 64]>>();
let image_descriptors = write.iter().filter_map(|write| {
match write.content {
DescriptorBind::Sampler(ref sampler) => {
match *write.content.inner() {
DescriptorBindInner::Sampler(ref sampler) => {
self_resources_samplers.push(sampler.clone());
Some(vk::DescriptorImageInfo {
sampler: sampler.internal_object(),
@ -164,43 +169,59 @@ impl<S> DescriptorSet<S> where S: SetLayout {
imageLayout: 0,
})
},
DescriptorBind::CombinedImageSampler(ref sampler, ref image) => {
assert!(image.inner_view().usage_sampled());
DescriptorBindInner::CombinedImageSampler(ref sampler, ref view, ref image, ref blocks) => {
assert!(view.inner_view().usage_sampled());
let layout = view.descriptor_set_combined_image_sampler_layout();
self_resources_samplers.push(sampler.clone());
self_resources_image_views.push(image.clone());
self_resources_image_views.push(view.clone());
for &block in blocks.iter() {
self_resources_images.push((image.clone(), block, layout)); // TODO: check for collisions
}
Some(vk::DescriptorImageInfo {
sampler: sampler.internal_object(),
imageView: image.inner_view().internal_object(),
imageLayout: image.descriptor_set_combined_image_sampler_layout() as u32,
imageView: view.inner_view().internal_object(),
imageLayout: layout as u32,
})
},
DescriptorBind::StorageImage(ref image) => {
assert!(image.inner_view().usage_storage());
assert!(image.identity_swizzle());
self_resources_image_views.push(image.clone());
DescriptorBindInner::StorageImage(ref view, ref image, ref blocks) => {
assert!(view.inner_view().usage_storage());
assert!(view.identity_swizzle());
let layout = view.descriptor_set_storage_image_layout();
self_resources_image_views.push(view.clone());
for &block in blocks.iter() {
self_resources_images.push((image.clone(), block, layout)); // TODO: check for collisions
}
Some(vk::DescriptorImageInfo {
sampler: 0,
imageView: image.inner_view().internal_object(),
imageLayout: image.descriptor_set_storage_image_layout() as u32,
imageView: view.inner_view().internal_object(),
imageLayout: layout as u32,
})
},
DescriptorBind::SampledImage(ref image) => {
assert!(image.inner_view().usage_sampled());
self_resources_image_views.push(image.clone());
DescriptorBindInner::SampledImage(ref view, ref image, ref blocks) => {
assert!(view.inner_view().usage_sampled());
let layout = view.descriptor_set_sampled_image_layout();
self_resources_image_views.push(view.clone());
for &block in blocks.iter() {
self_resources_images.push((image.clone(), block, layout)); // TODO: check for collisions
}
Some(vk::DescriptorImageInfo {
sampler: 0,
imageView: image.inner_view().internal_object(),
imageLayout: image.descriptor_set_sampled_image_layout() as u32,
imageView: view.inner_view().internal_object(),
imageLayout: layout as u32,
})
},
DescriptorBind::InputAttachment(ref image) => {
assert!(image.inner_view().usage_input_attachment());
assert!(image.identity_swizzle());
self_resources_image_views.push(image.clone());
DescriptorBindInner::InputAttachment(ref view, ref image, ref blocks) => {
assert!(view.inner_view().usage_input_attachment());
assert!(view.identity_swizzle());
let layout = view.descriptor_set_input_attachment_layout();
self_resources_image_views.push(view.clone());
for &block in blocks.iter() {
self_resources_images.push((image.clone(), block, layout)); // TODO: check for collisions
}
Some(vk::DescriptorImageInfo {
sampler: 0,
imageView: image.inner_view().internal_object(),
imageLayout: image.descriptor_set_input_attachment_layout() as u32,
imageView: view.inner_view().internal_object(),
imageLayout: layout as u32,
})
},
_ => None
@ -212,18 +233,18 @@ impl<S> DescriptorSet<S> where S: SetLayout {
let mut next_image_desc = 0;
let vk_writes = write.iter().map(|write| {
let (buffer_info, image_info) = match write.content {
DescriptorBind::Sampler(_) | DescriptorBind::CombinedImageSampler(_, _) |
DescriptorBind::SampledImage(_) | DescriptorBind::StorageImage(_) |
DescriptorBind::InputAttachment(_) => {
let (buffer_info, image_info) = match *write.content.inner() {
DescriptorBindInner::Sampler(_) | DescriptorBindInner::CombinedImageSampler(_, _, _, _) |
DescriptorBindInner::SampledImage(_, _, _) | DescriptorBindInner::StorageImage(_, _, _) |
DescriptorBindInner::InputAttachment(_, _, _) => {
let img = image_descriptors.as_ptr().offset(next_image_desc as isize);
next_image_desc += 1;
(ptr::null(), img)
},
//DescriptorBind::UniformTexelBuffer(_) | DescriptorBind::StorageTexelBuffer(_) =>
DescriptorBind::UniformBuffer { .. } | DescriptorBind::StorageBuffer { .. } |
DescriptorBind::DynamicUniformBuffer { .. } |
DescriptorBind::DynamicStorageBuffer { .. } => {
//DescriptorBindInner::UniformTexelBuffer(_) | DescriptorBindInner::StorageTexelBuffer(_) =>
DescriptorBindInner::UniformBuffer { .. } | DescriptorBindInner::StorageBuffer { .. } |
DescriptorBindInner::DynamicUniformBuffer { .. } |
DescriptorBindInner::DynamicStorageBuffer { .. } => {
let buf = buffer_descriptors.as_ptr().offset(next_buffer_desc as isize);
next_buffer_desc += 1;
(buf, ptr::null())

View File

@ -205,6 +205,11 @@ unsafe impl<F: 'static> ImageView for AttachmentImage<F> {
me.clone() as Arc<_>
}
#[inline]
fn blocks(&self) -> Vec<(u32, u32)> {
vec![(0, 0)]
}
#[inline]
fn inner_view(&self) -> &UnsafeImageView {
&self.view

View File

@ -172,6 +172,11 @@ unsafe impl<F: 'static> ImageView for ImmutableImage<F> {
me.clone() as Arc<_>
}
#[inline]
fn blocks(&self) -> Vec<(u32, u32)> {
vec![(0, 0)]
}
#[inline]
fn inner_view(&self) -> &UnsafeImageView {
&self.view

View File

@ -167,6 +167,11 @@ unsafe impl ImageView for SwapchainImage {
me.clone() as Arc<_>
}
#[inline]
fn blocks(&self) -> Vec<(u32, u32)> {
vec![(0, 0)]
}
#[inline]
fn inner_view(&self) -> &UnsafeImageView {
&self.view

View File

@ -120,6 +120,9 @@ pub unsafe trait ImageView {
// TODO: should be named "inner()" after https://github.com/rust-lang/rust/issues/12808 is fixed
fn inner_view(&self) -> &UnsafeImageView;
/// Returns the blocks of the parent image this image view overlaps.
fn blocks(&self) -> Vec<(u32, u32)>;
/// Returns the format of this view. This can be different from the parent's format.
#[inline]
fn format(&self) -> Format {