Commit 8514a398 authored by Hao Li's avatar Hao Li Committed by Commit Bot

Query API: Add Timestamp Query in blink

- Add query set with the types of occlusion query, pipeline statistic
  query and timestamp query.
- Add extension of timestamp query.
- Add query APIs:
  createQuerySet on device.
  writeTimestamp on command encoder, render encoder and compute encoder.
  resolveQuerySet on command encoder.
- Now timestamp query is available on D3D12 backend, other backends are
WIP.


Bug: dawn:434
Change-Id: Icfdb17da7f406bfd1d6e903503b103391d9c7d8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2415572
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809704}
parent bc2a1779
...@@ -652,6 +652,10 @@ error::Error WebGPUDecoderImpl::InitDawnDeviceAndSetWireServer( ...@@ -652,6 +652,10 @@ error::Error WebGPUDecoderImpl::InitDawnDeviceAndSetWireServer(
device_descriptor.requiredExtensions.push_back("shader_float16"); device_descriptor.requiredExtensions.push_back("shader_float16");
} }
if (request_device_properties.timestampQuery) {
device_descriptor.requiredExtensions.push_back("timestamp_query");
}
WGPUDevice wgpu_device = WGPUDevice wgpu_device =
dawn_adapters_[requested_adapter_index].CreateDevice(&device_descriptor); dawn_adapters_[requested_adapter_index].CreateDevice(&device_descriptor);
if (wgpu_device == nullptr) { if (wgpu_device == nullptr) {
......
...@@ -1433,6 +1433,8 @@ generated_interface_sources_in_modules = [ ...@@ -1433,6 +1433,8 @@ generated_interface_sources_in_modules = [
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_out_of_memory_error.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_out_of_memory_error.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_pipeline_layout.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_pipeline_layout.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_pipeline_layout.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_pipeline_layout.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_query_set.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_query_set.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_queue.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_queue.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_queue.h", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_queue.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_render_bundle.cc", "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_render_bundle.cc",
......
...@@ -886,6 +886,8 @@ static_idl_files_in_modules = get_path_info( ...@@ -886,6 +886,8 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout_descriptor.idl", "//third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_programmable_pass_encoder.idl", "//third_party/blink/renderer/modules/webgpu/gpu_programmable_pass_encoder.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_programmable_stage_descriptor.idl", "//third_party/blink/renderer/modules/webgpu/gpu_programmable_stage_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_query_set_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_query_set.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_queue.idl", "//third_party/blink/renderer/modules/webgpu/gpu_queue.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_rasterization_state_descriptor.idl", "//third_party/blink/renderer/modules/webgpu/gpu_rasterization_state_descriptor.idl",
"//third_party/blink/renderer/modules/webgpu/gpu_render_bundle.idl", "//third_party/blink/renderer/modules/webgpu/gpu_render_bundle.idl",
......
...@@ -48,6 +48,8 @@ blink_modules_sources("webgpu") { ...@@ -48,6 +48,8 @@ blink_modules_sources("webgpu") {
"gpu_pipeline_layout.h", "gpu_pipeline_layout.h",
"gpu_programmable_pass_encoder.cc", "gpu_programmable_pass_encoder.cc",
"gpu_programmable_pass_encoder.h", "gpu_programmable_pass_encoder.h",
"gpu_query_set.cc",
"gpu_query_set.h",
"gpu_queue.cc", "gpu_queue.cc",
"gpu_queue.h", "gpu_queue.h",
"gpu_render_bundle.cc", "gpu_render_bundle.cc",
......
...@@ -96,6 +96,43 @@ WGPUCompareFunction AsDawnEnum<WGPUCompareFunction>( ...@@ -96,6 +96,43 @@ WGPUCompareFunction AsDawnEnum<WGPUCompareFunction>(
return WGPUCompareFunction_Force32; return WGPUCompareFunction_Force32;
} }
template <>
WGPUQueryType AsDawnEnum<WGPUQueryType>(const WTF::String& webgpu_enum) {
if (webgpu_enum == "occlusion") {
return WGPUQueryType_Occlusion;
}
if (webgpu_enum == "pipeline-statistics") {
return WGPUQueryType_PipelineStatistics;
}
if (webgpu_enum == "timestamp") {
return WGPUQueryType_Timestamp;
}
NOTREACHED();
return WGPUQueryType_Force32;
}
template <>
WGPUPipelineStatisticName AsDawnEnum<WGPUPipelineStatisticName>(
const WTF::String& webgpu_enum) {
if (webgpu_enum == "vertex-shader-invocations") {
return WGPUPipelineStatisticName_VertexShaderInvocations;
}
if (webgpu_enum == "clipper-invocations") {
return WGPUPipelineStatisticName_ClipperInvocations;
}
if (webgpu_enum == "clipper-primitives-out") {
return WGPUPipelineStatisticName_ClipperPrimitivesOut;
}
if (webgpu_enum == "fragment-shader-invocations") {
return WGPUPipelineStatisticName_FragmentShaderInvocations;
}
if (webgpu_enum == "compute-shader-invocations") {
return WGPUPipelineStatisticName_ComputeShaderInvocations;
}
NOTREACHED();
return WGPUPipelineStatisticName_Force32;
}
template <> template <>
WGPUTextureFormat AsDawnEnum<WGPUTextureFormat>( WGPUTextureFormat AsDawnEnum<WGPUTextureFormat>(
const WTF::String& webgpu_enum) { const WTF::String& webgpu_enum) {
......
...@@ -30,6 +30,8 @@ WGPUDeviceProperties AsDawnType(const GPUDeviceDescriptor* descriptor) { ...@@ -30,6 +30,8 @@ WGPUDeviceProperties AsDawnType(const GPUDeviceDescriptor* descriptor) {
extension_set.Contains("textureCompressionBC"); extension_set.Contains("textureCompressionBC");
requested_device_properties.shaderFloat16 = requested_device_properties.shaderFloat16 =
extension_set.Contains("shader-float16"); extension_set.Contains("shader-float16");
requested_device_properties.timestampQuery =
extension_set.Contains("timestamp-query");
return requested_device_properties; return requested_device_properties;
} }
...@@ -81,6 +83,9 @@ void GPUAdapter::InitializeExtensionNameList() { ...@@ -81,6 +83,9 @@ void GPUAdapter::InitializeExtensionNameList() {
if (adapter_properties_.shaderFloat16) { if (adapter_properties_.shaderFloat16) {
extension_name_list_.emplace_back("shader-float16"); extension_name_list_.emplace_back("shader-float16");
} }
if (adapter_properties_.timestampQuery) {
extension_name_list_.emplace_back("timestamp-query");
}
} }
ScriptPromise GPUAdapter::requestDevice(ScriptState* script_state, ScriptPromise GPUAdapter::requestDevice(ScriptState* script_state,
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
enum GPUExtensionName { enum GPUExtensionName {
"texture-compression-bc", "texture-compression-bc",
"timestamp-query",
// Non-standard extension name string. Remove after a transition period. // Non-standard extension name string. Remove after a transition period.
"textureCompressionBC", "textureCompressionBC",
"shader-float16" "shader-float16"
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "third_party/blink/renderer/modules/webgpu/gpu_command_buffer.h" #include "third_party/blink/renderer/modules/webgpu/gpu_command_buffer.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_compute_pass_encoder.h" #include "third_party/blink/renderer/modules/webgpu/gpu_compute_pass_encoder.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device.h" #include "third_party/blink/renderer/modules/webgpu/gpu_device.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_query_set.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_render_pass_encoder.h" #include "third_party/blink/renderer/modules/webgpu/gpu_render_pass_encoder.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_texture.h" #include "third_party/blink/renderer/modules/webgpu/gpu_texture.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_texture_view.h" #include "third_party/blink/renderer/modules/webgpu/gpu_texture_view.h"
...@@ -323,6 +324,22 @@ void GPUCommandEncoder::insertDebugMarker(String markerLabel) { ...@@ -323,6 +324,22 @@ void GPUCommandEncoder::insertDebugMarker(String markerLabel) {
GetProcs().commandEncoderInsertDebugMarker(GetHandle(), label.c_str()); GetProcs().commandEncoderInsertDebugMarker(GetHandle(), label.c_str());
} }
void GPUCommandEncoder::resolveQuerySet(GPUQuerySet* querySet,
uint32_t firstQuery,
uint32_t queryCount,
GPUBuffer* destination,
uint64_t destinationOffset) {
GetProcs().commandEncoderResolveQuerySet(
GetHandle(), querySet->GetHandle(), firstQuery, queryCount,
destination->GetHandle(), destinationOffset);
}
void GPUCommandEncoder::writeTimestamp(GPUQuerySet* querySet,
uint32_t queryIndex) {
GetProcs().commandEncoderWriteTimestamp(GetHandle(), querySet->GetHandle(),
queryIndex);
}
GPUCommandBuffer* GPUCommandEncoder::finish( GPUCommandBuffer* GPUCommandEncoder::finish(
const GPUCommandBufferDescriptor* descriptor) { const GPUCommandBufferDescriptor* descriptor) {
std::string label; std::string label;
......
...@@ -18,6 +18,7 @@ class GPUCommandBufferDescriptor; ...@@ -18,6 +18,7 @@ class GPUCommandBufferDescriptor;
class GPUCommandEncoderDescriptor; class GPUCommandEncoderDescriptor;
class GPUComputePassDescriptor; class GPUComputePassDescriptor;
class GPUComputePassEncoder; class GPUComputePassEncoder;
class GPUQuerySet;
class GPURenderPassDescriptor; class GPURenderPassDescriptor;
class GPURenderPassEncoder; class GPURenderPassEncoder;
class GPUTextureCopyView; class GPUTextureCopyView;
...@@ -63,6 +64,12 @@ class GPUCommandEncoder : public DawnObject<WGPUCommandEncoder> { ...@@ -63,6 +64,12 @@ class GPUCommandEncoder : public DawnObject<WGPUCommandEncoder> {
void pushDebugGroup(String groupLabel); void pushDebugGroup(String groupLabel);
void popDebugGroup(); void popDebugGroup();
void insertDebugMarker(String markerLabel); void insertDebugMarker(String markerLabel);
void resolveQuerySet(GPUQuerySet* querySet,
uint32_t firstQuery,
uint32_t queryCount,
GPUBuffer* destination,
uint64_t destinationOffset);
void writeTimestamp(GPUQuerySet* querySet, uint32_t queryIndex);
GPUCommandBuffer* finish(const GPUCommandBufferDescriptor* descriptor); GPUCommandBuffer* finish(const GPUCommandBufferDescriptor* descriptor);
private: private:
......
...@@ -36,5 +36,14 @@ ...@@ -36,5 +36,14 @@
void popDebugGroup(); void popDebugGroup();
void insertDebugMarker(USVString markerLabel); void insertDebugMarker(USVString markerLabel);
void resolveQuerySet(
GPUQuerySet querySet,
GPUSize32 firstQuery,
GPUSize32 queryCount,
GPUBuffer destination,
GPUSize64 destinationOffset);
void writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {}); GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
}; };
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "third_party/blink/renderer/modules/webgpu/gpu_buffer.h" #include "third_party/blink/renderer/modules/webgpu/gpu_buffer.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_compute_pipeline.h" #include "third_party/blink/renderer/modules/webgpu/gpu_compute_pipeline.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device.h" #include "third_party/blink/renderer/modules/webgpu/gpu_device.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_query_set.h"
namespace blink { namespace blink {
...@@ -81,6 +82,12 @@ void GPUComputePassEncoder::dispatchIndirect(GPUBuffer* indirectBuffer, ...@@ -81,6 +82,12 @@ void GPUComputePassEncoder::dispatchIndirect(GPUBuffer* indirectBuffer,
GetHandle(), indirectBuffer->GetHandle(), indirectOffset); GetHandle(), indirectBuffer->GetHandle(), indirectOffset);
} }
void GPUComputePassEncoder::writeTimestamp(GPUQuerySet* querySet,
uint32_t queryIndex) {
GetProcs().computePassEncoderWriteTimestamp(
GetHandle(), querySet->GetHandle(), queryIndex);
}
void GPUComputePassEncoder::endPass() { void GPUComputePassEncoder::endPass() {
GetProcs().computePassEncoderEndPass(GetHandle()); GetProcs().computePassEncoderEndPass(GetHandle());
} }
......
...@@ -14,6 +14,7 @@ namespace blink { ...@@ -14,6 +14,7 @@ namespace blink {
class GPUBindGroup; class GPUBindGroup;
class GPUBuffer; class GPUBuffer;
class GPUComputePipeline; class GPUComputePipeline;
class GPUQuerySet;
class GPUComputePassEncoder : public DawnObject<WGPUComputePassEncoder>, class GPUComputePassEncoder : public DawnObject<WGPUComputePassEncoder>,
public GPUProgrammablePassEncoder { public GPUProgrammablePassEncoder {
...@@ -40,6 +41,7 @@ class GPUComputePassEncoder : public DawnObject<WGPUComputePassEncoder>, ...@@ -40,6 +41,7 @@ class GPUComputePassEncoder : public DawnObject<WGPUComputePassEncoder>,
void setPipeline(GPUComputePipeline* pipeline); void setPipeline(GPUComputePipeline* pipeline);
void dispatch(uint32_t x, uint32_t y, uint32_t z); void dispatch(uint32_t x, uint32_t y, uint32_t z);
void dispatchIndirect(GPUBuffer* indirectBuffer, uint64_t indirectOffset); void dispatchIndirect(GPUBuffer* indirectBuffer, uint64_t indirectOffset);
void writeTimestamp(GPUQuerySet* querySet, uint32_t queryIndex);
void endPass(); void endPass();
private: private:
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
optional GPUSize32 z = 1); optional GPUSize32 z = 1);
void dispatchIndirect(GPUBuffer indirectBuffer, void dispatchIndirect(GPUBuffer indirectBuffer,
GPUSize64 indirectOffset); GPUSize64 indirectOffset);
void writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
void endPass(); void endPass();
}; };
GPUComputePassEncoder includes GPUProgrammablePassEncoder; GPUComputePassEncoder includes GPUProgrammablePassEncoder;
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "third_party/blink/renderer/modules/webgpu/gpu_compute_pipeline.h" #include "third_party/blink/renderer/modules/webgpu/gpu_compute_pipeline.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device_lost_info.h" #include "third_party/blink/renderer/modules/webgpu/gpu_device_lost_info.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout.h" #include "third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_query_set.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_queue.h" #include "third_party/blink/renderer/modules/webgpu/gpu_queue.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_render_bundle_encoder.h" #include "third_party/blink/renderer/modules/webgpu/gpu_render_bundle_encoder.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_render_pipeline.h" #include "third_party/blink/renderer/modules/webgpu/gpu_render_pipeline.h"
...@@ -220,6 +221,11 @@ GPURenderBundleEncoder* GPUDevice::createRenderBundleEncoder( ...@@ -220,6 +221,11 @@ GPURenderBundleEncoder* GPUDevice::createRenderBundleEncoder(
return GPURenderBundleEncoder::Create(this, descriptor); return GPURenderBundleEncoder::Create(this, descriptor);
} }
GPUQuerySet* GPUDevice::createQuerySet(
const GPUQuerySetDescriptor* descriptor) {
return GPUQuerySet::Create(this, descriptor);
}
void GPUDevice::pushErrorScope(const WTF::String& filter) { void GPUDevice::pushErrorScope(const WTF::String& filter) {
GetProcs().devicePushErrorScope(GetHandle(), GetProcs().devicePushErrorScope(GetHandle(),
AsDawnEnum<WGPUErrorFilter>(filter)); AsDawnEnum<WGPUErrorFilter>(filter));
......
...@@ -33,6 +33,8 @@ class GPUDeviceDescriptor; ...@@ -33,6 +33,8 @@ class GPUDeviceDescriptor;
class GPUDeviceLostInfo; class GPUDeviceLostInfo;
class GPUPipelineLayout; class GPUPipelineLayout;
class GPUPipelineLayoutDescriptor; class GPUPipelineLayoutDescriptor;
class GPUQuerySet;
class GPUQuerySetDescriptor;
class GPUQueue; class GPUQueue;
class GPURenderBundleEncoder; class GPURenderBundleEncoder;
class GPURenderBundleEncoderDescriptor; class GPURenderBundleEncoderDescriptor;
...@@ -96,6 +98,8 @@ class GPUDevice final : public EventTargetWithInlineData, ...@@ -96,6 +98,8 @@ class GPUDevice final : public EventTargetWithInlineData,
GPURenderBundleEncoder* createRenderBundleEncoder( GPURenderBundleEncoder* createRenderBundleEncoder(
const GPURenderBundleEncoderDescriptor* descriptor); const GPURenderBundleEncoderDescriptor* descriptor);
GPUQuerySet* createQuerySet(const GPUQuerySetDescriptor* descriptor);
void pushErrorScope(const WTF::String& filter); void pushErrorScope(const WTF::String& filter);
ScriptPromise popErrorScope(ScriptState* script_state); ScriptPromise popErrorScope(ScriptState* script_state);
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {}); GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor); GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor);
GPUQuerySet createQuerySet(GPUQuerySetDescriptor descriptor);
void pushErrorScope(GPUErrorFilter filter); void pushErrorScope(GPUErrorFilter filter);
[CallWith=ScriptState] Promise<GPUError?> popErrorScope(); [CallWith=ScriptState] Promise<GPUError?> popErrorScope();
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/webgpu/gpu_query_set.h"
#include "gpu/command_buffer/client/webgpu_interface.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_query_set_descriptor.h"
#include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device.h"
namespace blink {
// static
GPUQuerySet* GPUQuerySet::Create(GPUDevice* device,
const GPUQuerySetDescriptor* webgpu_desc) {
DCHECK(device);
DCHECK(webgpu_desc);
WGPUQuerySetDescriptor dawn_desc = {};
dawn_desc.nextInChain = nullptr;
dawn_desc.type = AsDawnEnum<WGPUQueryType>(webgpu_desc->type());
dawn_desc.count = webgpu_desc->count();
std::unique_ptr<WGPUPipelineStatisticName[]> pipeline_statistics;
if (webgpu_desc->hasPipelineStatistics()) {
pipeline_statistics = AsDawnEnum<WGPUPipelineStatisticName>(
webgpu_desc->pipelineStatistics());
dawn_desc.pipelineStatistics = pipeline_statistics.get();
dawn_desc.pipelineStatisticsCount =
webgpu_desc->pipelineStatistics().size();
}
std::string label;
if (webgpu_desc->hasLabel()) {
label = webgpu_desc->label().Utf8();
dawn_desc.label = label.c_str();
}
return MakeGarbageCollected<GPUQuerySet>(
device,
device->GetProcs().deviceCreateQuerySet(device->GetHandle(), &dawn_desc));
}
GPUQuerySet::GPUQuerySet(GPUDevice* device, WGPUQuerySet querySet)
: DawnObject<WGPUQuerySet>(device, querySet) {}
GPUQuerySet::~GPUQuerySet() {
if (IsDawnControlClientDestroyed()) {
return;
}
GetProcs().querySetRelease(GetHandle());
}
void GPUQuerySet::destroy() {
GetProcs().querySetDestroy(GetHandle());
}
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_QUERY_SET_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_QUERY_SET_H_
#include "third_party/blink/renderer/modules/webgpu/dawn_object.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
namespace blink {
class GPUQuerySetDescriptor;
class GPUQuerySet : public DawnObject<WGPUQuerySet> {
DEFINE_WRAPPERTYPEINFO();
public:
static GPUQuerySet* Create(GPUDevice* device,
const GPUQuerySetDescriptor* webgpu_desc);
explicit GPUQuerySet(GPUDevice* device, WGPUQuerySet querySet);
~GPUQuerySet() override;
// gpu_queryset.idl
void destroy();
private:
DISALLOW_COPY_AND_ASSIGN(GPUQuerySet);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_QUERY_SET_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://gpuweb.github.io/gpuweb/
[
Exposed(Window WebGPU, Worker WebGPU)
] interface GPUQuerySet {
void destroy();
};
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://gpuweb.github.io/gpuweb/
dictionary GPUQuerySetDescriptor : GPUObjectDescriptorBase {
required GPUQueryType type;
required GPUSize32 count;
sequence<GPUPipelineStatisticName> pipelineStatistics = [];
};
enum GPUQueryType {
"occlusion",
"pipeline-statistics",
"timestamp"
};
enum GPUPipelineStatisticName {
"vertex-shader-invocations",
"clipper-invocations",
"clipper-primitives-out",
"fragment-shader-invocations",
"compute-shader-invocations"
};
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "third_party/blink/renderer/modules/webgpu/gpu_bind_group.h" #include "third_party/blink/renderer/modules/webgpu/gpu_bind_group.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_buffer.h" #include "third_party/blink/renderer/modules/webgpu/gpu_buffer.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device.h" #include "third_party/blink/renderer/modules/webgpu/gpu_device.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_query_set.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_render_bundle.h" #include "third_party/blink/renderer/modules/webgpu/gpu_render_bundle.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_render_pipeline.h" #include "third_party/blink/renderer/modules/webgpu/gpu_render_pipeline.h"
...@@ -178,6 +179,12 @@ void GPURenderPassEncoder::executeBundles( ...@@ -178,6 +179,12 @@ void GPURenderPassEncoder::executeBundles(
dawn_bundles.get()); dawn_bundles.get());
} }
void GPURenderPassEncoder::writeTimestamp(GPUQuerySet* querySet,
uint32_t queryIndex) {
GetProcs().renderPassEncoderWriteTimestamp(GetHandle(), querySet->GetHandle(),
queryIndex);
}
void GPURenderPassEncoder::endPass() { void GPURenderPassEncoder::endPass() {
GetProcs().renderPassEncoderEndPass(GetHandle()); GetProcs().renderPassEncoderEndPass(GetHandle());
} }
......
...@@ -16,6 +16,7 @@ class GPUBuffer; ...@@ -16,6 +16,7 @@ class GPUBuffer;
class DoubleSequenceOrGPUColorDict; class DoubleSequenceOrGPUColorDict;
class GPURenderBundle; class GPURenderBundle;
class GPURenderPipeline; class GPURenderPipeline;
class GPUQuerySet;
class GPURenderPassEncoder : public DawnObject<WGPURenderPassEncoder>, class GPURenderPassEncoder : public DawnObject<WGPURenderPassEncoder>,
public GPUProgrammablePassEncoder { public GPUProgrammablePassEncoder {
...@@ -73,6 +74,7 @@ class GPURenderPassEncoder : public DawnObject<WGPURenderPassEncoder>, ...@@ -73,6 +74,7 @@ class GPURenderPassEncoder : public DawnObject<WGPURenderPassEncoder>,
void drawIndirect(GPUBuffer* indirectBuffer, uint64_t indirectOffset); void drawIndirect(GPUBuffer* indirectBuffer, uint64_t indirectOffset);
void drawIndexedIndirect(GPUBuffer* indirectBuffer, uint64_t indirectOffset); void drawIndexedIndirect(GPUBuffer* indirectBuffer, uint64_t indirectOffset);
void executeBundles(const HeapVector<Member<GPURenderBundle>>& bundles); void executeBundles(const HeapVector<Member<GPURenderBundle>>& bundles);
void writeTimestamp(GPUQuerySet* querySet, uint32_t queryIndex);
void endPass(); void endPass();
private: private:
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
void setStencilReference(GPUStencilValue reference); void setStencilReference(GPUStencilValue reference);
void executeBundles(sequence<GPURenderBundle> bundles); void executeBundles(sequence<GPURenderBundle> bundles);
void writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
void endPass(); void endPass();
}; };
GPURenderPassEncoder includes GPUProgrammablePassEncoder; GPURenderPassEncoder includes GPUProgrammablePassEncoder;
......
...@@ -21,6 +21,7 @@ modules_idl_files = [ ...@@ -21,6 +21,7 @@ modules_idl_files = [
"gpu_map_mode.idl", "gpu_map_mode.idl",
"gpu_out_of_memory_error.idl", "gpu_out_of_memory_error.idl",
"gpu_pipeline_layout.idl", "gpu_pipeline_layout.idl",
"gpu_query_set.idl",
"gpu_queue.idl", "gpu_queue.idl",
"gpu_render_bundle.idl", "gpu_render_bundle.idl",
"gpu_render_bundle_encoder.idl", "gpu_render_bundle_encoder.idl",
...@@ -64,6 +65,7 @@ modules_dictionary_idl_files = [ ...@@ -64,6 +65,7 @@ modules_dictionary_idl_files = [
"gpu_pipeline_descriptor_base.idl", "gpu_pipeline_descriptor_base.idl",
"gpu_pipeline_layout_descriptor.idl", "gpu_pipeline_layout_descriptor.idl",
"gpu_programmable_stage_descriptor.idl", "gpu_programmable_stage_descriptor.idl",
"gpu_query_set_descriptor.idl",
"gpu_rasterization_state_descriptor.idl", "gpu_rasterization_state_descriptor.idl",
"gpu_render_bundle_descriptor.idl", "gpu_render_bundle_descriptor.idl",
"gpu_render_bundle_encoder_descriptor.idl", "gpu_render_bundle_encoder_descriptor.idl",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment