HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ptexTextureObject.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_PTEX_TEXTURE_OBJECT_H
8 #define PXR_IMAGING_HD_ST_PTEX_TEXTURE_OBJECT_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
13 
14 #include "pxr/imaging/hgi/handle.h"
15 
16 #include "pxr/base/gf/vec2i.h"
17 #include "pxr/base/gf/vec3i.h"
18 
19 #ifdef PXR_PTEX_SUPPORT_ENABLED
20 #include "pxr/imaging/hdSt/ptexMipmapTextureLoader.h"
21 #endif
22 
24 
25 /// Returns true if the file given by \p imageFilePath represents a ptex file,
26 /// and false otherwise.
27 ///
28 /// This function simply checks the extension of the file name and does not
29 /// otherwise guarantee that the file is in any way valid for reading.
30 ///
31 /// If ptex support is disabled, this function will always return false.
32 ///
33 HDST_API bool HdStIsSupportedPtexTexture(std::string const & imageFilePath);
34 
35 enum HgiFormat : int;
37 
38 /// \class HdStPtexTextureObject
39 ///
40 /// A Ptex texture.
41 ///
43 {
44 public:
45  HDST_API
47  const HdStTextureIdentifier &textureId,
48  HdSt_TextureObjectRegistry *textureObjectRegistry);
49 
50  HDST_API
51  ~HdStPtexTextureObject() override;
52 
53  /// Get the GPU texture handle for the texels
54  ///
55  /// Only valid after commit phase.
56  ///
57  HgiTextureHandle GetTexelTexture() const { return _texelTexture; }
58 
59  /// Get the GPU texture handle for the layout
60  ///
61  /// Only valid after commit phase.
62  ///
63  HgiTextureHandle GetLayoutTexture() const { return _layoutTexture; }
64 
65  HDST_API
66  bool IsValid() const override;
67 
68  HDST_API
69  HdStTextureType GetTextureType() const override;
70 
71  HDST_API
72  size_t GetCommittedSize() const override;
73 
74 protected:
75  HDST_API
76  void _Load() override;
77 
78  HDST_API
79  void _Commit() override;
80 
81 private:
82  HgiFormat _format;
83  GfVec3i _texelDimensions;
84  int _texelLayers;
85  size_t _texelDataSize;
86  GfVec2i _layoutDimensions;
87  size_t _layoutDataSize;
88 
89  std::unique_ptr<uint8_t[]> _texelData;
90  std::unique_ptr<uint8_t[]> _layoutData;
91 
92  HgiTextureHandle _texelTexture;
93  HgiTextureHandle _layoutTexture;
94 
95  void _DestroyTextures();
96 };
97 
98 template<>
101 };
102 
104 
105 #endif
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
Definition: vec2i.h:43
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
PXR_NAMESPACE_OPEN_SCOPE HDST_API bool HdStIsSupportedPtexTexture(std::string const &imageFilePath)
HDST_API bool IsValid() const override
int HgiHandle< class HgiTexture > HgiTextureHandle
HgiFormat
Definition: types.h:28
HDST_API void _Load() override
HDST_API size_t GetCommittedSize() const override
Returns the actual amount of memory committed to the GPU.
HDST_API ~HdStPtexTextureObject() override
Definition: vec3i.h:43
HgiTextureHandle GetLayoutTexture() const
HDST_API void _Commit() override
#define HDST_API
Definition: api.h:23
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HdStTextureType
Definition: enums.h:32
HDST_API HdStTextureType GetTextureType() const override
HgiTextureHandle GetTexelTexture() const
HDST_API HdStPtexTextureObject(const HdStTextureIdentifier &textureId, HdSt_TextureObjectRegistry *textureObjectRegistry)