@@ -437,8 +437,9 @@ class ImageTest : public ANGLETest
437437 aHardwareBufferDescription.height = height;
438438 aHardwareBufferDescription.layers = depth;
439439 aHardwareBufferDescription.format = androidFormat;
440- aHardwareBufferDescription.usage =
441- AHARDWAREBUFFER_USAGE_CPU_WRITE_RARELY | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
440+ aHardwareBufferDescription.usage = AHARDWAREBUFFER_USAGE_CPU_WRITE_RARELY |
441+ AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
442+ AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER;
442443 aHardwareBufferDescription.stride = 0 ;
443444 aHardwareBufferDescription.rfu0 = 0 ;
444445 aHardwareBufferDescription.rfu1 = 0 ;
@@ -1599,6 +1600,55 @@ void ImageTest::SourceAHBTarget2D_helper(const EGLint *attribs)
15991600 glDeleteTextures (1 , &target);
16001601}
16011602
1603+ // Testing source AHB EGL image, target 2D texture retaining initial data.
1604+ TEST_P (ImageTest, SourceAHBTarget2DRetainInitialData)
1605+ {
1606+ ANGLE_SKIP_TEST_IF (!IsAndroid ());
1607+
1608+ EGLWindow *window = getEGLWindow ();
1609+
1610+ ANGLE_SKIP_TEST_IF (!hasOESExt () || !hasBaseExt () || !has2DTextureExt ());
1611+ ANGLE_SKIP_TEST_IF (!hasAndroidImageNativeBufferExt () || !hasAndroidHardwareBufferSupport ());
1612+
1613+ GLubyte data[4 ] = {0 , 255 , 0 , 255 };
1614+
1615+ // Create the Image
1616+ AHardwareBuffer *source;
1617+ EGLImageKHR image;
1618+ createEGLImageAndroidHardwareBufferSource (1 , 1 , 1 , GL_RGBA8, kDefaultAttribs , data, 4 , &source,
1619+ &image);
1620+
1621+ // Create a texture target to bind the egl image
1622+ GLuint target;
1623+ createEGLImageTargetTexture2D (image, &target);
1624+
1625+ // Create a framebuffer, and blend into the texture.
1626+ GLFramebuffer fbo;
1627+ glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1628+ glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, target, 0 );
1629+ EXPECT_GL_FRAMEBUFFER_COMPLETE (GL_FRAMEBUFFER);
1630+
1631+ // Blend into the framebuffer.
1632+ ANGLE_GL_PROGRAM (drawRed, essl1_shaders::vs::Simple (), essl1_shaders::fs::Red ());
1633+ glEnable (GL_BLEND);
1634+ glBlendFunc (GL_ONE, GL_ONE);
1635+ drawQuad (drawRed, essl1_shaders::PositionAttrib (), 0 .0f );
1636+ ASSERT_GL_NO_ERROR ();
1637+
1638+ glBindFramebuffer (GL_FRAMEBUFFER, 0 );
1639+ glDisable (GL_BLEND);
1640+
1641+ // Use texture target bound to egl image as source and render to framebuffer
1642+ // Verify that data in framebuffer matches that in the egl image
1643+ GLubyte expect[4 ] = {255 , 255 , 0 , 255 };
1644+ verifyResults2D (target, expect);
1645+
1646+ // Clean up
1647+ eglDestroyImageKHR (window->getDisplay (), image);
1648+ destroyAndroidHardwareBuffer (source);
1649+ glDeleteTextures (1 , &target);
1650+ }
1651+
16021652// Testing source AHB EGL image, target 2D array texture
16031653TEST_P (ImageTest, SourceAHBTarget2DArray)
16041654{
@@ -3028,4 +3078,4 @@ TEST_P(ImageTest, UpdatedExternalTexture)
30283078// tests should be run against.
30293079ANGLE_INSTANTIATE_TEST_ES2_AND_ES3 (ImageTest);
30303080ANGLE_INSTANTIATE_TEST_ES3 (ImageTestES3);
3031- } // namespace angle
3081+ } // namespace angle
0 commit comments