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  HDST_API
67  size_t GetCommittedSize() const override;
68 
69 protected:
70  HDST_API
71  void _Load() override;
72 
73  HDST_API
74  void _Commit() override;
75 
76 private:
77  std::vector<uint8_t> _textureData;
78  std::vector<float> _layoutData;
79  size_t _textureDataSize;
80  size_t _layoutDataSize;
81 
82  GfVec3i _dimensions;
83  size_t _tileCount;
84  size_t _mipCount;
85  HgiFormat _hgiFormat;
86 
87  HgiTextureHandle _texelTexture;
88  HgiTextureHandle _layoutTexture;
89 
90  void _DestroyTextures();
91 };
92 
93 template<>
96 };
97 
99 
100 #endif
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
HgiTextureHandle const & GetLayoutTexture() const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
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 size_t GetCommittedSize() const override
Returns the actual amount of memory committed to the GPU.
HDST_API void _Load() override
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:32
HDST_API HdStUdimTextureObject(const HdStTextureIdentifier &textureId, HdSt_TextureObjectRegistry *textureObjectRegistry)
HgiTextureHandle const & GetTexelTexture() const
HDST_API bool HdStIsSupportedUdimTexture(std::string const &imageFilePath)