MCPcopy Create free account
hub / github.com/PerroEngine/Perro / prepare

Method prepare

perro_source/render_stack/perro_graphics/src/two_d/gpu.rs:376–565  ·  view source on GitHub ↗
(&mut self, device: &wgpu::Device, queue: &wgpu::Queue, frame: Prepare2D<'_>)

Source from the content-addressed store, hash-verified

374 size: (sprite_instance_capacity * std::mem::size_of::<SpriteInstanceGpu>()) as u64,
375 usage: wgpu::BufferUsages::VERTEX
376 | wgpu::BufferUsages::COPY_DST
377 | wgpu::BufferUsages::COPY_SRC,
378 mapped_at_creation: false,
379 });
380
381 let point_light_instance_capacity = 64usize;
382 let point_light_instance_buffer = device.create_buffer(&wgpu::BufferDescriptor {
383 label: Some("perro_point_light_2d_instances"),
384 size: (point_light_instance_capacity * std::mem::size_of::<Light2DGpu>()) as u64,
385 usage: wgpu::BufferUsages::VERTEX
386 | wgpu::BufferUsages::COPY_DST
387 | wgpu::BufferUsages::COPY_SRC,
388 mapped_at_creation: false,
389 });
390 let shadow_caster_capacity = 1usize;
391 let shadow_caster_buffer = device.create_buffer(&wgpu::BufferDescriptor {
392 label: Some("perro_shadow_caster_2d_instances"),
393 size: (shadow_caster_capacity * std::mem::size_of::<ShadowCaster2DGpu>()) as u64,
394 usage: wgpu::BufferUsages::STORAGE
395 | wgpu::BufferUsages::COPY_DST
396 | wgpu::BufferUsages::COPY_SRC,
397 mapped_at_creation: false,
398 });
399 let shadow_caster_bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
400 label: Some("perro_shadow_caster_2d_bg"),
401 layout: &shadow_caster_bgl,
402 entries: &[wgpu::BindGroupEntry {
403 binding: 0,
404 resource: shadow_caster_buffer.as_entire_binding(),
405 }],
406 });
407
408 Self {
409 camera_bgl,
410 texture_bgl,
411 rect_pipeline,
412 sprite_pipeline,
413 point_light_pipeline,
414 shadow_caster_bgl,
415 shadow_caster_buffer,
416 shadow_caster_capacity,
417 shadow_caster_bind_group,
418 rect_vertex_buffer,
419 rect_instance_buffer,
420 rect_instance_capacity,
421 sprite_vertex_buffer,
422 sprite_instance_buffer,
423 sprite_instance_capacity,
424 point_light_instance_buffer,
425 point_light_instance_capacity,
426 camera_buffer,
427 camera_bind_group,
428 sprite_instances: Vec::new(),
429 sprite_staged: Vec::new(),
430 sprite_staged_sort_scratch: Vec::new(),
431 sprite_batch_candidates: Vec::new(),
432 point_light_instances: Vec::new(),
433 shadow_caster_instances: Vec::new(),

Callers

nothing calls this directly

Calls 15

resolve_sprite_geometryFunction · 0.85
sprite_batch_sort_keyFunction · 0.85
sprite_world_boundsFunction · 0.85
light_2d_gpuFunction · 0.85
has_textureMethod · 0.80
ensure_sprite_textureMethod · 0.80
as_u64Method · 0.80

Tested by

no test coverage detected