mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
use .validate_dynamic_bindings()
in render bundle's set_bind_group
This commit is contained in:
parent
a2c60cea4f
commit
f54b354021
@ -79,7 +79,7 @@ index format changes.
|
|||||||
#![allow(clippy::reversed_empty_ranges)]
|
#![allow(clippy::reversed_empty_ranges)]
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
binding_model::{buffer_binding_type_alignment, BindGroup, BindGroupLayout, PipelineLayout},
|
binding_model::{BindError, BindGroup, BindGroupLayout, PipelineLayout},
|
||||||
command::{
|
command::{
|
||||||
BasePass, BindGroupStateChange, ColorAttachmentError, DrawError, MapPassErr,
|
BasePass, BindGroupStateChange, ColorAttachmentError, DrawError, MapPassErr,
|
||||||
PassErrorScope, RenderCommandError, StateChange,
|
PassErrorScope, RenderCommandError, StateChange,
|
||||||
@ -631,28 +631,7 @@ fn set_bind_group<A: HalApi>(
|
|||||||
state.next_dynamic_offset = offsets_range.end;
|
state.next_dynamic_offset = offsets_range.end;
|
||||||
let offsets = &dynamic_offsets[offsets_range.clone()];
|
let offsets = &dynamic_offsets[offsets_range.clone()];
|
||||||
|
|
||||||
if bind_group.dynamic_binding_info.len() != offsets.len() {
|
bind_group.validate_dynamic_bindings(index, offsets)?;
|
||||||
return Err(RenderCommandError::InvalidDynamicOffsetCount {
|
|
||||||
actual: offsets.len(),
|
|
||||||
expected: bind_group.dynamic_binding_info.len(),
|
|
||||||
}
|
|
||||||
.into());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for misaligned offsets.
|
|
||||||
for (offset, info) in offsets
|
|
||||||
.iter()
|
|
||||||
.map(|offset| *offset as wgt::BufferAddress)
|
|
||||||
.zip(bind_group.dynamic_binding_info.iter())
|
|
||||||
{
|
|
||||||
let (alignment, limit_name) =
|
|
||||||
buffer_binding_type_alignment(&state.device.limits, info.binding_type);
|
|
||||||
if offset % alignment as u64 != 0 {
|
|
||||||
return Err(
|
|
||||||
RenderCommandError::UnalignedBufferOffset(offset, limit_name, alignment).into(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
state
|
state
|
||||||
.buffer_memory_init_actions
|
.buffer_memory_init_actions
|
||||||
@ -1601,6 +1580,8 @@ pub(super) enum RenderBundleErrorInner {
|
|||||||
Draw(#[from] DrawError),
|
Draw(#[from] DrawError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
MissingDownlevelFlags(#[from] MissingDownlevelFlags),
|
MissingDownlevelFlags(#[from] MissingDownlevelFlags),
|
||||||
|
#[error(transparent)]
|
||||||
|
Bind(#[from] BindError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> From<T> for RenderBundleErrorInner
|
impl<T> From<T> for RenderBundleErrorInner
|
||||||
|
@ -83,8 +83,6 @@ pub enum RenderCommandError {
|
|||||||
VertexBufferIndexOutOfRange { index: u32, max: u32 },
|
VertexBufferIndexOutOfRange { index: u32, max: u32 },
|
||||||
#[error("Dynamic buffer offset {0} does not respect device's requested `{1}` limit {2}")]
|
#[error("Dynamic buffer offset {0} does not respect device's requested `{1}` limit {2}")]
|
||||||
UnalignedBufferOffset(u64, &'static str, u32),
|
UnalignedBufferOffset(u64, &'static str, u32),
|
||||||
#[error("Number of buffer offsets ({actual}) does not match the number of dynamic bindings ({expected})")]
|
|
||||||
InvalidDynamicOffsetCount { actual: usize, expected: usize },
|
|
||||||
#[error("Render pipeline {0:?} is invalid")]
|
#[error("Render pipeline {0:?} is invalid")]
|
||||||
InvalidPipeline(id::RenderPipelineId),
|
InvalidPipeline(id::RenderPipelineId),
|
||||||
#[error("QuerySet {0:?} is invalid")]
|
#[error("QuerySet {0:?} is invalid")]
|
||||||
|
Loading…
Reference in New Issue
Block a user