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"
16 class DoubleSequenceOrGPUColorDict
;
17 struct GPURenderPassDescriptor
;
20 namespace binding_detail
{
23 } // namespace binding_detail
27 struct WGPURecordedRenderPass
;
37 struct ffiWGPURenderPassDeleter
{
38 void operator()(ffi::WGPURecordedRenderPass
*);
41 class RenderPassEncoder final
: public ObjectBase
,
42 public ChildOf
<CommandEncoder
> {
44 GPU_DECL_CYCLE_COLLECTION(RenderPassEncoder
)
45 GPU_DECL_JS_WRAP(RenderPassEncoder
)
47 RenderPassEncoder(CommandEncoder
* const aParent
,
48 const dom::GPURenderPassDescriptor
& aDesc
);
51 virtual ~RenderPassEncoder();
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
;
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
,
71 void SetVertexBuffer(uint32_t aSlot
, const Buffer
& aBuffer
, uint64_t aOffset
,
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
);
82 void SetViewport(float x
, float y
, float width
, float height
, float minDepth
,
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
);
93 void InsertDebugMarker(const nsAString
& aString
);
96 const dom::Sequence
<OwningNonNull
<RenderBundle
>>& aBundles
);
101 } // namespace webgpu
102 } // namespace mozilla
104 #endif // GPU_RenderPassEncoder_H_