added underdeveloped but working image support (no freeing or samplers)

This commit is contained in:
2025-08-22 23:07:31 -04:00
parent bde929b05a
commit 7dbdcbba42
26 changed files with 1256 additions and 155 deletions

View File

@@ -35,9 +35,9 @@ macro_rules! primitives {
impl PrimitiveBuffers {
pub const LEN: usize = primitives!(@count $($name)*);
pub fn buffers(&self) -> [&Buffer; Self::LEN] {
pub fn buffers(&self) -> [(u32, &Buffer); Self::LEN] {
[
$(&self.$name.buffer)*
$((<$ty>::BINDING, &self.$name.buffer),)*
]
}
pub fn new(device: &Device) -> Self {
@@ -46,7 +46,7 @@ macro_rules! primitives {
device,
BufferUsages::STORAGE | BufferUsages::COPY_DST,
stringify!($name),
))*
),)*
}
}
}
@@ -62,14 +62,10 @@ macro_rules! primitives {
}
)*
};
(@count $t1:tt, $($t:tt),+) => { 1 + gen!(@count $($t),+) };
(@count $t1:tt $($t:tt)+) => { 1 + primitives!(@count $($t),+) };
(@count $t:tt) => { 1 };
}
primitives!(
rects: RoundedRectData => 0,
);
impl Primitives {
pub fn write<P: Primitive>(&mut self, data: P, region: UiRegion) {
let vec = P::vec(&mut self.data);
@@ -83,11 +79,23 @@ impl Primitives {
}
}
primitives!(
rects: RectPrimitive => 0,
textures: TexturePrimitive => 1,
);
#[repr(C)]
#[derive(Copy, Clone)]
pub struct RoundedRectData {
pub struct RectPrimitive {
pub color: Color<u8>,
pub radius: f32,
pub thickness: f32,
pub inner_radius: f32,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct TexturePrimitive {
pub view_idx: u32,
pub sampler_idx: u32,
}