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
175 HGI_API
176 virtual void SubmitLayoutChange(HgiTextureUsage newLayout) = 0;
177
178protected:
179 HGI_API
180 static
181 size_t _GetByteSizeOfResource(const HgiTextureDesc &descriptor);
182
183 HGI_API
184 HgiTexture(HgiTextureDesc const& desc);
185
186 HgiTextureDesc _descriptor;
187
188private:
189 HgiTexture() = delete;
190 HgiTexture & operator=(const HgiTexture&) = delete;
191 HgiTexture(const HgiTexture&) = delete;
192};
193
194
196using HgiTextureHandleVector = std::vector<HgiTextureHandle>;
197
198
228{
230 : format(HgiFormatInvalid)
231 , layerCount(1)
232 , mipLevels(1)
233 , sourceTexture()
234 , sourceFirstLayer(0)
235 , sourceFirstMip(0)
236 {}
237
238 std::string debugName;
239 HgiFormat format;
240 uint16_t layerCount;
241 uint16_t mipLevels;
242 HgiTextureHandle sourceTexture;
243 uint16_t sourceFirstLayer;
244 uint16_t sourceFirstMip;
245};
246
247HGI_API
248bool operator==(
249 const HgiTextureViewDesc& lhs,
250 const HgiTextureViewDesc& rhs);
251
252HGI_API
253bool operator!=(
254 const HgiTextureViewDesc& lhs,
255 const HgiTextureViewDesc& rhs);
256
276{
277public:
278 HGI_API
280
281 HGI_API
282 virtual ~HgiTextureView();
283
285 HGI_API
286 void SetViewTexture(HgiTextureHandle const& handle);
287
289 HGI_API
291
292protected:
293 HgiTextureHandle _viewTexture;
294
295private:
296 HgiTextureView() = delete;
297 HgiTextureView & operator=(const HgiTextureView&) = delete;
298 HgiTextureView(const HgiTextureView&) = delete;
299};
300
302using HgiTextureViewHandleVector = std::vector<HgiTextureViewHandle>;
303
304PXR_NAMESPACE_CLOSE_SCOPE
305
306#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 void SubmitLayoutChange(HgiTextureUsage newLayout)=0
This function initiates a layout change process on this texture resource.
virtual HGI_API size_t GetByteSizeOfResource() const =0
Returns the byte size of the GPU texture.
Represents a graphics platform independent GPU texture view resource.
Definition: texture.h:276
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:228