HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
texture.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 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_HGI_GL_TEXTURE_H
8 #define PXR_IMAGING_HGI_GL_TEXTURE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hgiGL/api.h"
13 
15 #include "pxr/base/tf/weakBase.h"
16 
17 
19 
21 
22 /// \class HgiGLTexture
23 ///
24 /// Represents a OpenGL GPU texture resource.
25 ///
26 /// Note that we inherit from TfWeakBase for deletion detection.
27 /// This is useful to invalidate container objects such as framebuffer objects
28 /// that reference a deleted texture resource as an attachment.
29 ///
30 class HgiGLTexture final : public HgiTexture, public TfWeakBase
31 {
32 public:
33  HGIGL_API
34  ~HgiGLTexture() override;
35 
36  HGIGL_API
37  size_t GetByteSizeOfResource() const override;
38 
39  HGIGL_API
40  uint64_t GetRawResource() const override;
41 
42  /// Returns the OpenGL id / name of the texture.
43  uint32_t GetTextureId() const {return _textureId;}
44 
45  /// Returns the bindless gpu handle (caller must verify extension support)
46  HGIGL_API
47  uint64_t GetBindlessHandle();
48 
49  /// This function does not do anything. There is no support for explicit
50  /// layout transition in non-explicit APIs like OpenGL. Hence this function
51  /// simply returns void.
52  HGIGL_API
53  void SubmitLayoutChange(HgiTextureUsage newLayout) override;
54 
55 protected:
56  friend class HgiGL;
57 
58  HGIGL_API
59  HgiGLTexture(HgiTextureDesc const & desc);
60 
61  HGIGL_API
62  HgiGLTexture(HgiTextureViewDesc const & desc);
63 
64 private:
65  HgiGLTexture() = delete;
66  HgiGLTexture & operator=(const HgiGLTexture&) = delete;
67  HgiGLTexture(const HgiGLTexture&) = delete;
68 
69  uint32_t _textureId;
70  uint64_t _bindlessHandle;
71 };
72 
73 
75 
76 #endif
HGIGL_API uint64_t GetRawResource() const override
uint32_t GetTextureId() const
Returns the OpenGL id / name of the texture.
Definition: texture.h:43
HGIGL_API ~HgiGLTexture() override
HgiBits HgiTextureUsage
Definition: enums.h:153
Definition: hgi.h:54
#define HGIGL_API
Definition: api.h:23
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_PTRS(HgiGLTexture)
HGIGL_API void SubmitLayoutChange(HgiTextureUsage newLayout) override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HGIGL_API size_t GetByteSizeOfResource() const override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HGIGL_API uint64_t GetBindlessHandle()
Returns the bindless gpu handle (caller must verify extension support)