HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
blitCmds.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HGI_BLIT_CMDS_H
25 #define PXR_IMAGING_HGI_BLIT_CMDS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hgi/api.h"
29 #include "pxr/imaging/hgi/buffer.h"
30 #include "pxr/imaging/hgi/cmds.h"
32 #include <memory>
33 
35 
38 struct HgiBufferGpuToGpuOp;
39 struct HgiBufferCpuToGpuOp;
40 struct HgiBufferGpuToCpuOp;
43 struct HgiResolveImageOp;
44 
45 using HgiBlitCmdsUniquePtr = std::unique_ptr<class HgiBlitCmds>;
46 
47 
48 /// \class HgiBlitCmds
49 ///
50 /// A graphics API independent abstraction of resource copy commands.
51 /// HgiBlitCmds is a lightweight object that cannot be re-used after it has
52 /// been submitted. A new cmds object should be acquired for each frame.
53 ///
54 class HgiBlitCmds : public HgiCmds
55 {
56 public:
57  HGI_API
58  ~HgiBlitCmds() override;
59 
60  /// Push a debug marker.
61  HGI_API
62  virtual void PushDebugGroup(const char* label) = 0;
63 
64  /// Pop the lastest debug.
65  HGI_API
66  virtual void PopDebugGroup() = 0;
67 
68  /// Copy a texture resource from GPU to CPU.
69  /// Synchronization between GPU writes and CPU reads must be managed by
70  /// the client by supplying the correct 'wait' flags in SubmitCmds.
71  HGI_API
72  virtual void CopyTextureGpuToCpu(HgiTextureGpuToCpuOp const& copyOp) = 0;
73 
74  /// Copy new data from the CPU into a GPU texture.
75  HGI_API
76  virtual void CopyTextureCpuToGpu(HgiTextureCpuToGpuOp const& copyOp) = 0;
77 
78  /// Copy a buffer resource from GPU to GPU.
79  HGI_API
80  virtual void CopyBufferGpuToGpu(HgiBufferGpuToGpuOp const& copyOp) = 0;
81 
82  /// Copy new data from CPU into GPU buffer.
83  /// For example copy new data into a uniform block or storage buffer.
84  HGI_API
85  virtual void CopyBufferCpuToGpu(HgiBufferCpuToGpuOp const& copyOp) = 0;
86 
87  /// Copy new data from GPU into CPU buffer.
88  /// Synchronization between GPU writes and CPU reads must be managed by
89  /// the client by supplying the correct 'wait' flags in SubmitCmds.
90  HGI_API
91  virtual void CopyBufferGpuToCpu(HgiBufferGpuToCpuOp const& copyOp) = 0;
92 
93  /// Copy a texture resource into a buffer resource from GPU to GPU.
94  HGI_API
95  virtual void CopyTextureToBuffer(HgiTextureToBufferOp const& copyOp) = 0;
96 
97  /// Copy a buffer resource into a texture resource from GPU to GPU.
98  HGI_API
99  virtual void CopyBufferToTexture(HgiBufferToTextureOp const& copyOp) = 0;
100 
101  /// Generate mip maps for a texture
102  HGI_API
103  virtual void GenerateMipMaps(HgiTextureHandle const& texture) = 0;
104 
105  /// Fill a buffer with a constant value.
106  HGI_API
107  virtual void FillBuffer(HgiBufferHandle const& buffer, uint8_t value) = 0;
108 
109  /// Inserts a barrier so that data written to memory by commands before
110  /// the barrier is available to commands after the barrier.
111  HGI_API
112  virtual void InsertMemoryBarrier(HgiMemoryBarrier barrier) = 0;
113 
114 protected:
115  HGI_API
116  HgiBlitCmds();
117 
118 private:
119  HgiBlitCmds & operator=(const HgiBlitCmds&) = delete;
120  HgiBlitCmds(const HgiBlitCmds&) = delete;
121 };
122 
123 
124 
126 
127 #endif
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
virtual HGI_API void CopyBufferToTexture(HgiBufferToTextureOp const &copyOp)=0
Copy a buffer resource into a texture resource from GPU to GPU.
virtual HGI_API void CopyTextureToBuffer(HgiTextureToBufferOp const &copyOp)=0
Copy a texture resource into a buffer resource from GPU to GPU.
virtual HGI_API void CopyBufferGpuToCpu(HgiBufferGpuToCpuOp const &copyOp)=0
int HgiHandle< class HgiTexture > HgiTextureHandle
virtual HGI_API void CopyTextureGpuToCpu(HgiTextureGpuToCpuOp const &copyOp)=0
virtual HGI_API void CopyTextureCpuToGpu(HgiTextureCpuToGpuOp const &copyOp)=0
Copy new data from the CPU into a GPU texture.
Definition: core.h:760
virtual HGI_API void InsertMemoryBarrier(HgiMemoryBarrier barrier)=0
virtual HGI_API void GenerateMipMaps(HgiTextureHandle const &texture)=0
Generate mip maps for a texture.
HgiBits HgiMemoryBarrier
Definition: enums.h:686
HGI_API ~HgiBlitCmds() override
virtual HGI_API void CopyBufferGpuToGpu(HgiBufferGpuToGpuOp const &copyOp)=0
Copy a buffer resource from GPU to GPU.
HGI_API HgiBlitCmds()
virtual HGI_API void FillBuffer(HgiBufferHandle const &buffer, uint8_t value)=0
Fill a buffer with a constant value.
std::unique_ptr< class HgiBlitCmds > HgiBlitCmdsUniquePtr
Definition: blitCmds.h:45
#define HGI_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
GLuint texture
Definition: glcorearb.h:415
virtual HGI_API void PushDebugGroup(const char *label)=0
Push a debug marker.
Definition: core.h:1131
virtual HGI_API void CopyBufferCpuToGpu(HgiBufferCpuToGpuOp const &copyOp)=0
Definition: cmds.h:44
virtual HGI_API void PopDebugGroup()=0
Pop the lastest debug.