Loading...
Searching...
No Matches
texture.h
Go to the documentation of this file.
1//
2// Copyright 2016 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_GLF_TEXTURE_H
8#define PXR_IMAGING_GLF_TEXTURE_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/imaging/glf/api.h"
16#include "pxr/base/tf/refPtr.h"
18#include "pxr/base/tf/weakPtr.h"
20
21#include "pxr/imaging/garch/glApi.h"
22
23#include <map>
24#include <string>
25#include <vector>
26
27PXR_NAMESPACE_OPEN_SCOPE
28
29
30#define GLF_TEXTURE_TOKENS \
31 (texels) \
32 (layout)
33
34TF_DECLARE_PUBLIC_TOKENS(GlfTextureTokens, GLF_API, GLF_TEXTURE_TOKENS);
35
37
45class GlfTexture : public TfRefBase, public TfWeakBase
46{
47public:
56 struct Binding {
57 Binding(TfToken name, TfToken role, GLenum target,
58 GLuint textureId, GLuint samplerId)
59 : name(name)
60 , role(role)
61 , target(target)
62 , textureId(textureId)
63 , samplerId(samplerId) { }
64
65 TfToken name;
66 TfToken role;
67 GLenum target;
68 GLuint textureId;
69 GLuint samplerId;
70 };
71 typedef std::vector<Binding> BindingVector;
72
73 GLF_API
74 virtual ~GlfTexture() = 0;
75
76 // Disallow copies
77 GlfTexture(const GlfTexture&) = delete;
78 GlfTexture& operator=(const GlfTexture&) = delete;
79
83 virtual BindingVector GetBindings(TfToken const & identifier,
84 GLuint samplerId = 0) = 0;
85
87 virtual GLuint GetGlTextureName() = 0;
88
90 GLF_API
91 size_t GetMemoryUsed() const;
92
94 GLF_API
95 size_t GetMemoryRequested() const;
96
98 GLF_API
99 void SetMemoryRequested(size_t targetMemory);
100
101 virtual VtDictionary GetTextureInfo(bool forceLoad) = 0;
102
103 GLF_API
104 virtual bool IsMinFilterSupported(GLenum filter);
105
106 GLF_API
107 virtual bool IsMagFilterSupported(GLenum filter);
108
110 GLF_API
112
119 GLF_API
120 size_t GetContentsID() const;
121
122 GLF_API
123 HioImage::ImageOriginLocation GetOriginLocation() const;
124
125 GLF_API
126 bool IsOriginLowerLeft() const;
127
128protected:
129 GLF_API
130 GlfTexture();
131
132 GLF_API
134
135 GLF_API
136 void _SetMemoryUsed(size_t size);
137
138 GLF_API
139 virtual void _OnMemoryRequestedDirty();
140
141 GLF_API
142 void _UpdateContentsID();
143
144private:
145 size_t _memoryUsed;
146 size_t _memoryRequested;
147 size_t _contentsID;
148 HioImage::ImageOriginLocation _originLocation;
149};
150
151class GlfTextureFactoryBase : public TfType::FactoryBase {
152public:
153 virtual GlfTextureRefPtr New(const TfToken& texturePath,
154 HioImage::ImageOriginLocation originLocation) const = 0;
155};
156
157PXR_NAMESPACE_CLOSE_SCOPE
158
159#endif // PXR_IMAGING_GLF_TEXTURE_H
Represents a texture object in Glf.
Definition: texture.h:46
static GLF_API size_t GetTextureMemoryAllocated()
static reporting function
GLF_API void SetMemoryRequested(size_t targetMemory)
Specify the amount of memory the user wishes to allocate to the texture.
GLF_API size_t GetContentsID() const
Returns an identifier that can be used to determine when the contents of this texture (i....
GLF_API size_t GetMemoryUsed() const
Amount of memory used to store the texture.
GLF_API size_t GetMemoryRequested() const
Amount of memory the user wishes to allocate to the texture.
virtual BindingVector GetBindings(TfToken const &identifier, GLuint samplerId=0)=0
Returns the bindings to use this texture for the shader resource named identifier.
virtual GLuint GetGlTextureName()=0
Returns the OpenGl texture name for the texture.
ImageOriginLocation
Specifies whether to treat the image origin as the upper-left corner or the lower left.
Definition: image.h:44
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:56
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Base class of all factory types.
Definition: type.h:56
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:124
A map with string keys and VtValue values.
Definition: dictionary.h:52
Standard pointer typedefs.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:72
Reference counting.
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:92
A texture has one or more bindings which describe how the different aspects of the texture should be ...
Definition: texture.h:56
Pointer storage with deletion detection.