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

[WebGPU] Define GPUOrigin3D as (sequence<unsigned long> or GPUOrigin3DDict)

This CL redefines GPUOrigin3D as not only a GPUOrigin3DDict, but also a
sequence of unsigned long as specified in
https://gpuweb.github.io/gpuweb/#typedefdef-gpuorigin3d

Bug: 877147
Change-Id: Ifa8dfef0891b1018fd497a30b8a9b5d4a05c91a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1828905
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: default avatarAustin Eng <enga@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701955}
parent 6f13c35b
...@@ -96,6 +96,8 @@ bindings_modules_generated_union_type_files = [ ...@@ -96,6 +96,8 @@ bindings_modules_generated_union_type_files = [
"$bindings_modules_v8_output_dir/unsigned_long_or_unsigned_long_sequence.h", "$bindings_modules_v8_output_dir/unsigned_long_or_unsigned_long_sequence.h",
"$bindings_modules_v8_output_dir/unsigned_long_sequence_or_gpu_extent_3d_dict.cc", "$bindings_modules_v8_output_dir/unsigned_long_sequence_or_gpu_extent_3d_dict.cc",
"$bindings_modules_v8_output_dir/unsigned_long_sequence_or_gpu_extent_3d_dict.h", "$bindings_modules_v8_output_dir/unsigned_long_sequence_or_gpu_extent_3d_dict.h",
"$bindings_modules_v8_output_dir/unsigned_long_sequence_or_gpu_origin_3d_dict.cc",
"$bindings_modules_v8_output_dir/unsigned_long_sequence_or_gpu_origin_3d_dict.h",
"$bindings_modules_v8_output_dir/webgl_rendering_context_or_webgl2_rendering_context.cc", "$bindings_modules_v8_output_dir/webgl_rendering_context_or_webgl2_rendering_context.cc",
"$bindings_modules_v8_output_dir/webgl_rendering_context_or_webgl2_rendering_context.h", "$bindings_modules_v8_output_dir/webgl_rendering_context_or_webgl2_rendering_context.h",
] ]
......
...@@ -854,7 +854,7 @@ modules_dictionary_idl_files = ...@@ -854,7 +854,7 @@ modules_dictionary_idl_files =
"webgpu/gpu_fence_descriptor.idl", "webgpu/gpu_fence_descriptor.idl",
"webgpu/gpu_limits.idl", "webgpu/gpu_limits.idl",
"webgpu/gpu_object_descriptor_base.idl", "webgpu/gpu_object_descriptor_base.idl",
"webgpu/gpu_origin_3d.idl", "webgpu/gpu_origin_3d_dict.idl",
"webgpu/gpu_pipeline_descriptor_base.idl", "webgpu/gpu_pipeline_descriptor_base.idl",
"webgpu/gpu_pipeline_layout_descriptor.idl", "webgpu/gpu_pipeline_layout_descriptor.idl",
"webgpu/gpu_pipeline_stage_descriptor.idl", "webgpu/gpu_pipeline_stage_descriptor.idl",
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/double_sequence_or_gpu_color_dict.h" #include "third_party/blink/renderer/bindings/modules/v8/double_sequence_or_gpu_color_dict.h"
#include "third_party/blink/renderer/bindings/modules/v8/unsigned_long_sequence_or_gpu_extent_3d_dict.h" #include "third_party/blink/renderer/bindings/modules/v8/unsigned_long_sequence_or_gpu_extent_3d_dict.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_origin_3d.h" #include "third_party/blink/renderer/bindings/modules/v8/unsigned_long_sequence_or_gpu_origin_3d_dict.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_pipeline_stage_descriptor.h" #include "third_party/blink/renderer/modules/webgpu/gpu_pipeline_stage_descriptor.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_shader_module.h" #include "third_party/blink/renderer/modules/webgpu/gpu_shader_module.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
...@@ -767,13 +767,30 @@ DawnExtent3D AsDawnType( ...@@ -767,13 +767,30 @@ DawnExtent3D AsDawnType(
return dawn_extent; return dawn_extent;
} }
DawnOrigin3D AsDawnType(const GPUOrigin3D* webgpu_origin) { DawnOrigin3D AsDawnType(
const UnsignedLongSequenceOrGPUOrigin3DDict* webgpu_origin) {
DCHECK(webgpu_origin); DCHECK(webgpu_origin);
DawnOrigin3D dawn_origin = {}; DawnOrigin3D dawn_origin = {};
dawn_origin.x = webgpu_origin->x();
dawn_origin.y = webgpu_origin->y(); if (webgpu_origin->IsUnsignedLongSequence()) {
dawn_origin.z = webgpu_origin->z(); const Vector<uint32_t>& webgpu_origin_sequence =
webgpu_origin->GetAsUnsignedLongSequence();
DCHECK_EQ(webgpu_origin_sequence.size(), 3UL);
dawn_origin.x = webgpu_origin_sequence[0];
dawn_origin.y = webgpu_origin_sequence[1];
dawn_origin.z = webgpu_origin_sequence[2];
} else if (webgpu_origin->IsGPUOrigin3DDict()) {
const GPUOrigin3DDict* webgpu_origin_3d_dict =
webgpu_origin->GetAsGPUOrigin3DDict();
dawn_origin.x = webgpu_origin_3d_dict->x();
dawn_origin.y = webgpu_origin_3d_dict->y();
dawn_origin.z = webgpu_origin_3d_dict->z();
} else {
NOTREACHED();
}
return dawn_origin; return dawn_origin;
} }
......
...@@ -21,9 +21,9 @@ namespace blink { ...@@ -21,9 +21,9 @@ namespace blink {
class DoubleSequenceOrGPUColorDict; class DoubleSequenceOrGPUColorDict;
class GPUColorDict; class GPUColorDict;
class GPUOrigin3D;
class GPUPipelineStageDescriptor; class GPUPipelineStageDescriptor;
class UnsignedLongSequenceOrGPUExtent3DDict; class UnsignedLongSequenceOrGPUExtent3DDict;
class UnsignedLongSequenceOrGPUOrigin3DDict;
// Convert WebGPU bitfield values to Dawn enums. These have the same value. // Convert WebGPU bitfield values to Dawn enums. These have the same value.
template <typename DawnEnum> template <typename DawnEnum>
...@@ -42,7 +42,7 @@ DawnColor AsDawnColor(const Vector<double>&); ...@@ -42,7 +42,7 @@ DawnColor AsDawnColor(const Vector<double>&);
DawnColor AsDawnType(const GPUColorDict*); DawnColor AsDawnType(const GPUColorDict*);
DawnColor AsDawnType(const DoubleSequenceOrGPUColorDict*); DawnColor AsDawnType(const DoubleSequenceOrGPUColorDict*);
DawnExtent3D AsDawnType(const UnsignedLongSequenceOrGPUExtent3DDict*); DawnExtent3D AsDawnType(const UnsignedLongSequenceOrGPUExtent3DDict*);
DawnOrigin3D AsDawnType(const GPUOrigin3D*); DawnOrigin3D AsDawnType(const UnsignedLongSequenceOrGPUOrigin3DDict*);
using OwnedPipelineStageDescriptor = using OwnedPipelineStageDescriptor =
std::tuple<DawnPipelineStageDescriptor, std::unique_ptr<char[]>>; std::tuple<DawnPipelineStageDescriptor, std::unique_ptr<char[]>>;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
typedef unsigned long long GPUBufferSize; typedef unsigned long long GPUBufferSize;
typedef (sequence<double> or GPUColorDict) GPUColor; typedef (sequence<double> or GPUColorDict) GPUColor;
typedef (sequence<unsigned long> or GPUExtent3DDict) GPUExtent3D; typedef (sequence<unsigned long> or GPUExtent3DDict) GPUExtent3D;
typedef (sequence<unsigned long> or GPUOrigin3DDict) GPUOrigin3D;
[ [
RuntimeEnabled=WebGPU RuntimeEnabled=WebGPU
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/double_sequence_or_gpu_color_dict.h" #include "third_party/blink/renderer/bindings/modules/v8/double_sequence_or_gpu_color_dict.h"
#include "third_party/blink/renderer/bindings/modules/v8/unsigned_long_sequence_or_gpu_extent_3d_dict.h" #include "third_party/blink/renderer/bindings/modules/v8/unsigned_long_sequence_or_gpu_extent_3d_dict.h"
#include "third_party/blink/renderer/bindings/modules/v8/unsigned_long_sequence_or_gpu_origin_3d_dict.h"
#include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h" #include "third_party/blink/renderer/modules/webgpu/dawn_conversions.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_buffer_copy_view.h" #include "third_party/blink/renderer/modules/webgpu/gpu_buffer_copy_view.h"
...@@ -15,7 +16,6 @@ ...@@ -15,7 +16,6 @@
#include "third_party/blink/renderer/modules/webgpu/gpu_compute_pass_descriptor.h" #include "third_party/blink/renderer/modules/webgpu/gpu_compute_pass_descriptor.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_origin_3d.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_render_pass_color_attachment_descriptor.h" #include "third_party/blink/renderer/modules/webgpu/gpu_render_pass_color_attachment_descriptor.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_render_pass_depth_stencil_attachment_descriptor.h" #include "third_party/blink/renderer/modules/webgpu/gpu_render_pass_depth_stencil_attachment_descriptor.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_render_pass_descriptor.h" #include "third_party/blink/renderer/modules/webgpu/gpu_render_pass_descriptor.h"
...@@ -36,6 +36,23 @@ bool ValidateCopySize(UnsignedLongSequenceOrGPUExtent3DDict& copy_size, ...@@ -36,6 +36,23 @@ bool ValidateCopySize(UnsignedLongSequenceOrGPUExtent3DDict& copy_size,
return true; return true;
} }
bool ValidateTextureCopyView(GPUTextureCopyView* texture_copy_view,
ExceptionState& exception_state) {
DCHECK(texture_copy_view);
if (texture_copy_view->hasOrigin()) {
const UnsignedLongSequenceOrGPUOrigin3DDict origin =
texture_copy_view->origin();
if (origin.IsUnsignedLongSequence() &&
origin.GetAsUnsignedLongSequence().size() != 3) {
exception_state.ThrowRangeError(
"texture copy view origin length must be 3");
return false;
}
}
return true;
}
DawnRenderPassColorAttachmentDescriptor AsDawnType( DawnRenderPassColorAttachmentDescriptor AsDawnType(
const GPURenderPassColorAttachmentDescriptor* webgpu_desc) { const GPURenderPassColorAttachmentDescriptor* webgpu_desc) {
DCHECK(webgpu_desc); DCHECK(webgpu_desc);
...@@ -139,7 +156,11 @@ DawnTextureCopyView AsDawnType(const GPUTextureCopyView* webgpu_view) { ...@@ -139,7 +156,11 @@ DawnTextureCopyView AsDawnType(const GPUTextureCopyView* webgpu_view) {
dawn_view.texture = webgpu_view->texture()->GetHandle(); dawn_view.texture = webgpu_view->texture()->GetHandle();
dawn_view.mipLevel = webgpu_view->mipLevel(); dawn_view.mipLevel = webgpu_view->mipLevel();
dawn_view.arrayLayer = webgpu_view->arrayLayer(); dawn_view.arrayLayer = webgpu_view->arrayLayer();
dawn_view.origin = AsDawnType(webgpu_view->origin()); if (webgpu_view->hasOrigin()) {
dawn_view.origin = AsDawnType(&webgpu_view->origin());
} else {
dawn_view.origin = DawnOrigin3D{};
}
return dawn_view; return dawn_view;
} }
...@@ -262,7 +283,8 @@ void GPUCommandEncoder::copyBufferToTexture( ...@@ -262,7 +283,8 @@ void GPUCommandEncoder::copyBufferToTexture(
GPUTextureCopyView* destination, GPUTextureCopyView* destination,
UnsignedLongSequenceOrGPUExtent3DDict& copy_size, UnsignedLongSequenceOrGPUExtent3DDict& copy_size,
ExceptionState& exception_state) { ExceptionState& exception_state) {
if (!ValidateCopySize(copy_size, exception_state)) { if (!ValidateCopySize(copy_size, exception_state) ||
!ValidateTextureCopyView(destination, exception_state)) {
return; return;
} }
...@@ -279,7 +301,8 @@ void GPUCommandEncoder::copyTextureToBuffer( ...@@ -279,7 +301,8 @@ void GPUCommandEncoder::copyTextureToBuffer(
GPUBufferCopyView* destination, GPUBufferCopyView* destination,
UnsignedLongSequenceOrGPUExtent3DDict& copy_size, UnsignedLongSequenceOrGPUExtent3DDict& copy_size,
ExceptionState& exception_state) { ExceptionState& exception_state) {
if (!ValidateCopySize(copy_size, exception_state)) { if (!ValidateCopySize(copy_size, exception_state) ||
!ValidateTextureCopyView(source, exception_state)) {
return; return;
} }
...@@ -296,7 +319,9 @@ void GPUCommandEncoder::copyTextureToTexture( ...@@ -296,7 +319,9 @@ void GPUCommandEncoder::copyTextureToTexture(
GPUTextureCopyView* destination, GPUTextureCopyView* destination,
UnsignedLongSequenceOrGPUExtent3DDict& copy_size, UnsignedLongSequenceOrGPUExtent3DDict& copy_size,
ExceptionState& exception_state) { ExceptionState& exception_state) {
if (!ValidateCopySize(copy_size, exception_state)) { if (!ValidateCopySize(copy_size, exception_state) ||
!ValidateTextureCopyView(source, exception_state) ||
!ValidateTextureCopyView(destination, exception_state)) {
return; return;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// https://gpuweb.github.io/gpuweb/ // https://gpuweb.github.io/gpuweb/
dictionary GPUOrigin3D { dictionary GPUOrigin3DDict {
unsigned long x = 0; unsigned long x = 0;
unsigned long y = 0; unsigned long y = 0;
unsigned long z = 0; unsigned long z = 0;
......
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