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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HGI_BLIT_CMDS_OPS_H
8 #define PXR_IMAGING_HGI_BLIT_CMDS_OPS_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/base/gf/vec3i.h"
12 #include "pxr/imaging/hgi/api.h"
13 #include "pxr/imaging/hgi/buffer.h"
14 #include "pxr/imaging/hgi/enums.h"
16 #include "pxr/imaging/hgi/types.h"
17 
18 #include <stddef.h>
19 
21 
22 
23 //// \struct HgiTextureGpuToCpuOp
24 ///
25 /// Describes the properties needed to copy texture data from GPU to CPU.
26 /// This copies one mip at a time.
27 ///
28 /// It is the responsibility of the caller to:
29 /// - ensure the destination buffer is large enough to receive the data
30 /// (keep in mind the destinationByteOffset, mipLevel, numLayers, etc).
31 /// - ensure the source texture and destination buffer are valid at the time
32 /// the command is executed.
33 ///
34 /// <ul>
35 /// <li>gpuSourceTexture:
36 /// The gpu texture to copy pixels from.</li>
37 /// <li>sourceTexelOffset:
38 /// The texel offset (width, height, depth) of where to start copying.
39 /// If the texture is a 2d_array the third element is the layer/slice.</li>
40 /// <li>mipLevel:
41 /// Mip level to copy from.</li>
42 /// <li>cpuDestinationBuffer:
43 /// The copy destination cpu buffer.</li>
44 /// <li>destinationByteOffset:
45 /// The byte offset in destination buffer where to start copying the data to.</li>
46 /// <li>destinationBufferByteSize:
47 /// Size of the destination buffer (in bytes)</li>
48 /// </ul>
49 ///
51 {
55  , mipLevel(0)
56  , cpuDestinationBuffer(nullptr)
59  {}
60 
63  uint32_t mipLevel;
67 };
68 
69 //// \struct HgiTextureCpuToGpuOp
70 ///
71 /// Describes the properties needed to copy texture data from CPU to GPU.
72 /// This uploads one mip at a time.
73 ///
74 /// It is the responsibility of the caller to:
75 /// - ensure the destination textures is large enough to receive the data.
76 /// - ensure the source buffer and destination texture are valid at the time
77 /// the command is executed.
78 ///
79 /// <ul>
80 /// <li>cpuSourceBuffer:
81 /// Pointer to CPU source (ie. texels) to copy the data from.</li>
82 /// <li>bufferByteSize:
83 /// Byte size (length) of cpuSourceBuffer.</li>
84 /// <li>destinationTexelOffset:
85 /// The texel offset (width, height, depth) of where to upload the data.
86 /// If the texture is a 2d_array the third element is the layer/slice.</li>
87 /// <li>mipLevel:
88 /// Mip level to upload into.</li>
89 /// <li>gpuDestinationTexture:
90 /// The GPU texture to upload the data into.</li>
91 /// </ul>
92 ///
94 {
96  : cpuSourceBuffer(nullptr)
97  , bufferByteSize(0)
99  , mipLevel(0)
101  {}
102 
103  void const* cpuSourceBuffer;
106  uint32_t mipLevel;
108 };
109 
110 //// \struct HgiBufferGpuToGpuOp
111 ///
112 /// Describes the properties needed to copy buffer data from GPU to GPU.
113 ///
114 /// It is the responsibility of the caller to:
115 /// - ensure the destination buffer is large enough to receive the data
116 /// (keep in mind the destinationByteOffset).
117 /// - ensure the source buffer and destination buffer are valid at the time
118 /// the command is executed.
119 ///
120 /// <ul>
121 /// <li>gpuSourceBuffer:
122 /// The gpu buffer to copy data from.</li>
123 /// <li>sourceByteOffset:
124 /// The byte offset in source buffer to start copying the data from.</li>
125 /// <li>byteSize:
126 /// Size of the data (in bytes) to copy</li>
127 /// <li>gpuDestinationBuffer:
128 /// The copy destination gpu buffer.</li>
129 /// <li>destinationByteOffset:
130 /// The byte offset in destination buffer where to start copying the data to.</li>
131 /// </ul>
132 ///
134 {
136  : gpuSourceBuffer()
137  , sourceByteOffset(0)
138  , byteSize(0)
141  {}
142 
145  size_t byteSize;
148 };
149 
150 
151 //// \struct HgiBufferCpuToGpuOp
152 ///
153 /// Describes the properties needed to copy buffer data from CPU to GPU.
154 ///
155 /// It is the responsibility of the caller to:
156 /// - ensure the destination buffer is large enough to receive the data.
157 /// - ensure the source buffer and destination buffer are valid at the time
158 /// the command is executed.
159 ///
160 /// <ul>
161 /// <li>cpuSourceBuffer:
162 /// Pointer to CPU source to copy the data from.</li>
163 /// <li>sourceByteOffset:
164 /// The byte location in cpuSourceBuffer where copying starts.</li>
165 /// <li>gpuDestinationBuffer:
166 /// The GPU buffer to copy the data into.</li>
167 /// <li>destinationByteOffset:
168 /// The byte location in gpuDestinationBuffer where copying starts.</li>
169 /// <li>byteSize:
170 /// The size in bytes to copy.</li>
171 /// </ul>
172 ///
174 {
176  : cpuSourceBuffer(nullptr)
177  , sourceByteOffset(0)
180  , byteSize(0)
181  {}
182 
183  void const* cpuSourceBuffer;
187  size_t byteSize;
188 };
189 
190 //// \struct HgiBufferGpuToCpuOp
191 ///
192 /// Describes the properties needed to copy buffer data from GPU to CPU.
193 ///
194 /// It is the responsibility of the caller to:
195 /// - ensure the destination buffer is large enough to receive the data
196 /// (keep in mind the destinationByteOffset).
197 /// - ensure the source buffer and destination buffer are valid at the time
198 /// the command is executed.
199 ///
200 /// <ul>
201 /// <li>gpuSourceBuffer:
202 /// The gpu buffer to copy data from.</li>
203 /// <li>sourceByteOffset:
204 /// The byte offset in source buffer to start copying the data from.</li>
205 /// <li>byteSize:
206 /// Size of the data (in bytes) to copy</li>
207 /// <li>cpuDestinationBuffer:
208 /// The copy destination cpu buffer.</li>
209 /// <li>destinationByteOffset:
210 /// The byte offset in destination buffer where to start copying the data to.</li>
211 /// </ul>
212 ///
214 {
216  : gpuSourceBuffer()
217  , sourceByteOffset(0)
218  , byteSize(0)
221  {}
222 
225  size_t byteSize;
228 };
229 
230 //// \struct HgiTextureToBufferOp
231 ///
232 /// Describes the properties needed to copy GPU texture data into a GPU buffer.
233 ///
234 /// It is the responsibility of the caller to:
235 /// - ensure the destination buffer is large enough to receive the data
236 /// (keep in mind the destinationByteOffset).
237 /// - ensure the source texture and destination buffer are valid at the time
238 /// the command is executed.
239 ///
240 /// <ul>
241 /// <li>gpuSourceTexture:
242 /// The gpu texture to copy pixels from.</li>
243 /// <li>mipLevel:
244 /// Mip level to copy from.</li>
245 /// <li>gpuDestinationBuffer:
246 /// The GPU buffer to copy the data into.</li>
247 /// <li>destinationByteOffset:
248 /// The byte offset in destination buffer where to start copying the data to.</li>
249 /// <li>byteSize:
250 /// Size of the data (in bytes) to copy</li>
251 /// </ul>
252 ///
254 {
256  : gpuSourceTexture()
258  , mipLevel(0)
261  , byteSize(0)
262  {}
263 
266  uint32_t mipLevel;
269  size_t byteSize;
270 };
271 
272 //// \struct HgiBufferToTextureOp
273 ///
274 /// Describes the properties needed to copy GPU buffer data into a GPU texture.
275 ///
276 /// It is the responsibility of the caller to:
277 /// - ensure the destination textures is large enough to receive the data.
278 /// - ensure the source buffer and destination texture are valid at the time
279 /// the command is executed.
280 ///
281 /// <ul>
282 /// <li>gpuSourceBuffer:
283 /// The gpu buffer to copy data from.</li>
284 /// <li>sourceByteOffset:
285 /// The byte offset in source buffer to start copying the data from.</li>
286 /// <li>gpuDestinationTexture:
287 /// The GPU texture to upload the data into.</li>
288 /// <li>destinationTexelOffset:
289 /// The texel offset (width, height, depth) of where to upload the data.
290 /// If the texture is a 2d_array the third element is the layer/slice.</li>
291 /// <li>mipLevel:
292 /// Mip level to upload into.</li>
293 /// <li>byteSize:
294 /// Size of the data (in bytes) to copy</li>
295 /// </ul>
296 ///
298 {
300  : gpuSourceBuffer()
301  , sourceByteOffset(0)
304  , mipLevel(0)
305  , byteSize(0)
306  {}
307 
312  uint32_t mipLevel;
313  size_t byteSize;
314 
315 };
316 
318 
319 #endif
size_t destinationByteOffset
Definition: blitCmdsOps.h:147
HgiBufferHandle gpuSourceBuffer
Definition: blitCmdsOps.h:223
GfVec3i sourceTexelOffset
Definition: blitCmdsOps.h:62
int HgiHandle< class HgiTexture > HgiTextureHandle
void const * cpuSourceBuffer
Definition: blitCmdsOps.h:103
HgiTextureHandle gpuDestinationTexture
Definition: blitCmdsOps.h:107
HgiBufferHandle gpuDestinationBuffer
Definition: blitCmdsOps.h:185
HgiBufferHandle gpuSourceBuffer
Definition: blitCmdsOps.h:143
GfVec3i destinationTexelOffset
Definition: blitCmdsOps.h:105
void const * cpuSourceBuffer
Definition: blitCmdsOps.h:183
Definition: vec3i.h:43
void * cpuDestinationBuffer
Definition: blitCmdsOps.h:226
GfVec3i destinationTexelOffset
Definition: blitCmdsOps.h:311
HgiBufferHandle gpuDestinationBuffer
Definition: blitCmdsOps.h:146
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
size_t destinationByteOffset
Definition: blitCmdsOps.h:65
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
size_t destinationBufferByteSize
Definition: blitCmdsOps.h:66
HgiBufferHandle gpuSourceBuffer
Definition: blitCmdsOps.h:308
HgiTextureHandle gpuDestinationTexture
Definition: blitCmdsOps.h:310
void * cpuDestinationBuffer
Definition: blitCmdsOps.h:64
size_t destinationByteOffset
Definition: blitCmdsOps.h:186
size_t destinationByteOffset
Definition: blitCmdsOps.h:227
HgiBufferHandle gpuDestinationBuffer
Definition: blitCmdsOps.h:267
HgiTextureHandle gpuSourceTexture
Definition: blitCmdsOps.h:61
size_t destinationByteOffset
Definition: blitCmdsOps.h:268
HgiTextureHandle gpuSourceTexture
Definition: blitCmdsOps.h:264