Loading...
Searching...
No Matches
buffer.h
1//
2// Copyright 2020 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_HGI_BUFFER_H
25#define PXR_IMAGING_HGI_BUFFER_H
26
27#include <string>
28#include <vector>
29
30#include "pxr/pxr.h"
31#include "pxr/base/gf/vec3i.h"
32#include "pxr/imaging/hgi/api.h"
33#include "pxr/imaging/hgi/enums.h"
34#include "pxr/imaging/hgi/handle.h"
35#include "pxr/imaging/hgi/types.h"
36
37
38PXR_NAMESPACE_OPEN_SCOPE
39
40
63{
64 HGI_API
66 : usage(HgiBufferUsageUniform)
67 , byteSize(0)
68 , vertexStride(0)
69 , initialData(nullptr)
70 {}
71
72 std::string debugName;
73 HgiBufferUsage usage;
74 size_t byteSize;
75 uint32_t vertexStride;
76 void const* initialData;
77};
78
79HGI_API
80bool operator==(
81 const HgiBufferDesc& lhs,
82 const HgiBufferDesc& rhs);
83
84HGI_API
85inline bool operator!=(
86 const HgiBufferDesc& lhs,
87 const HgiBufferDesc& rhs);
88
89
99{
100public:
101 HGI_API
102 virtual ~HgiBuffer();
103
105 HGI_API
107
110 HGI_API
111 virtual size_t GetByteSizeOfResource() const = 0;
112
124 HGI_API
125 virtual uint64_t GetRawResource() const = 0;
126
136 HGI_API
137 virtual void* GetCPUStagingAddress() = 0;
138
139protected:
140 HGI_API
141 HgiBuffer(HgiBufferDesc const& desc);
142
143 HgiBufferDesc _descriptor;
144
145private:
146 HgiBuffer() = delete;
147 HgiBuffer & operator=(const HgiBuffer&) = delete;
148 HgiBuffer(const HgiBuffer&) = delete;
149};
150
152using HgiBufferHandleVector = std::vector<HgiBufferHandle>;
153
154
155PXR_NAMESPACE_CLOSE_SCOPE
156
157#endif
Represents a graphics platform independent GPU buffer resource (base class).
Definition: buffer.h:99
virtual HGI_API uint64_t GetRawResource() const =0
This function returns the handle to the Hgi backend's gpu resource, cast to a uint64_t.
virtual HGI_API void * GetCPUStagingAddress()=0
Returns the 'staging area' in which new buffer data is copied before it is flushed to GPU.
HGI_API HgiBufferDesc const & GetDescriptor() const
The descriptor describes the object.
virtual HGI_API size_t GetByteSizeOfResource() const =0
Returns the byte size of the GPU buffer.
Describes the properties needed to create a GPU buffer.
Definition: buffer.h:63