Separate native-only feature for wgpu::CommandEncoder::write_timestamp (#5188)

* split out TIMESTAMP_QUERY_INSIDE_ENCODERS from TIMESTAMP_QUERY

* changelog entry

* update changelog change number

* fix web warnings

* single line changelog

* note on followup issue
This commit is contained in:
Andreas Reich 2024-02-13 17:03:33 +01:00 committed by GitHub
parent 95c026b2df
commit f350f28c35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 122 additions and 62 deletions

View File

@ -101,6 +101,7 @@ Bottom level categories:
+!wgpu::Instance::enabled_backend_features().is_empty()
```
- `wgpu::Id` now implements `PartialOrd`/`Ord` allowing it to be put in `BTreeMap`s. By @cwfitzgerald and @9291Sam in [#5176](https://github.com/gfx-rs/wgpu/pull/5176)
- `wgpu::CommandEncoder::write_timestamp` requires now the new `wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS` feature which is available on all native backends but not on WebGPU (due to a spec change `write_timestamp` is no longer supported on WebGPU). By @wumpf in [#5188](https://github.com/gfx-rs/wgpu/pull/5188)
### Bug Fixes

View File

@ -8,8 +8,8 @@ const MIP_PASS_COUNT: u32 = MIP_LEVEL_COUNT - 1;
const QUERY_FEATURES: wgpu::Features = {
wgpu::Features::TIMESTAMP_QUERY
.union(wgpu::Features::PIPELINE_STATISTICS_QUERY)
.union(wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES)
.union(wgpu::Features::PIPELINE_STATISTICS_QUERY)
};
fn create_texels(size: usize, cx: f32, cy: f32) -> Vec<u8> {

View File

@ -2,11 +2,11 @@
//!
//! Timestamp queries are typically used to profile how long certain operations take on the GPU.
//! wgpu has several ways of performing gpu timestamp queries:
//! * `wgpu::Encoder::write_timestamp` writes a between any commands recorded on an encoder.
//! (enabled with wgpu::Features::TIMESTAMP_QUERY)
//! * passing `wgpu::RenderPassTimestampWrites`/`wgpu::ComputePassTimestampWrites` during render/compute pass creation.
//! This writes timestamps for the beginning and end of a given pass.
//! (enabled with wgpu::Features::TIMESTAMP_QUERY)
//! * `wgpu::CommandEncoder::write_timestamp` writes a between any commands recorded on an encoder.
//! (enabled with wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS)
//! * `wgpu::RenderPass/ComputePass::write_timestamp` writes a timestamp within commands of a render pass.
//! Note that some GPU architectures do not support this.
//! (native only, enabled with wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES)
@ -241,8 +241,13 @@ fn submit_render_and_compute_pass_with_queries(
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("shader.wgsl"))),
});
if device
.features()
.contains(wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS)
{
encoder.write_timestamp(&queries.set, queries.next_unused_query);
queries.next_unused_query += 1;
}
// Render two triangles and profile it.
render_pass(
@ -262,8 +267,13 @@ fn submit_render_and_compute_pass_with_queries(
&mut queries.next_unused_query,
);
if device
.features()
.contains(wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS)
{
encoder.write_timestamp(&queries.set, queries.next_unused_query);
queries.next_unused_query += 1;
}
queries.resolve(&mut encoder);
queue.submit(Some(encoder.finish()));
@ -426,13 +436,25 @@ mod tests {
use super::{submit_render_and_compute_pass_with_queries, QueryResults};
#[gpu_test]
static TIMESTAMPS_ENCODER: GpuTestConfiguration = GpuTestConfiguration::new()
static TIMESTAMPS_PASS_BOUNDARIES: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(
wgpu_test::TestParameters::default()
.limits(wgpu::Limits::downlevel_defaults())
.features(wgpu::Features::TIMESTAMP_QUERY),
)
.run_sync(|ctx| test_timestamps(ctx, false));
.run_sync(|ctx| test_timestamps(ctx, false, false));
#[gpu_test]
static TIMESTAMPS_ENCODER: GpuTestConfiguration = GpuTestConfiguration::new()
.parameters(
wgpu_test::TestParameters::default()
.limits(wgpu::Limits::downlevel_defaults())
.features(
wgpu::Features::TIMESTAMP_QUERY
| wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS,
),
)
.run_sync(|ctx| test_timestamps(ctx, true, false));
#[gpu_test]
static TIMESTAMPS_PASSES: GpuTestConfiguration = GpuTestConfiguration::new()
@ -440,12 +462,18 @@ mod tests {
wgpu_test::TestParameters::default()
.limits(wgpu::Limits::downlevel_defaults())
.features(
wgpu::Features::TIMESTAMP_QUERY | wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES,
wgpu::Features::TIMESTAMP_QUERY
| wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS
| wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES,
),
)
.run_sync(|ctx| test_timestamps(ctx, true));
.run_sync(|ctx| test_timestamps(ctx, true, true));
fn test_timestamps(ctx: wgpu_test::TestingContext, timestamps_inside_passes: bool) {
fn test_timestamps(
ctx: wgpu_test::TestingContext,
timestamps_on_encoder: bool,
timestamps_inside_passes: bool,
) {
let queries = submit_render_and_compute_pass_with_queries(&ctx.device, &ctx.queue);
let raw_results = queries.wait_for_results(&ctx.device);
let QueryResults {
@ -464,9 +492,10 @@ mod tests {
compute_start_end_timestamps[1].wrapping_sub(compute_start_end_timestamps[0]);
let encoder_delta = encoder_timestamps[1].wrapping_sub(encoder_timestamps[0]);
if timestamps_on_encoder {
assert!(encoder_delta > 0);
assert!(encoder_delta >= render_delta + compute_delta);
}
if let Some(render_inside_timestamp) = render_inside_timestamp {
assert!(render_inside_timestamp >= render_start_end_timestamps[0]);
assert!(render_inside_timestamp <= render_start_end_timestamps[1]);

View File

@ -4,7 +4,7 @@ use hal::CommandEncoder as _;
use crate::device::trace::Command as TraceCommand;
use crate::{
command::{CommandBuffer, CommandEncoderError},
device::DeviceError,
device::{DeviceError, MissingFeatures},
global::Global,
hal_api::HalApi,
id::{self, Id},
@ -108,6 +108,8 @@ pub enum QueryError {
Device(#[from] DeviceError),
#[error(transparent)]
Encoder(#[from] CommandEncoderError),
#[error(transparent)]
MissingFeature(#[from] MissingFeatures),
#[error("Error encountered while trying to use queries")]
Use(#[from] QueryUseError),
#[error("Error encountered while trying to resolve a query")]
@ -355,6 +357,11 @@ impl Global {
let hub = A::hub(self);
let cmd_buf = CommandBuffer::get_encoder(hub, command_encoder_id)?;
cmd_buf
.device
.require_features(wgt::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS)?;
let mut cmd_buf_data = cmd_buf.data.lock();
let cmd_buf_data = cmd_buf_data.as_mut().unwrap();

View File

@ -242,6 +242,7 @@ impl super::Adapter {
| wgt::Features::POLYGON_MODE_LINE
| wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
| wgt::Features::TIMESTAMP_QUERY
| wgt::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS
| wgt::Features::TIMESTAMP_QUERY_INSIDE_PASSES
| wgt::Features::TEXTURE_COMPRESSION_BC
| wgt::Features::CLEAR_TEXTURE

View File

@ -472,6 +472,7 @@ impl super::Adapter {
features.set(wgt::Features::SHADER_UNUSED_VERTEX_OUTPUT, true);
if extensions.contains("GL_ARB_timer_query") {
features.set(wgt::Features::TIMESTAMP_QUERY, true);
features.set(wgt::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS, true);
features.set(wgt::Features::TIMESTAMP_QUERY_INSIDE_PASSES, true);
}
let gl_bcn_exts = [

View File

@ -839,7 +839,7 @@ impl super::PrivateCapabilities {
self.indirect_draw_dispatch,
);
features.set(
F::TIMESTAMP_QUERY,
F::TIMESTAMP_QUERY | F::TIMESTAMP_QUERY_INSIDE_ENCODERS,
self.timestamp_query_support
.contains(TimestampQuerySupport::STAGE_BOUNDARIES),
);

View File

@ -369,6 +369,7 @@ impl PhysicalDeviceFeatures {
| F::ADDRESS_MODE_CLAMP_TO_BORDER
| F::ADDRESS_MODE_CLAMP_TO_ZERO
| F::TIMESTAMP_QUERY
| F::TIMESTAMP_QUERY_INSIDE_ENCODERS
| F::TIMESTAMP_QUERY_INSIDE_PASSES
| F::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
| F::CLEAR_TEXTURE;

View File

@ -246,7 +246,7 @@ bitflags::bitflags! {
#[repr(transparent)]
#[derive(Default)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Features: u64 {
pub struct Features: u128 { // TODO(https://github.com/gfx-rs/wgpu/issues/5247): consider making this an `enumset`
//
// ---- Start numbering at 1 << 0 ----
//
@ -271,11 +271,12 @@ bitflags::bitflags! {
/// all work before the query is finished.
///
/// This feature allows the use of
/// - [`CommandEncoder::write_timestamp`]
/// - [`RenderPassDescriptor::timestamp_writes`]
/// - [`ComputePassDescriptor::timestamp_writes`]
/// to write out timestamps.
/// For timestamps within passes refer to [`Features::TIMESTAMP_QUERY_INSIDE_PASSES`]
///
/// For arbitrary timestamp write commands on encoders refer to [`Features::TIMESTAMP_QUERY_INSIDE_ENCODERS`].
/// For arbitrary timestamp write commands on passes refer to [`Features::TIMESTAMP_QUERY_INSIDE_PASSES`].
///
/// They must be resolved using [`CommandEncoder::resolve_query_sets`] into a buffer,
/// then the result must be multiplied by the timestamp period [`Queue::get_timestamp_period`]
@ -492,10 +493,24 @@ bitflags::bitflags! {
///
/// This is a native only feature with a [proposal](https://github.com/gpuweb/gpuweb/blob/0008bd30da2366af88180b511a5d0d0c1dffbc36/proposals/pipeline-statistics-query.md) for the web.
const PIPELINE_STATISTICS_QUERY = 1 << 32;
/// Allows for timestamp queries inside render passes.
/// Allows for timestamp queries directly on command encoders.
///
/// Implies [`Features::TIMESTAMP_QUERY`] is supported.
///
/// Additionally allows for timestamp writes on command encoders
/// using [`CommandEncoder::write_timestamp`].
///
/// Supported platforms:
/// - Vulkan
/// - DX12
/// - Metal
///
/// This is a native only feature.
const TIMESTAMP_QUERY_INSIDE_ENCODERS = 1 << 33;
/// Allows for timestamp queries directly on command encoders.
///
/// Implies [`Features::TIMESTAMP_QUERY`] & [`Features::TIMESTAMP_QUERY_INSIDE_ENCODERS`] is supported.
///
/// Additionally allows for timestamp queries to be used inside render & compute passes using:
/// - [`RenderPassEncoder::write_timestamp`]
/// - [`ComputePassEncoder::write_timestamp`]
@ -508,7 +523,7 @@ bitflags::bitflags! {
/// This is generally not available on tile-based rasterization GPUs.
///
/// This is a native only feature with a [proposal](https://github.com/gpuweb/gpuweb/blob/0008bd30da2366af88180b511a5d0d0c1dffbc36/proposals/timestamp-query-inside-passes.md) for the web.
const TIMESTAMP_QUERY_INSIDE_PASSES = 1 << 33;
const TIMESTAMP_QUERY_INSIDE_PASSES = 1 << 34;
/// Webgpu only allows the MAP_READ and MAP_WRITE buffer usage to be matched with
/// COPY_DST and COPY_SRC respectively. This removes this requirement.
///
@ -522,7 +537,7 @@ bitflags::bitflags! {
/// - Metal
///
/// This is a native only feature.
const MAPPABLE_PRIMARY_BUFFERS = 1 << 34;
const MAPPABLE_PRIMARY_BUFFERS = 1 << 35;
/// Allows the user to create uniform arrays of textures in shaders:
///
/// ex.
@ -545,7 +560,7 @@ bitflags::bitflags! {
/// - Vulkan
///
/// This is a native only feature.
const TEXTURE_BINDING_ARRAY = 1 << 35;
const TEXTURE_BINDING_ARRAY = 1 << 36;
/// Allows the user to create arrays of buffers in shaders:
///
/// ex.
@ -567,7 +582,7 @@ bitflags::bitflags! {
/// - Vulkan
///
/// This is a native only feature.
const BUFFER_BINDING_ARRAY = 1 << 36;
const BUFFER_BINDING_ARRAY = 1 << 37;
/// Allows the user to create uniform arrays of storage buffers or textures in shaders,
/// if resp. [`Features::BUFFER_BINDING_ARRAY`] or [`Features::TEXTURE_BINDING_ARRAY`]
/// is supported.
@ -580,7 +595,7 @@ bitflags::bitflags! {
/// - Vulkan
///
/// This is a native only feature.
const STORAGE_RESOURCE_BINDING_ARRAY = 1 << 37;
const STORAGE_RESOURCE_BINDING_ARRAY = 1 << 38;
/// Allows shaders to index sampled texture and storage buffer resource arrays with dynamically non-uniform values:
///
/// ex. `texture_array[vertex_data]`
@ -605,7 +620,7 @@ bitflags::bitflags! {
/// - Vulkan 1.2+ (or VK_EXT_descriptor_indexing)'s shaderSampledImageArrayNonUniformIndexing & shaderStorageBufferArrayNonUniformIndexing feature)
///
/// This is a native only feature.
const SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING = 1 << 38;
const SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING = 1 << 39;
/// Allows shaders to index uniform buffer and storage texture resource arrays with dynamically non-uniform values:
///
/// ex. `texture_array[vertex_data]`
@ -630,11 +645,11 @@ bitflags::bitflags! {
/// - Vulkan 1.2+ (or VK_EXT_descriptor_indexing)'s shaderUniformBufferArrayNonUniformIndexing & shaderStorageTextureArrayNonUniformIndexing feature)
///
/// This is a native only feature.
const UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING = 1 << 39;
const UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING = 1 << 40;
/// Allows the user to create bind groups containing arrays with less bindings than the BindGroupLayout.
///
/// This is a native only feature.
const PARTIALLY_BOUND_BINDING_ARRAY = 1 << 40;
const PARTIALLY_BOUND_BINDING_ARRAY = 1 << 41;
/// Allows the user to call [`RenderPass::multi_draw_indirect`] and [`RenderPass::multi_draw_indexed_indirect`].
///
/// Allows multiple indirect calls to be dispatched from a single buffer.
@ -648,7 +663,7 @@ bitflags::bitflags! {
///
/// [`RenderPass::multi_draw_indirect`]: ../wgpu/struct.RenderPass.html#method.multi_draw_indirect
/// [`RenderPass::multi_draw_indexed_indirect`]: ../wgpu/struct.RenderPass.html#method.multi_draw_indexed_indirect
const MULTI_DRAW_INDIRECT = 1 << 41;
const MULTI_DRAW_INDIRECT = 1 << 42;
/// Allows the user to call [`RenderPass::multi_draw_indirect_count`] and [`RenderPass::multi_draw_indexed_indirect_count`].
///
/// This allows the use of a buffer containing the actual number of draw calls.
@ -661,7 +676,7 @@ bitflags::bitflags! {
///
/// [`RenderPass::multi_draw_indirect_count`]: ../wgpu/struct.RenderPass.html#method.multi_draw_indirect_count
/// [`RenderPass::multi_draw_indexed_indirect_count`]: ../wgpu/struct.RenderPass.html#method.multi_draw_indexed_indirect_count
const MULTI_DRAW_INDIRECT_COUNT = 1 << 42;
const MULTI_DRAW_INDIRECT_COUNT = 1 << 43;
/// Allows the use of push constants: small, fast bits of memory that can be updated
/// inside a [`RenderPass`].
///
@ -681,7 +696,7 @@ bitflags::bitflags! {
/// [`RenderPass`]: ../wgpu/struct.RenderPass.html
/// [`PipelineLayoutDescriptor`]: ../wgpu/struct.PipelineLayoutDescriptor.html
/// [`RenderPass::set_push_constants`]: ../wgpu/struct.RenderPass.html#method.set_push_constants
const PUSH_CONSTANTS = 1 << 43;
const PUSH_CONSTANTS = 1 << 44;
/// Allows the use of [`AddressMode::ClampToBorder`] with a border color
/// of [`SamplerBorderColor::Zero`].
///
@ -692,7 +707,7 @@ bitflags::bitflags! {
/// - OpenGL
///
/// This is a native only feature.
const ADDRESS_MODE_CLAMP_TO_ZERO = 1 << 44;
const ADDRESS_MODE_CLAMP_TO_ZERO = 1 << 45;
/// Allows the use of [`AddressMode::ClampToBorder`] with a border color
/// other than [`SamplerBorderColor::Zero`].
///
@ -703,7 +718,7 @@ bitflags::bitflags! {
/// - OpenGL
///
/// This is a native only feature.
const ADDRESS_MODE_CLAMP_TO_BORDER = 1 << 45;
const ADDRESS_MODE_CLAMP_TO_BORDER = 1 << 46;
/// Allows the user to set [`PolygonMode::Line`] in [`PrimitiveState::polygon_mode`]
///
/// This allows drawing polygons/triangles as lines (wireframe) instead of filled
@ -714,7 +729,7 @@ bitflags::bitflags! {
/// - Metal
///
/// This is a native only feature.
const POLYGON_MODE_LINE = 1 << 46;
const POLYGON_MODE_LINE = 1 << 47;
/// Allows the user to set [`PolygonMode::Point`] in [`PrimitiveState::polygon_mode`]
///
/// This allows only drawing the vertices of polygons/triangles instead of filled
@ -723,7 +738,7 @@ bitflags::bitflags! {
/// - Vulkan
///
/// This is a native only feature.
const POLYGON_MODE_POINT = 1 << 47;
const POLYGON_MODE_POINT = 1 << 48;
/// Allows the user to set a overestimation-conservative-rasterization in [`PrimitiveState::conservative`]
///
/// Processing of degenerate triangles/lines is hardware specific.
@ -733,7 +748,7 @@ bitflags::bitflags! {
/// - Vulkan
///
/// This is a native only feature.
const CONSERVATIVE_RASTERIZATION = 1 << 48;
const CONSERVATIVE_RASTERIZATION = 1 << 49;
/// Enables bindings of writable storage buffers and textures visible to vertex shaders.
///
/// Note: some (tiled-based) platforms do not support vertex shaders with any side-effects.
@ -742,14 +757,14 @@ bitflags::bitflags! {
/// - All
///
/// This is a native only feature.
const VERTEX_WRITABLE_STORAGE = 1 << 49;
const VERTEX_WRITABLE_STORAGE = 1 << 50;
/// Enables clear to zero for textures.
///
/// Supported platforms:
/// - All
///
/// This is a native only feature.
const CLEAR_TEXTURE = 1 << 50;
const CLEAR_TEXTURE = 1 << 51;
/// Enables creating shader modules from SPIR-V binary data (unsafe).
///
/// SPIR-V data is not parsed or interpreted in any way; you can use
@ -761,7 +776,7 @@ bitflags::bitflags! {
/// Vulkan implementation.
///
/// This is a native only feature.
const SPIRV_SHADER_PASSTHROUGH = 1 << 51;
const SPIRV_SHADER_PASSTHROUGH = 1 << 52;
/// Enables multiview render passes and `builtin(view_index)` in vertex shaders.
///
/// Supported platforms:
@ -769,7 +784,7 @@ bitflags::bitflags! {
/// - OpenGL (web only)
///
/// This is a native only feature.
const MULTIVIEW = 1 << 52;
const MULTIVIEW = 1 << 53;
/// Enables using 64-bit types for vertex attributes.
///
/// Requires SHADER_FLOAT64.
@ -777,7 +792,7 @@ bitflags::bitflags! {
/// Supported Platforms: N/A
///
/// This is a native only feature.
const VERTEX_ATTRIBUTE_64BIT = 1 << 53;
const VERTEX_ATTRIBUTE_64BIT = 1 << 54;
/// Allows vertex shaders to have outputs which are not consumed
/// by the fragment shader.
///
@ -785,7 +800,7 @@ bitflags::bitflags! {
/// - Vulkan
/// - Metal
/// - OpenGL
const SHADER_UNUSED_VERTEX_OUTPUT = 1 << 54;
const SHADER_UNUSED_VERTEX_OUTPUT = 1 << 55;
/// Allows for creation of textures of format [`TextureFormat::NV12`]
///
/// Supported platforms:
@ -793,16 +808,16 @@ bitflags::bitflags! {
/// - Vulkan
///
/// This is a native only feature.
const TEXTURE_FORMAT_NV12 = 1 << 55;
const TEXTURE_FORMAT_NV12 = 1 << 56;
/// Allows for the creation of ray-tracing acceleration structures.
///
/// Supported platforms:
/// - Vulkan
///
/// This is a native-only feature.
const RAY_TRACING_ACCELERATION_STRUCTURE = 1 << 56;
const RAY_TRACING_ACCELERATION_STRUCTURE = 1 << 57;
// 57 available
// 58 available
// Shader:
@ -812,7 +827,7 @@ bitflags::bitflags! {
/// - Vulkan
///
/// This is a native-only feature.
const RAY_QUERY = 1 << 58;
const RAY_QUERY = 1 << 59;
/// Enables 64-bit floating point types in SPIR-V shaders.
///
/// Note: even when supported by GPU hardware, 64-bit floating point operations are
@ -822,14 +837,14 @@ bitflags::bitflags! {
/// - Vulkan
///
/// This is a native only feature.
const SHADER_F64 = 1 << 59;
const SHADER_F64 = 1 << 60;
/// Allows shaders to use i16. Not currently supported in `naga`, only available through `spirv-passthrough`.
///
/// Supported platforms:
/// - Vulkan
///
/// This is a native only feature.
const SHADER_I16 = 1 << 60;
const SHADER_I16 = 1 << 61;
/// Enables `builtin(primitive_index)` in fragment shaders.
///
/// Note: enables geometry processing for pipelines using the builtin.
@ -843,14 +858,14 @@ bitflags::bitflags! {
/// - OpenGL (some)
///
/// This is a native only feature.
const SHADER_PRIMITIVE_INDEX = 1 << 61;
const SHADER_PRIMITIVE_INDEX = 1 << 62;
/// Allows shaders to use the `early_depth_test` attribute.
///
/// Supported platforms:
/// - GLES 3.1+
///
/// This is a native only feature.
const SHADER_EARLY_DEPTH_TEST = 1 << 62;
const SHADER_EARLY_DEPTH_TEST = 1 << 63;
/// Allows two outputs from a shader to be used for blending.
/// Note that dual-source blending doesn't support multiple render targets.
///
@ -861,7 +876,7 @@ bitflags::bitflags! {
/// - Metal (with MSL 1.2+)
/// - Vulkan (with dualSrcBlend)
/// - DX12
const DUAL_SOURCE_BLENDING = 1 << 63;
const DUAL_SOURCE_BLENDING = 1 << 64;
}
}

View File

@ -2498,14 +2498,14 @@ impl crate::context::Context for ContextWebGpu {
fn command_encoder_write_timestamp(
&self,
_encoder: &Self::CommandEncoderId,
encoder_data: &Self::CommandEncoderData,
_encoder_data: &Self::CommandEncoderData,
_query_set: &Self::QuerySetId,
query_set_data: &Self::QuerySetData,
query_index: u32,
_query_set_data: &Self::QuerySetData,
_query_index: u32,
) {
encoder_data
.0
.write_timestamp(&query_set_data.0, query_index);
// Not available on WebGPU.
// This was part of the spec originally but got removed, see https://github.com/gpuweb/gpuweb/pull/4370
panic!("TIMESTAMP_QUERY_INSIDE_ENCODERS feature must be enabled to call write_timestamp on a command encoder.")
}
fn command_encoder_resolve_query_set(
@ -2816,7 +2816,7 @@ impl crate::context::Context for ContextWebGpu {
_query_set_data: &Self::QuerySetData,
_query_index: u32,
) {
panic!("TIMESTAMP_QUERY_INSIDE_PASSES feature must be enabled to call write_timestamp in a compute pass")
panic!("TIMESTAMP_QUERY_INSIDE_PASSES feature must be enabled to call write_timestamp in a compute pass.")
}
fn compute_pass_begin_pipeline_statistics_query(
@ -3394,7 +3394,7 @@ impl crate::context::Context for ContextWebGpu {
_query_set_data: &Self::QuerySetData,
_query_index: u32,
) {
panic!("TIMESTAMP_QUERY_INSIDE_PASSES feature must be enabled to call write_timestamp in a compute pass")
panic!("TIMESTAMP_QUERY_INSIDE_PASSES feature must be enabled to call write_timestamp in a render pass.")
}
fn render_pass_begin_occlusion_query(

View File

@ -3466,7 +3466,7 @@ impl CommandEncoder {
}
}
/// [`Features::TIMESTAMP_QUERY`] must be enabled on the device in order to call these functions.
/// [`Features::TIMESTAMP_QUERY_INSIDE_ENCODERS`] must be enabled on the device in order to call these functions.
impl CommandEncoder {
/// Issue a timestamp command at this point in the queue.
/// The timestamp will be written to the specified query set, at the specified index.
@ -3475,6 +3475,11 @@ impl CommandEncoder {
/// the value in nanoseconds. Absolute values have no meaning,
/// but timestamps can be subtracted to get the time it takes
/// for a string of operations to complete.
///
/// Attention: Since commands within a command recorder may be reordered,
/// there is no strict guarantee that timestamps are taken after all commands
/// recorded so far and all before all commands recorded after.
/// This may depend both on the backend and the driver.
pub fn write_timestamp(&mut self, query_set: &QuerySet, query_index: u32) {
DynContext::command_encoder_write_timestamp(
&*self.context,