From aa0fe8457cfff9c47c0c9fa4a1c86a79c7cbf9c5 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Sat, 27 Jul 2024 14:01:16 +1000 Subject: add a pool insert function. move RenderEnt to use handles --- src/new_render/pbr.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/new_render/pbr.c') diff --git a/src/new_render/pbr.c b/src/new_render/pbr.c index ccc4dcf..09da50e 100644 --- a/src/new_render/pbr.c +++ b/src/new_render/pbr.c @@ -103,12 +103,16 @@ void PBR_Execute(PBR_Storage* storage, Camera camera, TextureHandle shadowmap_te enc, 3, (ShaderData){ .data = &lights_data, .get_layout = &Binding_Lights_GetLayout }); // TODO: Add shadowmap texture to uniforms + Mesh_pool* mesh_pool = Render_GetMeshPool(); + Material_pool* material_pool = Render_GetMaterialPool(); for (size_t ent_i = 0; ent_i < entity_count; ent_i++) { RenderEnt renderable = entities[ent_i]; + Mesh* mesh = Mesh_pool_get(mesh_pool, renderable.mesh); + Material* mat = Material_pool_get(material_pool, renderable.material); // upload material data - PBRMaterialUniforms material_data = { .mat = *renderable.material }; + PBRMaterialUniforms material_data = { .mat = *mat }; GPU_EncodeBindShaderData( enc, 2, (ShaderData){ .data = &material_data, .get_layout = PBRMaterial_GetLayout }); @@ -118,10 +122,10 @@ void PBR_Execute(PBR_Storage* storage, Camera camera, TextureHandle shadowmap_te enc, 1, (ShaderData){ .data = &model_data, .get_layout = &Binding_Model_GetLayout }); // set buffers - GPU_EncodeSetVertexBuffer(enc, renderable.mesh->vertex_buffer); - GPU_EncodeSetIndexBuffer(enc, renderable.mesh->index_buffer); + GPU_EncodeSetVertexBuffer(enc, mesh->vertex_buffer); + GPU_EncodeSetIndexBuffer(enc, mesh->index_buffer); // draw - GPU_EncodeDrawIndexed(enc, renderable.mesh->geometry.indices->len); + GPU_EncodeDrawIndexed(enc, mesh->geometry.index_count); } GPU_CmdEncoder_EndRender(enc); -- cgit v1.2.3-70-g09d2