Loading...
Searching...
No Matches
texture.h
1//
2// Copyright 2019 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_TEXTURE_H
25#define PXR_IMAGING_HGI_TEXTURE_H
26
27#include "pxr/pxr.h"
28#include "pxr/base/gf/vec3i.h"
29#include "pxr/imaging/hgi/api.h"
30#include "pxr/imaging/hgi/enums.h"
31#include "pxr/imaging/hgi/handle.h"
32#include "pxr/imaging/hgi/types.h"
33
34#include <string>
35#include <vector>
36
37PXR_NAMESPACE_OPEN_SCOPE
38
55{
56 HgiComponentSwizzle r;
57 HgiComponentSwizzle g;
58 HgiComponentSwizzle b;
59 HgiComponentSwizzle a;
60};
61
62HGI_API
63bool operator==(
64 const HgiComponentMapping& lhs,
65 const HgiComponentMapping& rhs);
66
67HGI_API
68bool operator!=(
69 const HgiComponentMapping& lhs,
70 const HgiComponentMapping& rhs);
71
108{
110 : usage(0)
111 , format(HgiFormatInvalid)
112 , componentMapping{
113 HgiComponentSwizzleR,
114 HgiComponentSwizzleG,
115 HgiComponentSwizzleB,
116 HgiComponentSwizzleA}
117 , type(HgiTextureType2D)
118 , dimensions(0)
119 , layerCount(1)
120 , mipLevels(1)
121 , sampleCount(HgiSampleCount1)
122 , pixelsByteSize(0)
123 , initialData(nullptr)
124 {}
125
126 std::string debugName;
127 HgiTextureUsage usage;
128 HgiFormat format;
129 HgiComponentMapping componentMapping;
130 HgiTextureType type;
131 GfVec3i dimensions;
132 uint16_t layerCount;
133 uint16_t mipLevels;
134 HgiSampleCount sampleCount;
135 size_t pixelsByteSize;
136 void const* initialData;
137};
138
139HGI_API
140bool operator==(
141 const HgiTextureDesc& lhs,
142 const HgiTextureDesc& rhs);
143
144HGI_API
145bool operator!=(
146 const HgiTextureDesc& lhs,
147 const HgiTextureDesc& rhs);
148
149
161{
162public:
163 HGI_API
164 virtual ~HgiTexture();
165
167 HGI_API
169
172 HGI_API
173 virtual size_t GetByteSizeOfResource() const = 0;
174
186 HGI_API
187 virtual uint64_t GetRawResource() const = 0;
188
189protected:
190 HGI_API
191 static
192 size_t _GetByteSizeOfResource(const HgiTextureDesc &descriptor);
193
194 HGI_API
195 HgiTexture(HgiTextureDesc const& desc);
196
197 HgiTextureDesc _descriptor;
198
199private:
200 HgiTexture() = delete;
201 HgiTexture & operator=(const HgiTexture&) = delete;
202 HgiTexture(const HgiTexture&) = delete;
203};
204
205
207using HgiTextureHandleVector = std::vector<HgiTextureHandle>;
208
209
239{
241 : format(HgiFormatInvalid)
242 , layerCount(1)
243 , mipLevels(1)
244 , sourceTexture()
245 , sourceFirstLayer(0)
246 , sourceFirstMip(0)
247 {}
248
249 std::string debugName;
250 HgiFormat format;
251 uint16_t layerCount;
252 uint16_t mipLevels;
253 HgiTextureHandle sourceTexture;
254 uint16_t sourceFirstLayer;
255 uint16_t sourceFirstMip;
256};
257
258HGI_API
259bool operator==(
260 const HgiTextureViewDesc& lhs,
261 const HgiTextureViewDesc& rhs);
262
263HGI_API
264bool operator!=(
265 const HgiTextureViewDesc& lhs,
266 const HgiTextureViewDesc& rhs);
267
287{
288public:
289 HGI_API
291
292 HGI_API
293 virtual ~HgiTextureView();
294
296 HGI_API
297 void SetViewTexture(HgiTextureHandle const& handle);
298
300 HGI_API
302
303protected:
304 HgiTextureHandle _viewTexture;
305
306private:
307 HgiTextureView() = delete;
308 HgiTextureView & operator=(const HgiTextureView&) = delete;
309 HgiTextureView(const HgiTextureView&) = delete;
310};
311
313using HgiTextureViewHandleVector = std::vector<HgiTextureViewHandle>;
314
315PXR_NAMESPACE_CLOSE_SCOPE
316
317#endif
Basic type for a vector of 3 int components.
Definition: vec3i.h:61
Represents a graphics platform independent GPU texture resource.
Definition: texture.h:161
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.
Represents a graphics platform independent GPU texture view resource.
Definition: texture.h:287
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:55
Describes the properties needed to create a GPU texture.
Definition: texture.h:108
Describes the properties needed to create a GPU texture view from an existing GPU texture object.
Definition: texture.h:239