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/imaging/hgi/api.h"
30 #include "pxr/imaging/hgi/buffer.h"
31 #include "pxr/imaging/hgi/enums.h"
33 #include "pxr/imaging/hgi/types.h"
34 
35 #include <stddef.h>
36 
38 
39 
40 //// \struct HgiTextureGpuToCpuOp
41 ///
42 /// Describes the properties needed to copy texture data from GPU to CPU.
43 /// This copies one mip at a time.
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 ///
51 /// <ul>
52 /// <li>gpuSourceTexture:
53 /// The gpu texture to copy pixels from.</li>
54 /// <li>sourceTexelOffset:
55 /// The texel offset (width, height, depth) of where to start copying.
56 /// If the texture is a 2d_array the third element is the layer/slice.</li>
57 /// <li>mipLevel:
58 /// Mip level to copy from.</li>
59 /// <li>cpuDestinationBuffer:
60 /// The copy destination cpu buffer.</li>
61 /// <li>destinationByteOffset:
62 /// The byte offset in destination buffer where to start copying the data to.</li>
63 /// <li>destinationBufferByteSize:
64 /// Size of the destination buffer (in bytes)</li>
65 /// </ul>
66 ///
68 {
72  , mipLevel(0)
73  , cpuDestinationBuffer(nullptr)
76  {}
77 
80  uint32_t mipLevel;
84 };
85 
86 //// \struct HgiTextureCpuToGpuOp
87 ///
88 /// Describes the properties needed to copy texture data from CPU to GPU.
89 /// This uploads one mip at a time.
90 ///
91 /// It is the responsibility of the caller to:
92 /// - ensure the destination textures is large enough to receive the data.
93 /// - ensure the source buffer and destination texture are valid at the time
94 /// the command is executed.
95 ///
96 /// <ul>
97 /// <li>cpuSourceBuffer:
98 /// Pointer to CPU source (ie. texels) to copy the data from.</li>
99 /// <li>bufferByteSize:
100 /// Byte size (length) of cpuSourceBuffer.</li>
101 /// <li>destinationTexelOffset:
102 /// The texel offset (width, height, depth) of where to upload the data.
103 /// If the texture is a 2d_array the third element is the layer/slice.</li>
104 /// <li>mipLevel:
105 /// Mip level to upload into.</li>
106 /// <li>gpuDestinationTexture:
107 /// The GPU texture to upload the data into.</li>
108 /// </ul>
109 ///
111 {
113  : cpuSourceBuffer(nullptr)
114  , bufferByteSize(0)
116  , mipLevel(0)
118  {}
119 
120  void const* cpuSourceBuffer;
123  uint32_t mipLevel;
125 };
126 
127 //// \struct HgiBufferGpuToGpuOp
128 ///
129 /// Describes the properties needed to copy buffer data from GPU to GPU.
130 ///
131 /// It is the responsibility of the caller to:
132 /// - ensure the destination buffer is large enough to receive the data
133 /// (keep in mind the destinationByteOffset).
134 /// - ensure the source buffer and destination buffer are valid at the time
135 /// the command is executed.
136 ///
137 /// <ul>
138 /// <li>gpuSourceBuffer:
139 /// The gpu buffer to copy data from.</li>
140 /// <li>sourceByteOffset:
141 /// The byte offset in source buffer to start copying the data from.</li>
142 /// <li>byteSize:
143 /// Size of the data (in bytes) to copy</li>
144 /// <li>gpuDestinationBuffer:
145 /// The copy destination gpu buffer.</li>
146 /// <li>destinationByteOffset:
147 /// The byte offset in destination buffer where to start copying the data to.</li>
148 /// </ul>
149 ///
151 {
153  : gpuSourceBuffer()
154  , sourceByteOffset(0)
155  , byteSize(0)
158  {}
159 
162  size_t byteSize;
165 };
166 
167 
168 //// \struct HgiBufferCpuToGpuOp
169 ///
170 /// Describes the properties needed to copy buffer data from CPU to GPU.
171 ///
172 /// It is the responsibility of the caller to:
173 /// - ensure the destination buffer is large enough to receive the data.
174 /// - ensure the source buffer and destination buffer are valid at the time
175 /// the command is executed.
176 ///
177 /// <ul>
178 /// <li>cpuSourceBuffer:
179 /// Pointer to CPU source to copy the data from.</li>
180 /// <li>sourceByteOffset:
181 /// The byte location in cpuSourceBuffer where copying starts.</li>
182 /// <li>gpuDestinationBuffer:
183 /// The GPU buffer to copy the data into.</li>
184 /// <li>destinationByteOffset:
185 /// The byte location in gpuDestinationBuffer where copying starts.</li>
186 /// <li>byteSize:
187 /// The size in bytes to copy.</li>
188 /// </ul>
189 ///
191 {
193  : cpuSourceBuffer(nullptr)
194  , sourceByteOffset(0)
197  , byteSize(0)
198  {}
199 
200  void const* cpuSourceBuffer;
204  size_t byteSize;
205 };
206 
207 //// \struct HgiBufferGpuToCpuOp
208 ///
209 /// Describes the properties needed to copy buffer data from GPU to CPU.
210 ///
211 /// It is the responsibility of the caller to:
212 /// - ensure the destination buffer is large enough to receive the data
213 /// (keep in mind the destinationByteOffset).
214 /// - ensure the source buffer and destination buffer are valid at the time
215 /// the command is executed.
216 ///
217 /// <ul>
218 /// <li>gpuSourceBuffer:
219 /// The gpu buffer to copy data from.</li>
220 /// <li>sourceByteOffset:
221 /// The byte offset in source buffer to start copying the data from.</li>
222 /// <li>byteSize:
223 /// Size of the data (in bytes) to copy</li>
224 /// <li>cpuDestinationBuffer:
225 /// The copy destination cpu buffer.</li>
226 /// <li>destinationByteOffset:
227 /// The byte offset in destination buffer where to start copying the data to.</li>
228 /// </ul>
229 ///
231 {
233  : gpuSourceBuffer()
234  , sourceByteOffset(0)
235  , byteSize(0)
238  {}
239 
242  size_t byteSize;
245 };
246 
247 //// \struct HgiTextureToBufferOp
248 ///
249 /// Describes the properties needed to copy GPU texture data into a GPU buffer.
250 ///
251 /// It is the responsibility of the caller to:
252 /// - ensure the destination buffer is large enough to receive the data
253 /// (keep in mind the destinationByteOffset).
254 /// - ensure the source texture and destination buffer are valid at the time
255 /// the command is executed.
256 ///
257 /// <ul>
258 /// <li>gpuSourceTexture:
259 /// The gpu texture to copy pixels from.</li>
260 /// <li>mipLevel:
261 /// Mip level to copy from.</li>
262 /// <li>gpuDestinationBuffer:
263 /// The GPU buffer to copy the data into.</li>
264 /// <li>destinationByteOffset:
265 /// The byte offset in destination buffer where to start copying the data to.</li>
266 /// <li>byteSize:
267 /// Size of the data (in bytes) to copy</li>
268 /// </ul>
269 ///
271 {
273  : gpuSourceTexture()
275  , mipLevel(0)
278  , byteSize(0)
279  {}
280 
283  uint32_t mipLevel;
286  size_t byteSize;
287 };
288 
289 //// \struct HgiBufferToTextureOp
290 ///
291 /// Describes the properties needed to copy GPU buffer data into a GPU texture.
292 ///
293 /// It is the responsibility of the caller to:
294 /// - ensure the destination textures is large enough to receive the data.
295 /// - ensure the source buffer and destination texture are valid at the time
296 /// the command is executed.
297 ///
298 /// <ul>
299 /// <li>gpuSourceBuffer:
300 /// The gpu buffer to copy data from.</li>
301 /// <li>sourceByteOffset:
302 /// The byte offset in source buffer to start copying the data from.</li>
303 /// <li>gpuDestinationTexture:
304 /// The GPU texture to upload the data into.</li>
305 /// <li>destinationTexelOffset:
306 /// The texel offset (width, height, depth) of where to upload the data.
307 /// If the texture is a 2d_array the third element is the layer/slice.</li>
308 /// <li>mipLevel:
309 /// Mip level to upload into.</li>
310 /// <li>byteSize:
311 /// Size of the data (in bytes) to copy</li>
312 /// </ul>
313 ///
315 {
317  : gpuSourceBuffer()
318  , sourceByteOffset(0)
321  , mipLevel(0)
322  , byteSize(0)
323  {}
324 
329  uint32_t mipLevel;
330  size_t byteSize;
331 
332 };
333 
335 
336 #endif
size_t destinationByteOffset
Definition: blitCmdsOps.h:164
HgiBufferHandle gpuSourceBuffer
Definition: blitCmdsOps.h:240
GfVec3i sourceTexelOffset
Definition: blitCmdsOps.h:79
int HgiHandle< class HgiTexture > HgiTextureHandle
void const * cpuSourceBuffer
Definition: blitCmdsOps.h:120
HgiTextureHandle gpuDestinationTexture
Definition: blitCmdsOps.h:124
HgiBufferHandle gpuDestinationBuffer
Definition: blitCmdsOps.h:202
HgiBufferHandle gpuSourceBuffer
Definition: blitCmdsOps.h:160
GfVec3i destinationTexelOffset
Definition: blitCmdsOps.h:122
void const * cpuSourceBuffer
Definition: blitCmdsOps.h:200
Definition: vec3i.h:60
void * cpuDestinationBuffer
Definition: blitCmdsOps.h:243
GfVec3i destinationTexelOffset
Definition: blitCmdsOps.h:328
HgiBufferHandle gpuDestinationBuffer
Definition: blitCmdsOps.h:163
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
size_t destinationByteOffset
Definition: blitCmdsOps.h:82
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
size_t destinationBufferByteSize
Definition: blitCmdsOps.h:83
HgiBufferHandle gpuSourceBuffer
Definition: blitCmdsOps.h:325
HgiTextureHandle gpuDestinationTexture
Definition: blitCmdsOps.h:327
void * cpuDestinationBuffer
Definition: blitCmdsOps.h:81
size_t destinationByteOffset
Definition: blitCmdsOps.h:203
size_t destinationByteOffset
Definition: blitCmdsOps.h:244
HgiBufferHandle gpuDestinationBuffer
Definition: blitCmdsOps.h:284
HgiTextureHandle gpuSourceTexture
Definition: blitCmdsOps.h:78
size_t destinationByteOffset
Definition: blitCmdsOps.h:285
HgiTextureHandle gpuSourceTexture
Definition: blitCmdsOps.h:281