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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_ST_BUFFER_RESOURCE_H
8 #define PXR_IMAGING_HD_ST_BUFFER_RESOURCE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
12 
13 #include "pxr/imaging/hd/types.h"
14 
15 #include "pxr/imaging/hgi/buffer.h"
16 
17 #include "pxr/base/tf/token.h"
18 
19 #include <memory>
20 #include <utility>
21 #include <vector>
22 
24 
25 
27  std::shared_ptr<class HdStBufferResource>;
28 
30  std::pair<TfToken, HdStBufferResourceSharedPtr>;
32  std::vector<HdStBufferResourceNamedPair>;
33 
34 /// \class HdStBufferResource
35 ///
36 /// A GPU resource contained within an underlying HgiBuffer.
37 ///
38 class HdStBufferResource final
39 {
40 public:
41  HDST_API
42  HdStBufferResource(TfToken const &role,
43  HdTupleType tupleType,
44  int offset,
45  int stride);
46 
47  HDST_API
49 
50  /// Returns the role of the data in this resource.
51  TfToken const &GetRole() const { return _role; }
52 
53  /// Returns the size (in bytes) of the data.
54  size_t GetSize() const { return _size; }
55 
56  /// Data type and count
57  HdTupleType GetTupleType() const { return _tupleType; }
58 
59  /// Returns the interleaved offset (in bytes) of the data.
60  int GetOffset() const { return _offset; }
61 
62  /// Returns the stride (in bytes) between data elements.
63  int GetStride() const { return _stride; }
64 
65  /// Sets the HgiBufferHandle for this resource and its size.
66  HDST_API
67  void SetAllocation(HgiBufferHandle const &handle, size_t size);
68 
69  /// Returns the HgiBufferHandle for this GPU resource.
70  HgiBufferHandle &GetHandle() { return _handle; }
71 
72 private:
73  HdStBufferResource(const HdStBufferResource &) = delete;
74  HdStBufferResource &operator=(const HdStBufferResource &) = delete;
75 
76  HgiBufferHandle _handle;
77  size_t _size;
78 
79  TfToken const _role;
80  HdTupleType const _tupleType;
81  int const _offset;
82  int const _stride;
83 };
84 
85 
87 
88 #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:70
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:1425
int GetOffset() const
Returns the interleaved offset (in bytes) of the data.
#define HDST_API
Definition: api.h:23
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:74
HdTupleType GetTupleType() const
Data type and count.