Loading...
Searching...
No Matches
bufferResource.h
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
40PXR_NAMESPACE_OPEN_SCOPE
41
42
43using HdStBufferResourceSharedPtr =
44 std::shared_ptr<class HdStBufferResource>;
45
46using HdStBufferResourceNamedPair =
47 std::pair<TfToken, HdStBufferResourceSharedPtr>;
48using HdStBufferResourceNamedList =
49 std::vector<HdStBufferResourceNamedPair>;
50
56{
57public:
58 HDST_API
59 HdStBufferResource(TfToken const &role,
60 HdTupleType tupleType,
61 int offset,
62 int stride);
63
64 HDST_API
66
68 TfToken const &GetRole() const { return _role; }
69
71 size_t GetSize() const { return _size; }
72
74 HdTupleType GetTupleType() const { return _tupleType; }
75
77 int GetOffset() const { return _offset; }
78
80 int GetStride() const { return _stride; }
81
83 HDST_API
84 void SetAllocation(HgiBufferHandle const &handle, size_t size);
85
87 HgiBufferHandle &GetHandle() { return _handle; }
88
89private:
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
103PXR_NAMESPACE_CLOSE_SCOPE
104
105#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:88
HdTupleType represents zero, one, or more values of the same HdType.
Definition: types.h:358
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...