Commit eb32a2e9 by Jamie Madill

Fix cube map rendertargets.

We were using the entire level parameter of the cube map, instead of using the helper functions for cube map ImageIndexes, which set the layer corresponding to the cube map face. BUG=angle:849 BUG=440701 Change-Id: Id78db5c8281b6b644392bb961d69a7f869755a34 Reviewed-on: https://chromium-review.googlesource.com/234380Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org>
parent b1237ed7
...@@ -16,13 +16,14 @@ ...@@ -16,13 +16,14 @@
namespace gl namespace gl
{ {
class ImageIndexIterator;
struct ImageIndex struct ImageIndex
{ {
GLenum type; GLenum type;
GLint mipIndex; GLint mipIndex;
GLint layerIndex; GLint layerIndex;
ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn);
ImageIndex(const ImageIndex &other); ImageIndex(const ImageIndex &other);
ImageIndex &operator=(const ImageIndex &other); ImageIndex &operator=(const ImageIndex &other);
...@@ -35,6 +36,11 @@ struct ImageIndex ...@@ -35,6 +36,11 @@ struct ImageIndex
static ImageIndex MakeInvalid(); static ImageIndex MakeInvalid();
static const GLint ENTIRE_LEVEL = static_cast<GLint>(-1); static const GLint ENTIRE_LEVEL = static_cast<GLint>(-1);
private:
friend class ImageIndexIterator;
ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn);
}; };
class ImageIndexIterator class ImageIndexIterator
......
...@@ -1157,14 +1157,14 @@ TextureD3D_Cube::~TextureD3D_Cube() ...@@ -1157,14 +1157,14 @@ TextureD3D_Cube::~TextureD3D_Cube()
Image *TextureD3D_Cube::getImage(int level, int layer) const Image *TextureD3D_Cube::getImage(int level, int layer) const
{ {
ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(layer < 6); ASSERT(layer >= 0 && layer < 6);
return mImageArray[layer][level]; return mImageArray[layer][level];
} }
Image *TextureD3D_Cube::getImage(const gl::ImageIndex &index) const Image *TextureD3D_Cube::getImage(const gl::ImageIndex &index) const
{ {
ASSERT(index.mipIndex < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(index.mipIndex < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(index.layerIndex < 6); ASSERT(index.layerIndex >= 0 && index.layerIndex < 6);
return mImageArray[index.layerIndex][index.mipIndex]; return mImageArray[index.layerIndex][index.mipIndex];
} }
......
...@@ -1473,7 +1473,19 @@ void GL_APIENTRY FramebufferTexture2D(GLenum target, GLenum attachment, GLenum t ...@@ -1473,7 +1473,19 @@ void GL_APIENTRY FramebufferTexture2D(GLenum target, GLenum attachment, GLenum t
if (texture != 0) if (texture != 0)
{ {
Texture *textureObj = context->getTexture(texture); Texture *textureObj = context->getTexture(texture);
ImageIndex index(textarget, level, ImageIndex::ENTIRE_LEVEL);
ImageIndex index = ImageIndex::MakeInvalid();
if (textarget == GL_TEXTURE_2D)
{
index = ImageIndex::Make2D(level);
}
else
{
ASSERT(IsCubemapTextureTarget(textarget));
index = ImageIndex::MakeCube(textarget, level);
}
framebuffer->setTextureAttachment(attachment, textureObj, index); framebuffer->setTextureAttachment(attachment, textureObj, index);
} }
else else
......
...@@ -821,7 +821,19 @@ void GL_APIENTRY FramebufferTextureLayer(GLenum target, GLenum attachment, GLuin ...@@ -821,7 +821,19 @@ void GL_APIENTRY FramebufferTextureLayer(GLenum target, GLenum attachment, GLuin
if (texture != 0) if (texture != 0)
{ {
Texture *textureObject = context->getTexture(texture); Texture *textureObject = context->getTexture(texture);
ImageIndex index(textureObject->getTarget(), level, layer);
ImageIndex index = ImageIndex::MakeInvalid();
if (textureObject->getTarget() == GL_TEXTURE_3D)
{
index = ImageIndex::Make3D(level, layer);
}
else
{
ASSERT(textureObject->getTarget() == GL_TEXTURE_2D_ARRAY);
index = ImageIndex::Make2DArray(level, layer);
}
framebuffer->setTextureAttachment(attachment, textureObject, index); framebuffer->setTextureAttachment(attachment, textureObject, index);
} }
else else
......
...@@ -390,3 +390,21 @@ TYPED_TEST(TextureTestES3, MipmapsForTextureArray) ...@@ -390,3 +390,21 @@ TYPED_TEST(TextureTestES3, MipmapsForTextureArray)
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
EXPECT_PIXEL_EQ(px, py, 0, 0, 255, 255); EXPECT_PIXEL_EQ(px, py, 0, 0, 255, 255);
} }
// Test creating a FBO with a cube map render target, to test an ANGLE bug
// https://code.google.com/p/angleproject/issues/detail?id=849
TYPED_TEST(TextureTest, CubeMapFBO)
{
GLuint fbo;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, mTextureCube, 0);
EXPECT_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
glDeleteFramebuffers(1, &fbo);
EXPECT_GL_NO_ERROR();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment