diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-10 23:18:22 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-10 23:18:22 +1000 |
commit | ee1b7fd3bc66501b252ce9e3e5ba89ac9aa54632 (patch) | |
tree | 47b9b1916933d76bfcc327ad2f39370833bd3712 | |
parent | 8dc076e714fad6ee6fb493360e094c4002b1584a (diff) |
more work on bindings and ral
-rw-r--r-- | bindgen/rust/celeritas-sys/Cargo.lock | 29 | ||||
-rw-r--r-- | bindgen/rust/celeritas-sys/build.rs | 27 | ||||
-rw-r--r-- | bindgen/rust/celeritas-sys/src/lib.rs | 26 | ||||
-rw-r--r-- | bindgen/rust/examples/scene.rs | 2 | ||||
-rw-r--r-- | bindgen/rust/src/lib.rs | 50 | ||||
-rw-r--r-- | bindgen/rust/src/ral.rs | 157 | ||||
-rw-r--r-- | bindgen/rust/src/resources.rs | 4 | ||||
-rw-r--r-- | bindgen/rust/src/shader.rs | 1 | ||||
-rw-r--r-- | include/amalgamation.h | 1 | ||||
-rw-r--r-- | src/defines.h | 4 | ||||
-rw-r--r-- | src/ral/backends/opengl/backend_opengl.c | 11 | ||||
-rw-r--r-- | src/ral/backends/opengl/opengl_helpers.h | 2 | ||||
-rw-r--r-- | src/ral/ral_common.c | 11 | ||||
-rw-r--r-- | src/ral/ral_common.h | 1 | ||||
-rw-r--r-- | src/ral/ral_impl.h | 10 | ||||
-rw-r--r-- | src/ral/ral_types.h | 4 | ||||
-rw-r--r-- | src/render/render.c | 4 |
17 files changed, 311 insertions, 33 deletions
diff --git a/bindgen/rust/celeritas-sys/Cargo.lock b/bindgen/rust/celeritas-sys/Cargo.lock index 89c7407..43ae7fb 100644 --- a/bindgen/rust/celeritas-sys/Cargo.lock +++ b/bindgen/rust/celeritas-sys/Cargo.lock @@ -40,6 +40,15 @@ dependencies = [ ] [[package]] +name = "approx" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +dependencies = [ + "num-traits", +] + +[[package]] name = "autocfg" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -100,6 +109,7 @@ dependencies = [ "egui", "egui_glfw", "gl", + "glam", "serde", "serde_json", ] @@ -310,6 +320,16 @@ dependencies = [ ] [[package]] +name = "glam" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "779ae4bf7e8421cf91c0b3b64e7e8b40b862fba4d393f59150042de7c4965a94" +dependencies = [ + "approx", + "serde", +] + +[[package]] name = "glfw" version = "0.55.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -493,6 +513,15 @@ dependencies = [ ] [[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] name = "objc" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/bindgen/rust/celeritas-sys/build.rs b/bindgen/rust/celeritas-sys/build.rs index 9e97034..b356bb0 100644 --- a/bindgen/rust/celeritas-sys/build.rs +++ b/bindgen/rust/celeritas-sys/build.rs @@ -13,16 +13,26 @@ const SERIALIZABLE_TYPES: &[&'static str] = &[ "DirectionalLight", "PointLight", ]; +const EQ_TYPES: &[&'static str] = &[ + "BufferHandle", + "TextureHandle", + "MeshHandle", + "MaterialHandle", + "ModelHandle", +]; #[derive(Debug)] -struct DeriveSerialize; -impl ParseCallbacks for DeriveSerialize { +struct AdditionalDerives; +impl ParseCallbacks for AdditionalDerives { fn add_derives(&self, info: &bindgen::callbacks::DeriveInfo<'_>) -> Vec<String> { + let mut derives = vec![]; if SERIALIZABLE_TYPES.contains(&info.name) { - vec!["Serialize".to_string(), "Deserialize".to_string()] - } else { - vec![] + derives.extend_from_slice(&["Serialize".to_string(), "Deserialize".to_string()]); + } + if EQ_TYPES.contains(&info.name) { + derives.extend_from_slice(&["PartialEq".to_string()]); } + derives } } @@ -34,7 +44,8 @@ fn main() { // println!("cargo:rustc-link-search=../../build/windows/x64/debug"); let static_lib_path = - "/Users/josh/code/CodenameVentus/deps/celeritas-core/build/macosx/arm64/debug".to_string(); + "/Users/josh/code/CodenameVentus/deps/celeritas-core/build/macosx/arm64/release" + .to_string(); // let static_lib_path = std::env::var("CELERITAS_CORE_LIB") // .unwrap_or("../../../build/macosx/arm64/debug".to_string()); @@ -75,8 +86,10 @@ fn main() { .generate_inline_functions(true) // Tell cargo to invalidate the built crate whenever any of the // included header files changed. + .rustified_enum("GPU_TextureType") + .rustified_enum("GPU_TextureFormat") .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) - .parse_callbacks(Box::new(DeriveSerialize)) + .parse_callbacks(Box::new(AdditionalDerives)) // Finish the builder and generate the bindings. .generate() // Unwrap the Result and panic on failure. diff --git a/bindgen/rust/celeritas-sys/src/lib.rs b/bindgen/rust/celeritas-sys/src/lib.rs index 780ceff..90a5914 100644 --- a/bindgen/rust/celeritas-sys/src/lib.rs +++ b/bindgen/rust/celeritas-sys/src/lib.rs @@ -87,6 +87,19 @@ impl Transform { } } +impl Vec3 { + pub const ZERO: Self = Vec3 { + x: 0., + y: 0., + z: 0., + }; + pub const ONE: Self = Vec3 { + x: 1., + y: 1., + z: 1., + }; +} + impl Default for ShaderBinding { fn default() -> Self { Self { @@ -139,3 +152,16 @@ impl Default for Camera { camera } } + +// -- fat pointer string type + +impl Str8 { + pub fn from_str(s: &str) -> Self { + let s = s.to_owned(); + let s = s.leak(); // TODO: a better way than just leaking string memory :P + Self { + buf: s.as_mut_ptr(), + len: 0, + } + } +} diff --git a/bindgen/rust/examples/scene.rs b/bindgen/rust/examples/scene.rs index ba6b9ef..568ae89 100644 --- a/bindgen/rust/examples/scene.rs +++ b/bindgen/rust/examples/scene.rs @@ -56,7 +56,7 @@ fn main() { }, }, point_lights: [None, None, None, None], - camera_orientation: (camera_pos, camera_front), + camera_orientation: (camera_pos.into(), camera_front.into()), models: vec![], }; diff --git a/bindgen/rust/src/lib.rs b/bindgen/rust/src/lib.rs index f2e177f..dd83293 100644 --- a/bindgen/rust/src/lib.rs +++ b/bindgen/rust/src/lib.rs @@ -4,6 +4,7 @@ #![cfg_attr(docsrs, feature(doc_cfg))] pub use celeritas_sys as ffi; +use glam::Vec3; /// Commonly used types pub mod prelude; @@ -17,14 +18,20 @@ use std::{ fs::{self, File}, io::Write, path::Path, + ptr::addr_of_mut, }; use celeritas_sys::{ - Camera, Camera_Create, Core_Bringup, Core_Shutdown, DirectionalLight, PointLight, RenderEnt, - Transform, Vec3, + Core_Bringup, Core_Shutdown, DirectionalLight, Material, Material_Insert, Model, PointLight, + TextureHandle, Transform, }; use serde::{Deserialize, Serialize}; +pub trait IntoFFI { + type FFIType; + unsafe fn into_ffi(self) -> Self::FFIType; +} + /// Wrapper around a string that is the path to a gltf model **relative** to the configured /// `ASSETS` folder #[derive(Debug, Clone, Serialize, Deserialize)] @@ -103,3 +110,42 @@ bitflags::bitflags! { } } + +type M = Material; +/* +pub name: [::std::os::raw::c_char; 64usize], +pub kind: MaterialKind, +pub base_colour: Vec3, +pub metallic: f32_, +pub roughness: f32_, +pub ambient_occlusion: f32_, +pub albedo_map: TextureHandle, +pub normal_map: TextureHandle, +pub metallic_roughness_map: TextureHandle, +pub ambient_occlusion_map: TextureHandle, */ + +#[derive(Debug, Clone, Default, PartialEq)] +pub struct PBRMaterial { + pub name: String, + pub base_colour: glam::Vec3, + pub metallic: f32, + pub roughness: f32, + pub ambient_occlusion: f32, + pub albedo_map: Option<TextureHandle>, + pub normal_map: Option<TextureHandle>, + pub metallic_roughness_map: Option<TextureHandle>, + pub ambient_occlusion_map: Option<TextureHandle>, +} +impl PBRMaterial { + /// Creates the material in the C core returning a handle to it + pub fn create(mat: Self) -> ffi::MaterialHandle { + let mut ffi_mat = ffi::Material::from(mat); + unsafe { Material_Insert(addr_of_mut!(ffi_mat)) } + } +} + +impl From<PBRMaterial> for ffi::Material { + fn from(value: PBRMaterial) -> Self { + todo!("impl conv for materials") + } +} diff --git a/bindgen/rust/src/ral.rs b/bindgen/rust/src/ral.rs index 078121b..3ea69e2 100644 --- a/bindgen/rust/src/ral.rs +++ b/bindgen/rust/src/ral.rs @@ -1,23 +1,25 @@ //! Wrapper around the RAL code in celeritas-core -use std::ffi::c_void; +use std::ffi::{c_void, CString}; use celeritas_sys::{ BufferHandle, GPU_CmdEncoder, GPU_CmdEncoder_BeginRender, GPU_CmdEncoder_EndRender, GPU_EncodeBindShaderData, GPU_GetDefaultEncoder, GPU_GetDefaultRenderpass, GPU_GraphicsPipeline_Create, GPU_Pipeline, GraphicsPipelineDesc, ShaderBindingKind_BINDING_BYTES, ShaderBinding__bindgen_ty_1, - ShaderBinding__bindgen_ty_1__bindgen_ty_1, ShaderVisibility_VISIBILITY_COMPUTE, - ShaderVisibility_VISIBILITY_FRAGMENT, ShaderVisibility_VISIBILITY_VERTEX, TextureHandle, - MAX_SHADER_DATA_LAYOUTS, + ShaderBinding__bindgen_ty_1__bindgen_ty_1, ShaderDesc, ShaderVisibility_VISIBILITY_COMPUTE, + ShaderVisibility_VISIBILITY_FRAGMENT, ShaderVisibility_VISIBILITY_VERTEX, Str8, TextureHandle, + VertexDescription, MAX_SHADER_DATA_LAYOUTS, }; use thiserror::Error; +use crate::IntoFFI; + /// Holds a pointer to the raw `GPU_CmdEncoder` pub struct FrameRenderEncoder(*mut GPU_CmdEncoder); /// Holds a pointer to the raw `GPU_Renderpass` -pub struct RenderPass(*mut celeritas_sys::GPU_Renderpass); +pub struct RenderPass(pub *mut celeritas_sys::GPU_Renderpass); /// Holds a pointer to the raw `GPU_Pipeline` pub struct Pipeline(*mut celeritas_sys::GPU_Pipeline); @@ -58,9 +60,67 @@ impl FrameRenderEncoder { } } +// Vertex Descriptions +pub enum VertexAttrKind { + Floatx1, + Floatx2, + Floatx3, + Floatx4, + U32x1, + U32x2, + U32x3, + U32x4, + I32x1, + I32x2, + I32x3, + I32x4, +} + +pub struct VertexAttribute { + name: String, + kind: VertexAttrKind, +} + +#[derive(Default)] +pub struct VertexDesc { + debug_label: String, + attributes: Vec<VertexAttribute>, +} +impl VertexDesc { + pub fn new(name: String) -> Self { + Self { + debug_label: name, + attributes: vec![], + } + } + pub fn add_attr(mut self, attr_name: &str, kind: VertexAttrKind) -> Self { + self.attributes.push(VertexAttribute { + name: attr_name.to_owned(), + kind, + }); + self + } +} +impl IntoFFI for VertexDesc { + type FFIType = VertexDescription; + + unsafe fn into_ffi(self) -> Self::FFIType { + VertexDescription { + debug_label: todo!(), + attr_names: todo!(), + attributes: todo!(), + attributes_count: todo!(), + use_full_vertex_size: todo!(), + } + } +} + pub struct PipelineBuilder { + name: String, renderpass: Option<RenderPass>, + vertex_description: VertexDesc, data_layouts: Vec<ShaderDataLayout>, + shader_paths: Option<(String, String)>, } #[derive(Debug, Error)] @@ -70,6 +130,17 @@ pub enum RALError { } impl PipelineBuilder { + /// Create a new [PipelineBuilder] + pub fn new(name: String) -> Self { + let vertex_description = VertexDesc::new(format!("{} Vertex Description", name.clone())); + Self { + name, + renderpass: None, + vertex_description, + data_layouts: Vec::new(), + shader_paths: None, + } + } pub fn build(self) -> Result<Pipeline, RALError> { let layouts = [celeritas_sys::ShaderDataLayout::default(); 8]; if self.data_layouts.len() > MAX_SHADER_DATA_LAYOUTS as usize { @@ -78,12 +149,32 @@ impl PipelineBuilder { for (i, layout) in self.data_layouts.iter().enumerate().take(8) { // layouts[i] = celeritas_sys::ShaderDataLayout::from(layout); } + let (vert_path, frag_path) = self.shader_paths.expect("Shader paths must be provided"); + let vert_code = std::fs::read_to_string(vert_path.clone()).expect("msg"); + let frag_code = std::fs::read_to_string(frag_path.clone()).expect("msg"); - let mut desc = GraphicsPipelineDesc { - debug_name: todo!(), - vertex_desc: todo!(), - vs: todo!(), - fs: todo!(), + // TODO: convert VertexDesc -> ffi::VertexDescription + // load shader + let vs = ShaderDesc { + debug_name: "".as_ptr() as *const i8, + filepath: Str8::from_str(&vert_path), + code: Str8::from_str(&vert_code), + is_spirv: false, + is_combined_vert_frag: false, + }; + let fs = ShaderDesc { + debug_name: "".as_ptr() as *const i8, + filepath: Str8::from_str(&frag_path), + code: Str8::from_str(&frag_code), + is_spirv: false, + is_combined_vert_frag: false, + }; + + let desc = GraphicsPipelineDesc { + debug_name: "".as_ptr() as *const _, + vertex_desc: unsafe { self.vertex_description.into_ffi() }, + vs, + fs, data_layouts: layouts, data_layouts_count: layouts.len() as u32, wireframe: false, @@ -100,11 +191,19 @@ impl PipelineBuilder { Ok(Pipeline(p)) } - pub fn add_shader_layout<S: ShaderData>(&mut self) -> &mut Self { + pub fn add_vertex_desc(mut self, vertex_desc: VertexDesc) -> Self { + self.vertex_description = vertex_desc; + self + } + pub fn add_shader_layout<S: ShaderData>(mut self) -> Self { let layout = S::layout(); self.data_layouts.push(layout); self } + pub fn add_shader_src(mut self, vertex_path: &str, fragment_path: &str) -> Self { + self.shader_paths = Some((vertex_path.to_owned(), fragment_path.to_owned())); + self + } } impl Pipeline { @@ -159,6 +258,11 @@ pub struct ShaderDataLayout { pub bindings: heapless::Vec<ShaderBinding, 8>, } impl ShaderDataLayout { + pub fn from_slice(bindings: &[ShaderBinding]) -> Self { + todo!() + } +} +impl ShaderDataLayout { pub fn into_ffi_type(self) -> celeritas_sys::ShaderDataLayout { let mut bindings = [celeritas_sys::ShaderBinding::default(); 8]; for (i, b) in self.bindings.iter().enumerate().take(8) { @@ -210,3 +314,34 @@ impl From<celeritas_sys::PrimitiveTopology> for PrimitiveTopology { } } } +#[cfg(test)] +mod test { + use super::*; + + struct TestData { + a: [f32; 2], + b: [f32; 4], + } + impl ShaderData for TestData { + fn layout() -> ShaderDataLayout { + todo!() + } + + fn bind(&self) { + todo!() + } + } + + #[test] + fn typecheck_pipeline_create() { + let vertex_desc = VertexDesc::new("Empty".into()) + .add_attr("position", VertexAttrKind::Floatx2) + .add_attr("color", VertexAttrKind::Floatx4); + + let mut builder = PipelineBuilder::new("Test Pipeline".into()) + .add_shader_layout::<TestData>() + .add_vertex_desc(vertex_desc); + + let pipeline = builder.build().expect("Should be valid"); + } +} diff --git a/bindgen/rust/src/resources.rs b/bindgen/rust/src/resources.rs index 89cf6d7..e7f4505 100644 --- a/bindgen/rust/src/resources.rs +++ b/bindgen/rust/src/resources.rs @@ -1,6 +1,6 @@ -use std::{ffi::CString, path::Path}; +use std::ffi::CString; -use celeritas_sys::{ModelHandle, ModelLoad, ModelLoad_gltf}; +use celeritas_sys::{ModelHandle, ModelLoad_gltf}; /// Load a gltf from disk pub fn model_load_gltf(path: &str) -> Option<ModelHandle> { diff --git a/bindgen/rust/src/shader.rs b/bindgen/rust/src/shader.rs index e80e00b..ef221a0 100644 --- a/bindgen/rust/src/shader.rs +++ b/bindgen/rust/src/shader.rs @@ -1,3 +1,4 @@ +#![allow(unused_variables)] use std::{ffi::c_void, path::Path}; use crate::ral::{Pipeline, ShaderBinding}; diff --git a/include/amalgamation.h b/include/amalgamation.h index f368042..51ea382 100644 --- a/include/amalgamation.h +++ b/include/amalgamation.h @@ -11,6 +11,7 @@ #include "ral.h" #include "input.h" #include "primitives.h" +#include "immdraw.h" #include "maths_types.h" #include "maths.h" #include "skybox.h" diff --git a/src/defines.h b/src/defines.h index 108edef..67a4f17 100644 --- a/src/defines.h +++ b/src/defines.h @@ -65,7 +65,7 @@ CORE_DEFINE_HANDLE( // NOTE: The below is now handled in xmake.lua // Platform will inform renderer backend (unless user overrides) #if defined(CEL_PLATFORM_LINUX) -#define CEL_REND_BACKEND_OPENGL 1 +// #define CEL_REND_BACKEND_OPENGL 1 // #define CEL_REND_BACKEND_VULKAN 1 #endif @@ -79,4 +79,4 @@ CORE_DEFINE_HANDLE( // #define CEL_REND_BACKEND_METAL 1 #define CEL_REND_BACKEND_OPENGL 1 // #define CEL_REND_BACKEND_VULKAN 1 -#endif
\ No newline at end of file +#endif diff --git a/src/ral/backends/opengl/backend_opengl.c b/src/ral/backends/opengl/backend_opengl.c index f971568..6c1a301 100644 --- a/src/ral/backends/opengl/backend_opengl.c +++ b/src/ral/backends/opengl/backend_opengl.c @@ -416,6 +416,17 @@ void GPU_EncodeDrawIndexed(GPU_CmdEncoder* encoder, u64 index_count) { glDrawElements(GL_TRIANGLES, index_count, GL_UNSIGNED_INT, 0); } +PUB void GPU_WriteTextureRegion(GPU_CmdEncoder* encoder, TextureHandle dst, u32 x_offset, + u32 y_offset, u32 width, u32 height, const void* data) { + CASSERT_MSG(data, "const void* data must not be NULL"); + + GPU_Texture* tex = TEXTURE_GET(dst); + + glBindTexture(GL_TEXTURE_2D, tex->id); + glTexSubImage2D(GL_TEXTURE_2D, 0, x_offset, y_offset, width, height, GL_RGBA, GL_UNSIGNED_BYTE, + data); +} + bool GPU_Backend_BeginFrame() { glViewport(0, 0, context.swapchain.dimensions.x * 2, context.swapchain.dimensions.y * 2); glClearColor(0.8f, 0.8f, 0.8f, 1.0f); diff --git a/src/ral/backends/opengl/opengl_helpers.h b/src/ral/backends/opengl/opengl_helpers.h index f240050..0450c74 100644 --- a/src/ral/backends/opengl/opengl_helpers.h +++ b/src/ral/backends/opengl/opengl_helpers.h @@ -59,7 +59,7 @@ static u32 opengl_bindcreate_vao(GPU_Buffer* buf, VertexDescription desc) { u32 attr_count = desc.attributes_count; printf("N attributes %d\n", attr_count); u64 offset = 0; - size_t vertex_size = desc.use_full_vertex_size ? sizeof(Vertex) : desc.stride; + size_t vertex_size = desc.use_full_vertex_size ? sizeof(Vertex) : VertexDesc_CalcStride(&desc); for (u32 i = 0; i < desc.attributes_count; i++) { opengl_vertex_attr format = format_from_vertex_attr(desc.attributes[i]); glVertexAttribPointer(i, format.count, format.data_type, GL_FALSE, vertex_size, (void*)offset); diff --git a/src/ral/ral_common.c b/src/ral/ral_common.c index 35bf15f..53e35f0 100644 --- a/src/ral/ral_common.c +++ b/src/ral/ral_common.c @@ -32,7 +32,7 @@ void VertexDesc_AddAttr(VertexDescription* builder, const char* name, VertexAttr size_t size = VertexAttribSize(type); builder->attributes[i] = type; - builder->stride += size; + // builder->stride += size; builder->attr_names[i] = name; builder->attributes_count++; @@ -59,3 +59,12 @@ size_t VertexAttribSize(VertexAttribType attr) { break; } } + +size_t VertexDesc_CalcStride(VertexDescription* desc) { + size_t stride = 0; + for (int i = 0; i < desc->attributes_count; i++) { + size_t size =VertexAttribSize(desc->attributes[i]); + stride += size; + } + return stride; +} diff --git a/src/ral/ral_common.h b/src/ral/ral_common.h index 8fa09d9..5a797e5 100644 --- a/src/ral/ral_common.h +++ b/src/ral/ral_common.h @@ -56,5 +56,6 @@ void GPU_WindowResizedCallback(u32 x, u32 y); VertexDescription static_3d_vertex_description(); void VertexDesc_AddAttr(VertexDescription* builder, const char* name, VertexAttribType type); +size_t VertexDesc_CalcStride(VertexDescription* desc); size_t VertexAttribSize(VertexAttribType attr); diff --git a/src/ral/ral_impl.h b/src/ral/ral_impl.h index 0ca73c7..f5a16d2 100644 --- a/src/ral/ral_impl.h +++ b/src/ral/ral_impl.h @@ -73,11 +73,19 @@ void copy_buffer_to_image_oneshot(BufferHandle src, TextureHandle dst); // --- Render commands PUB void GPU_EncodeBindPipeline(GPU_CmdEncoder* encoder, GPU_Pipeline* pipeline); -// PUB void GPU_EncodeBindShaderData(GPU_CmdEncoder* encoder, u32 group, ShaderData data); PUB void GPU_EncodeBindShaderData(GPU_CmdEncoder* encoder, u32 group, ShaderDataLayout layout); void GPU_EncodeSetDefaults(GPU_CmdEncoder* encoder); PUB void GPU_EncodeSetVertexBuffer(GPU_CmdEncoder* encoder, BufferHandle buf); PUB void GPU_EncodeSetIndexBuffer(GPU_CmdEncoder* encoder, BufferHandle buf); +PUB void GPU_EncodeCopyBufToBuf(); + +// PUB void GPU_EncodeCopyBufToTex(GPU_CmdEncoder* encoder, BufferHandle src, TextureHandle dst, +// u32 x_offset, u32 y_offset, u32 width, u32 height, const void* data); +/** @brief Convenience method for writing data directly into a texture. Staging memory is handled internally. */ +PUB void GPU_WriteTextureRegion(GPU_CmdEncoder* encoder, TextureHandle dst, + u32 x_offset, u32 y_offset, u32 width, u32 height, const void* data); +PUB void GPU_WriteBuffer(GPU_CmdEncoder* encoder, BufferHandle buf, u64 offset, u64 size, const void* data); + PUB void GPU_EncodeDraw(GPU_CmdEncoder* encoder, u64 count); PUB void GPU_EncodeDrawIndexed(GPU_CmdEncoder* encoder, u64 index_count); PUB void GPU_EncodeDrawInstanced(GPU_CmdEncoder* encoder, u64 index_count, diff --git a/src/ral/ral_types.h b/src/ral/ral_types.h index ec302c1..470e4e9 100644 --- a/src/ral/ral_types.h +++ b/src/ral/ral_types.h @@ -148,11 +148,11 @@ typedef enum VertexAttribType { } VertexAttribType; typedef struct VertexDescription { - char* debug_label; + const char* debug_label; const char* attr_names[MAX_VERTEX_ATTRIBUTES]; VertexAttribType attributes[MAX_VERTEX_ATTRIBUTES]; u32 attributes_count; - size_t stride; + // size_t stride; bool use_full_vertex_size; } VertexDescription; diff --git a/src/render/render.c b/src/render/render.c index 697a79e..bad245a 100644 --- a/src/render/render.c +++ b/src/render/render.c @@ -287,9 +287,7 @@ PUB MeshHandle Mesh_Insert(Mesh* mesh) { return Mesh_pool_insert(Render_GetMeshP PUB MaterialHandle Material_Insert(Material* material) { return Material_pool_insert(Render_GetMaterialPool(), material); } -Mesh* Mesh_Get(MeshHandle handle) { - return Mesh_pool_get(Render_GetMeshPool(), handle); -} +Mesh* Mesh_Get(MeshHandle handle) { return Mesh_pool_get(Render_GetMeshPool(), handle); } size_t ModelExtractRenderEnts(RenderEnt_darray* entities, ModelHandle model_handle, Mat4 affine, RenderEntityFlags flags) { |