Skip to content

Commit

Permalink
A whole GLTF document (and buffers and images) on the GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
schell committed Dec 1, 2023
1 parent 64fab88 commit 299b822
Show file tree
Hide file tree
Showing 13 changed files with 1,702 additions and 265 deletions.
12 changes: 5 additions & 7 deletions crates/renderling-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,12 @@ pub fn derive_from_slab(input: proc_macro::TokenStream) -> proc_macro::TokenStre
FieldName::Index(i) => Ident::new(&format!("offset_of_{}", i.index), i.span),
FieldName::Ident(field) => Ident::new(&format!("offset_of_{}", field), field.span()),
};
offsets.push(
quote!{
pub fn #ident() -> usize {
#(<#offset_tys as renderling_shader::slab::Slabbed>::slab_size()+)*
0
}
offsets.push(quote! {
pub fn #ident() -> usize {
#(<#offset_tys as renderling_shader::slab::Slabbed>::slab_size()+)*
0
}
);
});
offset_tys.push(ty.clone());
}

Expand Down
23 changes: 19 additions & 4 deletions crates/renderling-shader/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@ use crate::id::Id;
use crate::slab::Slabbed;

#[repr(C)]
#[derive(Clone, Copy)]
pub struct Array<T: Slabbed> {
pub struct Array<T> {
index: u32,
len: u32,
_phantom: PhantomData<T>,
}

impl<T: Slabbed> core::fmt::Debug for Array<T> {
impl<T> Clone for Array<T> {
fn clone(&self) -> Self {
Self {
index: self.index,
len: self.len,
_phantom: PhantomData,
}
}
}

impl<T> Copy for Array<T> {}

impl<T> core::fmt::Debug for Array<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("Array")
.field("index", &self.index)
Expand All @@ -22,7 +33,7 @@ impl<T: Slabbed> core::fmt::Debug for Array<T> {
}
}

impl<T: Slabbed> PartialEq for Array<T> {
impl<T> PartialEq for Array<T> {
fn eq(&self, other: &Self) -> bool {
self.index == other.index && self.len == other.len
}
Expand Down Expand Up @@ -92,4 +103,8 @@ impl<T: Slabbed> Array<T> {
Id::new(self.index + (T::slab_size() * index) as u32)
}
}

pub fn starting_index(&self) -> usize {
self.index as usize
}
}
Loading

0 comments on commit 299b822

Please sign in to comment.