Commit 0c71fd40 by apatrick@chromium.org

Round swap chain surfaces to 64 pixels in width.

Review URL: https://codereview.appspot.com/6449123 git-svn-id: https://angleproject.googlecode.com/svn/trunk@1245 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 28a6b5f8
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 1243 #define BUILD_REVISION 1245
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -188,28 +188,8 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) ...@@ -188,28 +188,8 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
// before reallocating them to free up as much video memory as possible. // before reallocating them to free up as much video memory as possible.
device->EvictManagedResources(); device->EvictManagedResources();
D3DPRESENT_PARAMETERS presentParameters = {0};
HRESULT result; HRESULT result;
presentParameters.AutoDepthStencilFormat = mConfig->mDepthStencilFormat;
// We set BackBufferCount = 1 even when we use D3DSWAPEFFECT_FLIPEX.
// We do this because DirectX docs are a bit vague whether to set this to 1
// or 2. The runtime seems to accept 1, so we speculate that either it is
// forcing it to 2 without telling us, or better, doing something smart
// behind the scenes knowing that we don't need more.
presentParameters.BackBufferCount = 1;
presentParameters.BackBufferFormat = mConfig->mRenderTargetFormat;
presentParameters.EnableAutoDepthStencil = FALSE;
presentParameters.Flags = 0;
presentParameters.hDeviceWindow = getWindowHandle();
presentParameters.MultiSampleQuality = 0; // FIXME: Unimplemented
presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; // FIXME: Unimplemented
presentParameters.PresentationInterval = mPresentInterval;
presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
presentParameters.Windowed = TRUE;
presentParameters.BackBufferWidth = backbufferWidth;
presentParameters.BackBufferHeight = backbufferHeight;
// 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) if (mSwapChain)
...@@ -243,8 +223,8 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) ...@@ -243,8 +223,8 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
pShareHandle = &mShareHandle; pShareHandle = &mShareHandle;
} }
result = device->CreateTexture(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, 1, D3DUSAGE_RENDERTARGET, result = device->CreateTexture(backbufferWidth, backbufferHeight, 1, D3DUSAGE_RENDERTARGET,
presentParameters.BackBufferFormat, D3DPOOL_DEFAULT, &mOffscreenTexture, pShareHandle); mConfig->mRenderTargetFormat, D3DPOOL_DEFAULT, &mOffscreenTexture, pShareHandle);
if (FAILED(result)) if (FAILED(result))
{ {
ERR("Could not create offscreen texture: %08lX", result); ERR("Could not create offscreen texture: %08lX", result);
...@@ -274,14 +254,14 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) ...@@ -274,14 +254,14 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
mWidth, mHeight mWidth, mHeight
}; };
if (rect.right > static_cast<LONG>(presentParameters.BackBufferWidth)) if (rect.right > static_cast<LONG>(backbufferWidth))
{ {
rect.right = presentParameters.BackBufferWidth; rect.right = backbufferWidth;
} }
if (rect.bottom > static_cast<LONG>(presentParameters.BackBufferHeight)) if (rect.bottom > static_cast<LONG>(backbufferHeight))
{ {
rect.bottom = presentParameters.BackBufferHeight; rect.bottom = backbufferHeight;
} }
mDisplay->endScene(); mDisplay->endScene();
...@@ -294,6 +274,26 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) ...@@ -294,6 +274,26 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
if (mWindow) if (mWindow)
{ {
D3DPRESENT_PARAMETERS presentParameters = {0};
presentParameters.AutoDepthStencilFormat = mConfig->mDepthStencilFormat;
presentParameters.BackBufferCount = 1;
presentParameters.BackBufferFormat = mConfig->mRenderTargetFormat;
presentParameters.EnableAutoDepthStencil = FALSE;
presentParameters.Flags = 0;
presentParameters.hDeviceWindow = getWindowHandle();
presentParameters.MultiSampleQuality = 0; // FIXME: Unimplemented
presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; // FIXME: Unimplemented
presentParameters.PresentationInterval = mPresentInterval;
presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
presentParameters.Windowed = TRUE;
presentParameters.BackBufferWidth = backbufferWidth;
presentParameters.BackBufferHeight = backbufferHeight;
// http://crbug.com/140239
// Some AMD GPUs / drivers appear to round swap chain surfaces to a multiple of 64 pixels in width.
// This rounds the width up rather than down.
presentParameters.BackBufferWidth = (presentParameters.BackBufferWidth + 63) / 64 * 64;
result = device->CreateAdditionalSwapChain(&presentParameters, &mSwapChain); result = device->CreateAdditionalSwapChain(&presentParameters, &mSwapChain);
if (FAILED(result)) if (FAILED(result))
...@@ -320,9 +320,8 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) ...@@ -320,9 +320,8 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
if (mConfig->mDepthStencilFormat != D3DFMT_UNKNOWN) if (mConfig->mDepthStencilFormat != D3DFMT_UNKNOWN)
{ {
result = device->CreateDepthStencilSurface(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight, result = device->CreateDepthStencilSurface(backbufferWidth, backbufferHeight, mConfig->mDepthStencilFormat, D3DMULTISAMPLE_NONE,
presentParameters.AutoDepthStencilFormat, presentParameters.MultiSampleType, 0, FALSE, &mDepthStencil, NULL);
presentParameters.MultiSampleQuality, FALSE, &mDepthStencil, NULL);
if (FAILED(result)) if (FAILED(result))
{ {
...@@ -343,8 +342,8 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) ...@@ -343,8 +342,8 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
} }
} }
mWidth = presentParameters.BackBufferWidth; mWidth = backbufferWidth;
mHeight = presentParameters.BackBufferHeight; mHeight = backbufferHeight;
mPresentIntervalDirty = false; mPresentIntervalDirty = false;
return true; return true;
......
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