MCPcopy Create free account
hub / github.com/DioxusLabs/anyrender / new

Method new

crates/wgpu_context/src/buffer_renderer.rs:36–61  ·  view source on GitHub ↗

Creates a new render surface for the specified window and dimensions.

(config: BufferRendererConfig, device_handle: DeviceHandle, dev_id: usize)

Source from the content-addressed store, hash-verified

34impl BufferRenderer {
35 /// Creates a new render surface for the specified window and dimensions.
36 pub fn new(config: BufferRendererConfig, device_handle: DeviceHandle, dev_id: usize) -> Self {
37 let texture_view = create_texture(
38 config.width,
39 config.height,
40 TextureFormat::Rgba8Unorm,
41 config.usage | TextureUsages::COPY_SRC,
42 &device_handle.device,
43 );
44
45 let padded_byte_width = (config.width * 4).next_multiple_of(256);
46 let buffer_size = padded_byte_width as u64 * config.height as u64;
47 let gpu_buffer = device_handle.device.create_buffer(&BufferDescriptor {
48 label: None,
49 size: buffer_size,
50 usage: BufferUsages::MAP_READ | BufferUsages::COPY_DST,
51 mapped_at_creation: false,
52 });
53
54 Self {
55 dev_id,
56 device_handle,
57 config,
58 texture_view,
59 gpu_buffer,
60 }
61 }
62
63 pub fn device(&self) -> &Device {
64 &self.device_handle.device

Callers

nothing calls this directly

Calls 1

create_textureFunction · 0.85

Tested by

no test coverage detected