Refactor query commands (#1909)

This commit is contained in:
Rua 2022-06-06 00:43:07 +02:00 committed by GitHub
parent f5f1b39008
commit 1f685b1420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 518 additions and 489 deletions

View File

@ -8,17 +8,11 @@
// according to those terms. // according to those terms.
use super::{ use super::{
commands::{ commands::pipeline::{
pipeline::{
CheckDescriptorSetsValidityError, CheckDispatchError, CheckDynamicStateValidityError, CheckDescriptorSetsValidityError, CheckDispatchError, CheckDynamicStateValidityError,
CheckIndexBufferError, CheckIndirectBufferError, CheckPipelineError, CheckIndexBufferError, CheckIndirectBufferError, CheckPipelineError,
CheckPushConstantsValidityError, CheckVertexBufferError, CheckPushConstantsValidityError, CheckVertexBufferError,
}, },
query::{
CheckBeginQueryError, CheckCopyQueryPoolResultsError, CheckEndQueryError,
CheckResetQueryPoolError, CheckWriteTimestampError,
},
},
pool::{ pool::{
standard::{StandardCommandPoolAlloc, StandardCommandPoolBuilder}, standard::{StandardCommandPoolAlloc, StandardCommandPoolBuilder},
CommandPool, CommandPoolAlloc, CommandPoolBuilderAlloc, CommandPool, CommandPoolAlloc, CommandPoolBuilderAlloc,
@ -1015,12 +1009,6 @@ err_gen!(BuildError {
OomError, OomError,
}); });
err_gen!(CopyQueryPoolResultsError {
AutoCommandBufferBuilderContextError,
CheckCopyQueryPoolResultsError,
SyncCommandBufferBuilderError,
});
err_gen!(DispatchError { err_gen!(DispatchError {
AutoCommandBufferBuilderContextError, AutoCommandBufferBuilderContextError,
CheckPipelineError, CheckPipelineError,
@ -1084,26 +1072,6 @@ err_gen!(DrawIndexedIndirectError {
SyncCommandBufferBuilderError, SyncCommandBufferBuilderError,
}); });
err_gen!(BeginQueryError {
AutoCommandBufferBuilderContextError,
CheckBeginQueryError,
});
err_gen!(EndQueryError {
AutoCommandBufferBuilderContextError,
CheckEndQueryError,
});
err_gen!(WriteTimestampError {
AutoCommandBufferBuilderContextError,
CheckWriteTimestampError,
});
err_gen!(ResetQueryPoolError {
AutoCommandBufferBuilderContextError,
CheckResetQueryPoolError,
});
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub enum AutoCommandBufferBuilderContextError { pub enum AutoCommandBufferBuilderContextError {
/// Operation forbidden inside of a render pass. /// Operation forbidden inside of a render pass.

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ impl<P> AutoCommandBufferBuilder<PrimaryAutoCommandBuffer<P::Alloc>, P>
where where
P: CommandPoolBuilderAlloc, P: CommandPoolBuilderAlloc,
{ {
/// Adds a command that executes a secondary command buffer. /// Executes a secondary command buffer.
/// ///
/// If the `flags` that `command_buffer` was created with are more restrictive than those of /// If the `flags` that `command_buffer` was created with are more restrictive than those of
/// `self`, then `self` will be restricted to match. E.g. executing a secondary command buffer /// `self`, then `self` will be restricted to match. E.g. executing a secondary command buffer
@ -63,7 +63,7 @@ where
Ok(self) Ok(self)
} }
/// Adds a command that multiple secondary command buffers in a vector. /// Executes multiple secondary command buffers in a vector.
/// ///
/// This requires that the secondary command buffers do not have resource conflicts; an error /// This requires that the secondary command buffers do not have resource conflicts; an error
/// will be returned if there are any. Use `execute_commands` if you want to ensure that /// will be returned if there are any. Use `execute_commands` if you want to ensure that

View File

@ -87,10 +87,7 @@ pub use self::commands::{
CheckIndexBufferError, CheckIndirectBufferError, CheckPipelineError, CheckIndexBufferError, CheckIndirectBufferError, CheckPipelineError,
CheckPushConstantsValidityError, CheckVertexBufferError, CheckPushConstantsValidityError, CheckVertexBufferError,
}, },
query::{ query::QueryError,
CheckBeginQueryError, CheckCopyQueryPoolResultsError, CheckEndQueryError,
CheckResetQueryPoolError, CheckWriteTimestampError,
},
render_pass::{ render_pass::{
ClearAttachment, ClearRect, RenderPassBeginInfo, RenderPassError, RenderingAttachmentInfo, ClearAttachment, ClearRect, RenderPassBeginInfo, RenderPassError, RenderingAttachmentInfo,
RenderingAttachmentResolveInfo, RenderingInfo, RenderingAttachmentResolveInfo, RenderingInfo,
@ -104,11 +101,10 @@ pub use self::commands::{
}; };
pub use self::{ pub use self::{
auto::{ auto::{
AutoCommandBufferBuilder, AutoCommandBufferBuilderContextError, BeginQueryError, AutoCommandBufferBuilder, AutoCommandBufferBuilderContextError, BuildError,
BuildError, CommandBufferBeginError, CopyQueryPoolResultsError, DispatchError, CommandBufferBeginError, DispatchError, DispatchIndirectError, DrawError, DrawIndexedError,
DispatchIndirectError, DrawError, DrawIndexedError, DrawIndexedIndirectError, DrawIndexedIndirectError, DrawIndirectError, PrimaryAutoCommandBuffer,
DrawIndirectError, EndQueryError, PrimaryAutoCommandBuffer, ResetQueryPoolError, SecondaryAutoCommandBuffer,
SecondaryAutoCommandBuffer, WriteTimestampError,
}, },
traits::{ traits::{
CommandBufferExecError, CommandBufferExecFuture, PrimaryCommandBuffer, CommandBufferExecError, CommandBufferExecFuture, PrimaryCommandBuffer,

View File

@ -367,6 +367,9 @@ impl<'a> QueriesRange<'a> {
T: QueryResultElement, T: QueryResultElement,
{ {
assert!(buffer_len > 0); assert!(buffer_len > 0);
// VUID-vkGetQueryPoolResults-flags-02828
// VUID-vkGetQueryPoolResults-flags-00815
debug_assert!(buffer_start % std::mem::size_of::<T>() as DeviceSize == 0); debug_assert!(buffer_start % std::mem::size_of::<T>() as DeviceSize == 0);
let count = self.range.end - self.range.start; let count = self.range.end - self.range.start;
@ -374,6 +377,7 @@ impl<'a> QueriesRange<'a> {
self.pool.query_type.result_len() + flags.with_availability as DeviceSize; self.pool.query_type.result_len() + flags.with_availability as DeviceSize;
let required_len = per_query_len * count as DeviceSize; let required_len = per_query_len * count as DeviceSize;
// VUID-vkGetQueryPoolResults-dataSize-00817
if buffer_len < required_len { if buffer_len < required_len {
return Err(GetResultsError::BufferTooSmall { return Err(GetResultsError::BufferTooSmall {
required_len: required_len as DeviceSize, required_len: required_len as DeviceSize,
@ -385,6 +389,7 @@ impl<'a> QueriesRange<'a> {
QueryType::Occlusion => (), QueryType::Occlusion => (),
QueryType::PipelineStatistics(_) => (), QueryType::PipelineStatistics(_) => (),
QueryType::Timestamp => { QueryType::Timestamp => {
// VUID-vkGetQueryPoolResults-queryType-00818
if flags.partial { if flags.partial {
return Err(GetResultsError::InvalidFlags); return Err(GetResultsError::InvalidFlags);
} }