mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
render: only attempt to create camera bind group when the camera bind group descriptor exists
this fixes panics in empty scenes
This commit is contained in:
parent
5e1f81037d
commit
a4afa4e7f3
4 changed files with 23 additions and 5 deletions
|
@ -135,12 +135,16 @@ impl Node for PassNode {
|
|||
} else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let camera_bind_group = BindGroup::build().add_binding(0, camera_binding).finish();
|
||||
render_context
|
||||
if render_context
|
||||
.resources()
|
||||
.create_bind_group(self.camera_bind_group_descriptor.id, &camera_bind_group);
|
||||
camera_info.bind_group_id = Some(camera_bind_group.id);
|
||||
.bind_group_descriptor_exists(self.camera_bind_group_descriptor.id)
|
||||
{
|
||||
let camera_bind_group = BindGroup::build().add_binding(0, camera_binding).finish();
|
||||
render_context
|
||||
.resources()
|
||||
.create_bind_group(self.camera_bind_group_descriptor.id, &camera_bind_group);
|
||||
camera_info.bind_group_id = Some(camera_bind_group.id);
|
||||
}
|
||||
}
|
||||
|
||||
render_context.begin_pass(
|
||||
|
|
|
@ -120,4 +120,8 @@ impl RenderResourceContext for HeadlessRenderResourceContext {
|
|||
fn get_buffer_info(&self, buffer: BufferId) -> Option<BufferInfo> {
|
||||
self.buffer_info.read().unwrap().get(&buffer).cloned()
|
||||
}
|
||||
fn bind_group_descriptor_exists(&self, _bind_group_descriptor_id: BindGroupDescriptorId)
|
||||
-> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ pub trait RenderResourceContext: Downcast + Send + Sync + 'static {
|
|||
pipeline_descriptor: &PipelineDescriptor,
|
||||
shaders: &Assets<Shader>,
|
||||
);
|
||||
fn bind_group_descriptor_exists(&self, bind_group_descriptor_id: BindGroupDescriptorId)
|
||||
-> bool;
|
||||
fn create_bind_group(
|
||||
&self,
|
||||
bind_group_descriptor_id: BindGroupDescriptorId,
|
||||
|
|
|
@ -433,6 +433,14 @@ impl RenderResourceContext for WgpuRenderResourceContext {
|
|||
render_pipelines.insert(pipeline_handle, render_pipeline);
|
||||
}
|
||||
|
||||
fn bind_group_descriptor_exists(
|
||||
&self,
|
||||
bind_group_descriptor_id: BindGroupDescriptorId,
|
||||
) -> bool {
|
||||
let bind_group_layouts = self.resources.bind_group_layouts.read().unwrap();
|
||||
bind_group_layouts.get(&bind_group_descriptor_id).is_some()
|
||||
}
|
||||
|
||||
fn create_bind_group(
|
||||
&self,
|
||||
bind_group_descriptor_id: BindGroupDescriptorId,
|
||||
|
|
Loading…
Reference in a new issue