HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
blitCmdsOps.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_OPS_H
25 #define PXR_IMAGING_HGI_BLIT_CMDS_OPS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/base/gf/vec3i.h"
29 #include "pxr/base/gf/vec4i.h"
30 #include "pxr/imaging/hgi/api.h"
31 #include "pxr/imaging/hgi/buffer.h"
32 #include "pxr/imaging/hgi/enums.h"
34 #include "pxr/imaging/hgi/types.h"
35 
36 #include <stddef.h>
37 
39 
40 
41 //// \struct HgiTextureGpuToCpuOp
42 ///
43 /// Describes the properties needed to copy texture data from GPU to CPU.
44 ///
45 /// It is the responsibility of the caller to:
46 /// - ensure the destination buffer is large enough to receive the data
47 /// (keep in mind the destinationByteOffset, mipLevel, numLayers, etc).
48 /// - ensure the source texture and destination buffer are valid at the time
49 /// the command is executed.
50 /// - insert the appropriate barriers in the command buffer prior to
51 /// reading/writing to/from the resources.
52 ///
53 /// <ul>
54 /// <li>gpuSourceTexture:
55 /// The gpu texture to copy pixels from.</li>
56 /// <li>sourceTexelOffset:
57 /// The texel offset (width, height, depth) of where to start copying.</li>
58 /// <li>mipLevel:
59 /// Mip level to copy from.</li>
60 /// <li>startLayer:
61 /// The first layer to start copying from.</li>
62 /// <li>numLayers:
63 /// The number of layers to copy.</li>
64 /// <li>cpuDestinationBuffer:
65 /// The copy destination cpu buffer.</li>
66 /// <li>destinationByteOffset:
67 /// The byte offset in destination buffer where to start copying the data to.</li>
68 /// <li>destinationBufferByteSize:
69 /// Size of the destination buffer (in bytes)</li>
70 /// </ul>
71 ///
73 {
77  , mipLevel(0)
78  , startLayer(0)
79  , numLayers(1)
80  , cpuDestinationBuffer(nullptr)
83  {}
84 
87  uint32_t mipLevel;
88  uint32_t startLayer;
89  uint32_t numLayers;
93 };
94 
95 //// \struct HgiBufferGpuToGpuOp
96 ///
97 /// Describes the properties needed to copy buffer data from GPU to CPU.
98 ///
99 /// It is the responsibility of the caller to:
100 /// - ensure the destination buffer is large enough to receive the data
101 /// (keep in mind the destinationByteOffset).
102 /// - ensure the source buffer and destination buffer are valid at the time
103 /// the command is executed.
104 /// - insert the appropriate barriers in the command buffer prior to
105 /// reading/writing to/from the resources.
106 ///
107 /// <ul>
108 /// <li>gpuSourceBuffer:
109 /// The gpu buffer to copy pixels from.</li>
110 /// <li>sourceByteOffset:
111 /// The byte offset in source buffer to start copying the data from.</li>
112 /// <li>byteSize:
113 /// Size of the data (in bytes) to copy</li>
114 /// <li>gpuDestinationBuffer:
115 /// The copy destination cpu buffer.</li>
116 /// <li>destinationByteOffset:
117 /// The byte offset in destination buffer where to start copying the data to.</li>
118 /// </ul>
119 ///
121 {
123  : gpuSourceBuffer()
124  , sourceByteOffset(0)
125  , byteSize(0)
128  {}
129 
132  size_t byteSize;
135 };
136 
137 
138 //// \struct HgiBufferCpuToGpuOp
139 ///
140 /// Describes the properties needed to copy buffer data from CPU to GPU.
141 ///
142 /// It is the responsibility of the caller to:
143 /// - ensure the destination buffer is large enough to receive the data.
144 /// - ensure the source buffer and destination buffer are valid at the time
145 /// the command is executed.
146 /// - insert the appropriate barriers in the command buffer prior to
147 /// reading/writing to/from the resources.
148 ///
149 /// <ul>
150 /// <li>cpuSourceBuffer:
151 /// Pointer to CPU source to copy the data from.</li>
152 /// <li>sourceByteOffset:
153 /// The byte location in cpuSourceBuffer where copying starts.</li>
154 /// <li>gpuDestinationBuffer:
155 /// The GPU buffer to copy the data into.</li>
156 /// <li>destinationByteOffset:
157 /// The byte location in gpuDestinationBuffer where copying starts.</li>
158 /// <li>byteSize:
159 /// The size in bytes to copy.</li>
160 /// </ul>
161 ///
163 {
165  : cpuSourceBuffer(nullptr)
166  , sourceByteOffset(0)
169  , byteSize(0)
170  {}
171 
172  void const* cpuSourceBuffer;
176  size_t byteSize;
177 };
178 
179 
181 
182 #endif
size_t destinationByteOffset
Definition: blitCmdsOps.h:134
GfVec3i sourceTexelOffset
Definition: blitCmdsOps.h:86
HgiBufferHandle gpuDestinationBuffer
Definition: blitCmdsOps.h:174
HgiBufferHandle gpuSourceBuffer
Definition: blitCmdsOps.h:130
void const * cpuSourceBuffer
Definition: blitCmdsOps.h:172
Definition: vec3i.h:61
HgiBufferHandle gpuDestinationBuffer
Definition: blitCmdsOps.h:133
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
size_t destinationByteOffset
Definition: blitCmdsOps.h:91
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
size_t destinationBufferByteSize
Definition: blitCmdsOps.h:92
void * cpuDestinationBuffer
Definition: blitCmdsOps.h:90
size_t destinationByteOffset
Definition: blitCmdsOps.h:175
HgiTextureHandle gpuSourceTexture
Definition: blitCmdsOps.h:85