Queue.h (2470B)
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_Queue_H_ 7 #define GPU_Queue_H_ 8 9 #include "ObjectModel.h" 10 #include "mozilla/dom/BufferSourceBindingFwd.h" 11 #include "mozilla/webgpu/WebGPUTypes.h" 12 #include "nsWrapperCache.h" 13 14 namespace mozilla { 15 class ErrorResult; 16 namespace dom { 17 class RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict; 18 template <typename T> 19 class Optional; 20 template <typename T> 21 class Sequence; 22 struct GPUCopyExternalImageDestInfo; 23 struct GPUCopyExternalImageSourceInfo; 24 struct GPUTexelCopyTextureInfo; 25 struct GPUTexelCopyBufferLayout; 26 struct TextureCopyView; 27 struct TextureDataLayout; 28 using GPUExtent3D = RangeEnforcedUnsignedLongSequenceOrGPUExtent3DDict; 29 } // namespace dom 30 namespace webgpu { 31 32 class Buffer; 33 class CommandBuffer; 34 class Device; 35 class Fence; 36 37 class Queue final : public nsWrapperCache, 38 public ObjectBase, 39 public ChildOf<Device> { 40 public: 41 GPU_DECL_CYCLE_COLLECTION(Queue) 42 GPU_DECL_JS_WRAP(Queue) 43 44 Queue(Device* const aParent, RawId aId); 45 46 void Submit( 47 const dom::Sequence<OwningNonNull<CommandBuffer>>& aCommandBuffers); 48 49 already_AddRefed<dom::Promise> OnSubmittedWorkDone(ErrorResult& aRv); 50 51 void WriteBuffer(const Buffer& aBuffer, uint64_t aBufferOffset, 52 const dom::AllowSharedBufferSource& data, 53 uint64_t aDataOffset, const dom::Optional<uint64_t>& aSize, 54 ErrorResult& aRv); 55 56 void WriteTexture(const dom::GPUTexelCopyTextureInfo& aDestination, 57 const dom::AllowSharedBufferSource& data, 58 const dom::GPUTexelCopyBufferLayout& aDataLayout, 59 const dom::GPUExtent3D& aSize, ErrorResult& aRv); 60 61 void CopyExternalImageToTexture( 62 const dom::GPUCopyExternalImageSourceInfo& aSource, 63 const dom::GPUCopyExternalImageDestInfo& aDestination, 64 const dom::GPUExtent3D& aCopySize, ErrorResult& aRv); 65 66 private: 67 virtual ~Queue(); 68 69 // Index to use for the next submission containing external textures. Used to 70 // keep track of when work involving external textures is done. 71 uint64_t mNextExternalTextureSubmissionIndex = 1; 72 }; 73 74 } // namespace webgpu 75 } // namespace mozilla 76 77 #endif // GPU_Queue_H_