All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
textureResource.h
1 //
2 // Copyright 2016 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 HDST_TEXTURE_RESOURCE_H
25 #define HDST_TEXTURE_RESOURCE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/textureResource.h"
29 #include "pxr/imaging/hd/enums.h"
30 #include "pxr/imaging/hdSt/api.h"
31 
32 #include "pxr/imaging/glf/texture.h"
33 #include "pxr/imaging/glf/textureHandle.h"
34 #include "pxr/imaging/garch/gl.h"
35 
36 #include "pxr/base/tf/declarePtrs.h"
37 #include "pxr/base/tf/token.h"
38 #include "pxr/base/gf/vec4f.h"
39 
40 #include <boost/noncopyable.hpp>
41 #include <boost/shared_ptr.hpp>
42 
43 #include <cstdint>
44 
45 PXR_NAMESPACE_OPEN_SCOPE
46 
47 
48 typedef boost::shared_ptr<class HdStTextureResource> HdStTextureResourceSharedPtr;
49 typedef boost::shared_ptr<class HdStSimpleTextureResource> HdStSimpleTextureResourceSharedPtr;
50 
52 class HdStTextureResource : public HdTextureResource, boost::noncopyable {
53 public:
54  HDST_API
55  virtual ~HdStTextureResource();
56 
57  // Access to underlying GL storage.
58  HDST_API virtual GLuint GetTexelsTextureId() = 0;
59  HDST_API virtual GLuint GetTexelsSamplerId() = 0;
60  HDST_API virtual uint64_t GetTexelsTextureHandle() = 0;
61  HDST_API virtual GLuint GetLayoutTextureId() = 0;
62  HDST_API virtual uint64_t GetLayoutTextureHandle() = 0;
63 };
64 
67 public:
75  HDST_API
76  HdStSimpleTextureResource(GlfTextureHandleRefPtr const &textureHandle,
77  HdTextureType textureType,
78  HdWrap wrapS,
79  HdWrap wrapT,
80  HdWrap wrapR,
81  HdMinFilter minFilter,
82  HdMagFilter magFilter,
83  size_t memoryRequest = 0);
84 
85  HDST_API
86  virtual ~HdStSimpleTextureResource();
87 
88  virtual HdTextureType GetTextureType() const override;
89  virtual size_t GetMemoryUsed() override;
90 
91  HDST_API virtual GLuint GetTexelsTextureId() override;
92  HDST_API virtual GLuint GetTexelsSamplerId() override;
93  HDST_API virtual uint64_t GetTexelsTextureHandle() override;
94  HDST_API virtual GLuint GetLayoutTextureId() override;
95  HDST_API virtual uint64_t GetLayoutTextureHandle() override;
96 
97 private:
98  GlfTextureHandleRefPtr _textureHandle;
99  GlfTextureRefPtr _texture;
100  GfVec4f _borderColor;
101  float _maxAnisotropy;
102  GLuint _sampler;
103  HdTextureType _textureType;
104  size_t _memoryRequest;
105 
106  HdWrap _wrapS;
107  HdWrap _wrapT;
108  HdWrap _wrapR;
109  HdMinFilter _minFilter;
110  HdMagFilter _magFilter;
111 };
112 
113 
114 PXR_NAMESPACE_CLOSE_SCOPE
115 
116 #endif //HDST_TEXTURE_RESOURCE_H
HdStSimpleTextureResource is a simple (non-drawtarget) texture.
Basic type for a vector of 4 float components.
Definition: vec4f.h:63
HdStTextureResource is an interface to a GL-backed texture.
HDST_API HdStSimpleTextureResource(GlfTextureHandleRefPtr const &textureHandle, HdTextureType textureType, HdWrap wrapS, HdWrap wrapT, HdWrap wrapR, HdMinFilter minFilter, HdMagFilter magFilter, size_t memoryRequest=0)
Create a texture resource around a Glf handle.