Loading...
Searching...
No Matches
texture.h
1//
2// Copyright 2019 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_HGI_TEXTURE_H
8#define PXR_IMAGING_HGI_TEXTURE_H
9
10#include "pxr/pxr.h"
11#include "pxr/base/gf/vec3i.h"
12#include "pxr/imaging/hgi/api.h"
13#include "pxr/imaging/hgi/enums.h"
14#include "pxr/imaging/hgi/handle.h"
15#include "pxr/imaging/hgi/types.h"
16
17#include <string>
18#include <vector>
19
20PXR_NAMESPACE_OPEN_SCOPE
21
38{
39 HgiComponentSwizzle r;
40 HgiComponentSwizzle g;
41 HgiComponentSwizzle b;
42 HgiComponentSwizzle a;
43};
44
45HGI_API
46bool operator==(
47 const HgiComponentMapping& lhs,
48 const HgiComponentMapping& rhs);
49
50HGI_API
51bool operator!=(
52 const HgiComponentMapping& lhs,
53 const HgiComponentMapping& rhs);
54
91{
93 : usage(0)
94 , format(HgiFormatInvalid)
95 , componentMapping{
96 HgiComponentSwizzleR,
97 HgiComponentSwizzleG,
98 HgiComponentSwizzleB,
99 HgiComponentSwizzleA}
100 , type(HgiTextureType2D)
101 , dimensions(0)
102 , layerCount(1)
103 , mipLevels(1)
104 , sampleCount(HgiSampleCount1)
105 , pixelsByteSize(0)
106 , initialData(nullptr)
107 {}
108
109 std::string debugName;
110 HgiTextureUsage usage;
111 HgiFormat format;
112 HgiComponentMapping componentMapping;
113 HgiTextureType type;
114 GfVec3i dimensions;
115 uint16_t layerCount;
116 uint16_t mipLevels;
117 HgiSampleCount sampleCount;
118 size_t pixelsByteSize;
119 void const* initialData;
120};
121
122HGI_API
123bool operator==(
124 const HgiTextureDesc& lhs,
125 const HgiTextureDesc& rhs);
126
127HGI_API
128bool operator!=(
129 const HgiTextureDesc& lhs,
130 const HgiTextureDesc& rhs);
131
132
144{
145public:
146 HGI_API
147 virtual ~HgiTexture();
148
150 HGI_API
152
155 HGI_API
156 virtual size_t GetByteSizeOfResource() const = 0;
157
169 HGI_API
170 virtual uint64_t GetRawResource() const = 0;
171
176 HGI_API
177 virtual HgiTextureUsage SubmitLayoutChange(HgiTextureUsage newLayout) = 0;
178
179protected:
180 HGI_API
181 static
182 size_t _GetByteSizeOfResource(const HgiTextureDesc &descriptor);
183
184 HGI_API
185 HgiTexture(HgiTextureDesc const& desc);
186
187 HgiTextureDesc _descriptor;
188
189private:
190 HgiTexture() = delete;
191 HgiTexture & operator=(const HgiTexture&) = delete;
192 HgiTexture(const HgiTexture&) = delete;
193};
194
195
197using HgiTextureHandleVector = std::vector<HgiTextureHandle>;
198
199
229{
231 : format(HgiFormatInvalid)
232 , layerCount(1)
233 , mipLevels(1)
234 , sourceTexture()
235 , sourceFirstLayer(0)
236 , sourceFirstMip(0)
237 {}
238
239 std::string debugName;
240 HgiFormat format;
241 uint16_t layerCount;
242 uint16_t mipLevels;
243 HgiTextureHandle sourceTexture;
244 uint16_t sourceFirstLayer;
245 uint16_t sourceFirstMip;
246};
247
248HGI_API
249bool operator==(
250 const HgiTextureViewDesc& lhs,
251 const HgiTextureViewDesc& rhs);
252
253HGI_API
254bool operator!=(
255 const HgiTextureViewDesc& lhs,
256 const HgiTextureViewDesc& rhs);
257
277{
278public:
279 HGI_API
281
282 HGI_API
283 virtual ~HgiTextureView();
284
286 HGI_API
287 void SetViewTexture(HgiTextureHandle const& handle);
288
290 HGI_API
292
293protected:
294 HgiTextureHandle _viewTexture;
295
296private:
297 HgiTextureView() = delete;
298 HgiTextureView & operator=(const HgiTextureView&) = delete;
299 HgiTextureView(const HgiTextureView&) = delete;
300};
301
303using HgiTextureViewHandleVector = std::vector<HgiTextureViewHandle>;
304
305PXR_NAMESPACE_CLOSE_SCOPE
306
307#endif
Basic type for a vector of 3 int components.
Definition: vec3i.h:44
Represents a graphics platform independent GPU texture resource.
Definition: texture.h:144
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.
HGI_API HgiTextureDesc const & GetDescriptor() const
The descriptor describes the object.
virtual HGI_API size_t GetByteSizeOfResource() const =0
Returns the byte size of the GPU texture.
virtual HGI_API HgiTextureUsage SubmitLayoutChange(HgiTextureUsage newLayout)=0
This function initiates a layout change process on this texture resource.
Represents a graphics platform independent GPU texture view resource.
Definition: texture.h:277
HGI_API void SetViewTexture(HgiTextureHandle const &handle)
Set the handle to the texture that aliases another texture.
HGI_API HgiTextureHandle const & GetViewTexture() const
Returns the handle to the texture that aliases another texture.
Describes color component mapping.
Definition: texture.h:38
Describes the properties needed to create a GPU texture.
Definition: texture.h:91
Describes the properties needed to create a GPU texture view from an existing GPU texture object.
Definition: texture.h:229