Loading...
Searching...
No Matches
bufferResource.h
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
23PXR_NAMESPACE_OPEN_SCOPE
24
25
26using HdStBufferResourceSharedPtr =
27 std::shared_ptr<class HdStBufferResource>;
28
29using HdStBufferResourceNamedPair =
30 std::pair<TfToken, HdStBufferResourceSharedPtr>;
31using HdStBufferResourceNamedList =
32 std::vector<HdStBufferResourceNamedPair>;
33
39{
40public:
41 HDST_API
42 HdStBufferResource(TfToken const &role,
43 HdTupleType tupleType,
44 int offset,
45 int stride);
46
47 HDST_API
49
51 TfToken const &GetRole() const { return _role; }
52
54 size_t GetSize() const { return _size; }
55
57 HdTupleType GetTupleType() const { return _tupleType; }
58
60 int GetOffset() const { return _offset; }
61
63 int GetStride() const { return _stride; }
64
66 HDST_API
67 void SetAllocation(HgiBufferHandle const &handle, size_t size);
68
70 HgiBufferHandle &GetHandle() { return _handle; }
71
72private:
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
86PXR_NAMESPACE_CLOSE_SCOPE
87
88#endif // PXR_IMAGING_HD_ST_BUFFER_RESOURCE_H
A GPU resource contained within an underlying HgiBuffer.
size_t GetSize() const
Returns the size (in bytes) of the data.
int GetOffset() const
Returns the interleaved offset (in bytes) of the data.
HdTupleType GetTupleType() const
Data type and count.
HgiBufferHandle & GetHandle()
Returns the HgiBufferHandle for this GPU resource.
HDST_API void SetAllocation(HgiBufferHandle const &handle, size_t size)
Sets the HgiBufferHandle for this resource and its size.
int GetStride() const
Returns the stride (in bytes) between data elements.
TfToken const & GetRole() const
Returns the role of the data in this resource.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
HdTupleType represents zero, one, or more values of the same HdType.
Definition: types.h:343
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...