2019-10-02 19:46:03 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef GPU_ComputePassEncoder_H_
|
|
|
|
#define GPU_ComputePassEncoder_H_
|
|
|
|
|
|
|
|
#include "mozilla/dom/TypedArray.h"
|
2020-01-22 10:31:51 +03:00
|
|
|
#include "mozilla/webgpu/WebGPUTypes.h"
|
|
|
|
#include "mozilla/webgpu/ffi/wgpu.h"
|
2019-10-02 19:46:03 +03:00
|
|
|
#include "ObjectModel.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace webgpu {
|
|
|
|
|
2020-03-05 06:30:41 +03:00
|
|
|
class BindGroup;
|
2019-10-02 19:46:03 +03:00
|
|
|
class Buffer;
|
|
|
|
class CommandEncoder;
|
|
|
|
class ComputePipeline;
|
|
|
|
|
2020-02-11 06:03:47 +03:00
|
|
|
class ComputePassEncoder final : public ObjectBase,
|
2019-10-02 19:46:03 +03:00
|
|
|
public ChildOf<CommandEncoder> {
|
|
|
|
public:
|
2020-02-11 06:03:47 +03:00
|
|
|
GPU_DECL_CYCLE_COLLECTION(ComputePassEncoder)
|
2019-10-02 19:46:03 +03:00
|
|
|
GPU_DECL_JS_WRAP(ComputePassEncoder)
|
|
|
|
|
2020-01-22 10:31:51 +03:00
|
|
|
ComputePassEncoder(CommandEncoder* const aParent,
|
|
|
|
const dom::GPUComputePassDescriptor& aDesc);
|
2019-10-02 19:46:03 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~ComputePassEncoder();
|
2020-01-22 10:31:51 +03:00
|
|
|
void Cleanup() {}
|
|
|
|
|
2020-11-07 05:43:09 +03:00
|
|
|
ffi::WGPUComputePass* const mRaw;
|
2020-03-05 06:30:41 +03:00
|
|
|
// keep all the used objects alive while the pass is recorded
|
2020-03-18 20:29:51 +03:00
|
|
|
nsTArray<RefPtr<const BindGroup>> mUsedBindGroups;
|
|
|
|
nsTArray<RefPtr<const ComputePipeline>> mUsedPipelines;
|
2019-10-02 19:46:03 +03:00
|
|
|
|
|
|
|
public:
|
2020-01-24 19:27:09 +03:00
|
|
|
void SetBindGroup(uint32_t aSlot, const BindGroup& aBindGroup,
|
2020-02-11 06:03:47 +03:00
|
|
|
const dom::Sequence<uint32_t>& aDynamicOffsets);
|
2020-01-24 19:27:09 +03:00
|
|
|
void SetPipeline(const ComputePipeline& aPipeline);
|
2020-01-22 10:31:51 +03:00
|
|
|
void Dispatch(uint32_t x, uint32_t y, uint32_t z);
|
2020-07-21 16:20:18 +03:00
|
|
|
void DispatchIndirect(const Buffer& aIndirectBuffer,
|
|
|
|
uint64_t aIndirectOffset);
|
2020-01-22 10:31:51 +03:00
|
|
|
void EndPass(ErrorResult& aRv);
|
2019-10-02 19:46:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace webgpu
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GPU_ComputePassEncoder_H_
|