Commit fbfa47c4 by Geoff Lang

Implement copyImage and copySubImage in TextureGL.

BUG=angleproject:885 BUG=angleproject:884 Change-Id: I083b72059c55157e2a3ee00ec778f819a100be7b Reviewed-on: https://chromium-review.googlesource.com/263179Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 69bde01a
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/gl/BufferGL.h" #include "libANGLE/renderer/gl/BufferGL.h"
#include "libANGLE/renderer/gl/FramebufferGL.h"
#include "libANGLE/renderer/gl/FunctionsGL.h" #include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/StateManagerGL.h" #include "libANGLE/renderer/gl/StateManagerGL.h"
...@@ -203,15 +204,49 @@ gl::Error TextureGL::setCompressedSubImage(GLenum target, size_t level, const gl ...@@ -203,15 +204,49 @@ gl::Error TextureGL::setCompressedSubImage(GLenum target, size_t level, const gl
gl::Error TextureGL::copyImage(GLenum target, size_t level, const gl::Rectangle &sourceArea, GLenum internalFormat, gl::Error TextureGL::copyImage(GLenum target, size_t level, const gl::Rectangle &sourceArea, GLenum internalFormat,
const gl::Framebuffer *source) const gl::Framebuffer *source)
{ {
UNIMPLEMENTED(); const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source);
return gl::Error(GL_INVALID_OPERATION);
mStateManager->bindTexture(mTextureType, mTextureID);
mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID());
if (UseTexImage2D(mTextureType))
{
mFunctions->copyTexImage2D(target, level, internalFormat, sourceArea.x, sourceArea.y,
sourceArea.width, sourceArea.height, 0);
}
else
{
UNREACHABLE();
}
return gl::Error(GL_NO_ERROR);
} }
gl::Error TextureGL::copySubImage(GLenum target, size_t level, const gl::Offset &destOffset, const gl::Rectangle &sourceArea, gl::Error TextureGL::copySubImage(GLenum target, size_t level, const gl::Offset &destOffset, const gl::Rectangle &sourceArea,
const gl::Framebuffer *source) const gl::Framebuffer *source)
{ {
UNIMPLEMENTED(); const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source);
return gl::Error(GL_INVALID_OPERATION);
mStateManager->bindTexture(mTextureType, mTextureID);
mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID());
if (UseTexImage2D(mTextureType))
{
ASSERT(destOffset.z == 0);
mFunctions->copyTexSubImage2D(target, level, destOffset.x, destOffset.y,
sourceArea.x, sourceArea.y, sourceArea.width, sourceArea.height);
}
else if (UseTexImage3D(mTextureType))
{
mFunctions->copyTexSubImage3D(target, level, destOffset.x, destOffset.y, destOffset.z,
sourceArea.x, sourceArea.y, sourceArea.width, sourceArea.height);
}
else
{
UNREACHABLE();
}
return gl::Error(GL_NO_ERROR);
} }
gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFormat, const gl::Extents &size) gl::Error TextureGL::setStorage(GLenum target, size_t levels, GLenum internalFormat, const gl::Extents &size)
......
#include "ANGLETest.h" #include "ANGLETest.h"
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_TYPED_TEST_CASE(TextureTest, ES2_D3D9, ES2_D3D11, ES2_D3D11_FL9_3); ANGLE_TYPED_TEST_CASE(TextureTest, ES2_D3D9, ES2_D3D11, ES2_D3D11_FL9_3, ES2_OPENGL);
template<typename T> template<typename T>
class TextureTest : public ANGLETest class TextureTest : public ANGLETest
...@@ -106,6 +106,21 @@ class TextureTest : public ANGLETest ...@@ -106,6 +106,21 @@ class TextureTest : public ANGLETest
// Tests CopyTexSubImage with floating point textures of various formats. // Tests CopyTexSubImage with floating point textures of various formats.
void testFloatCopySubImage(int sourceImageChannels, int destImageChannels) void testFloatCopySubImage(int sourceImageChannels, int destImageChannels)
{ {
if (getClientVersion() < 3)
{
if (!extensionEnabled("GL_OES_texture_float"))
{
std::cout << "Test skipped due to missing GL_OES_texture_float." << std::endl;
return;
}
if ((sourceImageChannels < 3 || destImageChannels < 3) && !extensionEnabled("GL_EXT_texture_rg"))
{
std::cout << "Test skipped due to missing GL_EXT_texture_rg." << std::endl;
return;
}
}
GLfloat sourceImageData[4][16] = GLfloat sourceImageData[4][16] =
{ {
{ // R { // R
...@@ -388,8 +403,12 @@ TYPED_TEST(TextureTest, TexStorage) ...@@ -388,8 +403,12 @@ TYPED_TEST(TextureTest, TexStorage)
drawQuad(m2DProgram, "position", 0.5f); drawQuad(m2DProgram, "position", 0.5f);
glDeleteTextures(1, &tex2D); glDeleteTextures(1, &tex2D);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
EXPECT_PIXEL_EQ(3*width/4, 3*height/4, 0, 0, 0, 255);
EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255); EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255);
// Validate that the region of the texture without data has an alpha of 1.0
GLubyte pixel[4];
glReadPixels(3 * width / 4, 3 * height / 4, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
EXPECT_EQ(pixel[3], 255);
} }
// Test that glTexSubImage2D combined with a PBO works properly when glTexStorage2DEXT has initialized the image with a default color. // Test that glTexSubImage2D combined with a PBO works properly when glTexStorage2DEXT has initialized the image with a default color.
...@@ -444,32 +463,27 @@ TYPED_TEST(TextureTest, TexStorageWithPBO) ...@@ -444,32 +463,27 @@ TYPED_TEST(TextureTest, TexStorageWithPBO)
} }
// See description on testFloatCopySubImage // See description on testFloatCopySubImage
// TODO(jmadill): Fix sampling from unused channels on D3D9 TYPED_TEST(TextureTest, CopySubImageFloat_R_R)
TYPED_TEST(TextureTest, DISABLED_CopySubImageFloat_R_R)
{ {
testFloatCopySubImage(1, 1); testFloatCopySubImage(1, 1);
} }
// TODO(jmadill): Fix sampling from unused channels on D3D9 TYPED_TEST(TextureTest, CopySubImageFloat_RG_R)
TYPED_TEST(TextureTest, DISABLED_CopySubImageFloat_RG_R)
{ {
testFloatCopySubImage(2, 1); testFloatCopySubImage(2, 1);
} }
// TODO(jmadill): Fix sampling from unused channels on D3D9 TYPED_TEST(TextureTest, CopySubImageFloat_RG_RG)
TYPED_TEST(TextureTest, DISABLED_CopySubImageFloat_RG_RG)
{ {
testFloatCopySubImage(2, 2); testFloatCopySubImage(2, 2);
} }
// TODO(jmadill): Fix sampling from unused channels on D3D9 TYPED_TEST(TextureTest, CopySubImageFloat_RGB_R)
TYPED_TEST(TextureTest, DISABLED_CopySubImageFloat_RGB_R)
{ {
testFloatCopySubImage(3, 1); testFloatCopySubImage(3, 1);
} }
// TODO(jmadill): Fix sampling from unused channels on D3D9 TYPED_TEST(TextureTest, CopySubImageFloat_RGB_RG)
TYPED_TEST(TextureTest, DISABLED_CopySubImageFloat_RGB_RG)
{ {
testFloatCopySubImage(3, 2); testFloatCopySubImage(3, 2);
} }
...@@ -486,14 +500,12 @@ TYPED_TEST(TextureTest, CopySubImageFloat_RGB_RGB) ...@@ -486,14 +500,12 @@ TYPED_TEST(TextureTest, CopySubImageFloat_RGB_RGB)
testFloatCopySubImage(3, 3); testFloatCopySubImage(3, 3);
} }
// TODO(jmadill): Fix sampling from unused channels on D3D9 TYPED_TEST(TextureTest, CopySubImageFloat_RGBA_R)
TYPED_TEST(TextureTest, DISABLED_CopySubImageFloat_RGBA_R)
{ {
testFloatCopySubImage(4, 1); testFloatCopySubImage(4, 1);
} }
// TODO(jmadill): Fix sampling from unused channels on D3D9 TYPED_TEST(TextureTest, CopySubImageFloat_RGBA_RG)
TYPED_TEST(TextureTest, DISABLED_CopySubImageFloat_RGBA_RG)
{ {
testFloatCopySubImage(4, 2); testFloatCopySubImage(4, 2);
} }
......
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