1use std::sync::Arc;
2
3use crate::{Buffer, GpuSamplerSet, Pipeline, mesh::Mesh};
4
5pub struct MeshBuffer {
7 pub(crate) mesh: Arc<Mesh>,
8 pub(crate) vertices: Arc<dyn Buffer>,
9 pub(crate) indices: Arc<dyn Buffer>,
10}
11
12pub struct Object {
14 pub(crate) pipeline: Arc<dyn Pipeline>,
15 pub(crate) mesh_buffer: Option<Arc<MeshBuffer>>,
16 pub(crate) sampler: Option<Arc<GpuSamplerSet>>,
17 pub(crate) groups: Option<[u32; 3]>,
18 pub(crate) array: u32,
19}
20
21unsafe impl Sync for Object {}
22unsafe impl Send for Object {}
23
24#[allow(dead_code)]
25impl Object {
26 pub fn new_compute(pipeline: Arc<dyn Pipeline>, groups: [u32; 3]) -> Arc<Self> {
28 Arc::new(Self {
29 pipeline,
30 mesh_buffer: None,
31 sampler: None,
32 groups: Some(groups),
33 array: 0,
34 })
35 }
36
37 pub fn compute_with_textures(
39 pipeline: Arc<dyn Pipeline>,
40 groups: [u32; 3],
41 sampler: Arc<GpuSamplerSet>,
42 ) -> Arc<Self> {
43 Arc::new(Self {
44 pipeline,
45 mesh_buffer: None,
46 sampler: Some(sampler),
47 groups: Some(groups),
48 array: 1,
49 })
50 }
51
52 pub fn with_mesh(pipeline: Arc<dyn Pipeline>, mesh: Arc<MeshBuffer>) -> Arc<Self> {
54 Arc::new(Self {
55 pipeline,
56 mesh_buffer: Some(mesh),
57 sampler: None,
58 groups: None,
59 array: 1,
60 })
61 }
62
63 pub fn with_mesh_sampled(
65 pipeline: Arc<dyn Pipeline>,
66 mesh: Arc<MeshBuffer>,
67 sampler: Arc<GpuSamplerSet>,
68 ) -> Arc<Self> {
69 Arc::new(Self {
70 pipeline,
71 mesh_buffer: Some(mesh),
72 sampler: Some(sampler),
73 groups: None,
74 array: 1,
75 })
76 }
77
78 pub fn with_mesh_sampled_array(
80 pipeline: Arc<dyn Pipeline>,
81 mesh: Arc<MeshBuffer>,
82 sampler: Arc<GpuSamplerSet>,
83 array: u32,
84 ) -> Arc<Self> {
85 Arc::new(Self {
86 pipeline,
87 mesh_buffer: Some(mesh),
88 sampler: Some(sampler),
89 groups: None,
90 array,
91 })
92 }
93}