Skip to content

Commit

Permalink
Remove additional uses of deprecated WebGPU APIs
Browse files Browse the repository at this point in the history
Discovered several more places where deprecated APIs were being used,
which prevents them from being removed in Dawn. Scrubbed as many as I
could find.

Bug: 1206740
Change-Id: I90a1b6ae9bd05a8b2ff024577b253db951dcb1fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2907653
Auto-Submit: Brandon Jones <bajones@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#885246}
  • Loading branch information
toji authored and Chromium LUCI CQ committed May 20, 2021
1 parent 5e7c437 commit 6665574
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 182 deletions.
1 change: 0 additions & 1 deletion gpu/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ test("gl_tests") {
sources += [
"command_buffer/service/webgpu_decoder_unittest.cc",
"command_buffer/tests/shared_image_gl_backing_produce_dawn_unittest.cc",
"command_buffer/tests/webgpu_fence_unittest.cc",
"command_buffer/tests/webgpu_mailbox_unittest.cc",
"command_buffer/tests/webgpu_test.cc",
"command_buffer/tests/webgpu_test.h",
Expand Down
132 changes: 0 additions & 132 deletions gpu/command_buffer/tests/webgpu_fence_unittest.cc

This file was deleted.

16 changes: 9 additions & 7 deletions gpu/command_buffer/tests/webgpu_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,19 @@ void WebGPUTest::RunPendingTasks() {
}

void WebGPUTest::WaitForCompletion(wgpu::Device device) {
// Insert a fence signal and wait for it to be signaled. The guarantees of
// Wait for any work submitted to the queue to be finished. The guarantees of
// Dawn are that all previous operations will have been completed and more
// importantly the callbacks will have been called.
wgpu::Queue queue = device.GetQueue();
wgpu::FenceDescriptor fence_desc{nullptr, 0};
wgpu::Fence fence = queue.CreateFence(&fence_desc);

queue.Submit(0, nullptr);
queue.Signal(fence, 1u);
bool done = false;
queue.OnSubmittedWorkDone(
0u,
[](WGPUQueueWorkDoneStatus, void* userdata) {
*static_cast<bool*>(userdata) = true;
},
&done);

while (fence.GetCompletedValue() < 1) {
while (!done) {
device.Tick();
webgpu()->FlushCommands();
RunPendingTasks();
Expand Down
33 changes: 0 additions & 33 deletions third_party/blink/renderer/modules/webgpu/dawn_enum_conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,6 @@

namespace blink {

template <>
WGPUBindingType AsDawnEnum<WGPUBindingType>(const WTF::String& webgpu_enum) {
if (webgpu_enum == "uniform-buffer") {
return WGPUBindingType_UniformBuffer;
}
if (webgpu_enum == "storage-buffer") {
return WGPUBindingType_StorageBuffer;
}
if (webgpu_enum == "readonly-storage-buffer") {
return WGPUBindingType_ReadonlyStorageBuffer;
}
if (webgpu_enum == "sampler") {
return WGPUBindingType_Sampler;
}
if (webgpu_enum == "comparison-sampler") {
return WGPUBindingType_ComparisonSampler;
}
if (webgpu_enum == "sampled-texture") {
return WGPUBindingType_SampledTexture;
}
if (webgpu_enum == "multisampled-texture") {
return WGPUBindingType_MultisampledTexture;
}
if (webgpu_enum == "readonly-storage-texture") {
return WGPUBindingType_ReadonlyStorageTexture;
}
if (webgpu_enum == "writeonly-storage-texture") {
return WGPUBindingType_WriteonlyStorageTexture;
}
NOTREACHED();
return WGPUBindingType_Force32;
}

template <>
WGPUBufferBindingType AsDawnEnum<WGPUBufferBindingType>(
const WTF::String& webgpu_enum) {
Expand Down
18 changes: 9 additions & 9 deletions third_party/blink/renderer/modules/webgpu/gpu_render_pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ void AsDawnVertexBufferLayouts(
v8::Isolate* isolate,
GPUDevice* device,
v8::Local<v8::Value> vertex_buffers_value,
Vector<WGPUVertexBufferLayoutDescriptor>* dawn_vertex_buffers,
Vector<WGPUVertexAttributeDescriptor>* dawn_vertex_attributes,
Vector<WGPUVertexBufferLayout>* dawn_vertex_buffers,
Vector<WGPUVertexAttribute>* dawn_vertex_attributes,
ExceptionState& exception_state) {
if (!vertex_buffers_value->IsArray()) {
exception_state.ThrowTypeError("vertexBuffers must be an array");
Expand All @@ -190,17 +190,17 @@ void AsDawnVertexBufferLayouts(
v8::Local<v8::Array> vertex_buffers = vertex_buffers_value.As<v8::Array>();

// First we collect all the descriptors but we don't set
// WGPUVertexBufferLayoutDescriptor::attributes
// WGPUVertexBufferLayout::attributes
// TODO(cwallez@chromium.org): Should we validate the Length() first so we
// don't risk creating HUGE vectors of WGPUVertexBufferLayoutDescriptor from
// don't risk creating HUGE vectors of WGPUVertexBufferLayout from
// the sparse array?
for (uint32_t i = 0; i < vertex_buffers->Length(); ++i) {
// This array can be sparse. Skip empty slots.
v8::MaybeLocal<v8::Value> maybe_value = vertex_buffers->Get(context, i);
v8::Local<v8::Value> value;
if (!maybe_value.ToLocal(&value) || value.IsEmpty() ||
value->IsNullOrUndefined()) {
WGPUVertexBufferLayoutDescriptor dawn_vertex_buffer = {};
WGPUVertexBufferLayout dawn_vertex_buffer = {};
dawn_vertex_buffer.arrayStride = 0;
dawn_vertex_buffer.stepMode = WGPUInputStepMode_Vertex;
dawn_vertex_buffer.attributeCount = 0;
Expand All @@ -216,7 +216,7 @@ void AsDawnVertexBufferLayouts(
return;
}

WGPUVertexBufferLayoutDescriptor dawn_vertex_buffer = {};
WGPUVertexBufferLayout dawn_vertex_buffer = {};
dawn_vertex_buffer.arrayStride = vertex_buffer->arrayStride();
dawn_vertex_buffer.stepMode =
AsDawnEnum<WGPUInputStepMode>(vertex_buffer->stepMode());
Expand All @@ -227,7 +227,7 @@ void AsDawnVertexBufferLayouts(

for (wtf_size_t j = 0; j < vertex_buffer->attributes().size(); ++j) {
const GPUVertexAttribute* attribute = vertex_buffer->attributes()[j];
WGPUVertexAttributeDescriptor dawn_vertex_attribute = {};
WGPUVertexAttribute dawn_vertex_attribute = {};
dawn_vertex_attribute.shaderLocation = attribute->shaderLocation();
dawn_vertex_attribute.offset = attribute->offset();
dawn_vertex_attribute.format =
Expand All @@ -236,11 +236,11 @@ void AsDawnVertexBufferLayouts(
}
}

// Set up pointers in DawnVertexBufferLayoutDescriptor::attributes only
// Set up pointers in DawnVertexBufferLayout::attributes only
// after we stopped appending to the vector so the pointers aren't
// invalidated.
uint32_t attributeIndex = 0;
for (WGPUVertexBufferLayoutDescriptor& buffer : *dawn_vertex_buffers) {
for (WGPUVertexBufferLayout& buffer : *dawn_vertex_buffers) {
if (buffer.attributeCount == 0) {
continue;
}
Expand Down

0 comments on commit 6665574

Please sign in to comment.