Skip to content

[Merged by Bors] - Helpers to check pipeline cache status #5796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
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