1 // 2 // Copyright 2014 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // ImageIndex.h: A helper struct for indexing into an Image array 8 9 #ifndef LIBANGLE_IMAGE_INDEX_H_ 10 #define LIBANGLE_IMAGE_INDEX_H_ 11 12 #include "common/mathutil.h" 13 14 #include "angle_gl.h" 15 16 namespace gl 17 { 18 19 class ImageIndexIterator; 20 21 struct ImageIndex 22 { 23 GLenum type; 24 GLint mipIndex; 25 GLint layerIndex; 26 GLint numLayers; 27 28 ImageIndex(const ImageIndex &other); 29 ImageIndex &operator=(const ImageIndex &other); 30 hasLayerImageIndex31 bool hasLayer() const { return layerIndex != ENTIRE_LEVEL; } 32 bool is3D() const; 33 34 static ImageIndex Make2D(GLint mipIndex); 35 static ImageIndex MakeRectangle(GLint mipIndex); 36 static ImageIndex MakeCube(GLenum target, GLint mipIndex); 37 static ImageIndex Make2DArray(GLint mipIndex, GLint layerIndex); 38 static ImageIndex Make2DArrayRange(GLint mipIndex, GLint layerIndex, GLint numLayers); 39 static ImageIndex Make3D(GLint mipIndex, GLint layerIndex = ENTIRE_LEVEL); 40 static ImageIndex MakeGeneric(GLenum target, GLint mipIndex); 41 static ImageIndex Make2DMultisample(); 42 43 static ImageIndex MakeInvalid(); 44 45 static const GLint ENTIRE_LEVEL = static_cast<GLint>(-1); 46 47 bool operator<(const ImageIndex &other) const; 48 bool operator==(const ImageIndex &other) const; 49 bool operator!=(const ImageIndex &other) const; 50 51 private: 52 friend class ImageIndexIterator; 53 54 ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn, GLint numLayersIn); 55 }; 56 57 class ImageIndexIterator 58 { 59 public: 60 ImageIndexIterator(const ImageIndexIterator &other); 61 62 static ImageIndexIterator Make2D(GLint minMip, GLint maxMip); 63 static ImageIndexIterator MakeRectangle(GLint minMip, GLint maxMip); 64 static ImageIndexIterator MakeCube(GLint minMip, GLint maxMip); 65 static ImageIndexIterator Make3D(GLint minMip, GLint maxMip, GLint minLayer, GLint maxLayer); 66 static ImageIndexIterator Make2DArray(GLint minMip, GLint maxMip, const GLsizei *layerCounts); 67 static ImageIndexIterator Make2DMultisample(); 68 69 ImageIndex next(); 70 ImageIndex current() const; 71 bool hasNext() const; 72 73 private: 74 75 ImageIndexIterator(GLenum type, const Range<GLint> &mipRange, 76 const Range<GLint> &layerRange, const GLsizei *layerCounts); 77 78 GLint maxLayer() const; 79 void done(); 80 81 GLenum mType; 82 Range<GLint> mMipRange; 83 Range<GLint> mLayerRange; 84 const GLsizei *mLayerCounts; 85 GLint mCurrentMip; 86 GLint mCurrentLayer; 87 }; 88 89 } 90 91 #endif // LIBANGLE_IMAGE_INDEX_H_ 92