Commit 85892919 authored by François Beaufort's avatar François Beaufort Committed by Commit Bot

[WebGPU] Consolidate *loadOp and clear* into a unioned field

Following WebGPU spec change at https://github.com/gpuweb/gpuweb/issues/283,
this CL makes sure *loadOp and clear* are consolidated into an unioned
field in GPURenderPassColorAttachmentDescriptor and
GPURenderPassDepthStencilAttachmentDescriptor.

Bug: 877147
Change-Id: I4a676e8cfa52844f2df54b6201e6db453c1d9e9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715267Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#680373}
parent 8521257c
......@@ -48,6 +48,12 @@ bindings_modules_generated_union_type_files = [
"$bindings_modules_v8_output_dir/float32_array_or_float64_array_or_dom_matrix.h",
"$bindings_modules_v8_output_dir/gpu_out_of_memory_error_or_gpu_validation_error.cc",
"$bindings_modules_v8_output_dir/gpu_out_of_memory_error_or_gpu_validation_error.h",
"$bindings_modules_v8_output_dir/gpu_load_op_or_gpu_color.cc",
"$bindings_modules_v8_output_dir/gpu_load_op_or_gpu_color.h",
"$bindings_modules_v8_output_dir/gpu_load_op_or_float.cc",
"$bindings_modules_v8_output_dir/gpu_load_op_or_float.h",
"$bindings_modules_v8_output_dir/gpu_load_op_or_long.cc",
"$bindings_modules_v8_output_dir/gpu_load_op_or_long.h",
"$bindings_modules_v8_output_dir/gpu_sampler_or_gpu_texture_view_or_gpu_buffer_binding.cc",
"$bindings_modules_v8_output_dir/gpu_sampler_or_gpu_texture_view_or_gpu_buffer_binding.h",
"$bindings_modules_v8_output_dir/html_canvas_element_or_offscreen_canvas.cc",
......
......@@ -289,9 +289,6 @@ DawnStoreOp AsDawnEnum<DawnStoreOp>(const WTF::String& webgpu_enum) {
template <>
DawnLoadOp AsDawnEnum<DawnLoadOp>(const WTF::String& webgpu_enum) {
if (webgpu_enum == "clear") {
return DAWN_LOAD_OP_CLEAR;
}
if (webgpu_enum == "load") {
return DAWN_LOAD_OP_LOAD;
}
......
......@@ -32,9 +32,22 @@ DawnRenderPassColorAttachmentDescriptor AsDawnType(
dawn_desc.resolveTarget = webgpu_desc->resolveTarget()
? webgpu_desc->resolveTarget()->GetHandle()
: nullptr;
dawn_desc.loadOp = AsDawnEnum<DawnLoadOp>(webgpu_desc->loadOp());
if (webgpu_desc->loadValue().IsGPULoadOp()) {
const WTF::String& gpuLoadOp = webgpu_desc->loadValue().GetAsGPULoadOp();
dawn_desc.loadOp = AsDawnEnum<DawnLoadOp>(gpuLoadOp);
dawn_desc.clearColor = AsDawnType(GPUColor::Create());
} else if (webgpu_desc->loadValue().IsGPUColor()) {
GPUColor* gpuColor = webgpu_desc->loadValue().GetAsGPUColor();
dawn_desc.loadOp = DAWN_LOAD_OP_CLEAR;
dawn_desc.clearColor = AsDawnType(gpuColor);
} else {
NOTREACHED();
}
dawn_desc.storeOp = AsDawnEnum<DawnStoreOp>(webgpu_desc->storeOp());
dawn_desc.clearColor = AsDawnType(webgpu_desc->clearColor());
return dawn_desc;
}
......@@ -47,14 +60,39 @@ DawnRenderPassDepthStencilAttachmentDescriptor AsDawnType(
DawnRenderPassDepthStencilAttachmentDescriptor dawn_desc = {};
dawn_desc.attachment = webgpu_desc->attachment()->GetHandle();
dawn_desc.depthLoadOp = AsDawnEnum<DawnLoadOp>(webgpu_desc->depthLoadOp());
if (webgpu_desc->depthLoadValue().IsGPULoadOp()) {
const WTF::String& gpuLoadOp =
webgpu_desc->depthLoadValue().GetAsGPULoadOp();
dawn_desc.depthLoadOp = AsDawnEnum<DawnLoadOp>(gpuLoadOp);
dawn_desc.clearDepth = 1.0f;
} else if (webgpu_desc->depthLoadValue().IsFloat()) {
dawn_desc.depthLoadOp = DAWN_LOAD_OP_CLEAR;
dawn_desc.clearDepth = webgpu_desc->depthLoadValue().GetAsFloat();
} else {
NOTREACHED();
}
dawn_desc.depthStoreOp = AsDawnEnum<DawnStoreOp>(webgpu_desc->depthStoreOp());
dawn_desc.clearDepth = webgpu_desc->clearDepth();
dawn_desc.stencilLoadOp =
AsDawnEnum<DawnLoadOp>(webgpu_desc->stencilLoadOp());
if (webgpu_desc->stencilLoadValue().IsGPULoadOp()) {
const WTF::String& gpuLoadOp =
webgpu_desc->stencilLoadValue().GetAsGPULoadOp();
dawn_desc.stencilLoadOp = AsDawnEnum<DawnLoadOp>(gpuLoadOp);
dawn_desc.clearStencil = 0;
} else if (webgpu_desc->stencilLoadValue().IsLong()) {
dawn_desc.stencilLoadOp = DAWN_LOAD_OP_CLEAR;
dawn_desc.clearStencil = webgpu_desc->stencilLoadValue().GetAsLong();
} else {
NOTREACHED();
}
dawn_desc.stencilStoreOp =
AsDawnEnum<DawnStoreOp>(webgpu_desc->stencilStoreOp());
dawn_desc.clearStencil = webgpu_desc->clearStencil();
return dawn_desc;
}
......
......@@ -8,7 +8,6 @@ dictionary GPURenderPassColorAttachmentDescriptor {
required GPUTextureView attachment;
GPUTextureView? resolveTarget = null;
required GPULoadOp loadOp;
required (GPULoadOp or GPUColor) loadValue;
required GPUStoreOp storeOp;
required GPUColor clearColor;
};
......@@ -7,11 +7,9 @@
dictionary GPURenderPassDepthStencilAttachmentDescriptor {
required GPUTextureView attachment;
required GPULoadOp depthLoadOp;
required (GPULoadOp or float) depthLoadValue;
required GPUStoreOp depthStoreOp;
required float clearDepth;
required GPULoadOp stencilLoadOp;
required (GPULoadOp or long) stencilLoadValue;
required GPUStoreOp stencilStoreOp;
unsigned long clearStencil = 0;
};
......@@ -10,7 +10,6 @@ dictionary GPURenderPassDescriptor {
};
enum GPULoadOp {
"clear",
"load"
};
......
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