Validate the number of color attachments in create_render_pipeline (#2913)

This commit is contained in:
Nicolas Silva authored and GitHub committed 2022-07-25 23:28:52 -04:00
1 parent 537c6bed4e
commit d0aa3f471a
3 files changed
+13

No files matched your search

+1
View File
@@ -85,6 +85,7 @@ the same every time it is rendered, we now warn if it is missing.
- Fix panics that occur when using `as_hal` functions when the hal generic type does not match the hub being looked up in by @i509VCB [#2871](https://github.com/gfx-rs/wgpu/pull/2871)
- Add some validation in map_async by @nical in [#2876](https://github.com/gfx-rs/wgpu/pull/2876)
- Fix bugs when mapping/unmapping zero-sized buffers and ranges by @nical in [#2877](https://github.com/gfx-rs/wgpu/pull/2877)
- Validate the number of color attachments in `create_render_pipeline` by @nical in [#2913](https://github.com/gfx-rs/wgpu/pull/2913)
#### DX12
- `DownlevelCapabilities::default()` now returns the `ANISOTROPIC_FILTERING` flag set to true so DX12 lists `ANISOTROPIC_FILTERING` as true again by @cwfitzgerald in [#2851](https://github.com/gfx-rs/wgpu/pull/2851)
+10
View File
@@ -2469,6 +2469,16 @@ impl<A: HalApi> Device<A> {
ArrayVec::<binding_model::BindEntryMap, { hal::MAX_BIND_GROUPS }>::new();
let mut shader_binding_sizes = FastHashMap::default();
let num_attachments = desc.fragment.as_ref().map(|f| f.targets.len()).unwrap_or(0);
if num_attachments > hal::MAX_COLOR_ATTACHMENTS {
return Err(
pipeline::CreateRenderPipelineError::TooManyColorAttachments {
given: num_attachments as u32,
limit: hal::MAX_COLOR_ATTACHMENTS as u32,
},
);
}
let color_targets = desc
.fragment
.as_ref()
+2
View File
@@ -323,6 +323,8 @@ pub enum CreateRenderPipelineError {
DepthStencilState(#[from] DepthStencilStateError),
#[error("invalid sample count {0}")]
InvalidSampleCount(u32),
#[error("the number of color attachments {given} exceeds the limit {limit}")]
TooManyColorAttachments { given: u32, limit: u32 },
#[error("the number of vertex buffers {given} exceeds the limit {limit}")]
TooManyVertexBuffers { given: u32, limit: u32 },
#[error("the total number of vertex attributes {given} exceeds the limit {limit}")]