Skip to content

Commit

Permalink
Add safety comment to create_shader_module_spirv invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Shfty committed Mar 22, 2023
1 parent b70c34a commit 24b138a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions crates/bevy_render/src/renderer/render_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,18 @@ impl RenderDevice {
if self
.features()
.contains(wgpu::Features::SPIRV_SHADER_PASSTHROUGH) =>
unsafe {
self.device
.create_shader_module_spirv(&wgpu::ShaderModuleDescriptorSpirV {
label: desc.label,
source: source.clone(),
})
},
{
// SAFETY:
// This call passes binary data to the backend as-is and can potentially result in a driver crash or bogus behaviour.
// No attempt is made to ensure that data is valid SPIR-V.
unsafe {
self.device
.create_shader_module_spirv(&wgpu::ShaderModuleDescriptorSpirV {
label: desc.label,
source: source.clone(),
})
}
}
_ => self.device.create_shader_module(desc),
}

Expand Down

0 comments on commit 24b138a

Please sign in to comment.