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_
|
|
|
|
|
2020-11-07 17:42:28 +03:00
|
|
|
#include "mozilla/Scoped.h"
|
2019-10-02 19:46:03 +03:00
|
|
|
#include "mozilla/dom/TypedArray.h"
|
|
|
|
#include "ObjectModel.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2021-03-25 13:19:44 +03:00
|
|
|
class ErrorResult;
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
struct GPUComputePassDescriptor;
|
|
|
|
}
|
|
|
|
|
2019-10-02 19:46:03 +03:00
|
|
|
namespace webgpu {
|
2020-11-07 17:42:28 +03:00
|
|
|
namespace ffi {
|
|
|
|
struct WGPUComputePass;
|
|
|
|
} // namespace ffi
|
2019-10-02 19:46:03 +03:00
|
|
|
|
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-11-07 17:42:28 +03:00
|
|
|
struct ScopedFfiComputeTraits {
|
2021-08-05 03:11:58 +03:00
|
|
|
using type = ffi::WGPUComputePass*;
|
2020-11-07 17:42:28 +03:00
|
|
|
static type empty();
|
|
|
|
static void release(type raw);
|
|
|
|
};
|
|
|
|
|
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 17:42:28 +03:00
|
|
|
Scoped<ScopedFfiComputeTraits> mPass;
|
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:
|
2021-05-26 23:30:45 +03:00
|
|
|
// programmable pass encoder
|
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);
|
2021-05-26 23:30:45 +03:00
|
|
|
// self
|
2020-01-24 19:27:09 +03:00
|
|
|
void SetPipeline(const ComputePipeline& aPipeline);
|
2021-12-21 17:51:16 +03:00
|
|
|
|
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);
|
2021-12-21 17:51:16 +03:00
|
|
|
|
|
|
|
void PushDebugGroup(const nsAString& aString);
|
|
|
|
void PopDebugGroup();
|
|
|
|
void InsertDebugMarker(const nsAString& aString);
|
|
|
|
|
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_
|