HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bufferResource.h
Go to the documentation of this file.
1 //
2 // Copyright 2017 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_HD_ST_BUFFER_RESOURCE_H
25 #define PXR_IMAGING_HD_ST_BUFFER_RESOURCE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 
30 #include "pxr/imaging/hd/types.h"
31 
32 #include "pxr/imaging/hgi/buffer.h"
33 
34 #include "pxr/base/tf/token.h"
35 
36 #include <memory>
37 #include <utility>
38 #include <vector>
39 
41 
42 
44  std::shared_ptr<class HdStBufferResource>;
45 
47  std::pair<TfToken, HdStBufferResourceSharedPtr>;
49  std::vector<HdStBufferResourceNamedPair>;
50 
51 /// \class HdStBufferResource
52 ///
53 /// A GPU resource contained within an underlying HgiBuffer.
54 ///
55 class HdStBufferResource final
56 {
57 public:
58  HDST_API
59  HdStBufferResource(TfToken const &role,
60  HdTupleType tupleType,
61  int offset,
62  int stride);
63 
64  HDST_API
66 
67  /// Returns the role of the data in this resource.
68  TfToken const &GetRole() const { return _role; }
69 
70  /// Returns the size (in bytes) of the data.
71  size_t GetSize() const { return _size; }
72 
73  /// Data type and count
74  HdTupleType GetTupleType() const { return _tupleType; }
75 
76  /// Returns the interleaved offset (in bytes) of the data.
77  int GetOffset() const { return _offset; }
78 
79  /// Returns the stride (in bytes) between data elements.
80  int GetStride() const { return _stride; }
81 
82  /// Sets the HgiBufferHandle for this resource and its size.
83  HDST_API
84  void SetAllocation(HgiBufferHandle const &handle, size_t size);
85 
86  /// Returns the HgiBufferHandle for this GPU resource.
87  HgiBufferHandle &GetHandle() { return _handle; }
88 
89 private:
90  HdStBufferResource(const HdStBufferResource &) = delete;
91  HdStBufferResource &operator=(const HdStBufferResource &) = delete;
92 
93  HgiBufferHandle _handle;
94  size_t _size;
95 
96  TfToken const _role;
97  HdTupleType const _tupleType;
98  int const _offset;
99  int const _stride;
100 };
101 
102 
104 
105 #endif // PXR_IMAGING_HD_ST_BUFFER_RESOURCE_H
TfToken const & GetRole() const
Returns the role of the data in this resource.
std::pair< TfToken, HdStBufferResourceSharedPtr > HdStBufferResourceNamedPair
std::vector< std::pair< TfToken, HdStBufferResourceSharedPtr > > HdStBufferResourceNamedList
HgiBufferHandle & GetHandle()
Returns the HgiBufferHandle for this GPU resource.
Definition: token.h:87
GLintptr offset
Definition: glcorearb.h:665
HDST_API HdStBufferResource(TfToken const &role, HdTupleType tupleType, int offset, int stride)
int GetStride() const
Returns the stride (in bytes) between data elements.
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:872
size_t GetSize() const
Returns the size (in bytes) of the data.
std::shared_ptr< class HdStBufferResource > HdStBufferResourceSharedPtr
GLsizeiptr size
Definition: glcorearb.h:664
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
int GetOffset() const
Returns the interleaved offset (in bytes) of the data.
#define HDST_API
Definition: api.h:40
HDST_API ~HdStBufferResource()
HDST_API void SetAllocation(HgiBufferHandle const &handle, size_t size)
Sets the HgiBufferHandle for this resource and its size.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HdTupleType GetTupleType() const
Data type and count.