1/*
2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "config.h"
22
23#if ENABLE(WEBGPU)
24
25#include "JSWebGPUCommandEncoder.h"
26
27#include "JSDOMBinding.h"
28#include "JSDOMConstructorNotConstructable.h"
29#include "JSDOMConvertInterface.h"
30#include "JSDOMConvertNumbers.h"
31#include "JSDOMExceptionHandling.h"
32#include "JSDOMGlobalObject.h"
33#include "JSDOMOperation.h"
34#include "JSDOMWrapperCache.h"
35#include "JSGPUExtent3D.h"
36#include "JSGPUOrigin3D.h"
37#include "JSWebGPUBuffer.h"
38#include "JSWebGPUCommandBuffer.h"
39#include "JSWebGPUComputePassEncoder.h"
40#include "JSWebGPURenderPassDescriptor.h"
41#include "JSWebGPURenderPassEncoder.h"
42#include "JSWebGPUTexture.h"
43#include "ScriptExecutionContext.h"
44#include <JavaScriptCore/FunctionPrototype.h>
45#include <JavaScriptCore/HeapSnapshotBuilder.h>
46#include <JavaScriptCore/JSCInlines.h>
47#include <wtf/GetPtr.h>
48#include <wtf/PointerPreparations.h>
49#include <wtf/URL.h>
50
51
52namespace WebCore {
53using namespace JSC;
54
55#if ENABLE(WEBGPU)
56
57template<> WebGPUBufferCopyView convertDictionary<WebGPUBufferCopyView>(ExecState& state, JSValue value)
58{
59 VM& vm = state.vm();
60 auto throwScope = DECLARE_THROW_SCOPE(vm);
61 bool isNullOrUndefined = value.isUndefinedOrNull();
62 auto* object = isNullOrUndefined ? nullptr : value.getObject();
63 if (UNLIKELY(!isNullOrUndefined && !object)) {
64 throwTypeError(&state, throwScope);
65 return { };
66 }
67 WebGPUBufferCopyView result;
68 JSValue bufferValue;
69 if (isNullOrUndefined)
70 bufferValue = jsUndefined();
71 else {
72 bufferValue = object->get(&state, Identifier::fromString(&state, "buffer"));
73 RETURN_IF_EXCEPTION(throwScope, { });
74 }
75 if (!bufferValue.isUndefined()) {
76 result.buffer = convert<IDLInterface<WebGPUBuffer>>(state, bufferValue);
77 RETURN_IF_EXCEPTION(throwScope, { });
78 } else {
79 throwRequiredMemberTypeError(state, throwScope, "buffer", "GPUBufferCopyView", "WebGPUBuffer");
80 return { };
81 }
82 JSValue imageHeightValue;
83 if (isNullOrUndefined)
84 imageHeightValue = jsUndefined();
85 else {
86 imageHeightValue = object->get(&state, Identifier::fromString(&state, "imageHeight"));
87 RETURN_IF_EXCEPTION(throwScope, { });
88 }
89 if (!imageHeightValue.isUndefined()) {
90 result.imageHeight = convert<IDLUnsignedLong>(state, imageHeightValue);
91 RETURN_IF_EXCEPTION(throwScope, { });
92 } else {
93 throwRequiredMemberTypeError(state, throwScope, "imageHeight", "GPUBufferCopyView", "unsigned long");
94 return { };
95 }
96 JSValue offsetValue;
97 if (isNullOrUndefined)
98 offsetValue = jsUndefined();
99 else {
100 offsetValue = object->get(&state, Identifier::fromString(&state, "offset"));
101 RETURN_IF_EXCEPTION(throwScope, { });
102 }
103 if (!offsetValue.isUndefined()) {
104 result.offset = convert<IDLUnsignedLongLong>(state, offsetValue);
105 RETURN_IF_EXCEPTION(throwScope, { });
106 } else
107 result.offset = 0;
108 JSValue rowPitchValue;
109 if (isNullOrUndefined)
110 rowPitchValue = jsUndefined();
111 else {
112 rowPitchValue = object->get(&state, Identifier::fromString(&state, "rowPitch"));
113 RETURN_IF_EXCEPTION(throwScope, { });
114 }
115 if (!rowPitchValue.isUndefined()) {
116 result.rowPitch = convert<IDLUnsignedLong>(state, rowPitchValue);
117 RETURN_IF_EXCEPTION(throwScope, { });
118 } else {
119 throwRequiredMemberTypeError(state, throwScope, "rowPitch", "GPUBufferCopyView", "unsigned long");
120 return { };
121 }
122 return result;
123}
124
125#endif
126
127#if ENABLE(WEBGPU)
128
129template<> WebGPUTextureCopyView convertDictionary<WebGPUTextureCopyView>(ExecState& state, JSValue value)
130{
131 VM& vm = state.vm();
132 auto throwScope = DECLARE_THROW_SCOPE(vm);
133 bool isNullOrUndefined = value.isUndefinedOrNull();
134 auto* object = isNullOrUndefined ? nullptr : value.getObject();
135 if (UNLIKELY(!isNullOrUndefined && !object)) {
136 throwTypeError(&state, throwScope);
137 return { };
138 }
139 WebGPUTextureCopyView result;
140 JSValue arrayLayerValue;
141 if (isNullOrUndefined)
142 arrayLayerValue = jsUndefined();
143 else {
144 arrayLayerValue = object->get(&state, Identifier::fromString(&state, "arrayLayer"));
145 RETURN_IF_EXCEPTION(throwScope, { });
146 }
147 if (!arrayLayerValue.isUndefined()) {
148 result.arrayLayer = convert<IDLUnsignedLong>(state, arrayLayerValue);
149 RETURN_IF_EXCEPTION(throwScope, { });
150 } else
151 result.arrayLayer = 0;
152 JSValue mipLevelValue;
153 if (isNullOrUndefined)
154 mipLevelValue = jsUndefined();
155 else {
156 mipLevelValue = object->get(&state, Identifier::fromString(&state, "mipLevel"));
157 RETURN_IF_EXCEPTION(throwScope, { });
158 }
159 if (!mipLevelValue.isUndefined()) {
160 result.mipLevel = convert<IDLUnsignedLong>(state, mipLevelValue);
161 RETURN_IF_EXCEPTION(throwScope, { });
162 } else
163 result.mipLevel = 0;
164 JSValue originValue;
165 if (isNullOrUndefined)
166 originValue = jsUndefined();
167 else {
168 originValue = object->get(&state, Identifier::fromString(&state, "origin"));
169 RETURN_IF_EXCEPTION(throwScope, { });
170 }
171 if (!originValue.isUndefined()) {
172 result.origin = convert<IDLDictionary<GPUOrigin3D>>(state, originValue);
173 RETURN_IF_EXCEPTION(throwScope, { });
174 }
175 JSValue textureValue;
176 if (isNullOrUndefined)
177 textureValue = jsUndefined();
178 else {
179 textureValue = object->get(&state, Identifier::fromString(&state, "texture"));
180 RETURN_IF_EXCEPTION(throwScope, { });
181 }
182 if (!textureValue.isUndefined()) {
183 result.texture = convert<IDLInterface<WebGPUTexture>>(state, textureValue);
184 RETURN_IF_EXCEPTION(throwScope, { });
185 } else {
186 throwRequiredMemberTypeError(state, throwScope, "texture", "GPUTextureCopyView", "WebGPUTexture");
187 return { };
188 }
189 return result;
190}
191
192#endif
193
194// Functions
195
196JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionBeginRenderPass(JSC::ExecState*);
197JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionBeginComputePass(JSC::ExecState*);
198JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionCopyBufferToBuffer(JSC::ExecState*);
199JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionCopyBufferToTexture(JSC::ExecState*);
200JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionCopyTextureToBuffer(JSC::ExecState*);
201JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionCopyTextureToTexture(JSC::ExecState*);
202JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionFinish(JSC::ExecState*);
203
204// Attributes
205
206JSC::EncodedJSValue jsWebGPUCommandEncoderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
207bool setJSWebGPUCommandEncoderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
208
209class JSWebGPUCommandEncoderPrototype : public JSC::JSNonFinalObject {
210public:
211 using Base = JSC::JSNonFinalObject;
212 static JSWebGPUCommandEncoderPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
213 {
214 JSWebGPUCommandEncoderPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebGPUCommandEncoderPrototype>(vm.heap)) JSWebGPUCommandEncoderPrototype(vm, globalObject, structure);
215 ptr->finishCreation(vm);
216 return ptr;
217 }
218
219 DECLARE_INFO;
220 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
221 {
222 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
223 }
224
225private:
226 JSWebGPUCommandEncoderPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
227 : JSC::JSNonFinalObject(vm, structure)
228 {
229 }
230
231 void finishCreation(JSC::VM&);
232};
233
234using JSWebGPUCommandEncoderConstructor = JSDOMConstructorNotConstructable<JSWebGPUCommandEncoder>;
235
236template<> JSValue JSWebGPUCommandEncoderConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
237{
238 UNUSED_PARAM(vm);
239 return globalObject.functionPrototype();
240}
241
242template<> void JSWebGPUCommandEncoderConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
243{
244 putDirect(vm, vm.propertyNames->prototype, JSWebGPUCommandEncoder::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
245 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("GPUCommandEncoder"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
246 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
247}
248
249template<> const ClassInfo JSWebGPUCommandEncoderConstructor::s_info = { "GPUCommandEncoder", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUCommandEncoderConstructor) };
250
251/* Hash table for prototype */
252
253static const HashTableValue JSWebGPUCommandEncoderPrototypeTableValues[] =
254{
255 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebGPUCommandEncoderConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebGPUCommandEncoderConstructor) } },
256 { "beginRenderPass", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUCommandEncoderPrototypeFunctionBeginRenderPass), (intptr_t) (1) } },
257 { "beginComputePass", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUCommandEncoderPrototypeFunctionBeginComputePass), (intptr_t) (0) } },
258 { "copyBufferToBuffer", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUCommandEncoderPrototypeFunctionCopyBufferToBuffer), (intptr_t) (5) } },
259 { "copyBufferToTexture", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUCommandEncoderPrototypeFunctionCopyBufferToTexture), (intptr_t) (3) } },
260 { "copyTextureToBuffer", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUCommandEncoderPrototypeFunctionCopyTextureToBuffer), (intptr_t) (3) } },
261 { "copyTextureToTexture", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUCommandEncoderPrototypeFunctionCopyTextureToTexture), (intptr_t) (3) } },
262 { "finish", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUCommandEncoderPrototypeFunctionFinish), (intptr_t) (0) } },
263};
264
265const ClassInfo JSWebGPUCommandEncoderPrototype::s_info = { "GPUCommandEncoderPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUCommandEncoderPrototype) };
266
267void JSWebGPUCommandEncoderPrototype::finishCreation(VM& vm)
268{
269 Base::finishCreation(vm);
270 reifyStaticProperties(vm, JSWebGPUCommandEncoder::info(), JSWebGPUCommandEncoderPrototypeTableValues, *this);
271}
272
273const ClassInfo JSWebGPUCommandEncoder::s_info = { "GPUCommandEncoder", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUCommandEncoder) };
274
275JSWebGPUCommandEncoder::JSWebGPUCommandEncoder(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebGPUCommandEncoder>&& impl)
276 : JSDOMWrapper<WebGPUCommandEncoder>(structure, globalObject, WTFMove(impl))
277{
278}
279
280void JSWebGPUCommandEncoder::finishCreation(VM& vm)
281{
282 Base::finishCreation(vm);
283 ASSERT(inherits(vm, info()));
284
285}
286
287JSObject* JSWebGPUCommandEncoder::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
288{
289 return JSWebGPUCommandEncoderPrototype::create(vm, &globalObject, JSWebGPUCommandEncoderPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
290}
291
292JSObject* JSWebGPUCommandEncoder::prototype(VM& vm, JSDOMGlobalObject& globalObject)
293{
294 return getDOMPrototype<JSWebGPUCommandEncoder>(vm, globalObject);
295}
296
297JSValue JSWebGPUCommandEncoder::getConstructor(VM& vm, const JSGlobalObject* globalObject)
298{
299 return getDOMConstructor<JSWebGPUCommandEncoderConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
300}
301
302void JSWebGPUCommandEncoder::destroy(JSC::JSCell* cell)
303{
304 JSWebGPUCommandEncoder* thisObject = static_cast<JSWebGPUCommandEncoder*>(cell);
305 thisObject->JSWebGPUCommandEncoder::~JSWebGPUCommandEncoder();
306}
307
308template<> inline JSWebGPUCommandEncoder* IDLOperation<JSWebGPUCommandEncoder>::cast(ExecState& state)
309{
310 return jsDynamicCast<JSWebGPUCommandEncoder*>(state.vm(), state.thisValue());
311}
312
313EncodedJSValue jsWebGPUCommandEncoderConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
314{
315 VM& vm = state->vm();
316 auto throwScope = DECLARE_THROW_SCOPE(vm);
317 auto* prototype = jsDynamicCast<JSWebGPUCommandEncoderPrototype*>(vm, JSValue::decode(thisValue));
318 if (UNLIKELY(!prototype))
319 return throwVMTypeError(state, throwScope);
320 return JSValue::encode(JSWebGPUCommandEncoder::getConstructor(state->vm(), prototype->globalObject()));
321}
322
323bool setJSWebGPUCommandEncoderConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
324{
325 VM& vm = state->vm();
326 auto throwScope = DECLARE_THROW_SCOPE(vm);
327 auto* prototype = jsDynamicCast<JSWebGPUCommandEncoderPrototype*>(vm, JSValue::decode(thisValue));
328 if (UNLIKELY(!prototype)) {
329 throwVMTypeError(state, throwScope);
330 return false;
331 }
332 // Shadowing a built-in constructor
333 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
334}
335
336static inline JSC::EncodedJSValue jsWebGPUCommandEncoderPrototypeFunctionBeginRenderPassBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUCommandEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
337{
338 UNUSED_PARAM(state);
339 UNUSED_PARAM(throwScope);
340 auto& impl = castedThis->wrapped();
341 if (UNLIKELY(state->argumentCount() < 1))
342 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
343 auto descriptor = convert<IDLDictionary<WebGPURenderPassDescriptor>>(*state, state->uncheckedArgument(0));
344 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
345 return JSValue::encode(toJS<IDLInterface<WebGPURenderPassEncoder>>(*state, *castedThis->globalObject(), impl.beginRenderPass(WTFMove(descriptor))));
346}
347
348EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionBeginRenderPass(ExecState* state)
349{
350 return IDLOperation<JSWebGPUCommandEncoder>::call<jsWebGPUCommandEncoderPrototypeFunctionBeginRenderPassBody>(*state, "beginRenderPass");
351}
352
353static inline JSC::EncodedJSValue jsWebGPUCommandEncoderPrototypeFunctionBeginComputePassBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUCommandEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
354{
355 UNUSED_PARAM(state);
356 UNUSED_PARAM(throwScope);
357 auto& impl = castedThis->wrapped();
358 return JSValue::encode(toJS<IDLInterface<WebGPUComputePassEncoder>>(*state, *castedThis->globalObject(), impl.beginComputePass()));
359}
360
361EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionBeginComputePass(ExecState* state)
362{
363 return IDLOperation<JSWebGPUCommandEncoder>::call<jsWebGPUCommandEncoderPrototypeFunctionBeginComputePassBody>(*state, "beginComputePass");
364}
365
366static inline JSC::EncodedJSValue jsWebGPUCommandEncoderPrototypeFunctionCopyBufferToBufferBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUCommandEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
367{
368 UNUSED_PARAM(state);
369 UNUSED_PARAM(throwScope);
370 auto& impl = castedThis->wrapped();
371 if (UNLIKELY(state->argumentCount() < 5))
372 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
373 auto src = convert<IDLInterface<WebGPUBuffer>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "src", "GPUCommandEncoder", "copyBufferToBuffer", "WebGPUBuffer"); });
374 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
375 auto srcOffset = convert<IDLUnsignedLongLong>(*state, state->uncheckedArgument(1));
376 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
377 auto dst = convert<IDLInterface<WebGPUBuffer>>(*state, state->uncheckedArgument(2), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 2, "dst", "GPUCommandEncoder", "copyBufferToBuffer", "WebGPUBuffer"); });
378 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
379 auto dstOffset = convert<IDLUnsignedLongLong>(*state, state->uncheckedArgument(3));
380 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
381 auto size = convert<IDLUnsignedLongLong>(*state, state->uncheckedArgument(4));
382 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
383 impl.copyBufferToBuffer(*src, WTFMove(srcOffset), *dst, WTFMove(dstOffset), WTFMove(size));
384 return JSValue::encode(jsUndefined());
385}
386
387EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionCopyBufferToBuffer(ExecState* state)
388{
389 return IDLOperation<JSWebGPUCommandEncoder>::call<jsWebGPUCommandEncoderPrototypeFunctionCopyBufferToBufferBody>(*state, "copyBufferToBuffer");
390}
391
392static inline JSC::EncodedJSValue jsWebGPUCommandEncoderPrototypeFunctionCopyBufferToTextureBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUCommandEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
393{
394 UNUSED_PARAM(state);
395 UNUSED_PARAM(throwScope);
396 auto& impl = castedThis->wrapped();
397 if (UNLIKELY(state->argumentCount() < 3))
398 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
399 auto source = convert<IDLDictionary<WebGPUBufferCopyView>>(*state, state->uncheckedArgument(0));
400 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
401 auto destination = convert<IDLDictionary<WebGPUTextureCopyView>>(*state, state->uncheckedArgument(1));
402 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
403 auto copySize = convert<IDLDictionary<GPUExtent3D>>(*state, state->uncheckedArgument(2));
404 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
405 impl.copyBufferToTexture(WTFMove(source), WTFMove(destination), WTFMove(copySize));
406 return JSValue::encode(jsUndefined());
407}
408
409EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionCopyBufferToTexture(ExecState* state)
410{
411 return IDLOperation<JSWebGPUCommandEncoder>::call<jsWebGPUCommandEncoderPrototypeFunctionCopyBufferToTextureBody>(*state, "copyBufferToTexture");
412}
413
414static inline JSC::EncodedJSValue jsWebGPUCommandEncoderPrototypeFunctionCopyTextureToBufferBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUCommandEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
415{
416 UNUSED_PARAM(state);
417 UNUSED_PARAM(throwScope);
418 auto& impl = castedThis->wrapped();
419 if (UNLIKELY(state->argumentCount() < 3))
420 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
421 auto source = convert<IDLDictionary<WebGPUTextureCopyView>>(*state, state->uncheckedArgument(0));
422 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
423 auto destination = convert<IDLDictionary<WebGPUBufferCopyView>>(*state, state->uncheckedArgument(1));
424 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
425 auto copySize = convert<IDLDictionary<GPUExtent3D>>(*state, state->uncheckedArgument(2));
426 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
427 impl.copyTextureToBuffer(WTFMove(source), WTFMove(destination), WTFMove(copySize));
428 return JSValue::encode(jsUndefined());
429}
430
431EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionCopyTextureToBuffer(ExecState* state)
432{
433 return IDLOperation<JSWebGPUCommandEncoder>::call<jsWebGPUCommandEncoderPrototypeFunctionCopyTextureToBufferBody>(*state, "copyTextureToBuffer");
434}
435
436static inline JSC::EncodedJSValue jsWebGPUCommandEncoderPrototypeFunctionCopyTextureToTextureBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUCommandEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
437{
438 UNUSED_PARAM(state);
439 UNUSED_PARAM(throwScope);
440 auto& impl = castedThis->wrapped();
441 if (UNLIKELY(state->argumentCount() < 3))
442 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
443 auto source = convert<IDLDictionary<WebGPUTextureCopyView>>(*state, state->uncheckedArgument(0));
444 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
445 auto destination = convert<IDLDictionary<WebGPUTextureCopyView>>(*state, state->uncheckedArgument(1));
446 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
447 auto copySize = convert<IDLDictionary<GPUExtent3D>>(*state, state->uncheckedArgument(2));
448 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
449 impl.copyTextureToTexture(WTFMove(source), WTFMove(destination), WTFMove(copySize));
450 return JSValue::encode(jsUndefined());
451}
452
453EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionCopyTextureToTexture(ExecState* state)
454{
455 return IDLOperation<JSWebGPUCommandEncoder>::call<jsWebGPUCommandEncoderPrototypeFunctionCopyTextureToTextureBody>(*state, "copyTextureToTexture");
456}
457
458static inline JSC::EncodedJSValue jsWebGPUCommandEncoderPrototypeFunctionFinishBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUCommandEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
459{
460 UNUSED_PARAM(state);
461 UNUSED_PARAM(throwScope);
462 auto& impl = castedThis->wrapped();
463 return JSValue::encode(toJS<IDLInterface<WebGPUCommandBuffer>>(*state, *castedThis->globalObject(), impl.finish()));
464}
465
466EncodedJSValue JSC_HOST_CALL jsWebGPUCommandEncoderPrototypeFunctionFinish(ExecState* state)
467{
468 return IDLOperation<JSWebGPUCommandEncoder>::call<jsWebGPUCommandEncoderPrototypeFunctionFinishBody>(*state, "finish");
469}
470
471void JSWebGPUCommandEncoder::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
472{
473 auto* thisObject = jsCast<JSWebGPUCommandEncoder*>(cell);
474 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
475 if (thisObject->scriptExecutionContext())
476 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
477 Base::heapSnapshot(cell, builder);
478}
479
480bool JSWebGPUCommandEncoderOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
481{
482 UNUSED_PARAM(handle);
483 UNUSED_PARAM(visitor);
484 UNUSED_PARAM(reason);
485 return false;
486}
487
488void JSWebGPUCommandEncoderOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
489{
490 auto* jsWebGPUCommandEncoder = static_cast<JSWebGPUCommandEncoder*>(handle.slot()->asCell());
491 auto& world = *static_cast<DOMWrapperWorld*>(context);
492 uncacheWrapper(world, &jsWebGPUCommandEncoder->wrapped(), jsWebGPUCommandEncoder);
493}
494
495JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGPUCommandEncoder>&& impl)
496{
497 // If you hit this failure the interface definition has the ImplementationLacksVTable
498 // attribute. You should remove that attribute. If the class has subclasses
499 // that may be passed through this toJS() function you should use the SkipVTableValidation
500 // attribute to WebGPUCommandEncoder.
501 static_assert(!std::is_polymorphic<WebGPUCommandEncoder>::value, "WebGPUCommandEncoder is polymorphic but the IDL claims it is not");
502 return createWrapper<WebGPUCommandEncoder>(globalObject, WTFMove(impl));
503}
504
505JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebGPUCommandEncoder& impl)
506{
507 return wrap(state, globalObject, impl);
508}
509
510WebGPUCommandEncoder* JSWebGPUCommandEncoder::toWrapped(JSC::VM& vm, JSC::JSValue value)
511{
512 if (auto* wrapper = jsDynamicCast<JSWebGPUCommandEncoder*>(vm, value))
513 return &wrapper->wrapped();
514 return nullptr;
515}
516
517}
518
519#endif // ENABLE(WEBGPU)
520