Hash :
0fe40534
Author :
Date :
2015-02-10T12:01:27
Cache sampler completeness in the Texture class. BUG=angle:909 Change-Id: I14e06e01d111e9d5eec415f4c2d831b61dcb1e3d Reviewed-on: https://chromium-review.googlesource.com/248070 Reviewed-by: Nicolas Capens <capn@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
//
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Texture.h: Defines the gl::Texture class [OpenGL ES 2.0.24] section 3.7 page 63.
#ifndef LIBANGLE_TEXTURE_H_
#define LIBANGLE_TEXTURE_H_
#include "common/debug.h"
#include "libANGLE/RefCountObject.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/Constants.h"
#include "libANGLE/renderer/TextureImpl.h"
#include "libANGLE/Caps.h"
#include "angle_gl.h"
#include <vector>
#include <map>
namespace egl
{
class Surface;
}
namespace gl
{
class Framebuffer;
struct Data;
bool IsMipmapFiltered(const gl::SamplerState &samplerState);
class Texture final : public RefCountObject
{
public:
Texture(rx::TextureImpl *impl, GLuint id, GLenum target);
virtual ~Texture();
GLenum getTarget() const;
const SamplerState &getSamplerState() const { return mSamplerState; }
SamplerState &getSamplerState() { return mSamplerState; }
void setUsage(GLenum usage);
GLenum getUsage() const;
size_t getWidth(GLenum target, size_t level) const;
size_t getHeight(GLenum target, size_t level) const;
size_t getDepth(GLenum target, size_t level) const;
GLenum getInternalFormat(GLenum target, size_t level) const;
bool isSamplerComplete(const SamplerState &samplerState, const Data &data) const;
bool isCubeComplete() const;
virtual Error setImage(GLenum target, size_t level, GLenum internalFormat, const Extents &size, GLenum format, GLenum type,
const PixelUnpackState &unpack, const uint8_t *pixels);
virtual Error setSubImage(GLenum target, size_t level, const Box &area, GLenum format, GLenum type,
const PixelUnpackState &unpack, const uint8_t *pixels);
virtual Error setCompressedImage(GLenum target, size_t level, GLenum internalFormat, const Extents &size,
const PixelUnpackState &unpack, const uint8_t *pixels);
virtual Error setCompressedSubImage(GLenum target, size_t level, const Box &area, GLenum format,
const PixelUnpackState &unpack, const uint8_t *pixels);
virtual Error copyImage(GLenum target, size_t level, const Rectangle &sourceArea, GLenum internalFormat,
const Framebuffer *source);
virtual Error copySubImage(GLenum target, size_t level, const Offset &destOffset, const Rectangle &sourceArea,
const Framebuffer *source);
virtual Error setStorage(GLenum target, size_t levels, GLenum internalFormat, const Extents &size);
virtual Error generateMipmaps();
// Texture serials provide a unique way of identifying a Texture that isn't a raw pointer.
// "id" is not good enough, as Textures can be deleted, then re-allocated with the same id.
unsigned int getTextureSerial() const;
bool isImmutable() const;
GLsizei immutableLevelCount();
void bindTexImage(egl::Surface *surface);
void releaseTexImage();
rx::TextureImpl *getImplementation() { return mTexture; }
const rx::TextureImpl *getImplementation() const { return mTexture; }
static const GLuint INCOMPLETE_TEXTURE_ID = static_cast<GLuint>(-1); // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager.
private:
DISALLOW_COPY_AND_ASSIGN(Texture);
static unsigned int issueTextureSerial();
rx::TextureImpl *mTexture;
SamplerState mSamplerState;
GLenum mUsage;
GLsizei mImmutableLevelCount;
GLenum mTarget;
struct ImageDesc
{
Extents size;
GLenum internalFormat;
ImageDesc();
ImageDesc(const Extents &size, GLenum internalFormat);
};
const unsigned int mTextureSerial;
static unsigned int mCurrentTextureSerial;
GLenum getBaseImageTarget() const;
size_t getExpectedMipLevels() const;
bool computeSamplerCompleteness(const SamplerState &samplerState, const Data &data) const;
bool computeMipmapCompleteness(const gl::SamplerState &samplerState) const;
bool computeLevelCompleteness(GLenum target, size_t level, const gl::SamplerState &samplerState) const;
const ImageDesc &getImageDesc(GLenum target, size_t level) const;
void setImageDesc(GLenum target, size_t level, const ImageDesc &desc);
void setImageDescChain(size_t levels, Extents baseSize, GLenum sizedInternalFormat);
void clearImageDesc(GLenum target, size_t level);
void clearImageDescs();
std::vector<ImageDesc> mImageDescs;
struct SamplerCompletenessCache
{
SamplerCompletenessCache();
bool cacheValid;
// All values that affect sampler completeness that are not stored within
// the texture itself
SamplerState samplerState;
bool filterable;
GLint clientVersion;
bool supportsNPOT;
// Result of the sampler completeness with the above parameters
bool samplerComplete;
};
mutable SamplerCompletenessCache mCompletenessCache;
egl::Surface *mBoundSurface;
};
}
#endif // LIBANGLE_TEXTURE_H_