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

Implement resolve query set (#3489 #3489

Merged
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ By @teoxoy in [#3436](https://github.com/gfx-rs/wgpu/pull/3436)
#### General

- Added `TextureFormatFeatureFlags::MULTISAMPLE_X16`. By @Dinnerbone in [#3454](https://github.com/gfx-rs/wgpu/pull/3454)
- Added `BufferUsages::QUERY_RESOLVE`. By @JolifantoBambla in [#3489](https://github.com/gfx-rs/wgpu/pull/3489)
- Support stencil-only views and copying to/from combined depth-stencil textures. By @teoxoy in [#3436](https://github.com/gfx-rs/wgpu/pull/3436)
- Added `Features::SHADER_EARLY_DEPTH_TEST`. By @teoxoy in [#3494](https://github.com/gfx-rs/wgpu/pull/3494)

Expand All @@ -87,6 +88,7 @@ By @teoxoy in [#3436](https://github.com/gfx-rs/wgpu/pull/3436)
- Implement `CommandEncoder::clear_buffer`. By @raphlinus in [#3426](https://github.com/gfx-rs/wgpu/pull/3426)
- Implement the new checks for readonly stencils. By @JCapucho in [#3443](https://github.com/gfx-rs/wgpu/pull/3443)
- Reimplement `adapter|device_features`. By @jinleili in [#3428](https://github.com/gfx-rs/wgpu/pull/3428)
- Implement `command_encoder_resolve_query_set`. By @JolifantoBambla in [#3489](https://github.com/gfx-rs/wgpu/pull/3489)

#### Vulkan

Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/command/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub enum QueryUseError {
/// Error encountered while trying to resolve a query.
#[derive(Clone, Debug, Error)]
pub enum ResolveError {
#[error("Queries can only be resolved to buffers that contain the COPY_DST usage")]
#[error("Queries can only be resolved to buffers that contain the QUERY_RESOLVE usage")]
MissingBufferUsage,
#[error("Resolve buffer offset has to be aligned to `QUERY_RESOLVE_BUFFER_ALIGNMENT")]
BufferOffsetAlignment,
Expand Down Expand Up @@ -367,7 +367,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.ok_or(QueryError::InvalidBuffer(destination))?;
let dst_barrier = dst_pending.map(|pending| pending.into_hal(dst_buffer));

if !dst_buffer.usage.contains(wgt::BufferUsages::COPY_DST) {
if !dst_buffer.usage.contains(wgt::BufferUsages::QUERY_RESOLVE) {
return Err(ResolveError::MissingBufferUsage.into());
}

Expand Down
2 changes: 2 additions & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4177,6 +4177,8 @@ bitflags::bitflags! {
const STORAGE = 1 << 7;
/// Allow a buffer to be the indirect buffer in an indirect draw call.
const INDIRECT = 1 << 8;
/// Allow a buffer to be the destination buffer for a [`CommandEncoder::resolve_query_set`] operation.
const QUERY_RESOLVE = 1 << 9;
}
}

Expand Down
20 changes: 13 additions & 7 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2225,17 +2225,23 @@ impl crate::context::Context for Context {

fn command_encoder_resolve_query_set(
&self,
_encoder: &Self::CommandEncoderId,
encoder: &Self::CommandEncoderId,
_encoder_data: &Self::CommandEncoderData,
_query_set: &Self::QuerySetId,
query_set: &Self::QuerySetId,
_query_set_data: &Self::QuerySetData,
_first_query: u32,
_query_count: u32,
_destination: &Self::BufferId,
first_query: u32,
query_count: u32,
destination: &Self::BufferId,
_destination_data: &Self::BufferData,
_destination_offset: wgt::BufferAddress,
destination_offset: wgt::BufferAddress,
) {
unimplemented!();
encoder.0.resolve_query_set_with_u32(
&query_set.0,
first_query,
query_count,
&destination.0,
destination_offset as u32,
);
}

fn render_bundle_encoder_finish(
Expand Down