daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 1 | // |
daniel@transgaming.com | c6f7f9d | 2012-01-27 15:40:00 +0000 | [diff] [blame] | 2 | // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // Display.cpp: Implements the egl::Display class, representing the abstract |
| 8 | // display on which graphics are drawn. Implements EGLDisplay. |
| 9 | // [EGL 1.4] section 2.1.2 page 3. |
| 10 | |
| 11 | #include "libEGL/Display.h" |
| 12 | |
| 13 | #include <algorithm> |
jbauman@chromium.org | 84d7cbc | 2011-07-14 22:53:19 +0000 | [diff] [blame] | 14 | #include <map> |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 15 | #include <vector> |
| 16 | |
| 17 | #include "common/debug.h" |
jbauman@chromium.org | 06d7a75 | 2011-04-30 01:02:52 +0000 | [diff] [blame] | 18 | #include "libGLESv2/mathutil.h" |
apatrick@chromium.org | a5ddde9 | 2012-01-10 23:00:07 +0000 | [diff] [blame] | 19 | #include "libGLESv2/utilities.h" |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 20 | |
| 21 | #include "libEGL/main.h" |
| 22 | |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 23 | |
| 24 | namespace egl |
| 25 | { |
jbauman@chromium.org | 84d7cbc | 2011-07-14 22:53:19 +0000 | [diff] [blame] | 26 | namespace |
| 27 | { |
| 28 | typedef std::map<EGLNativeDisplayType, Display*> DisplayMap; |
| 29 | DisplayMap displays; |
| 30 | } |
| 31 | |
| 32 | egl::Display *Display::getDisplay(EGLNativeDisplayType displayId) |
| 33 | { |
| 34 | if (displays.find(displayId) != displays.end()) |
| 35 | { |
| 36 | return displays[displayId]; |
| 37 | } |
| 38 | |
| 39 | egl::Display *display = NULL; |
| 40 | |
| 41 | if (displayId == EGL_DEFAULT_DISPLAY) |
| 42 | { |
| 43 | display = new egl::Display(displayId, (HDC)NULL, false); |
| 44 | } |
| 45 | else if (displayId == EGL_SOFTWARE_DISPLAY_ANGLE) |
| 46 | { |
| 47 | display = new egl::Display(displayId, (HDC)NULL, true); |
| 48 | } |
| 49 | else |
| 50 | { |
| 51 | // FIXME: Check if displayId is a valid display device context |
| 52 | |
| 53 | display = new egl::Display(displayId, (HDC)displayId, false); |
| 54 | } |
| 55 | |
| 56 | displays[displayId] = display; |
| 57 | return display; |
| 58 | } |
| 59 | |
| 60 | Display::Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software) : mDc(deviceContext) |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 61 | { |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 62 | |
| 63 | mMinSwapInterval = 1; |
| 64 | mMaxSwapInterval = 1; |
jbauman@chromium.org | 84d7cbc | 2011-07-14 22:53:19 +0000 | [diff] [blame] | 65 | mSoftwareDevice = software; |
| 66 | mDisplayId = displayId; |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 67 | mRenderer = NULL; |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | Display::~Display() |
| 71 | { |
| 72 | terminate(); |
jbauman@chromium.org | 84d7cbc | 2011-07-14 22:53:19 +0000 | [diff] [blame] | 73 | |
| 74 | DisplayMap::iterator thisDisplay = displays.find(mDisplayId); |
| 75 | |
| 76 | if (thisDisplay != displays.end()) |
| 77 | { |
| 78 | displays.erase(thisDisplay); |
| 79 | } |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | bool Display::initialize() |
| 83 | { |
| 84 | if (isInitialized()) |
| 85 | { |
| 86 | return true; |
| 87 | } |
| 88 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 89 | HMODULE hModule = NULL; |
jbauman@chromium.org | 84d7cbc | 2011-07-14 22:53:19 +0000 | [diff] [blame] | 90 | if (mSoftwareDevice) |
| 91 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 92 | hModule = GetModuleHandle(TEXT("swiftshader_d3d9.dll")); |
jbauman@chromium.org | 84d7cbc | 2011-07-14 22:53:19 +0000 | [diff] [blame] | 93 | } |
| 94 | else |
| 95 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 96 | hModule = GetModuleHandle(TEXT("d3d9.dll")); |
jbauman@chromium.org | 84d7cbc | 2011-07-14 22:53:19 +0000 | [diff] [blame] | 97 | } |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 98 | if (hModule == NULL) |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 99 | { |
| 100 | terminate(); |
| 101 | return false; |
| 102 | } |
| 103 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 104 | mRenderer = glCreateRenderer(hModule, mDc); |
| 105 | EGLint status = EGL_BAD_ALLOC; |
| 106 | if (mRenderer) |
| 107 | status = mRenderer->initialize(); |
| 108 | if (status != EGL_SUCCESS) |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 109 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 110 | terminate(); |
| 111 | return error(status, false); |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 112 | } |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 113 | D3DCAPS9 deviceCaps = mRenderer->getDeviceCaps(); // D3D9_REPLACE |
| 114 | IDirect3D9 *d3d9 = mRenderer->getD3D(); // D3D9_REPLACE |
| 115 | UINT adapter = mRenderer->getAdapter(); // D3D9_REPLACE |
| 116 | D3DDEVTYPE deviceType = mRenderer->getDeviceType(); // D3D9_REPLACE |
| 117 | IDirect3DDevice9 *device = mRenderer->getDevice(); // D3D9_REPLACE |
| 118 | |
| 119 | mMinSwapInterval = 4; |
| 120 | mMaxSwapInterval = 0; |
| 121 | |
| 122 | // START D3D9_REPLACE |
| 123 | if (deviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) {mMinSwapInterval = std::min(mMinSwapInterval, 0); mMaxSwapInterval = std::max(mMaxSwapInterval, 0);} |
| 124 | if (deviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_ONE) {mMinSwapInterval = std::min(mMinSwapInterval, 1); mMaxSwapInterval = std::max(mMaxSwapInterval, 1);} |
| 125 | if (deviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO) {mMinSwapInterval = std::min(mMinSwapInterval, 2); mMaxSwapInterval = std::max(mMaxSwapInterval, 2);} |
| 126 | if (deviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_THREE) {mMinSwapInterval = std::min(mMinSwapInterval, 3); mMaxSwapInterval = std::max(mMaxSwapInterval, 3);} |
| 127 | if (deviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_FOUR) {mMinSwapInterval = std::min(mMinSwapInterval, 4); mMaxSwapInterval = std::max(mMaxSwapInterval, 4);} |
| 128 | |
| 129 | const D3DFORMAT renderTargetFormats[] = |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 130 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 131 | D3DFMT_A1R5G5B5, |
| 132 | // D3DFMT_A2R10G10B10, // The color_ramp conformance test uses ReadPixels with UNSIGNED_BYTE causing it to think that rendering skipped a colour value. |
| 133 | D3DFMT_A8R8G8B8, |
| 134 | D3DFMT_R5G6B5, |
| 135 | // D3DFMT_X1R5G5B5, // Has no compatible OpenGL ES renderbuffer format |
| 136 | D3DFMT_X8R8G8B8 |
| 137 | }; |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 138 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 139 | const D3DFORMAT depthStencilFormats[] = |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 140 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 141 | D3DFMT_UNKNOWN, |
| 142 | // D3DFMT_D16_LOCKABLE, |
| 143 | D3DFMT_D32, |
| 144 | // D3DFMT_D15S1, |
| 145 | D3DFMT_D24S8, |
| 146 | D3DFMT_D24X8, |
| 147 | // D3DFMT_D24X4S4, |
| 148 | D3DFMT_D16, |
| 149 | // D3DFMT_D32F_LOCKABLE, |
| 150 | // D3DFMT_D24FS8 |
| 151 | }; |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 152 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 153 | D3DDISPLAYMODE currentDisplayMode; |
| 154 | d3d9->GetAdapterDisplayMode(adapter, ¤tDisplayMode); |
| 155 | |
| 156 | ConfigSet configSet; |
| 157 | |
| 158 | for (int formatIndex = 0; formatIndex < sizeof(renderTargetFormats) / sizeof(D3DFORMAT); formatIndex++) |
| 159 | { |
| 160 | D3DFORMAT renderTargetFormat = renderTargetFormats[formatIndex]; |
| 161 | |
| 162 | HRESULT result = d3d9->CheckDeviceFormat(adapter, deviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, renderTargetFormat); |
| 163 | |
| 164 | if (SUCCEEDED(result)) |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 165 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 166 | for (int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(D3DFORMAT); depthStencilIndex++) |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 167 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 168 | D3DFORMAT depthStencilFormat = depthStencilFormats[depthStencilIndex]; |
| 169 | HRESULT result = D3D_OK; |
daniel@transgaming.com | a114c27 | 2011-04-22 04:18:50 +0000 | [diff] [blame] | 170 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 171 | if(depthStencilFormat != D3DFMT_UNKNOWN) |
| 172 | { |
| 173 | result = d3d9->CheckDeviceFormat(adapter, deviceType, currentDisplayMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, depthStencilFormat); |
| 174 | } |
| 175 | |
| 176 | if (SUCCEEDED(result)) |
| 177 | { |
daniel@transgaming.com | a114c27 | 2011-04-22 04:18:50 +0000 | [diff] [blame] | 178 | if(depthStencilFormat != D3DFMT_UNKNOWN) |
| 179 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 180 | result = d3d9->CheckDepthStencilMatch(adapter, deviceType, currentDisplayMode.Format, renderTargetFormat, depthStencilFormat); |
daniel@transgaming.com | a114c27 | 2011-04-22 04:18:50 +0000 | [diff] [blame] | 181 | } |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 182 | |
| 183 | if (SUCCEEDED(result)) |
| 184 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 185 | // FIXME: enumerate multi-sampling |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 186 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 187 | configSet.add(currentDisplayMode, mMinSwapInterval, mMaxSwapInterval, renderTargetFormat, depthStencilFormat, 0, |
| 188 | deviceCaps.MaxTextureWidth, deviceCaps.MaxTextureHeight); |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | } |
| 192 | } |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 193 | } |
| 194 | // END D3D9_REPLACE |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 195 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 196 | // Give the sorted configs a unique ID and store them internally |
| 197 | EGLint index = 1; |
| 198 | for (ConfigSet::Iterator config = configSet.mSet.begin(); config != configSet.mSet.end(); config++) |
| 199 | { |
| 200 | Config configuration = *config; |
| 201 | configuration.mConfigID = index; |
| 202 | index++; |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 203 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 204 | mConfigSet.mSet.insert(configuration); |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | if (!isInitialized()) |
| 208 | { |
| 209 | terminate(); |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 210 | return false; |
| 211 | } |
| 212 | |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 213 | initExtensionString(); |
| 214 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 215 | mVertexShaderCache.initialize(device); |
| 216 | mPixelShaderCache.initialize(device); |
apatrick@chromium.org | 3cfd722 | 2012-07-13 22:36:58 +0000 | [diff] [blame] | 217 | |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 218 | return true; |
| 219 | } |
| 220 | |
| 221 | void Display::terminate() |
| 222 | { |
| 223 | while (!mSurfaceSet.empty()) |
| 224 | { |
| 225 | destroySurface(*mSurfaceSet.begin()); |
| 226 | } |
| 227 | |
| 228 | while (!mContextSet.empty()) |
| 229 | { |
| 230 | destroyContext(*mContextSet.begin()); |
| 231 | } |
| 232 | |
apatrick@chromium.org | f289ee8 | 2012-01-11 20:03:29 +0000 | [diff] [blame] | 233 | while (!mEventQueryPool.empty()) |
apatrick@chromium.org | a5ddde9 | 2012-01-10 23:00:07 +0000 | [diff] [blame] | 234 | { |
apatrick@chromium.org | f289ee8 | 2012-01-11 20:03:29 +0000 | [diff] [blame] | 235 | mEventQueryPool.back()->Release(); |
| 236 | mEventQueryPool.pop_back(); |
apatrick@chromium.org | a5ddde9 | 2012-01-10 23:00:07 +0000 | [diff] [blame] | 237 | } |
| 238 | |
apatrick@chromium.org | 3cfd722 | 2012-07-13 22:36:58 +0000 | [diff] [blame] | 239 | mVertexShaderCache.clear(); |
| 240 | mPixelShaderCache.clear(); |
| 241 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 242 | glDestroyRenderer(mRenderer); |
| 243 | mRenderer = NULL; |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | bool Display::getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig) |
| 247 | { |
| 248 | return mConfigSet.getConfigs(configs, attribList, configSize, numConfig); |
| 249 | } |
| 250 | |
| 251 | bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value) |
| 252 | { |
| 253 | const egl::Config *configuration = mConfigSet.get(config); |
| 254 | |
| 255 | switch (attribute) |
| 256 | { |
| 257 | case EGL_BUFFER_SIZE: *value = configuration->mBufferSize; break; |
| 258 | case EGL_ALPHA_SIZE: *value = configuration->mAlphaSize; break; |
| 259 | case EGL_BLUE_SIZE: *value = configuration->mBlueSize; break; |
| 260 | case EGL_GREEN_SIZE: *value = configuration->mGreenSize; break; |
| 261 | case EGL_RED_SIZE: *value = configuration->mRedSize; break; |
| 262 | case EGL_DEPTH_SIZE: *value = configuration->mDepthSize; break; |
| 263 | case EGL_STENCIL_SIZE: *value = configuration->mStencilSize; break; |
| 264 | case EGL_CONFIG_CAVEAT: *value = configuration->mConfigCaveat; break; |
| 265 | case EGL_CONFIG_ID: *value = configuration->mConfigID; break; |
| 266 | case EGL_LEVEL: *value = configuration->mLevel; break; |
| 267 | case EGL_NATIVE_RENDERABLE: *value = configuration->mNativeRenderable; break; |
| 268 | case EGL_NATIVE_VISUAL_TYPE: *value = configuration->mNativeVisualType; break; |
| 269 | case EGL_SAMPLES: *value = configuration->mSamples; break; |
| 270 | case EGL_SAMPLE_BUFFERS: *value = configuration->mSampleBuffers; break; |
| 271 | case EGL_SURFACE_TYPE: *value = configuration->mSurfaceType; break; |
| 272 | case EGL_TRANSPARENT_TYPE: *value = configuration->mTransparentType; break; |
| 273 | case EGL_TRANSPARENT_BLUE_VALUE: *value = configuration->mTransparentBlueValue; break; |
| 274 | case EGL_TRANSPARENT_GREEN_VALUE: *value = configuration->mTransparentGreenValue; break; |
| 275 | case EGL_TRANSPARENT_RED_VALUE: *value = configuration->mTransparentRedValue; break; |
| 276 | case EGL_BIND_TO_TEXTURE_RGB: *value = configuration->mBindToTextureRGB; break; |
| 277 | case EGL_BIND_TO_TEXTURE_RGBA: *value = configuration->mBindToTextureRGBA; break; |
| 278 | case EGL_MIN_SWAP_INTERVAL: *value = configuration->mMinSwapInterval; break; |
| 279 | case EGL_MAX_SWAP_INTERVAL: *value = configuration->mMaxSwapInterval; break; |
| 280 | case EGL_LUMINANCE_SIZE: *value = configuration->mLuminanceSize; break; |
| 281 | case EGL_ALPHA_MASK_SIZE: *value = configuration->mAlphaMaskSize; break; |
| 282 | case EGL_COLOR_BUFFER_TYPE: *value = configuration->mColorBufferType; break; |
| 283 | case EGL_RENDERABLE_TYPE: *value = configuration->mRenderableType; break; |
| 284 | case EGL_MATCH_NATIVE_PIXMAP: *value = false; UNIMPLEMENTED(); break; |
| 285 | case EGL_CONFORMANT: *value = configuration->mConformant; break; |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 286 | case EGL_MAX_PBUFFER_WIDTH: *value = configuration->mMaxPBufferWidth; break; |
| 287 | case EGL_MAX_PBUFFER_HEIGHT: *value = configuration->mMaxPBufferHeight; break; |
| 288 | case EGL_MAX_PBUFFER_PIXELS: *value = configuration->mMaxPBufferPixels; break; |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 289 | default: |
| 290 | return false; |
| 291 | } |
| 292 | |
| 293 | return true; |
| 294 | } |
| 295 | |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 296 | |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 297 | |
jbauman@chromium.org | 06d7a75 | 2011-04-30 01:02:52 +0000 | [diff] [blame] | 298 | EGLSurface Display::createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList) |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 299 | { |
| 300 | const Config *configuration = mConfigSet.get(config); |
apatrick@chromium.org | f4490e2 | 2011-12-06 02:05:22 +0000 | [diff] [blame] | 301 | EGLint postSubBufferSupported = EGL_FALSE; |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 302 | |
jbauman@chromium.org | 06d7a75 | 2011-04-30 01:02:52 +0000 | [diff] [blame] | 303 | if (attribList) |
| 304 | { |
| 305 | while (*attribList != EGL_NONE) |
| 306 | { |
| 307 | switch (attribList[0]) |
| 308 | { |
| 309 | case EGL_RENDER_BUFFER: |
| 310 | switch (attribList[1]) |
| 311 | { |
| 312 | case EGL_BACK_BUFFER: |
| 313 | break; |
| 314 | case EGL_SINGLE_BUFFER: |
| 315 | return error(EGL_BAD_MATCH, EGL_NO_SURFACE); // Rendering directly to front buffer not supported |
| 316 | default: |
| 317 | return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); |
| 318 | } |
| 319 | break; |
apatrick@chromium.org | f4490e2 | 2011-12-06 02:05:22 +0000 | [diff] [blame] | 320 | case EGL_POST_SUB_BUFFER_SUPPORTED_NV: |
| 321 | postSubBufferSupported = attribList[1]; |
| 322 | break; |
jbauman@chromium.org | 06d7a75 | 2011-04-30 01:02:52 +0000 | [diff] [blame] | 323 | case EGL_VG_COLORSPACE: |
| 324 | return error(EGL_BAD_MATCH, EGL_NO_SURFACE); |
| 325 | case EGL_VG_ALPHA_FORMAT: |
| 326 | return error(EGL_BAD_MATCH, EGL_NO_SURFACE); |
| 327 | default: |
| 328 | return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); |
| 329 | } |
| 330 | |
| 331 | attribList += 2; |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | if (hasExistingWindowSurface(window)) |
| 336 | { |
| 337 | return error(EGL_BAD_ALLOC, EGL_NO_SURFACE); |
| 338 | } |
| 339 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 340 | if (mRenderer->testDeviceLost()) |
daniel@transgaming.com | cf23c45 | 2011-11-09 17:47:26 +0000 | [diff] [blame] | 341 | { |
vangelis@google.com | 8c9c452 | 2011-09-09 18:22:28 +0000 | [diff] [blame] | 342 | if (!restoreLostDevice()) |
| 343 | return EGL_NO_SURFACE; |
| 344 | } |
| 345 | |
apatrick@chromium.org | f4490e2 | 2011-12-06 02:05:22 +0000 | [diff] [blame] | 346 | Surface *surface = new Surface(this, configuration, window, postSubBufferSupported); |
jbauman@chromium.org | 4e29770 | 2011-05-12 23:04:07 +0000 | [diff] [blame] | 347 | |
| 348 | if (!surface->initialize()) |
| 349 | { |
| 350 | delete surface; |
| 351 | return EGL_NO_SURFACE; |
| 352 | } |
| 353 | |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 354 | mSurfaceSet.insert(surface); |
| 355 | |
jbauman@chromium.org | 06d7a75 | 2011-04-30 01:02:52 +0000 | [diff] [blame] | 356 | return success(surface); |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 357 | } |
| 358 | |
jbauman@chromium.org | 4e29770 | 2011-05-12 23:04:07 +0000 | [diff] [blame] | 359 | EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList) |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 360 | { |
jbauman@chromium.org | 06d7a75 | 2011-04-30 01:02:52 +0000 | [diff] [blame] | 361 | EGLint width = 0, height = 0; |
| 362 | EGLenum textureFormat = EGL_NO_TEXTURE; |
| 363 | EGLenum textureTarget = EGL_NO_TEXTURE; |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 364 | const Config *configuration = mConfigSet.get(config); |
| 365 | |
jbauman@chromium.org | 06d7a75 | 2011-04-30 01:02:52 +0000 | [diff] [blame] | 366 | if (attribList) |
| 367 | { |
| 368 | while (*attribList != EGL_NONE) |
| 369 | { |
| 370 | switch (attribList[0]) |
| 371 | { |
| 372 | case EGL_WIDTH: |
| 373 | width = attribList[1]; |
| 374 | break; |
| 375 | case EGL_HEIGHT: |
| 376 | height = attribList[1]; |
| 377 | break; |
| 378 | case EGL_LARGEST_PBUFFER: |
| 379 | if (attribList[1] != EGL_FALSE) |
| 380 | UNIMPLEMENTED(); // FIXME |
| 381 | break; |
| 382 | case EGL_TEXTURE_FORMAT: |
| 383 | switch (attribList[1]) |
| 384 | { |
| 385 | case EGL_NO_TEXTURE: |
| 386 | case EGL_TEXTURE_RGB: |
| 387 | case EGL_TEXTURE_RGBA: |
| 388 | textureFormat = attribList[1]; |
| 389 | break; |
| 390 | default: |
| 391 | return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); |
| 392 | } |
| 393 | break; |
| 394 | case EGL_TEXTURE_TARGET: |
| 395 | switch (attribList[1]) |
| 396 | { |
| 397 | case EGL_NO_TEXTURE: |
| 398 | case EGL_TEXTURE_2D: |
| 399 | textureTarget = attribList[1]; |
| 400 | break; |
| 401 | default: |
| 402 | return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); |
| 403 | } |
| 404 | break; |
| 405 | case EGL_MIPMAP_TEXTURE: |
| 406 | if (attribList[1] != EGL_FALSE) |
| 407 | return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); |
| 408 | break; |
| 409 | case EGL_VG_COLORSPACE: |
| 410 | return error(EGL_BAD_MATCH, EGL_NO_SURFACE); |
| 411 | case EGL_VG_ALPHA_FORMAT: |
| 412 | return error(EGL_BAD_MATCH, EGL_NO_SURFACE); |
| 413 | default: |
| 414 | return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); |
| 415 | } |
| 416 | |
| 417 | attribList += 2; |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | if (width < 0 || height < 0) |
| 422 | { |
| 423 | return error(EGL_BAD_PARAMETER, EGL_NO_SURFACE); |
| 424 | } |
| 425 | |
| 426 | if (width == 0 || height == 0) |
| 427 | { |
| 428 | return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); |
| 429 | } |
| 430 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 431 | if (textureFormat != EGL_NO_TEXTURE && !mRenderer->getNonPower2TextureSupport() && (!gl::isPow2(width) || !gl::isPow2(height))) |
jbauman@chromium.org | 06d7a75 | 2011-04-30 01:02:52 +0000 | [diff] [blame] | 432 | { |
| 433 | return error(EGL_BAD_MATCH, EGL_NO_SURFACE); |
| 434 | } |
| 435 | |
| 436 | if ((textureFormat != EGL_NO_TEXTURE && textureTarget == EGL_NO_TEXTURE) || |
| 437 | (textureFormat == EGL_NO_TEXTURE && textureTarget != EGL_NO_TEXTURE)) |
| 438 | { |
| 439 | return error(EGL_BAD_MATCH, EGL_NO_SURFACE); |
| 440 | } |
| 441 | |
| 442 | if (!(configuration->mSurfaceType & EGL_PBUFFER_BIT)) |
| 443 | { |
| 444 | return error(EGL_BAD_MATCH, EGL_NO_SURFACE); |
| 445 | } |
| 446 | |
| 447 | if ((textureFormat == EGL_TEXTURE_RGB && configuration->mBindToTextureRGB != EGL_TRUE) || |
| 448 | (textureFormat == EGL_TEXTURE_RGBA && configuration->mBindToTextureRGBA != EGL_TRUE)) |
| 449 | { |
| 450 | return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); |
| 451 | } |
| 452 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 453 | if (mRenderer->testDeviceLost()) |
daniel@transgaming.com | cf23c45 | 2011-11-09 17:47:26 +0000 | [diff] [blame] | 454 | { |
vangelis@google.com | 8c9c452 | 2011-09-09 18:22:28 +0000 | [diff] [blame] | 455 | if (!restoreLostDevice()) |
| 456 | return EGL_NO_SURFACE; |
| 457 | } |
| 458 | |
jbauman@chromium.org | 4e29770 | 2011-05-12 23:04:07 +0000 | [diff] [blame] | 459 | Surface *surface = new Surface(this, configuration, shareHandle, width, height, textureFormat, textureTarget); |
| 460 | |
| 461 | if (!surface->initialize()) |
| 462 | { |
| 463 | delete surface; |
| 464 | return EGL_NO_SURFACE; |
| 465 | } |
| 466 | |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 467 | mSurfaceSet.insert(surface); |
| 468 | |
jbauman@chromium.org | 06d7a75 | 2011-04-30 01:02:52 +0000 | [diff] [blame] | 469 | return success(surface); |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 470 | } |
| 471 | |
daniel@transgaming.com | 4ff960d | 2011-11-09 17:47:09 +0000 | [diff] [blame] | 472 | EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *shareContext, bool notifyResets, bool robustAccess) |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 473 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 474 | if (!mRenderer) |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 475 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 476 | return NULL; |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 477 | } |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 478 | else if (mRenderer->testDeviceLost()) // Lost device |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 479 | { |
vangelis@google.com | 8c9c452 | 2011-09-09 18:22:28 +0000 | [diff] [blame] | 480 | if (!restoreLostDevice()) |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 481 | return NULL; |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | const egl::Config *config = mConfigSet.get(configHandle); |
| 485 | |
daniel@transgaming.com | 4ff960d | 2011-11-09 17:47:09 +0000 | [diff] [blame] | 486 | gl::Context *context = glCreateContext(config, shareContext, notifyResets, robustAccess); |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 487 | mContextSet.insert(context); |
| 488 | |
| 489 | return context; |
| 490 | } |
| 491 | |
vangelis@google.com | 8c9c452 | 2011-09-09 18:22:28 +0000 | [diff] [blame] | 492 | bool Display::restoreLostDevice() |
| 493 | { |
daniel@transgaming.com | cf23c45 | 2011-11-09 17:47:26 +0000 | [diff] [blame] | 494 | for (ContextSet::iterator ctx = mContextSet.begin(); ctx != mContextSet.end(); ctx++) |
| 495 | { |
| 496 | if ((*ctx)->isResetNotificationEnabled()) |
| 497 | return false; // If reset notifications have been requested, application must delete all contexts first |
| 498 | } |
| 499 | |
vangelis@google.com | 8c9c452 | 2011-09-09 18:22:28 +0000 | [diff] [blame] | 500 | // Release surface resources to make the Reset() succeed |
| 501 | for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++) |
| 502 | { |
| 503 | (*surface)->release(); |
| 504 | } |
| 505 | |
apatrick@chromium.org | f289ee8 | 2012-01-11 20:03:29 +0000 | [diff] [blame] | 506 | while (!mEventQueryPool.empty()) |
apatrick@chromium.org | a5ddde9 | 2012-01-10 23:00:07 +0000 | [diff] [blame] | 507 | { |
apatrick@chromium.org | f289ee8 | 2012-01-11 20:03:29 +0000 | [diff] [blame] | 508 | mEventQueryPool.back()->Release(); |
| 509 | mEventQueryPool.pop_back(); |
apatrick@chromium.org | a5ddde9 | 2012-01-10 23:00:07 +0000 | [diff] [blame] | 510 | } |
| 511 | |
apatrick@chromium.org | 3cfd722 | 2012-07-13 22:36:58 +0000 | [diff] [blame] | 512 | mVertexShaderCache.clear(); |
| 513 | mPixelShaderCache.clear(); |
| 514 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 515 | if (!mRenderer->resetDevice()) |
vangelis@google.com | 8c9c452 | 2011-09-09 18:22:28 +0000 | [diff] [blame] | 516 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 517 | return error(EGL_BAD_ALLOC, false); |
vangelis@google.com | 8c9c452 | 2011-09-09 18:22:28 +0000 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | // Restore any surfaces that may have been lost |
| 521 | for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++) |
| 522 | { |
| 523 | (*surface)->resetSwapChain(); |
| 524 | } |
| 525 | |
| 526 | return true; |
| 527 | } |
| 528 | |
| 529 | |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 530 | void Display::destroySurface(egl::Surface *surface) |
| 531 | { |
daniel@transgaming.com | c556fa5 | 2011-05-26 14:13:29 +0000 | [diff] [blame] | 532 | delete surface; |
| 533 | mSurfaceSet.erase(surface); |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | void Display::destroyContext(gl::Context *context) |
| 537 | { |
| 538 | glDestroyContext(context); |
| 539 | mContextSet.erase(context); |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 540 | } |
| 541 | |
daniel@transgaming.com | 09fcc9f | 2011-11-09 17:46:47 +0000 | [diff] [blame] | 542 | void Display::notifyDeviceLost() |
| 543 | { |
| 544 | for (ContextSet::iterator context = mContextSet.begin(); context != mContextSet.end(); context++) |
| 545 | { |
| 546 | (*context)->markContextLost(); |
| 547 | } |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 548 | mRenderer->markDeviceLost(); |
daniel@transgaming.com | 09fcc9f | 2011-11-09 17:46:47 +0000 | [diff] [blame] | 549 | error(EGL_CONTEXT_LOST); |
| 550 | } |
| 551 | |
daniel@transgaming.com | 3b1703f | 2011-05-11 15:36:26 +0000 | [diff] [blame] | 552 | bool Display::isInitialized() const |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 553 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 554 | return mRenderer != NULL && mConfigSet.size() > 0; |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | bool Display::isValidConfig(EGLConfig config) |
| 558 | { |
| 559 | return mConfigSet.get(config) != NULL; |
| 560 | } |
| 561 | |
| 562 | bool Display::isValidContext(gl::Context *context) |
| 563 | { |
| 564 | return mContextSet.find(context) != mContextSet.end(); |
| 565 | } |
| 566 | |
| 567 | bool Display::isValidSurface(egl::Surface *surface) |
| 568 | { |
daniel@transgaming.com | c556fa5 | 2011-05-26 14:13:29 +0000 | [diff] [blame] | 569 | return mSurfaceSet.find(surface) != mSurfaceSet.end(); |
daniel@transgaming.com | e979ead | 2010-09-23 18:03:14 +0000 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | bool Display::hasExistingWindowSurface(HWND window) |
| 573 | { |
| 574 | for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++) |
| 575 | { |
| 576 | if ((*surface)->getWindowHandle() == window) |
| 577 | { |
| 578 | return true; |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | return false; |
| 583 | } |
| 584 | |
| 585 | EGLint Display::getMinSwapInterval() |
| 586 | { |
| 587 | return mMinSwapInterval; |
| 588 | } |
| 589 | |
| 590 | EGLint Display::getMaxSwapInterval() |
| 591 | { |
| 592 | return mMaxSwapInterval; |
| 593 | } |
| 594 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 595 | // D3D9_REPLACE |
apatrick@chromium.org | a5ddde9 | 2012-01-10 23:00:07 +0000 | [diff] [blame] | 596 | void Display::sync(bool block) |
| 597 | { |
| 598 | HRESULT result; |
| 599 | |
apatrick@chromium.org | f289ee8 | 2012-01-11 20:03:29 +0000 | [diff] [blame] | 600 | IDirect3DQuery9* query = allocateEventQuery(); |
| 601 | if (!query) |
apatrick@chromium.org | a5ddde9 | 2012-01-10 23:00:07 +0000 | [diff] [blame] | 602 | { |
| 603 | return; |
| 604 | } |
| 605 | |
apatrick@chromium.org | f289ee8 | 2012-01-11 20:03:29 +0000 | [diff] [blame] | 606 | result = query->Issue(D3DISSUE_END); |
apatrick@chromium.org | a5ddde9 | 2012-01-10 23:00:07 +0000 | [diff] [blame] | 607 | ASSERT(SUCCEEDED(result)); |
| 608 | |
| 609 | do |
| 610 | { |
apatrick@chromium.org | f289ee8 | 2012-01-11 20:03:29 +0000 | [diff] [blame] | 611 | result = query->GetData(NULL, 0, D3DGETDATA_FLUSH); |
apatrick@chromium.org | a5ddde9 | 2012-01-10 23:00:07 +0000 | [diff] [blame] | 612 | |
| 613 | if(block && result == S_FALSE) |
| 614 | { |
| 615 | // Keep polling, but allow other threads to do something useful first |
| 616 | Sleep(0); |
| 617 | // explicitly check for device loss |
| 618 | // some drivers seem to return S_FALSE even if the device is lost |
| 619 | // instead of D3DERR_DEVICELOST like they should |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 620 | if (mRenderer->testDeviceLost()) |
apatrick@chromium.org | a5ddde9 | 2012-01-10 23:00:07 +0000 | [diff] [blame] | 621 | { |
| 622 | result = D3DERR_DEVICELOST; |
| 623 | } |
| 624 | } |
| 625 | } |
| 626 | while(block && result == S_FALSE); |
| 627 | |
apatrick@chromium.org | f289ee8 | 2012-01-11 20:03:29 +0000 | [diff] [blame] | 628 | freeEventQuery(query); |
| 629 | |
daniel@transgaming.com | 2678b34 | 2012-01-18 16:29:40 +0000 | [diff] [blame] | 630 | if (isDeviceLostError(result)) |
| 631 | { |
| 632 | notifyDeviceLost(); |
apatrick@chromium.org | f289ee8 | 2012-01-11 20:03:29 +0000 | [diff] [blame] | 633 | } |
| 634 | } |
| 635 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 636 | // D3D9_REPLACE |
apatrick@chromium.org | f289ee8 | 2012-01-11 20:03:29 +0000 | [diff] [blame] | 637 | IDirect3DQuery9* Display::allocateEventQuery() |
| 638 | { |
| 639 | IDirect3DQuery9 *query = NULL; |
| 640 | |
| 641 | if (mEventQueryPool.empty()) |
apatrick@chromium.org | a5ddde9 | 2012-01-10 23:00:07 +0000 | [diff] [blame] | 642 | { |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 643 | HRESULT result = mRenderer->getDevice()->CreateQuery(D3DQUERYTYPE_EVENT, &query); |
apatrick@chromium.org | f289ee8 | 2012-01-11 20:03:29 +0000 | [diff] [blame] | 644 | ASSERT(SUCCEEDED(result)); |
| 645 | } |
| 646 | else |
| 647 | { |
| 648 | query = mEventQueryPool.back(); |
| 649 | mEventQueryPool.pop_back(); |
| 650 | } |
| 651 | |
| 652 | return query; |
| 653 | } |
| 654 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 655 | // D3D9_REPLACE |
apatrick@chromium.org | f289ee8 | 2012-01-11 20:03:29 +0000 | [diff] [blame] | 656 | void Display::freeEventQuery(IDirect3DQuery9* query) |
| 657 | { |
| 658 | if (mEventQueryPool.size() > 1000) |
| 659 | { |
| 660 | query->Release(); |
| 661 | } |
| 662 | else |
| 663 | { |
| 664 | mEventQueryPool.push_back(query); |
apatrick@chromium.org | a5ddde9 | 2012-01-10 23:00:07 +0000 | [diff] [blame] | 665 | } |
| 666 | } |
| 667 | |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 668 | |
| 669 | void Display::initExtensionString() |
| 670 | { |
jbauman@chromium.org | 84d7cbc | 2011-07-14 22:53:19 +0000 | [diff] [blame] | 671 | HMODULE swiftShader = GetModuleHandle(TEXT("swiftshader_d3d9.dll")); |
daniel@transgaming.com | 313e392 | 2012-10-31 17:52:39 +0000 | [diff] [blame^] | 672 | bool shareHandleSupported = mRenderer->getShareHandleSupport(); |
daniel@transgaming.com | 1a1fe24 | 2011-09-26 18:25:45 +0000 | [diff] [blame] | 673 | |
| 674 | mExtensionString = ""; |
| 675 | |
daniel@transgaming.com | 8747f18 | 2011-11-09 17:50:38 +0000 | [diff] [blame] | 676 | // Multi-vendor (EXT) extensions |
| 677 | mExtensionString += "EGL_EXT_create_context_robustness "; |
| 678 | |
| 679 | // ANGLE-specific extensions |
daniel@transgaming.com | 313e392 | 2012-10-31 17:52:39 +0000 | [diff] [blame^] | 680 | if (shareHandleSupported) |
apatrick@chromium.org | f4490e2 | 2011-12-06 02:05:22 +0000 | [diff] [blame] | 681 | { |
daniel@transgaming.com | 1a1fe24 | 2011-09-26 18:25:45 +0000 | [diff] [blame] | 682 | mExtensionString += "EGL_ANGLE_d3d_share_handle_client_buffer "; |
| 683 | } |
| 684 | |
| 685 | mExtensionString += "EGL_ANGLE_query_surface_pointer "; |
jbauman@chromium.org | 84d7cbc | 2011-07-14 22:53:19 +0000 | [diff] [blame] | 686 | |
| 687 | if (swiftShader) |
| 688 | { |
apatrick@chromium.org | f4490e2 | 2011-12-06 02:05:22 +0000 | [diff] [blame] | 689 | mExtensionString += "EGL_ANGLE_software_display "; |
jbauman@chromium.org | 84d7cbc | 2011-07-14 22:53:19 +0000 | [diff] [blame] | 690 | } |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 691 | |
daniel@transgaming.com | 313e392 | 2012-10-31 17:52:39 +0000 | [diff] [blame^] | 692 | if (shareHandleSupported) |
apatrick@chromium.org | f4490e2 | 2011-12-06 02:05:22 +0000 | [diff] [blame] | 693 | { |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 694 | mExtensionString += "EGL_ANGLE_surface_d3d_texture_2d_share_handle "; |
| 695 | } |
| 696 | |
apatrick@chromium.org | f4490e2 | 2011-12-06 02:05:22 +0000 | [diff] [blame] | 697 | mExtensionString += "EGL_NV_post_sub_buffer"; |
| 698 | |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 699 | std::string::size_type end = mExtensionString.find_last_not_of(' '); |
| 700 | if (end != std::string::npos) |
| 701 | { |
| 702 | mExtensionString.resize(end+1); |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | const char *Display::getExtensionString() const |
| 707 | { |
| 708 | return mExtensionString.c_str(); |
| 709 | } |
| 710 | |
apatrick@chromium.org | 3cfd722 | 2012-07-13 22:36:58 +0000 | [diff] [blame] | 711 | IDirect3DVertexShader9 *Display::createVertexShader(const DWORD *function, size_t length) |
| 712 | { |
| 713 | return mVertexShaderCache.create(function, length); |
| 714 | } |
| 715 | |
| 716 | IDirect3DPixelShader9 *Display::createPixelShader(const DWORD *function, size_t length) |
| 717 | { |
| 718 | return mPixelShaderCache.create(function, length); |
| 719 | } |
| 720 | |
daniel@transgaming.com | c6f7f9d | 2012-01-27 15:40:00 +0000 | [diff] [blame] | 721 | |
vladimirv@gmail.com | 721b7f2 | 2011-02-11 00:54:47 +0000 | [diff] [blame] | 722 | } |