Commit 79169b5a by nduca@chromium.org

Use DwmAPI, if available, to minimize queueing of presents.

Review URL: http://codereview.appspot.com/4559065 git-svn-id: https://angleproject.googlecode.com/svn/trunk@673 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 250f06c9
......@@ -228,7 +228,11 @@
'AdditionalDependencies': [
'd3d9.lib',
'dxguid.lib',
'dwmapi.lib',
],
'DelayLoadDLLs': [
'dwmapi.dll',
]
}
},
},
......
#define MAJOR_VERSION 0
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 672
#define BUILD_REVISION 673
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -18,6 +18,8 @@
#include "libEGL/main.h"
#include "libEGL/Display.h"
#include <dwmapi.h>
namespace egl
{
Surface::Surface(Display *display, const Config *config, HWND window)
......@@ -69,7 +71,29 @@ Surface::~Surface()
bool Surface::initialize()
{
ASSERT(!mSwapChain && !mOffscreenTexture && !mDepthStencil);
return resetSwapChain();
if (!resetSwapChain())
return false;
// Modify present parameters for this window, if we are composited,
// to minimize the amount of queuing done by DWM between our calls to
// present and the actual screen.
if (mWindow && (LOWORD(GetVersion()) >= 0x60)) {
BOOL isComposited;
HRESULT result = DwmIsCompositionEnabled(&isComposited);
if (SUCCEEDED(result) && isComposited) {
DWM_PRESENT_PARAMETERS presentParams;
memset(&presentParams, 0, sizeof(presentParams));
presentParams.cbSize = sizeof(DWM_PRESENT_PARAMETERS);
presentParams.cBuffer = 2;
result = DwmSetPresentParameters(mWindow, &presentParams);
if (FAILED(result))
ERR("Unable to set present parameters: %081X", result);
}
}
return true;
}
void Surface::release()
......@@ -143,16 +167,6 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
bool useFlipEx = (LOWORD(GetVersion()) >= 0x61) && mDisplay->isD3d9ExDevice();
// FlipEx causes unseemly stretching when resizing windows AND when one
// draws outside of the WM_PAINT callback. While this is seldom a problem in
// single process applications, it is particuarly noticeable in multi-process
// applications. Therefore, if we find that the creator process of our window
// is not the current process, disable use of FlipEx.
DWORD windowPID;
GetWindowThreadProcessId(mWindow, &windowPID);
if(windowPID != GetCurrentProcessId())
useFlipEx = false;
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
......
......@@ -62,9 +62,10 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="d3d9.lib dxguid.lib"
AdditionalDependencies="d3d9.lib dxguid.lib dwmapi.lib"
LinkIncremental="2"
ModuleDefinitionFile="libEGL.def"
DelayLoadDLLs="dwmapi.dll"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
......
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