1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/dom/WebGPUBinding.h"
7 #include "mozilla/dom/Promise.h"
8 #include "ShaderModule.h"
9 #include "CompilationInfo.h"
10 #include "ipc/WebGPUChild.h"
14 namespace mozilla::webgpu
{
16 GPU_IMPL_CYCLE_COLLECTION(ShaderModule
, mParent
, mCompilationInfo
)
17 GPU_IMPL_JS_WRAP(ShaderModule
)
19 ShaderModule::ShaderModule(Device
* const aParent
, RawId aId
,
20 const RefPtr
<dom::Promise
>& aCompilationInfo
)
21 : ChildOf(aParent
), mId(aId
), mCompilationInfo(aCompilationInfo
) {
22 MOZ_RELEASE_ASSERT(aId
);
25 ShaderModule::~ShaderModule() { Cleanup(); }
27 void ShaderModule::Cleanup() {
28 if (mValid
&& mParent
) {
30 auto bridge
= mParent
->GetBridge();
31 if (bridge
&& bridge
->IsOpen()) {
32 bridge
->SendShaderModuleDrop(mId
);
37 already_AddRefed
<dom::Promise
> ShaderModule::CompilationInfo(ErrorResult
& aRv
) {
38 return GetCompilationInfo(aRv
);
41 already_AddRefed
<dom::Promise
> ShaderModule::GetCompilationInfo(
43 RefPtr
<dom::Promise
> tmp
= mCompilationInfo
;
47 } // namespace mozilla::webgpu