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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HGI_BLIT_CMDS_H
8 #define PXR_IMAGING_HGI_BLIT_CMDS_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hgi/api.h"
12 #include "pxr/imaging/hgi/buffer.h"
13 #include "pxr/imaging/hgi/cmds.h"
15 #include <memory>
16 
18 
21 struct HgiBufferGpuToGpuOp;
22 struct HgiBufferCpuToGpuOp;
23 struct HgiBufferGpuToCpuOp;
26 struct HgiResolveImageOp;
27 
28 using HgiBlitCmdsUniquePtr = std::unique_ptr<class HgiBlitCmds>;
29 
30 
31 /// \class HgiBlitCmds
32 ///
33 /// A graphics API independent abstraction of resource copy commands.
34 /// HgiBlitCmds is a lightweight object that cannot be re-used after it has
35 /// been submitted. A new cmds object should be acquired for each frame.
36 ///
37 class HgiBlitCmds : public HgiCmds
38 {
39 public:
40  HGI_API
41  ~HgiBlitCmds() override;
42 
43  /// Push a debug scope.
44  HGI_API
45  virtual void PushDebugGroup(const char* label,
46  const GfVec4f& color = s_blitDebugColor) = 0;
47 
48  /// Pop the lastest scope.
49  HGI_API
50  virtual void PopDebugGroup() = 0;
51 
52  /// Insert a debug marker
53  HGI_API
54  virtual void InsertDebugMarker(
55  const char* label,
56  const GfVec4f& color = s_markerDebugColor) = 0;
57 
58  /// Copy a texture resource from GPU to CPU.
59  /// Synchronization between GPU writes and CPU reads must be managed by
60  /// the client by supplying the correct 'wait' flags in SubmitCmds.
61  HGI_API
62  virtual void CopyTextureGpuToCpu(HgiTextureGpuToCpuOp const& copyOp) = 0;
63 
64  /// Copy new data from the CPU into a GPU texture.
65  HGI_API
66  virtual void CopyTextureCpuToGpu(HgiTextureCpuToGpuOp const& copyOp) = 0;
67 
68  /// Copy a buffer resource from GPU to GPU.
69  HGI_API
70  virtual void CopyBufferGpuToGpu(HgiBufferGpuToGpuOp const& copyOp) = 0;
71 
72  /// Copy new data from CPU into GPU buffer.
73  /// For example copy new data into a uniform block or storage buffer.
74  HGI_API
75  virtual void CopyBufferCpuToGpu(HgiBufferCpuToGpuOp const& copyOp) = 0;
76 
77  /// Copy new data from GPU into CPU buffer.
78  /// Synchronization between GPU writes and CPU reads must be managed by
79  /// the client by supplying the correct 'wait' flags in SubmitCmds.
80  HGI_API
81  virtual void CopyBufferGpuToCpu(HgiBufferGpuToCpuOp const& copyOp) = 0;
82 
83  /// Copy a texture resource into a buffer resource from GPU to GPU.
84  HGI_API
85  virtual void CopyTextureToBuffer(HgiTextureToBufferOp const& copyOp) = 0;
86 
87  /// Copy a buffer resource into a texture resource from GPU to GPU.
88  HGI_API
89  virtual void CopyBufferToTexture(HgiBufferToTextureOp const& copyOp) = 0;
90 
91  /// Generate mip maps for a texture
92  HGI_API
93  virtual void GenerateMipMaps(HgiTextureHandle const& texture) = 0;
94 
95  /// Fill a buffer with a constant value.
96  HGI_API
97  virtual void FillBuffer(HgiBufferHandle const& buffer, uint8_t value) = 0;
98 
99  /// Inserts a barrier so that data written to memory by commands before
100  /// the barrier is available to commands after the barrier.
101  HGI_API
102  virtual void InsertMemoryBarrier(HgiMemoryBarrier barrier) = 0;
103 
104 protected:
105  HGI_API
106  HgiBlitCmds();
107 
108 private:
109  HgiBlitCmds & operator=(const HgiBlitCmds&) = delete;
110  HgiBlitCmds(const HgiBlitCmds&) = delete;
111 };
112 
113 
114 
116 
117 #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.
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLfloat * value
Definition: glcorearb.h:824
virtual HGI_API void CopyBufferGpuToCpu(HgiBufferGpuToCpuOp const &copyOp)=0
int HgiHandle< class HgiTexture > HgiTextureHandle
virtual HGI_API void CopyTextureGpuToCpu(HgiTextureGpuToCpuOp const &copyOp)=0
GLuint buffer
Definition: glcorearb.h:660
virtual HGI_API void CopyTextureCpuToGpu(HgiTextureCpuToGpuOp const &copyOp)=0
Copy new data from the CPU into a GPU texture.
static constexpr GfVec4f s_blitDebugColor
Definition: cmds.h:59
virtual HGI_API void InsertMemoryBarrier(HgiMemoryBarrier barrier)=0
virtual HGI_API void InsertDebugMarker(const char *label, const GfVec4f &color=s_markerDebugColor)=0
Insert a debug marker.
virtual HGI_API void GenerateMipMaps(HgiTextureHandle const &texture)=0
Generate mip maps for a texture.
HgiBits HgiMemoryBarrier
Definition: enums.h:679
HGI_API ~HgiBlitCmds() override
static constexpr GfVec4f s_markerDebugColor
Definition: cmds.h:61
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.
Definition: vec4f.h:45
std::unique_ptr< class HgiBlitCmds > HgiBlitCmdsUniquePtr
Definition: blitCmds.h:28
#define HGI_API
Definition: api.h:23
GLuint color
Definition: glcorearb.h:1261
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
GLuint texture
Definition: glcorearb.h:415
virtual HGI_API void PushDebugGroup(const char *label, const GfVec4f &color=s_blitDebugColor)=0
Push a debug scope.
virtual HGI_API void CopyBufferCpuToGpu(HgiBufferCpuToGpuOp const &copyOp)=0
Definition: cmds.h:28
virtual HGI_API void PopDebugGroup()=0
Pop the lastest scope.