CommandBuffer.h (1485B)
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/. */ 5 6 #ifndef GPU_CommandBuffer_H_ 7 #define GPU_CommandBuffer_H_ 8 9 #include "ObjectModel.h" 10 #include "mozilla/Span.h" 11 #include "mozilla/WeakPtr.h" 12 #include "mozilla/webgpu/WebGPUTypes.h" 13 #include "nsTArrayForwardDeclare.h" 14 #include "nsWrapperCache.h" 15 16 namespace mozilla::webgpu { 17 18 class CanvasContext; 19 class CommandEncoder; 20 class Device; 21 class ExternalTexture; 22 23 class CommandBuffer final : public nsWrapperCache, 24 public ObjectBase, 25 public ChildOf<Device> { 26 public: 27 GPU_DECL_CYCLE_COLLECTION(CommandBuffer) 28 GPU_DECL_JS_WRAP(CommandBuffer) 29 30 CommandBuffer(Device* const aParent, RawId aId, 31 nsTArray<WeakPtr<CanvasContext>>&& aPresentationContexts, 32 nsTArray<RefPtr<ExternalTexture>>&& aExternalTextures); 33 34 Span<const RefPtr<ExternalTexture>> GetExternalTextures() const { 35 return mExternalTextures; 36 } 37 38 RawId Commit(); 39 40 private: 41 virtual ~CommandBuffer(); 42 43 const nsTArray<WeakPtr<CanvasContext>> mPresentationContexts; 44 45 // List of external textures used in this command buffer. 46 nsTArray<RefPtr<ExternalTexture>> mExternalTextures; 47 }; 48 49 } // namespace mozilla::webgpu 50 51 #endif // GPU_CommandBuffer_H_