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
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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
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 @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion wgpu/examples/mipmap/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl framework::Example for Example {
label: Some("query buffer"),
size: pipeline_statistics_offset()
+ mem::size_of::<PipelineStatisticsQueries>() 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,
});

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