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
192 HGI_API
193 virtual void SubmitLayoutChange(HgiTextureUsage newLayout) = 0;
194
195protected:
196 HGI_API
197 static
198 size_t _GetByteSizeOfResource(const HgiTextureDesc &descriptor);
199
200 HGI_API
201 HgiTexture(HgiTextureDesc const& desc);
202
203 HgiTextureDesc _descriptor;
204
205private:
206 HgiTexture() = delete;
207 HgiTexture & operator=(const HgiTexture&) = delete;
208 HgiTexture(const HgiTexture&) = delete;
209};
210
211
213using HgiTextureHandleVector = std::vector<HgiTextureHandle>;
214
215
245{
247 : format(HgiFormatInvalid)
248 , layerCount(1)
249 , mipLevels(1)
250 , sourceTexture()
251 , sourceFirstLayer(0)
252 , sourceFirstMip(0)
253 {}
254
255 std::string debugName;
256 HgiFormat format;
257 uint16_t layerCount;
258 uint16_t mipLevels;
259 HgiTextureHandle sourceTexture;
260 uint16_t sourceFirstLayer;
261 uint16_t sourceFirstMip;
262};
263
264HGI_API
265bool operator==(
266 const HgiTextureViewDesc& lhs,
267 const HgiTextureViewDesc& rhs);
268
269HGI_API
270bool operator!=(
271 const HgiTextureViewDesc& lhs,
272 const HgiTextureViewDesc& rhs);
273
293{
294public:
295 HGI_API
297
298 HGI_API
299 virtual ~HgiTextureView();
300
302 HGI_API
303 void SetViewTexture(HgiTextureHandle const& handle);
304
306 HGI_API
308
309protected:
310 HgiTextureHandle _viewTexture;
311
312private:
313 HgiTextureView() = delete;
314 HgiTextureView & operator=(const HgiTextureView&) = delete;
315 HgiTextureView(const HgiTextureView&) = delete;
316};
317
319using HgiTextureViewHandleVector = std::vector<HgiTextureViewHandle>;
320
321PXR_NAMESPACE_CLOSE_SCOPE
322
323#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 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:293
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:245