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 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_PTEX_TEXTURE_OBJECT_H
25 #define PXR_IMAGING_HD_ST_PTEX_TEXTURE_OBJECT_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
30 
31 #include "pxr/imaging/hgi/handle.h"
32 
33 #include "pxr/base/gf/vec2i.h"
34 #include "pxr/base/gf/vec3i.h"
35 
36 #ifdef PXR_PTEX_SUPPORT_ENABLED
37 #include "pxr/imaging/hdSt/ptexMipmapTextureLoader.h"
38 #endif
39 
41 
42 /// Returns true if the file given by \p imageFilePath represents a ptex file,
43 /// and false otherwise.
44 ///
45 /// This function simply checks the extension of the file name and does not
46 /// otherwise guarantee that the file is in any way valid for reading.
47 ///
48 /// If ptex support is disabled, this function will always return false.
49 ///
50 HDST_API bool HdStIsSupportedPtexTexture(std::string const & imageFilePath);
51 
52 enum HgiFormat : int;
54 
55 /// \class HdStPtexTextureObject
56 ///
57 /// A Ptex texture.
58 ///
60 {
61 public:
62  HDST_API
64  const HdStTextureIdentifier &textureId,
65  HdSt_TextureObjectRegistry *textureObjectRegistry);
66 
67  HDST_API
68  ~HdStPtexTextureObject() override;
69 
70  /// Get the GPU texture handle for the texels
71  ///
72  /// Only valid after commit phase.
73  ///
74  HgiTextureHandle GetTexelTexture() const { return _texelTexture; }
75 
76  /// Get the GPU texture handle for the layout
77  ///
78  /// Only valid after commit phase.
79  ///
80  HgiTextureHandle GetLayoutTexture() const { return _layoutTexture; }
81 
82  HDST_API
83  bool IsValid() const override;
84 
85  HDST_API
86  HdTextureType GetTextureType() const override;
87 
88 protected:
89  HDST_API
90  void _Load() override;
91 
92  HDST_API
93  void _Commit() override;
94 
95 private:
96  HgiFormat _format;
97  GfVec3i _texelDimensions;
98  int _texelLayers;
99  size_t _texelDataSize;
100  GfVec2i _layoutDimensions;
101  size_t _layoutDataSize;
102 
103  std::unique_ptr<uint8_t[]> _texelData;
104  std::unique_ptr<uint8_t[]> _layoutData;
105 
106  HgiTextureHandle _texelTexture;
107  HgiTextureHandle _layoutTexture;
108 
109  void _DestroyTextures();
110 };
111 
112 template<>
115 };
116 
118 
119 #endif
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
Definition: vec2i.h:60
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
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:45
HDST_API void _Load() override
HdTextureType
Definition: enums.h:221
HDST_API ~HdStPtexTextureObject() override
Definition: vec3i.h:60
HgiTextureHandle GetLayoutTexture() const
HDST_API void _Commit() override
HDST_API HdTextureType GetTextureType() const override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define HDST_API
Definition: api.h:40
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HgiTextureHandle GetTexelTexture() const
HDST_API HdStPtexTextureObject(const HdStTextureIdentifier &textureId, HdSt_TextureObjectRegistry *textureObjectRegistry)