pub struct RenderResources {
pub sampler: Option<Sampler>,
pub sampler_nearest: Option<Sampler>,
pub uniform_buffer: Option<UniformBuffer>,
pub nearest_common_bind_group: Option<BindGroup>,
pub image_bind_groups: HashMap<TextureId, BindGroup>,
pub image_bind_group_layout: Option<BindGroupLayout>,
}Expand description
Shared render resources
This corresponds to the RenderResources struct in the C++ implementation. Contains samplers, uniform buffers, and bind group layouts that are shared across all frames.
Fields§
§sampler: Option<Sampler>Linear texture sampler
sampler_nearest: Option<Sampler>Nearest/point texture sampler
uniform_buffer: Option<UniformBuffer>Uniform buffer manager (also owns the common bind group layout)
nearest_common_bind_group: Option<BindGroup>Common bind group using the nearest/point sampler
image_bind_groups: HashMap<TextureId, BindGroup>Image bind groups cache (texture_id -> bind_group)
image_bind_group_layout: Option<BindGroupLayout>Image bind group layout (cached for efficiency)
Implementations§
Source§impl RenderResources
impl RenderResources
Sourcepub fn initialize(&mut self, device: &Device) -> RendererResult<()>
pub fn initialize(&mut self, device: &Device) -> RendererResult<()>
Initialize render resources
Sourcepub fn create_image_bind_group(
&self,
device: &Device,
texture_view: &TextureView,
) -> RendererResult<BindGroup>
pub fn create_image_bind_group( &self, device: &Device, texture_view: &TextureView, ) -> RendererResult<BindGroup>
Create an image bind group for a texture
Sourcepub fn get_or_create_image_bind_group(
&mut self,
device: &Device,
texture_id: TextureId,
texture_view: &TextureView,
) -> RendererResult<&BindGroup>
pub fn get_or_create_image_bind_group( &mut self, device: &Device, texture_id: TextureId, texture_view: &TextureView, ) -> RendererResult<&BindGroup>
Get or create an image bind group for a texture
Sourcepub fn remove_image_bind_group(&mut self, texture_id: TextureId)
pub fn remove_image_bind_group(&mut self, texture_id: TextureId)
Remove an image bind group
Sourcepub fn clear_image_bind_groups(&mut self)
pub fn clear_image_bind_groups(&mut self)
Clear all image bind groups
Sourcepub fn sampler_nearest(&self) -> Option<&Sampler>
pub fn sampler_nearest(&self) -> Option<&Sampler>
Get the nearest/point texture sampler
Sourcepub fn uniform_buffer(&self) -> Option<&UniformBuffer>
pub fn uniform_buffer(&self) -> Option<&UniformBuffer>
Get the uniform buffer
Sourcepub fn common_bind_group(&self) -> Option<&BindGroup>
pub fn common_bind_group(&self) -> Option<&BindGroup>
Get the common bind group
Sourcepub fn nearest_common_bind_group(&self) -> Option<&BindGroup>
pub fn nearest_common_bind_group(&self) -> Option<&BindGroup>
Get the common bind group using nearest/point sampling
Sourcepub fn image_bind_group_layout(&self) -> Option<&BindGroupLayout>
pub fn image_bind_group_layout(&self) -> Option<&BindGroupLayout>
Get the image bind group layout
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if resources are initialized
Sourcepub fn stats(&self) -> RenderResourcesStats
pub fn stats(&self) -> RenderResourcesStats
Get statistics for debugging