Loading...
Searching...
No Matches
stagingBuffer.h
1//
2// Copyright 2021 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_HD_ST_STAGING_BUFFER_H
8#define PXR_IMAGING_HD_ST_STAGING_BUFFER_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hdSt/api.h"
12
13#include "pxr/imaging/hgi/blitCmdsOps.h"
14#include "pxr/imaging/hgi/buffer.h"
15
16#include <memory>
17#include <vector>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
22
23using HdStStagingBufferSharedPtr =
24 std::shared_ptr<class HdStStagingBuffer>;
25
33{
34public:
35 HDST_API
36 HdStStagingBuffer(HdStResourceRegistry *resourceRegistry);
37
38 HDST_API
40
42 HDST_API
43 void Deallocate();
44
49 HDST_API
50 void Resize(size_t totalSize);
51
55 HDST_API
56 void StageCopy(HgiBufferCpuToGpuOp const &copyOp);
57
60 HDST_API
61 void Flush();
62
63private:
64 static constexpr int32_t MULTIBUFFERING = 3;
65
66 HdStResourceRegistry *_resourceRegistry;
67 HgiBufferHandle _handles[MULTIBUFFERING];
68 std::vector<HgiBufferGpuToGpuOp> _gpuCopyOps;
69 size_t _head;
70 size_t _capacity;
71 size_t _activeSlot;
72 bool _isUma;
73};
74
75PXR_NAMESPACE_CLOSE_SCOPE
76
77#endif // PXR_IMAGING_HD_ST_STAGING_BUFFER_H
A central registry of all GPU resources.
Provides a staging buffer for CPU writes of triple-buffered resources.
Definition: stagingBuffer.h:33
HDST_API void StageCopy(HgiBufferCpuToGpuOp const &copyOp)
Submit a CPU to GPU copy operation to be added to the staging buffer.
HDST_API void Resize(size_t totalSize)
Set the capacity for the staging buffer.
HDST_API void Flush()
Flush the queued GPU to GPU blits from the calls to StageCopy.
HDST_API void Deallocate()
Destroys contained HgiBuffers and resets state to empty.
Describes the properties needed to copy buffer data from CPU to GPU.
Definition: blitCmdsOps.h:174