I have kinda given up trying to wrangle this descriptorsetbuilder. Going to read more on how sprites are best handled in regards to their textures

This commit is contained in:
2019-07-31 22:39:45 -07:00
parent 9951afd5a5
commit a8679459ea
2 changed files with 108 additions and 19 deletions

48
notes
View File

@@ -7,3 +7,51 @@ StorageImage
AttachmentImage
ImageAccess whose purpose is to be used as a framebuffer attachment
Hello!
Any of you guys use the Vulkano library? There is this PersistentDescriptorSetBuilder struct
which uses this fun chaining dynamic
```
PersistentDescriptorSet::start(layout, 0)
.add_sampled_image(sampled_image1).unwrap()
.add_sampled_image(sampled_image2).unwrap()
.add_sampled_image(sampled_image3).unwrap()
.build().unwrap();
```
But it modifies the return values template values so I can't store it between loops
```
let mut set_builder = PersistentDescriptorSet::start(layout, 0);
for image in images {
set_builder = set_builder.add_sampled_image(image);
}
let descriptor_set = set_builder.build().unwrap();
```
The gist of the error that I get is something like:
```
expected:
PersistentDescriptorSetBuilder<Arc<GraphicsPipelineAbstract>, ()>
got:
PersistentDescriptorSetBuilder<Arc<GraphicsPipelineAbstract>, ((), PersistentDescriptorSetImg<Arc<ImmutableImage<Format>>>)>
```
So it's adding tuples of tuples of tuples of tuples of tuples each time I chain a
.add_sampled_image() call. I really really want to be able to do this dynamically in
a loop; I've tried this neat iter().fold() thinking that if I didn't explicitly
overwrite the previous returned value, rust would figure it out. It didn't
```
let descriptor_set = images.iter().fold(
PersistentDescriptorSet::start(layout, 0)
,|a, &b| a.add_image(b))
.unwrap()).build().unwrap();
```
How do I do this dynamically?