Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions crates/bevy_render/src/render_resource/pipeline_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ use crate::{
use bevy_asset::{AssetEvent, Assets, Handle};
use bevy_ecs::system::{Res, ResMut};
use bevy_ecs::{event::EventReader, system::Resource};
use bevy_utils::{default, tracing::error, Entry, HashMap, HashSet};
use bevy_utils::{
default,
tracing::{debug, error},
Entry, HashMap, HashSet,
};
use std::{hash::Hash, iter::FusedIterator, mem, ops::Deref, sync::Arc};
use thiserror::Error;
use wgpu::{
BufferBindingType, PipelineLayoutDescriptor, ShaderModule,
VertexBufferLayout as RawVertexBufferLayout,
};

enum PipelineDescriptor {
pub enum PipelineDescriptor {
RenderPipelineDescriptor(Box<RenderPipelineDescriptor>),
ComputePipelineDescriptor(Box<ComputePipelineDescriptor>),
}
Expand All @@ -47,9 +51,9 @@ impl CachedComputePipelineId {
pub const INVALID: Self = CachedComputePipelineId(usize::MAX);
}

struct CachedPipeline {
descriptor: PipelineDescriptor,
state: CachedPipelineState,
pub struct CachedPipeline {
pub descriptor: PipelineDescriptor,
pub state: CachedPipelineState,
}

#[derive(Debug)]
Expand Down Expand Up @@ -137,6 +141,10 @@ impl ShaderCache {
shader_defs.push(String::from("NO_STORAGE_BUFFERS_SUPPORT"));
}

debug!(
"processing shader {:?}, with shader defs {:?}",
handle, shader_defs
);
let processed = self.processor.process(
shader,
&shader_defs,
Expand Down Expand Up @@ -273,6 +281,10 @@ pub struct PipelineCache {
}

impl PipelineCache {
pub fn pipelines(&self) -> impl Iterator<Item = &CachedPipeline> {
self.pipelines.iter()
}

pub fn new(device: RenderDevice) -> Self {
Self {
device,
Expand Down