Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / webgpu / RenderPassEncoder.h
blob203241a5f88e19ef25be57ea8c0a4163179703f3
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 #ifndef GPU_RenderPassEncoder_H_
7 #define GPU_RenderPassEncoder_H_
9 #include "mozilla/dom/TypedArray.h"
10 #include "ObjectModel.h"
12 namespace mozilla {
13 class ErrorResult;
15 namespace dom {
16 class DoubleSequenceOrGPUColorDict;
17 struct GPURenderPassDescriptor;
18 template <typename T>
19 class Sequence;
20 namespace binding_detail {
21 template <typename T>
22 class AutoSequence;
23 } // namespace binding_detail
24 } // namespace dom
25 namespace webgpu {
26 namespace ffi {
27 struct WGPURecordedRenderPass;
28 } // namespace ffi
30 class BindGroup;
31 class Buffer;
32 class CommandEncoder;
33 class RenderBundle;
34 class RenderPipeline;
35 class TextureView;
37 struct ffiWGPURenderPassDeleter {
38 void operator()(ffi::WGPURecordedRenderPass*);
41 class RenderPassEncoder final : public ObjectBase,
42 public ChildOf<CommandEncoder> {
43 public:
44 GPU_DECL_CYCLE_COLLECTION(RenderPassEncoder)
45 GPU_DECL_JS_WRAP(RenderPassEncoder)
47 RenderPassEncoder(CommandEncoder* const aParent,
48 const dom::GPURenderPassDescriptor& aDesc);
50 protected:
51 virtual ~RenderPassEncoder();
52 void Cleanup();
54 std::unique_ptr<ffi::WGPURecordedRenderPass, ffiWGPURenderPassDeleter> mPass;
55 // keep all the used objects alive while the pass is recorded
56 nsTArray<RefPtr<const BindGroup>> mUsedBindGroups;
57 nsTArray<RefPtr<const Buffer>> mUsedBuffers;
58 nsTArray<RefPtr<const RenderPipeline>> mUsedPipelines;
59 nsTArray<RefPtr<const TextureView>> mUsedTextureViews;
60 nsTArray<RefPtr<const RenderBundle>> mUsedRenderBundles;
62 public:
63 // programmable pass encoder
64 void SetBindGroup(uint32_t aSlot, BindGroup* const aBindGroup,
65 const dom::Sequence<uint32_t>& aDynamicOffsets);
66 // render encoder base
67 void SetPipeline(const RenderPipeline& aPipeline);
68 void SetIndexBuffer(const Buffer& aBuffer,
69 const dom::GPUIndexFormat& aIndexFormat, uint64_t aOffset,
70 uint64_t aSize);
71 void SetVertexBuffer(uint32_t aSlot, const Buffer& aBuffer, uint64_t aOffset,
72 uint64_t aSize);
73 void Draw(uint32_t aVertexCount, uint32_t aInstanceCount,
74 uint32_t aFirstVertex, uint32_t aFirstInstance);
75 void DrawIndexed(uint32_t aIndexCount, uint32_t aInstanceCount,
76 uint32_t aFirstIndex, int32_t aBaseVertex,
77 uint32_t aFirstInstance);
78 void DrawIndirect(const Buffer& aIndirectBuffer, uint64_t aIndirectOffset);
79 void DrawIndexedIndirect(const Buffer& aIndirectBuffer,
80 uint64_t aIndirectOffset);
81 // self
82 void SetViewport(float x, float y, float width, float height, float minDepth,
83 float maxDepth);
84 void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
85 void SetBlendConstant(const dom::DoubleSequenceOrGPUColorDict& color);
86 void SetStencilReference(uint32_t reference);
88 void BeginOcclusionQuery(uint32_t queryIndex);
89 void EndOcclusionQuery();
91 void PushDebugGroup(const nsAString& aString);
92 void PopDebugGroup();
93 void InsertDebugMarker(const nsAString& aString);
95 void ExecuteBundles(
96 const dom::Sequence<OwningNonNull<RenderBundle>>& aBundles);
98 void End();
101 } // namespace webgpu
102 } // namespace mozilla
104 #endif // GPU_RenderPassEncoder_H_