Commit a0bcc50b by Geoff Lang Committed by Commit Bot

TextureD3D: Mark images clean after binding a surface.

By marking the images as dirty after binding a surface, the surface would be cleared when it was first read or written to. BUG=750813 BUG=angleproject:1635 Change-Id: Ic0d1c985151d55a0f1a1af67bb1edc4b0e8f2063 Reviewed-on: https://chromium-review.googlesource.com/598731 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 38abd6c9
...@@ -1150,7 +1150,9 @@ gl::Error TextureD3D_2D::bindTexImage(const gl::Context *context, egl::Surface * ...@@ -1150,7 +1150,9 @@ gl::Error TextureD3D_2D::bindTexImage(const gl::Context *context, egl::Surface *
mTexStorage = mRenderer->createTextureStorage2D(surfaceD3D->getSwapChain()); mTexStorage = mRenderer->createTextureStorage2D(surfaceD3D->getSwapChain());
mEGLImageTarget = false; mEGLImageTarget = false;
mDirtyImages = true; mDirtyImages = false;
mImageArray[0]->markClean();
return gl::NoError(); return gl::NoError();
} }
......
...@@ -471,6 +471,69 @@ TEST_P(RobustResourceInitTest, CopyTexSubImage3DTextureWronglyInitialized) ...@@ -471,6 +471,69 @@ TEST_P(RobustResourceInitTest, CopyTexSubImage3DTextureWronglyInitialized)
EXPECT_EQ(data, pixels); EXPECT_EQ(data, pixels);
} }
// Test that binding an EGL surface to a texture does not cause it to be cleared.
TEST_P(RobustResourceInitTest, BindTexImage)
{
if (!setup() || getClientMajorVersion() < 3)
{
return;
}
if (IsOpenGL())
{
std::cout << "Robust resource init is not yet fully implemented. (" << GetParam() << ")"
<< std::endl;
return;
}
EGLWindow *window = getEGLWindow();
EGLSurface surface = window->getSurface();
EGLDisplay display = window->getDisplay();
EGLConfig config = window->getConfig();
EGLContext context = window->getContext();
EGLint surfaceType = 0;
eglGetConfigAttrib(display, config, EGL_SURFACE_TYPE, &surfaceType);
if ((surfaceType & EGL_PBUFFER_BIT) == 0)
{
std::cout << "Test skipped because EGL config cannot be used to create pbuffers."
<< std::endl;
return;
}
EGLint attribs[] = {
EGL_WIDTH, 32,
EGL_HEIGHT, 32,
EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA,
EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
EGL_NONE,
};
EGLSurface pbuffer = eglCreatePbufferSurface(display, config, attribs);
ASSERT_NE(EGL_NO_SURFACE, pbuffer);
// Clear the pbuffer
eglMakeCurrent(display, pbuffer, pbuffer, context);
GLColor clearColor = GLColor::magenta;
glClearColor(clearColor.R, clearColor.G, clearColor.B, clearColor.A);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_PIXEL_COLOR_EQ(0, 0, clearColor);
// Bind the pbuffer to a texture and read its color
eglMakeCurrent(display, surface, surface, context);
GLTexture texture;
glBindTexture(GL_TEXTURE_2D, texture);
eglBindTexImage(display, pbuffer, EGL_BACK_BUFFER);
GLFramebuffer fbo;
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
EXPECT_PIXEL_COLOR_EQ(0, 0, clearColor);
eglDestroySurface(display, pbuffer);
}
ANGLE_INSTANTIATE_TEST(RobustResourceInitTest, ANGLE_INSTANTIATE_TEST(RobustResourceInitTest,
ES2_D3D9(), ES2_D3D9(),
ES2_D3D11(), ES2_D3D11(),
......
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