Commit 9a8d004a by Jamie Madill

Fix swapchain resize errors when sizing to 0 width or height.

BUG=angle:519 Change-Id: I3d3d0746b2b3027d04c91cc5fdcd301930e3b22a Reviewed-on: https://chromium-review.googlesource.com/178455Reviewed-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Commit-Queue: Nicolas Capens <nicolascapens@chromium.org> Tested-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 1b6ef526
...@@ -48,83 +48,19 @@ SwapChain11::~SwapChain11() ...@@ -48,83 +48,19 @@ SwapChain11::~SwapChain11()
void SwapChain11::release() void SwapChain11::release()
{ {
if (mSwapChain) SafeRelease(mSwapChain);
{ SafeRelease(mBackBufferTexture);
mSwapChain->Release(); SafeRelease(mBackBufferRTView);
mSwapChain = NULL; SafeRelease(mOffscreenTexture);
} SafeRelease(mOffscreenRTView);
SafeRelease(mOffscreenSRView);
if (mBackBufferTexture) SafeRelease(mDepthStencilTexture);
{ SafeRelease(mDepthStencilDSView);
mBackBufferTexture->Release(); SafeRelease(mQuadVB);
mBackBufferTexture = NULL; SafeRelease(mPassThroughSampler);
} SafeRelease(mPassThroughIL);
SafeRelease(mPassThroughVS);
if (mBackBufferRTView) SafeRelease(mPassThroughPS);
{
mBackBufferRTView->Release();
mBackBufferRTView = NULL;
}
if (mOffscreenTexture)
{
mOffscreenTexture->Release();
mOffscreenTexture = NULL;
}
if (mOffscreenRTView)
{
mOffscreenRTView->Release();
mOffscreenRTView = NULL;
}
if (mOffscreenSRView)
{
mOffscreenSRView->Release();
mOffscreenSRView = NULL;
}
if (mDepthStencilTexture)
{
mDepthStencilTexture->Release();
mDepthStencilTexture = NULL;
}
if (mDepthStencilDSView)
{
mDepthStencilDSView->Release();
mDepthStencilDSView = NULL;
}
if (mQuadVB)
{
mQuadVB->Release();
mQuadVB = NULL;
}
if (mPassThroughSampler)
{
mPassThroughSampler->Release();
mPassThroughSampler = NULL;
}
if (mPassThroughIL)
{
mPassThroughIL->Release();
mPassThroughIL = NULL;
}
if (mPassThroughVS)
{
mPassThroughVS->Release();
mPassThroughVS = NULL;
}
if (mPassThroughPS)
{
mPassThroughPS->Release();
mPassThroughPS = NULL;
}
if (!mAppCreatedShareHandle) if (!mAppCreatedShareHandle)
{ {
...@@ -134,35 +70,11 @@ void SwapChain11::release() ...@@ -134,35 +70,11 @@ void SwapChain11::release()
void SwapChain11::releaseOffscreenTexture() void SwapChain11::releaseOffscreenTexture()
{ {
if (mOffscreenTexture) SafeRelease(mOffscreenTexture);
{ SafeRelease(mOffscreenRTView);
mOffscreenTexture->Release(); SafeRelease(mOffscreenSRView);
mOffscreenTexture = NULL; SafeRelease(mDepthStencilTexture);
} SafeRelease(mDepthStencilDSView);
if (mOffscreenRTView)
{
mOffscreenRTView->Release();
mOffscreenRTView = NULL;
}
if (mOffscreenSRView)
{
mOffscreenSRView->Release();
mOffscreenSRView = NULL;
}
if (mDepthStencilTexture)
{
mDepthStencilTexture->Release();
mDepthStencilTexture = NULL;
}
if (mDepthStencilDSView)
{
mDepthStencilDSView->Release();
mDepthStencilDSView = NULL;
}
} }
EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHeight) EGLint SwapChain11::resetOffscreenTexture(int backbufferWidth, int backbufferHeight)
...@@ -369,20 +281,17 @@ EGLint SwapChain11::resize(EGLint backbufferWidth, EGLint backbufferHeight) ...@@ -369,20 +281,17 @@ EGLint SwapChain11::resize(EGLint backbufferWidth, EGLint backbufferHeight)
return EGL_BAD_ACCESS; return EGL_BAD_ACCESS;
} }
// Can only call resize if we have already created our swap buffer and resources // EGL allows creating a surface with 0x0 dimension, however, DXGI does not like 0x0 swapchains
ASSERT(mSwapChain && mBackBufferTexture && mBackBufferRTView); if (backbufferWidth < 1 || backbufferHeight < 1)
if (mBackBufferTexture)
{ {
mBackBufferTexture->Release(); return EGL_SUCCESS;
mBackBufferTexture = NULL;
} }
if (mBackBufferRTView) // Can only call resize if we have already created our swap buffer and resources
{ ASSERT(mSwapChain && mBackBufferTexture && mBackBufferRTView);
mBackBufferRTView->Release();
mBackBufferRTView = NULL; SafeRelease(mBackBufferTexture);
} SafeRelease(mBackBufferRTView);
// Resize swap chain // Resize swap chain
DXGI_FORMAT backbufferDXGIFormat = gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat); DXGI_FORMAT backbufferDXGIFormat = gl_d3d11::ConvertRenderbufferFormat(mBackBufferFormat);
...@@ -431,23 +340,9 @@ EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swap ...@@ -431,23 +340,9 @@ EGLint SwapChain11::reset(int backbufferWidth, int backbufferHeight, EGLint swap
// Release specific resources to free up memory for the new render target, while the // Release specific resources to free up memory for the new render target, while the
// old render target still exists for the purpose of preserving its contents. // old render target still exists for the purpose of preserving its contents.
if (mSwapChain) SafeRelease(mSwapChain);
{ SafeRelease(mBackBufferTexture);
mSwapChain->Release(); SafeRelease(mBackBufferRTView);
mSwapChain = NULL;
}
if (mBackBufferTexture)
{
mBackBufferTexture->Release();
mBackBufferTexture = NULL;
}
if (mBackBufferRTView)
{
mBackBufferRTView->Release();
mBackBufferRTView = NULL;
}
mSwapInterval = static_cast<unsigned int>(swapInterval); mSwapInterval = static_cast<unsigned int>(swapInterval);
if (mSwapInterval > 4) if (mSwapInterval > 4)
......
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