From 4b63074631fa35bd875a79b5c31d490d10a0491e Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Mon, 17 Aug 2026 03:32:02 -0700 Subject: draw three teapots and split out the model rendering code a bunch for rapid instancing Force-Push: yes Change-Id: I75be46d8cd11bbf662013711ee5ec56abeb5e6ea --- src/graphics/model.rs | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) (limited to 'src/graphics/model.rs') diff --git a/src/graphics/model.rs b/src/graphics/model.rs index 096de86..053818f 100644 --- a/src/graphics/model.rs +++ b/src/graphics/model.rs @@ -5,8 +5,6 @@ use crate::graphics::util::init_buffer; use crate::linear_algebra::{ Vec3, Vec4, Transformation }; use crate::shader_data::{ Vertex, VertexPushBlock }; -use std::f32::consts::{ TAU }; - use vulkanalia::{ Device, Instance }; use vulkanalia::vk::{ self, DeviceV1_0 }; @@ -60,8 +58,8 @@ impl Model { } #[allow(unsafe_code)] - pub fn render(&self, time: f32, device: &Device, render: &Render, - command_buffer: &vk::CommandBuffer) + pub fn make_active(&self, device: &Device, render: &Render, + command_buffer: &vk::CommandBuffer) { unsafe { device.cmd_bind_vertex_buffers(*command_buffer, 0, @@ -72,28 +70,12 @@ impl Model { device.cmd_bind_index_buffer(*command_buffer, self.index_buffer, 0, vk::IndexType::UINT32) }; + } - let scale = Vec3::new(1.0, 1.0, 1.0); - let model = Transformation { - rotation: Vec4::rotation_quaternion(&Vec3::new(0.0, 1.0, 0.0), - time % TAU), - translation: Vec3::new(0.0, 0.0, 0.0), - }; - let push_block = VertexPushBlock:: { scale, model }; - let size = size_of::>(); - let push_block_bytes = unsafe { - std::slice::from_raw_parts(&push_block as *const VertexPushBlock - as *const u8, - size) - }; - - unsafe { - device.cmd_push_constants(*command_buffer, render.pipeline_layout, - vk::ShaderStageFlags::VERTEX, - 0, - push_block_bytes) - }; - + #[allow(unsafe_code)] + pub fn render(&self, device: &Device, render: &Render, + command_buffer: &vk::CommandBuffer) + { unsafe { device.cmd_draw_indexed(*command_buffer, self.index_count as u32, 1, 0, 0, 0) -- cgit 1.4.1