Skip to content

Commit

Permalink
Communicate WebGPU label attribute changes to Dawn
Browse files Browse the repository at this point in the history
This change forwards label changes to Dawn for every object that has
*SetLabel() implemented.

Does not include Device or Queue, since those will require
https://dawn-review.googlesource.com/c/dawn/+/85540 to land first
but doing so requires the command_buffer change from this patch.

Bug: dawn:840
Change-Id: I1ab173e4d036fea49f7d7343a29ffefdc4b301bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3565481
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/main@{#988194}
  • Loading branch information
toji authored and Chromium LUCI CQ committed Apr 2, 2022
1 parent 987b4b3 commit 1cdda74
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gpu/command_buffer/service/webgpu_decoder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ void WebGPUDecoderImpl::DoRequestDevice(
DCHECK_LT(static_cast<size_t>(requested_adapter_index),
dawn_adapters_.size());

WGPUDeviceDescriptor device_descriptor;
WGPUDeviceDescriptor device_descriptor = {};

// We need to request internal usage to be able to do operations with internal
// methods that would need specific usages.
Expand Down
1 change: 1 addition & 0 deletions third_party/blink/renderer/modules/webgpu/dawn_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void DawnObjectBase::setLabel(ScriptState* script_state,
void DawnObjectBase::setLabel(const String& value) {
// TODO: Relay label changes to Dawn
label_ = value;
setLabelImpl(value);
}

void DawnObjectBase::EnsureFlush() {
Expand Down
2 changes: 2 additions & 0 deletions third_party/blink/renderer/modules/webgpu/dawn_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class DawnObjectBase {

void setLabel(const String& value);

virtual void setLabelImpl(const String& value){};

private:
scoped_refptr<DawnControlClientHolder> dawn_control_client_;
String label_;
Expand Down
5 changes: 5 additions & 0 deletions third_party/blink/renderer/modules/webgpu/gpu_bind_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class GPUBindGroup : public DawnObject<WGPUBindGroup> {

GPUBindGroup(const GPUBindGroup&) = delete;
GPUBindGroup& operator=(const GPUBindGroup&) = delete;

void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().bindGroupSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class GPUBindGroupLayout : public DawnObject<WGPUBindGroupLayout> {

GPUBindGroupLayout(const GPUBindGroupLayout&) = delete;
GPUBindGroupLayout& operator=(const GPUBindGroupLayout&) = delete;

void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().bindGroupLayoutSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down
5 changes: 5 additions & 0 deletions third_party/blink/renderer/modules/webgpu/gpu_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ class GPUBuffer : public DawnObject<WGPUBuffer> {
ExecutionContext* execution_context);
void ResetMappingState(v8::Isolate* isolate);

void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().bufferSetLabel(GetHandle(), utf8_label.c_str());
}

uint64_t size_;

// Holds onto any ArrayBuffers returned by getMappedRange, mapReadAsync, or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class GPUCommandBuffer : public DawnObject<WGPUCommandBuffer> {

GPUCommandBuffer(const GPUCommandBuffer&) = delete;
GPUCommandBuffer& operator=(const GPUCommandBuffer&) = delete;

private:
void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().commandBufferSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ class GPUCommandEncoder : public DawnObject<WGPUCommandEncoder> {
offset, size);
}
GPUCommandBuffer* finish(const GPUCommandBufferDescriptor* descriptor);

void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().commandEncoderSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ class GPUComputePassEncoder : public DawnObject<WGPUComputePassEncoder>,
}
void end() { GetProcs().computePassEncoderEnd(GetHandle()); }
void endPass();

void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().computePassEncoderSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class GPUComputePipeline : public DawnObject<WGPUComputePipeline> {
GPUComputePipeline& operator=(const GPUComputePipeline&) = delete;

GPUBindGroupLayout* getBindGroupLayout(uint32_t index);

void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().computePipelineSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class GPUExternalTexture : public DawnObject<WGPUExternalTexture> {
void Destroy();

private:
void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().externalTextureSetLabel(GetHandle(), utf8_label.c_str());
}

scoped_refptr<WebGPUMailboxTexture> mailbox_texture_;
};

Expand Down
6 changes: 6 additions & 0 deletions third_party/blink/renderer/modules/webgpu/gpu_query_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class GPUQuerySet : public DawnObject<WGPUQuerySet> {

// gpu_queryset.idl
void destroy();

private:
void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().querySetSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class GPURenderBundleEncoder : public DawnObject<WGPURenderBundleEncoder>,
}

GPURenderBundle* finish(const GPURenderBundleDescriptor* webgpu_desc);

void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().renderBundleEncoderSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ class GPURenderPassEncoder : public DawnObject<WGPURenderPassEncoder>,
}
void end() { GetProcs().renderPassEncoderEnd(GetHandle()); }
void endPass();

void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().renderPassEncoderSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ class GPURenderPipeline : public DawnObject<WGPURenderPipeline> {
GPURenderPipeline& operator=(const GPURenderPipeline&) = delete;

GPUBindGroupLayout* getBindGroupLayout(uint32_t index);

private:
void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().renderPipelineSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down
6 changes: 6 additions & 0 deletions third_party/blink/renderer/modules/webgpu/gpu_sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class GPUSampler : public DawnObject<WGPUSampler> {

GPUSampler(const GPUSampler&) = delete;
GPUSampler& operator=(const GPUSampler&) = delete;

private:
void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().samplerSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down
5 changes: 5 additions & 0 deletions third_party/blink/renderer/modules/webgpu/gpu_shader_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class GPUShaderModule : public DawnObject<WGPUShaderModule> {
void OnCompilationInfoCallback(ScriptPromiseResolver* resolver,
WGPUCompilationInfoRequestStatus status,
const WGPUCompilationInfo* info);

void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().shaderModuleSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down
5 changes: 5 additions & 0 deletions third_party/blink/renderer/modules/webgpu/gpu_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class GPUTexture : public DawnObject<WGPUTexture> {
WGPUTextureUsage Usage() { return usage_; }

private:
void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().textureSetLabel(GetHandle(), utf8_label.c_str());
}

WGPUTextureDimension dimension_;
WGPUTextureFormat format_;
WGPUTextureUsage usage_;
Expand Down
6 changes: 6 additions & 0 deletions third_party/blink/renderer/modules/webgpu/gpu_texture_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ class GPUTextureView : public DawnObject<WGPUTextureView> {

GPUTextureView(const GPUTextureView&) = delete;
GPUTextureView& operator=(const GPUTextureView&) = delete;

private:
void setLabelImpl(const String& value) override {
std::string utf8_label = value.Utf8();
GetProcs().textureViewSetLabel(GetHandle(), utf8_label.c_str());
}
};

} // namespace blink
Expand Down

0 comments on commit 1cdda74

Please sign in to comment.