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

Improved display of some error and remove unimplemented! for UnexpectedImageLayout display #2305

Merged
merged 1 commit into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
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
38 changes: 22 additions & 16 deletions vulkano/src/command_buffer/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,22 +482,28 @@ impl Error for CommandBufferExecError {

impl Display for CommandBufferExecError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(
f,
"{}",
match self {
CommandBufferExecError::AccessError { .. } =>
"access to a resource has been denied",
CommandBufferExecError::OneTimeSubmitAlreadySubmitted => {
"the command buffer or one of the secondary command buffers it executes was \
created with the \"one time submit\" flag, but has already been submitted in \
the past"
}
CommandBufferExecError::ExclusiveAlreadyInUse => {
"the command buffer or one of the secondary command buffers it executes is \
already in use was not created with the \"concurrent\" flag"
}
let value = match self {
CommandBufferExecError::AccessError {
error,
command_name,
command_offset,
command_param,
} => return write!(
f,
"access to a resource has been denied on command {} (offset: {}, param: {}): {}",
command_name, command_offset, command_param, error
),
CommandBufferExecError::OneTimeSubmitAlreadySubmitted => {
"the command buffer or one of the secondary command buffers it executes was \
created with the \"one time submit\" flag, but has already been submitted in \
the past"
}
)
CommandBufferExecError::ExclusiveAlreadyInUse => {
"the command buffer or one of the secondary command buffers it executes is \
already in use was not created with the \"concurrent\" flag"
}
};

write!(f, "{}", value)
}
}
52 changes: 26 additions & 26 deletions vulkano/src/sync/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,26 +502,28 @@ impl Error for AccessError {}

impl Display for AccessError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(
f,
"{}",
match self {
AccessError::AlreadyInUse => {
"the resource is already in use, and there is no tracking of concurrent usages"
}
AccessError::UnexpectedImageLayout { .. } => {
unimplemented!() // TODO: find a description
}
AccessError::ImageNotInitialized { .. } => {
"trying to use an image without transitioning it from the undefined or \
preinitialized layouts first"
}
AccessError::SwapchainImageNotAcquired => {
"trying to use a swapchain image without depending on a corresponding acquire \
image future"
}
let value = match self {
AccessError::AlreadyInUse => {
"the resource is already in use, and there is no tracking of concurrent usages"
}
)
AccessError::UnexpectedImageLayout { allowed, requested } => {
return write!(
f,
"unexpected image layout: requested {:?}, allowed {:?}",
allowed, requested
)
}
AccessError::ImageNotInitialized { .. } => {
"trying to use an image without transitioning it from the undefined or \
preinitialized layouts first"
}
AccessError::SwapchainImageNotAcquired => {
"trying to use a swapchain image without depending on a corresponding acquire \
image future"
}
};

write!(f, "{}", value,)
}
}

Expand All @@ -538,14 +540,12 @@ impl Error for AccessCheckError {}

impl Display for AccessCheckError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(
f,
"{}",
match self {
AccessCheckError::Denied(_) => "access to the resource has been denied",
AccessCheckError::Unknown => "the resource is unknown",
match self {
AccessCheckError::Denied(err) => {
write!(f, "access to the resource has been denied: {}", err)
}
)
AccessCheckError::Unknown => write!(f, "the resource is unknown"),
}
}
}

Expand Down