1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use crate::;
use crateDevice;
const MAX_TEXTURE: usize = 100000;
;
// pub struct TextureCollection {
// pub is_dirty: bool,
// pub data: Vec<Texture>,
// pub buffer: GpuBuffer,
// }
// impl TextureCollection {
// pub fn destroy(&mut self, device: &Device) {
// unsafe {
// device.allocator.destroy_buffer(self.buffer.raw, &mut self.buffer.allocation);
// }
// }
// pub fn new(device: &Device) -> VulkanResult<Self> {
// let count = MAX_TEXTURE;
// let size = (size_of::<Transform>() * count) as u64;
// let mut buffer = GpuBufferBuilder::cpu_only(&device)
// .usage(vk::BufferUsageFlags::STORAGE_BUFFER)
// .size(size)
// .build()?;
// let mut data = Vec::with_capacity(count);
// for _ in 0..count {
// data.push(Transform::identity());
// }
// buffer.upload_data(device, &data)?;
// Ok(Self {
// data,
// buffer,
// is_dirty: false
// })
// }
// pub fn get_mut(&mut self, handle: &TransformHandle) -> &mut Transform {
// self.is_dirty = true;
// &mut self.data[handle.0]
// }
// pub fn get(&self, handle: &TransformHandle) -> &Transform {
// &self.data[handle.0]
// }
// pub fn create_transform(&mut self, data: Transform) -> TransformHandle {
// self.is_dirty = true;
// let index = self.data.len();
// self.data.push(data);
// TransformHandle(index)
// }
// pub fn update(&mut self, device: &Device) -> VulkanResult<()> {
// if self.is_dirty {
// self.is_dirty = false;
// return self.buffer.upload_data(device, &self.data);
// }
// Ok(())
// }
// }