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
@ -135,12 +135,16 @@ impl Node for PassNode {
|
|||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
if render_context
|
||||||
let camera_bind_group = BindGroup::build().add_binding(0, camera_binding).finish();
|
|
||||||
render_context
|
|
||||||
.resources()
|
.resources()
|
||||||
.create_bind_group(self.camera_bind_group_descriptor.id, &camera_bind_group);
|
.bind_group_descriptor_exists(self.camera_bind_group_descriptor.id)
|
||||||
camera_info.bind_group_id = Some(camera_bind_group.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(
|
render_context.begin_pass(
|
||||||
|
|||||||
@ -120,4 +120,8 @@ impl RenderResourceContext for HeadlessRenderResourceContext {
|
|||||||
fn get_buffer_info(&self, buffer: BufferId) -> Option<BufferInfo> {
|
fn get_buffer_info(&self, buffer: BufferId) -> Option<BufferInfo> {
|
||||||
self.buffer_info.read().unwrap().get(&buffer).cloned()
|
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,
|
pipeline_descriptor: &PipelineDescriptor,
|
||||||
shaders: &Assets<Shader>,
|
shaders: &Assets<Shader>,
|
||||||
);
|
);
|
||||||
|
fn bind_group_descriptor_exists(&self, bind_group_descriptor_id: BindGroupDescriptorId)
|
||||||
|
-> bool;
|
||||||
fn create_bind_group(
|
fn create_bind_group(
|
||||||
&self,
|
&self,
|
||||||
bind_group_descriptor_id: BindGroupDescriptorId,
|
bind_group_descriptor_id: BindGroupDescriptorId,
|
||||||
|
|||||||
@ -433,6 +433,14 @@ impl RenderResourceContext for WgpuRenderResourceContext {
|
|||||||
render_pipelines.insert(pipeline_handle, render_pipeline);
|
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(
|
fn create_bind_group(
|
||||||
&self,
|
&self,
|
||||||
bind_group_descriptor_id: BindGroupDescriptorId,
|
bind_group_descriptor_id: BindGroupDescriptorId,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user