mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Implement resolve query set (#3489
* implement command_encoder_resolve_query_set * fix args * add BufferUsages::QUERY_RESOLVE * update changelog * fix link text * validate query resolve: check for QUERY_RESOLVE instead of CPY_DST * update changelog, replace COPY_DST with QUERY_RESOLVE in mipmap example
This commit is contained in:
22
CHANGELOG.md
22
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
|
||||
|
||||
@@ -164,6 +182,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
|
||||
|
||||
@@ -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<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());
|
||||
}
|
||||
|
||||
|
||||
@@ -4220,6 +4220,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user