fix: ensure render pipelines have at least 1 target

This commit is contained in:
Erich Gubler 2024-05-16 18:44:58 -04:00
parent 4902e470ce
commit 447e3eee8d
3 changed files with 19 additions and 0 deletions

View File

@ -90,6 +90,10 @@ By @stefnotch in [#5410](https://github.com/gfx-rs/wgpu/pull/5410)
### Bug Fixes ### Bug Fixes
### General
- Ensure render pipelines have at least 1 target. By @ErichDonGubler in [#5715](https://github.com/gfx-rs/wgpu/pull/5715)
#### Vulkan #### Vulkan
- Fix enablement of subgroup ops extension on Vulkan devices that don't support Vulkan 1.3. By @cwfitzgerald in [#5624](https://github.com/gfx-rs/wgpu/pull/5624). - Fix enablement of subgroup ops extension on Vulkan devices that don't support Vulkan 1.3. By @cwfitzgerald in [#5624](https://github.com/gfx-rs/wgpu/pull/5624).

View File

@ -3044,8 +3044,11 @@ impl<A: HalApi> Device<A> {
); );
} }
let mut target_specified = false;
for (i, cs) in color_targets.iter().enumerate() { for (i, cs) in color_targets.iter().enumerate() {
if let Some(cs) = cs.as_ref() { if let Some(cs) = cs.as_ref() {
target_specified = true;
let error = loop { let error = loop {
if cs.write_mask.contains_invalid_bits() { if cs.write_mask.contains_invalid_bits() {
break Some(pipeline::ColorStateError::InvalidWriteMask(cs.write_mask)); break Some(pipeline::ColorStateError::InvalidWriteMask(cs.write_mask));
@ -3073,6 +3076,7 @@ impl<A: HalApi> Device<A> {
if !hal::FormatAspects::from(cs.format).contains(hal::FormatAspects::COLOR) { if !hal::FormatAspects::from(cs.format).contains(hal::FormatAspects::COLOR) {
break Some(pipeline::ColorStateError::FormatNotColor(cs.format)); break Some(pipeline::ColorStateError::FormatNotColor(cs.format));
} }
if desc.multisample.count > 1 if desc.multisample.count > 1
&& !format_features && !format_features
.flags .flags
@ -3091,6 +3095,7 @@ impl<A: HalApi> Device<A> {
.supported_sample_counts(), .supported_sample_counts(),
)); ));
} }
if let Some(blend_mode) = cs.blend { if let Some(blend_mode) = cs.blend {
for factor in [ for factor in [
blend_mode.color.src_factor, blend_mode.color.src_factor,
@ -3130,6 +3135,7 @@ impl<A: HalApi> Device<A> {
} }
if let Some(ds) = depth_stencil_state { if let Some(ds) = depth_stencil_state {
target_specified = true;
let error = loop { let error = loop {
let format_features = self.describe_format_features(adapter, ds.format)?; let format_features = self.describe_format_features(adapter, ds.format)?;
if !format_features if !format_features
@ -3180,6 +3186,10 @@ impl<A: HalApi> Device<A> {
} }
} }
if !target_specified {
return Err(pipeline::CreateRenderPipelineError::NoTargetSpecified);
}
// Get the pipeline layout from the desc if it is provided. // Get the pipeline layout from the desc if it is provided.
let pipeline_layout = match desc.layout { let pipeline_layout = match desc.layout {
Some(pipeline_layout_id) => { Some(pipeline_layout_id) => {

View File

@ -495,6 +495,11 @@ pub enum CreateRenderPipelineError {
PipelineExpectsShaderToUseDualSourceBlending, PipelineExpectsShaderToUseDualSourceBlending,
#[error("Shader entry point expects the pipeline to make use of dual-source blending.")] #[error("Shader entry point expects the pipeline to make use of dual-source blending.")]
ShaderExpectsPipelineToUseDualSourceBlending, ShaderExpectsPipelineToUseDualSourceBlending,
#[error("{}", concat!(
"At least one color attachment or depth-stencil attachment was expected, ",
"but no render target for the pipeline was specified."
))]
NoTargetSpecified,
} }
bitflags::bitflags! { bitflags::bitflags! {