HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
udimTextureObject.h
Go to the documentation of this file.
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_HD_ST_UDIM_TEXTURE_OBJECT_H
25 #define PXR_IMAGING_HD_ST_UDIM_TEXTURE_OBJECT_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 
31 
32 #include "pxr/imaging/hgi/handle.h"
33 
34 #include "pxr/base/gf/vec3i.h"
35 
37 
38 enum HgiFormat : int;
40 
41 /// Returns true if the file given by \p imageFilePath represents a udim file,
42 /// and false otherwise.
43 ///
44 /// This function simply checks the existence of the <udim> tag in the
45 /// file name and does not otherwise guarantee that
46 /// the file is in any way valid for reading.
47 ///
48 HDST_API bool HdStIsSupportedUdimTexture(std::string const& imageFilePath);
49 
50 /// \class HdStUdimTextureObject
51 ///
52 /// A UDIM texture.
53 ///
55 {
56 public:
57  HDST_API
59  const HdStTextureIdentifier &textureId,
60  HdSt_TextureObjectRegistry *textureObjectRegistry);
61 
62  HDST_API
63  ~HdStUdimTextureObject() override;
64 
65  /// Get the gpu texture name for the texels
66  ///
67  /// Only valid after commit phase.
68  ///
69  HgiTextureHandle const& GetTexelTexture() const { return _texelTexture; }
70 
71  /// Get the gpu texture name for the layout
72  ///
73  /// Only valid after commit phase.
74  ///
75  HgiTextureHandle const& GetLayoutTexture() const { return _layoutTexture; }
76 
77  HDST_API
78  bool IsValid() const override;
79 
80  HDST_API
81  HdTextureType GetTextureType() const override;
82 
83 protected:
84  HDST_API
85  void _Load() override;
86 
87  HDST_API
88  void _Commit() override;
89 
90 private:
91  std::vector<uint8_t> _textureData;
92  std::vector<float> _layoutData;
93 
94  GfVec3i _dimensions;
95  size_t _tileCount;
96  size_t _mipCount;
97  HgiFormat _hgiFormat;
98 
99  HgiTextureHandle _texelTexture;
100  HgiTextureHandle _layoutTexture;
101 
102  void _DestroyTextures();
103 };
104 
105 template<>
108 };
109 
111 
112 #endif
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
HgiTextureHandle const & GetLayoutTexture() const
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
HDST_API bool IsValid() const override
int HgiHandle< class HgiTexture > HgiTextureHandle
HgiFormat
Definition: types.h:45
HdTextureType
Definition: enums.h:221
Definition: vec3i.h:60
HDST_API void _Load() override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
HDST_API ~HdStUdimTextureObject() override
#define HDST_API
Definition: api.h:40
HDST_API void _Commit() override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HDST_API HdTextureType GetTextureType() const override
HDST_API HdStUdimTextureObject(const HdStTextureIdentifier &textureId, HdSt_TextureObjectRegistry *textureObjectRegistry)
HgiTextureHandle const & GetTexelTexture() const
HDST_API bool HdStIsSupportedUdimTexture(std::string const &imageFilePath)