Skip to content

Commit 447e3ee

Browse files
fix: ensure render pipelines have at least 1 target
1 parent 4902e47 commit 447e3ee

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ By @stefnotch in [#5410](https://github.com/gfx-rs/wgpu/pull/5410)
9090

9191
### Bug Fixes
9292

93+
### General
94+
95+
- Ensure render pipelines have at least 1 target. By @ErichDonGubler in [#5715](https://github.com/gfx-rs/wgpu/pull/5715)
96+
9397
#### Vulkan
9498

9599
- 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).

wgpu-core/src/device/resource.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3044,8 +3044,11 @@ impl<A: HalApi> Device<A> {
30443044
);
30453045
}
30463046

3047+
let mut target_specified = false;
3048+
30473049
for (i, cs) in color_targets.iter().enumerate() {
30483050
if let Some(cs) = cs.as_ref() {
3051+
target_specified = true;
30493052
let error = loop {
30503053
if cs.write_mask.contains_invalid_bits() {
30513054
break Some(pipeline::ColorStateError::InvalidWriteMask(cs.write_mask));
@@ -3073,6 +3076,7 @@ impl<A: HalApi> Device<A> {
30733076
if !hal::FormatAspects::from(cs.format).contains(hal::FormatAspects::COLOR) {
30743077
break Some(pipeline::ColorStateError::FormatNotColor(cs.format));
30753078
}
3079+
30763080
if desc.multisample.count > 1
30773081
&& !format_features
30783082
.flags
@@ -3091,6 +3095,7 @@ impl<A: HalApi> Device<A> {
30913095
.supported_sample_counts(),
30923096
));
30933097
}
3098+
30943099
if let Some(blend_mode) = cs.blend {
30953100
for factor in [
30963101
blend_mode.color.src_factor,
@@ -3130,6 +3135,7 @@ impl<A: HalApi> Device<A> {
31303135
}
31313136

31323137
if let Some(ds) = depth_stencil_state {
3138+
target_specified = true;
31333139
let error = loop {
31343140
let format_features = self.describe_format_features(adapter, ds.format)?;
31353141
if !format_features
@@ -3180,6 +3186,10 @@ impl<A: HalApi> Device<A> {
31803186
}
31813187
}
31823188

3189+
if !target_specified {
3190+
return Err(pipeline::CreateRenderPipelineError::NoTargetSpecified);
3191+
}
3192+
31833193
// Get the pipeline layout from the desc if it is provided.
31843194
let pipeline_layout = match desc.layout {
31853195
Some(pipeline_layout_id) => {

wgpu-core/src/pipeline.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,11 @@ pub enum CreateRenderPipelineError {
495495
PipelineExpectsShaderToUseDualSourceBlending,
496496
#[error("Shader entry point expects the pipeline to make use of dual-source blending.")]
497497
ShaderExpectsPipelineToUseDualSourceBlending,
498+
#[error("{}", concat!(
499+
"At least one color attachment or depth-stencil attachment was expected, ",
500+
"but no render target for the pipeline was specified."
501+
))]
502+
NoTargetSpecified,
498503
}
499504

500505
bitflags::bitflags! {

0 commit comments

Comments
 (0)