Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow dispatch calls with dimensions of zero-length #1886

Merged
merged 2 commits into from
Apr 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions vulkano/src/command_buffer/commands/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,10 @@ fn check_dispatch(device: &Device, dimensions: [u32; 3]) -> Result<(), CheckDisp
});
}

if dimensions.contains(&0) {
return Err(CheckDispatchError::ZeroLengthDimensions);
}

Ok(())
}

Expand All @@ -1624,6 +1628,9 @@ pub enum CheckDispatchError {
/// The actual supported dimensions.
max_supported: [u32; 3],
},

/// At least one of the requested dimensions were zero.
ZeroLengthDimensions,
}

impl error::Error for CheckDispatchError {}
Expand All @@ -1638,6 +1645,9 @@ impl fmt::Display for CheckDispatchError {
CheckDispatchError::UnsupportedDimensions { .. } => {
"the dimensions are too large for the device's limits"
}
CheckDispatchError::ZeroLengthDimensions => {
"at least one of the requested dimensions were zero"
}
}
)
}
Expand Down Expand Up @@ -2365,4 +2375,16 @@ mod tests {
_ => panic!(),
}
}

#[test]
fn zero_dimension_checked() {
let (device, _) = gfx_dev_and_queue!();

let attempted = [128, 1, 0];

match check_dispatch(&device, attempted) {
Err(CheckDispatchError::ZeroLengthDimensions) => {}
_ => panic!(),
}
}
}