Use constant for number of texture slots in batch

This commit is contained in:
meehl committed 2026-08-27 12:59:23 +02:00
1 parent 93ce072d40
commit 49fab3c787
3 files changed
+8 -11

No files matched your search

-2
View File
@@ -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,
))
};
+3 -2
View File
@@ -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<f32>,
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();
+5 -7
View File
@@ -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"),