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 protected:
72  HDST_API
73  void _Load() override;
74 
75  HDST_API
76  void _Commit() override;
77 
78 private:
79  HgiFormat _format;
80  GfVec3i _texelDimensions;
81  int _texelLayers;
82  size_t _texelDataSize;
83  GfVec2i _layoutDimensions;
84  size_t _layoutDataSize;
85 
86  std::unique_ptr<uint8_t[]> _texelData;
87  std::unique_ptr<uint8_t[]> _layoutData;
88 
89  HgiTextureHandle _texelTexture;
90  HgiTextureHandle _layoutTexture;
91 
92  void _DestroyTextures();
93 };
94 
95 template<>
98 };
99 
101 
102 #endif
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
Definition: vec2i.h:43
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 ~HdStPtexTextureObject() override
Definition: vec3i.h:43
HgiTextureHandle GetLayoutTexture() const
HDST_API void _Commit() override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define HDST_API
Definition: api.h:23
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HdStTextureType
Definition: enums.h:30
HDST_API HdStTextureType GetTextureType() const override
HgiTextureHandle GetTexelTexture() const
HDST_API HdStPtexTextureObject(const HdStTextureIdentifier &textureId, HdSt_TextureObjectRegistry *textureObjectRegistry)