diff --git a/CHANGELOG.md b/CHANGELOG.md index 16d7bb93cd..564b9ab963 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,22 @@ Additionally `sample_type` and `block_size` now take an optional `TextureAspect` By @teoxoy in [#3436](https://github.com/gfx-rs/wgpu/pull/3436) +#### BufferUsages::QUERY_RESOLVE + +Buffers used as the `destination` argument of `CommandEncoder::resolve_query_set` now have to contain the `QUERY_RESOLVE` usage instead of the `COPY_DST` usage. + +```diff + let destination = device.create_buffer(&wgpu::BufferDescriptor { + // ... +- usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ, ++ usage: wgpu::BufferUsages::QUERY_RESOLVE | wgpu::BufferUsages::MAP_READ, + mapped_at_creation: false, + }); + command_encoder.resolve_query_set(&query_set, query_range, &destination, destination_offset); +``` + +By @JolifantoBambla in [#3489](https://github.com/gfx-rs/wgpu/pull/3489) + #### Renamed features The following `Features` have been renamed. @@ -108,6 +124,7 @@ By @cwfitzgerald in [#3610](https://github.com/gfx-rs/wgpu/pull/3610). #### 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) - Allow copying of textures with copy-compatible formats. By @teoxoy in [#3528](https://github.com/gfx-rs/wgpu/pull/3528) @@ -120,6 +137,7 @@ By @cwfitzgerald in [#3610](https://github.com/gfx-rs/wgpu/pull/3610). - 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 @@ -163,6 +181,10 @@ By @cwfitzgerald in [#3610](https://github.com/gfx-rs/wgpu/pull/3610). - Fix definition of `NSOperatingSystemVersion` to avoid potential crashes. By @grovesNL in [#3557](https://github.com/gfx-rs/wgpu/pull/3557) - Fix shader bounds checking being ignored. By @FL33TW00D in [#3603](https://github.com/gfx-rs/wgpu/pull/3603) +### Examples + + - Use `BufferUsages::QUERY_RESOLVE` instead of `BufferUsages::COPY_DST` for buffers used in `CommandEncoder::resolve_query_set` calls in `mipmap` example. By @JolifantoBambla in [#3489](https://github.com/gfx-rs/wgpu/pull/3489) + ## wgpu-0.15.0 (2023-01-25) ### Major Changes diff --git a/wgpu-core/src/command/query.rs b/wgpu-core/src/command/query.rs index d4176195a8..ad46083605 100644 --- a/wgpu-core/src/command/query.rs +++ b/wgpu-core/src/command/query.rs @@ -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, @@ -367,7 +367,7 @@ impl Global { .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()); } diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 1202882d0d..97df9647ac 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -4219,6 +4219,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; } } diff --git a/wgpu/examples/mipmap/main.rs b/wgpu/examples/mipmap/main.rs index e5da83ec60..7cfd3d3afb 100644 --- a/wgpu/examples/mipmap/main.rs +++ b/wgpu/examples/mipmap/main.rs @@ -360,7 +360,7 @@ impl framework::Example for Example { label: Some("query buffer"), size: pipeline_statistics_offset() + mem::size_of::() as wgpu::BufferAddress, - usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ, + usage: wgpu::BufferUsages::QUERY_RESOLVE | wgpu::BufferUsages::MAP_READ, mapped_at_creation: false, }); diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index bb39335d1c..f6f465c46d 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -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(