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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_ST_UDIM_TEXTURE_OBJECT_H
8 #define PXR_IMAGING_HD_ST_UDIM_TEXTURE_OBJECT_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
12 
14 
15 #include "pxr/imaging/hgi/handle.h"
16 
17 #include "pxr/base/gf/vec3i.h"
18 
20 
21 enum HgiFormat : int;
23 
24 /// Returns true if the file given by \p imageFilePath represents a udim file,
25 /// and false otherwise.
26 ///
27 /// This function simply checks the existence of the <udim> tag in the
28 /// file name and does not otherwise guarantee that
29 /// the file is in any way valid for reading.
30 ///
31 HDST_API bool HdStIsSupportedUdimTexture(std::string const& imageFilePath);
32 
33 /// \class HdStUdimTextureObject
34 ///
35 /// A UDIM texture.
36 ///
38 {
39 public:
40  HDST_API
42  const HdStTextureIdentifier &textureId,
43  HdSt_TextureObjectRegistry *textureObjectRegistry);
44 
45  HDST_API
46  ~HdStUdimTextureObject() override;
47 
48  /// Get the gpu texture name for the texels
49  ///
50  /// Only valid after commit phase.
51  ///
52  HgiTextureHandle const& GetTexelTexture() const { return _texelTexture; }
53 
54  /// Get the gpu texture name for the layout
55  ///
56  /// Only valid after commit phase.
57  ///
58  HgiTextureHandle const& GetLayoutTexture() const { return _layoutTexture; }
59 
60  HDST_API
61  bool IsValid() const override;
62 
63  HDST_API
64  HdStTextureType GetTextureType() const override;
65 
66 protected:
67  HDST_API
68  void _Load() override;
69 
70  HDST_API
71  void _Commit() override;
72 
73 private:
74  std::vector<uint8_t> _textureData;
75  std::vector<float> _layoutData;
76 
77  GfVec3i _dimensions;
78  size_t _tileCount;
79  size_t _mipCount;
80  HgiFormat _hgiFormat;
81 
82  HgiTextureHandle _texelTexture;
83  HgiTextureHandle _layoutTexture;
84 
85  void _DestroyTextures();
86 };
87 
88 template<>
91 };
92 
94 
95 #endif
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
HgiTextureHandle const & GetLayoutTexture() const
HDST_API bool IsValid() const override
HDST_API HdStTextureType GetTextureType() const override
int HgiHandle< class HgiTexture > HgiTextureHandle
HgiFormat
Definition: types.h:28
Definition: vec3i.h:43
HDST_API void _Load() override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HDST_API ~HdStUdimTextureObject() override
#define HDST_API
Definition: api.h:23
HDST_API void _Commit() override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HdStTextureType
Definition: enums.h:30
HDST_API HdStUdimTextureObject(const HdStTextureIdentifier &textureId, HdSt_TextureObjectRegistry *textureObjectRegistry)
HgiTextureHandle const & GetTexelTexture() const
HDST_API bool HdStIsSupportedUdimTexture(std::string const &imageFilePath)