Fix failure initting 2D Array textures.
Our code currently failed in retrieving a NULL Image internally,
when we relied on getting texture dimensions on an unitialized
texture.
BUG=angle:813
Change-Id: Iaf6791ee291e45daae9c80d6452c4d9154227fdb
Reviewed-on: https://chromium-review.googlesource.com/229350
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
diff --git a/src/libGLESv2/renderer/d3d/TextureD3D.cpp b/src/libGLESv2/renderer/d3d/TextureD3D.cpp
index 6405d33..56f3a45 100644
--- a/src/libGLESv2/renderer/d3d/TextureD3D.cpp
+++ b/src/libGLESv2/renderer/d3d/TextureD3D.cpp
@@ -2255,16 +2255,18 @@
Image *TextureD3D_2DArray::getImage(int level, int layer) const
{
ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(layer < mLayerCounts[level]);
- return mImageArray[level][layer];
+ ASSERT((layer == 0 && mLayerCounts[level] == 0) ||
+ layer < mLayerCounts[level]);
+ return (mImageArray[level] ? mImageArray[level][layer] : NULL);
}
Image *TextureD3D_2DArray::getImage(const gl::ImageIndex &index) const
{
ASSERT(index.mipIndex < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
- ASSERT(index.layerIndex < mLayerCounts[index.mipIndex]);
+ ASSERT((index.layerIndex == 0 && mLayerCounts[index.mipIndex] == 0) ||
+ index.layerIndex < mLayerCounts[index.mipIndex]);
ASSERT(index.type == GL_TEXTURE_2D_ARRAY);
- return mImageArray[index.mipIndex][index.layerIndex];
+ return (mImageArray[index.mipIndex] ? mImageArray[index.mipIndex][index.layerIndex] : NULL);
}
GLsizei TextureD3D_2DArray::getLayerCount(int level) const