Commit 9494572a by Nicolas Capens

Fix allowing to make null EGL surfaces current.

eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, context) resulted in a null dereference. It should be supported and is a common idiom for detaching the surfaces from the context before destroying them. Bug swiftshader:70 Change-Id: I5b4406c8d594bc5db34c51bd08371ce69bbd471b Reviewed-on: https://swiftshader-review.googlesource.com/10389Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 9eaa19c2
...@@ -274,35 +274,42 @@ void Context::makeCurrent(gl::Surface *surface) ...@@ -274,35 +274,42 @@ void Context::makeCurrent(gl::Surface *surface)
mState.viewportX = 0; mState.viewportX = 0;
mState.viewportY = 0; mState.viewportY = 0;
mState.viewportWidth = surface->getWidth(); mState.viewportWidth = surface ? surface->getWidth() : 0;
mState.viewportHeight = surface->getHeight(); mState.viewportHeight = surface ? surface->getHeight() : 0;
mState.scissorX = 0; mState.scissorX = 0;
mState.scissorY = 0; mState.scissorY = 0;
mState.scissorWidth = surface->getWidth(); mState.scissorWidth = surface ? surface->getWidth() : 0;
mState.scissorHeight = surface->getHeight(); mState.scissorHeight = surface ? surface->getHeight() : 0;
mHasBeenCurrent = true; mHasBeenCurrent = true;
} }
// Wrap the existing resources into GL objects and assign them to the '0' names if(surface)
egl::Image *defaultRenderTarget = surface->getRenderTarget(); {
egl::Image *depthStencil = surface->getDepthStencil(); // Wrap the existing resources into GL objects and assign them to the '0' names
egl::Image *defaultRenderTarget = surface->getRenderTarget();
egl::Image *depthStencil = surface->getDepthStencil();
Colorbuffer *colorbufferZero = new Colorbuffer(defaultRenderTarget); Colorbuffer *colorbufferZero = new Colorbuffer(defaultRenderTarget);
DepthStencilbuffer *depthStencilbufferZero = new DepthStencilbuffer(depthStencil); DepthStencilbuffer *depthStencilbufferZero = new DepthStencilbuffer(depthStencil);
Framebuffer *framebufferZero = new DefaultFramebuffer(colorbufferZero, depthStencilbufferZero); Framebuffer *framebufferZero = new DefaultFramebuffer(colorbufferZero, depthStencilbufferZero);
setFramebufferZero(framebufferZero); setFramebufferZero(framebufferZero);
if(defaultRenderTarget) if(defaultRenderTarget)
{ {
defaultRenderTarget->release(); defaultRenderTarget->release();
} }
if(depthStencil) if(depthStencil)
{
depthStencil->release();
}
}
else
{ {
depthStencil->release(); setFramebufferZero(nullptr);
} }
markAllStateDirty(); markAllStateDirty();
......
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