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,16 +8,10 @@
// according to those terms.
use super::{
commands::{
pipeline::{
CheckDescriptorSetsValidityError, CheckDispatchError, CheckDynamicStateValidityError,
CheckIndexBufferError, CheckIndirectBufferError, CheckPipelineError,
CheckPushConstantsValidityError, CheckVertexBufferError,
},
query::{
CheckBeginQueryError, CheckCopyQueryPoolResultsError, CheckEndQueryError,
CheckResetQueryPoolError, CheckWriteTimestampError,
},
commands::pipeline::{
CheckDescriptorSetsValidityError, CheckDispatchError, CheckDynamicStateValidityError,
CheckIndexBufferError, CheckIndirectBufferError, CheckPipelineError,
CheckPushConstantsValidityError, CheckVertexBufferError,
},
pool::{
standard::{StandardCommandPoolAlloc, StandardCommandPoolBuilder},
@ -1015,12 +1009,6 @@ err_gen!(BuildError {
OomError,
});
err_gen!(CopyQueryPoolResultsError {
AutoCommandBufferBuilderContextError,
CheckCopyQueryPoolResultsError,
SyncCommandBufferBuilderError,
});
err_gen!(DispatchError {
AutoCommandBufferBuilderContextError,
CheckPipelineError,
@ -1084,26 +1072,6 @@ err_gen!(DrawIndexedIndirectError {
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)]
pub enum AutoCommandBufferBuilderContextError {
/// 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
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
/// `self`, then `self` will be restricted to match. E.g. executing a secondary command buffer
@ -63,7 +63,7 @@ where
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
/// 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,
CheckPushConstantsValidityError, CheckVertexBufferError,
},
query::{
CheckBeginQueryError, CheckCopyQueryPoolResultsError, CheckEndQueryError,
CheckResetQueryPoolError, CheckWriteTimestampError,
},
query::QueryError,
render_pass::{
ClearAttachment, ClearRect, RenderPassBeginInfo, RenderPassError, RenderingAttachmentInfo,
RenderingAttachmentResolveInfo, RenderingInfo,
@ -104,11 +101,10 @@ pub use self::commands::{
};
pub use self::{
auto::{
AutoCommandBufferBuilder, AutoCommandBufferBuilderContextError, BeginQueryError,
BuildError, CommandBufferBeginError, CopyQueryPoolResultsError, DispatchError,
DispatchIndirectError, DrawError, DrawIndexedError, DrawIndexedIndirectError,
DrawIndirectError, EndQueryError, PrimaryAutoCommandBuffer, ResetQueryPoolError,
SecondaryAutoCommandBuffer, WriteTimestampError,
AutoCommandBufferBuilder, AutoCommandBufferBuilderContextError, BuildError,
CommandBufferBeginError, DispatchError, DispatchIndirectError, DrawError, DrawIndexedError,
DrawIndexedIndirectError, DrawIndirectError, PrimaryAutoCommandBuffer,
SecondaryAutoCommandBuffer,
},
traits::{
CommandBufferExecError, CommandBufferExecFuture, PrimaryCommandBuffer,

View File

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