2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2018-06-13 20:43:48 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "RenderPipeline.h"
|
|
|
|
|
|
|
|
#include "Device.h"
|
2020-11-16 22:57:04 +03:00
|
|
|
#include "ipc/WebGPUChild.h"
|
|
|
|
#include "mozilla/dom/WebGPUBinding.h"
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2022-05-09 23:41:19 +03:00
|
|
|
namespace mozilla::webgpu {
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
GPU_IMPL_CYCLE_COLLECTION(RenderPipeline, mParent)
|
|
|
|
GPU_IMPL_JS_WRAP(RenderPipeline)
|
2018-06-13 20:43:48 +03:00
|
|
|
|
2020-11-13 17:15:49 +03:00
|
|
|
RenderPipeline::RenderPipeline(Device* const aParent, RawId aId,
|
2021-05-18 19:26:27 +03:00
|
|
|
RawId aImplicitPipelineLayoutId,
|
2020-11-13 17:15:49 +03:00
|
|
|
nsTArray<RawId>&& aImplicitBindGroupLayoutIds)
|
|
|
|
: ChildOf(aParent),
|
2021-05-18 19:26:27 +03:00
|
|
|
mImplicitPipelineLayoutId(aImplicitPipelineLayoutId),
|
2020-11-13 17:15:49 +03:00
|
|
|
mImplicitBindGroupLayoutIds(std::move(aImplicitBindGroupLayoutIds)),
|
|
|
|
mId(aId) {}
|
2020-02-19 22:25:30 +03:00
|
|
|
|
|
|
|
RenderPipeline::~RenderPipeline() { Cleanup(); }
|
|
|
|
|
|
|
|
void RenderPipeline::Cleanup() {
|
|
|
|
if (mValid && mParent) {
|
|
|
|
mValid = false;
|
2020-04-07 01:29:18 +03:00
|
|
|
auto bridge = mParent->GetBridge();
|
2020-02-19 22:25:30 +03:00
|
|
|
if (bridge && bridge->IsOpen()) {
|
2020-03-23 10:54:08 +03:00
|
|
|
bridge->SendRenderPipelineDestroy(mId);
|
2021-05-20 18:30:55 +03:00
|
|
|
if (mImplicitPipelineLayoutId) {
|
|
|
|
bridge->SendImplicitLayoutDestroy(mImplicitPipelineLayoutId,
|
|
|
|
mImplicitBindGroupLayoutIds);
|
|
|
|
}
|
2020-02-19 22:25:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-22 10:31:51 +03:00
|
|
|
|
2020-11-13 17:15:49 +03:00
|
|
|
already_AddRefed<BindGroupLayout> RenderPipeline::GetBindGroupLayout(
|
|
|
|
uint32_t index) const {
|
2021-05-27 18:08:02 +03:00
|
|
|
const RawId id = index < mImplicitBindGroupLayoutIds.Length()
|
|
|
|
? mImplicitBindGroupLayoutIds[index]
|
|
|
|
: 0;
|
|
|
|
RefPtr<BindGroupLayout> object = new BindGroupLayout(mParent, id, false);
|
2020-11-13 17:15:49 +03:00
|
|
|
return object.forget();
|
|
|
|
}
|
|
|
|
|
2022-05-09 23:41:19 +03:00
|
|
|
} // namespace mozilla::webgpu
|