diff --git a/src/app.rs b/src/app.rs index c8e9e7c..08a2339 100644 --- a/src/app.rs +++ b/src/app.rs @@ -104,8 +104,6 @@ impl App { &stage_output.draw_commands, textures_delta, stage_output.scale_factor, - // TODO: find better way to determine this value and how to pass it in - 32, )) }; diff --git a/src/batcher.rs b/src/batcher.rs index a1c2687..365ea31 100644 --- a/src/batcher.rs +++ b/src/batcher.rs @@ -4,7 +4,7 @@ use crate::{ dpi::{LogicalRect, ScaleFactor}, draw_commands::DrawCommand, renderer::{ - Batch, RenderJob, Vertex, + BATCH_TEX_SLOTS, Batch, RenderJob, Vertex, textures::{TextureId, TexturesDelta}, }, }; @@ -69,10 +69,11 @@ pub fn build_render_job( commands: &[DrawCommand], textures_delta: TexturesDelta, scale_factor: ScaleFactor, - max_slots: u32, ) -> RenderJob { profiling::scope!("build_render_job"); + let max_slots = BATCH_TEX_SLOTS; + let mut vertices = Vec::with_capacity(commands.len() * 4); let mut indices = Vec::with_capacity(commands.len() * 6); let mut batches = Vec::new(); diff --git a/src/renderer.rs b/src/renderer.rs index aa4b665..94d71bc 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -21,9 +21,7 @@ pub mod image; mod mipmap; pub mod textures; -// TODO: -const MAX_SLOTS: u32 = 32; -// TODO: use font atlas as dummy texture for now +pub const BATCH_TEX_SLOTS: u32 = 32; const DUMMY_TEXTURE_ID: TextureId = 0; #[repr(C)] @@ -141,13 +139,13 @@ impl Renderer { sample_type: wgpu::TextureSampleType::Float { filterable: true }, view_dimension: wgpu::TextureViewDimension::D2Array, }, - count: Some(NonZeroU32::new(MAX_SLOTS).unwrap()), + count: Some(NonZeroU32::new(BATCH_TEX_SLOTS).unwrap()), }, wgpu::BindGroupLayoutEntry { binding: 1, visibility: wgpu::ShaderStages::FRAGMENT, ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering), - count: Some(NonZeroU32::new(MAX_SLOTS).unwrap()), + count: Some(NonZeroU32::new(BATCH_TEX_SLOTS).unwrap()), }, ], }); @@ -486,8 +484,8 @@ impl Renderer { // so we pad to up MAX_SLOTS with a dummy view/sampler let dummy = &self.textures[&DUMMY_TEXTURE_ID]; let dummy_sampler = self.samplers.get(&dummy.options).unwrap(); - views.resize(MAX_SLOTS as usize, &dummy.view); - samplers.resize(MAX_SLOTS as usize, dummy_sampler); + views.resize(BATCH_TEX_SLOTS as usize, &dummy.view); + samplers.resize(BATCH_TEX_SLOTS as usize, dummy_sampler); device.create_bind_group(&wgpu::BindGroupDescriptor { label: Some("batch_textures_bind_group"),