blob: 8ac20ab98b69a7def9f7c3a8a710769349bd0d47 [file] [log] [blame]
daniel@transgaming.come979ead2010-09-23 18:03:14 +00001//
daniel@transgaming.com3b1703f2011-05-11 15:36:26 +00002// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.come979ead2010-09-23 18:03:14 +00003// 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.org84d7cbc2011-07-14 22:53:19 +000014#include <map>
daniel@transgaming.come979ead2010-09-23 18:03:14 +000015#include <vector>
16
17#include "common/debug.h"
jbauman@chromium.org06d7a752011-04-30 01:02:52 +000018#include "libGLESv2/mathutil.h"
daniel@transgaming.come979ead2010-09-23 18:03:14 +000019
20#include "libEGL/main.h"
21
baustin@google.com250f06c2011-06-06 16:59:53 +000022// Can also be enabled by defining FORCE_REF_RAST in the project's predefined macros
23#define REF_RAST 0
24
25// The "Debug This Pixel..." feature in PIX often fails when using the
26// D3D9Ex interfaces. In order to get debug pixel to work on a Vista/Win 7
27// machine, define "ANGLE_ENABLE_D3D9EX=0" in your project file.
28#if !defined(ANGLE_ENABLE_D3D9EX)
29// Enables use of the IDirect3D9Ex interface, when available
30#define ANGLE_ENABLE_D3D9EX 1
31#endif // !defined(ANGLE_ENABLE_D3D9EX)
daniel@transgaming.come979ead2010-09-23 18:03:14 +000032
33namespace egl
34{
jbauman@chromium.org84d7cbc2011-07-14 22:53:19 +000035namespace
36{
37 typedef std::map<EGLNativeDisplayType, Display*> DisplayMap;
38 DisplayMap displays;
39}
40
41egl::Display *Display::getDisplay(EGLNativeDisplayType displayId)
42{
43 if (displays.find(displayId) != displays.end())
44 {
45 return displays[displayId];
46 }
47
48 egl::Display *display = NULL;
49
50 if (displayId == EGL_DEFAULT_DISPLAY)
51 {
52 display = new egl::Display(displayId, (HDC)NULL, false);
53 }
54 else if (displayId == EGL_SOFTWARE_DISPLAY_ANGLE)
55 {
56 display = new egl::Display(displayId, (HDC)NULL, true);
57 }
58 else
59 {
60 // FIXME: Check if displayId is a valid display device context
61
62 display = new egl::Display(displayId, (HDC)displayId, false);
63 }
64
65 displays[displayId] = display;
66 return display;
67}
68
69Display::Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software) : mDc(deviceContext)
daniel@transgaming.come979ead2010-09-23 18:03:14 +000070{
71 mD3d9Module = NULL;
72
73 mD3d9 = NULL;
apatrick@chromium.org9e83b592011-02-10 22:04:34 +000074 mD3d9Ex = NULL;
daniel@transgaming.come979ead2010-09-23 18:03:14 +000075 mDevice = NULL;
apatrick@chromium.org9e83b592011-02-10 22:04:34 +000076 mDeviceEx = NULL;
daniel@transgaming.come979ead2010-09-23 18:03:14 +000077 mDeviceWindow = NULL;
78
79 mAdapter = D3DADAPTER_DEFAULT;
80
81 #if REF_RAST == 1 || defined(FORCE_REF_RAST)
82 mDeviceType = D3DDEVTYPE_REF;
83 #else
84 mDeviceType = D3DDEVTYPE_HAL;
85 #endif
86
87 mMinSwapInterval = 1;
88 mMaxSwapInterval = 1;
jbauman@chromium.org84d7cbc2011-07-14 22:53:19 +000089 mSoftwareDevice = software;
90 mDisplayId = displayId;
daniel@transgaming.come979ead2010-09-23 18:03:14 +000091}
92
93Display::~Display()
94{
95 terminate();
jbauman@chromium.org84d7cbc2011-07-14 22:53:19 +000096
97 DisplayMap::iterator thisDisplay = displays.find(mDisplayId);
98
99 if (thisDisplay != displays.end())
100 {
101 displays.erase(thisDisplay);
102 }
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000103}
104
105bool Display::initialize()
106{
107 if (isInitialized())
108 {
109 return true;
110 }
111
jbauman@chromium.org84d7cbc2011-07-14 22:53:19 +0000112 if (mSoftwareDevice)
113 {
114 mD3d9Module = GetModuleHandle(TEXT("swiftshader_d3d9.dll"));
115 }
116 else
117 {
118 mD3d9Module = GetModuleHandle(TEXT("d3d9.dll"));
119 }
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000120 if (mD3d9Module == NULL)
121 {
122 terminate();
123 return false;
124 }
125
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000126 typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT, IDirect3D9Ex**);
127 Direct3DCreate9ExFunc Direct3DCreate9ExPtr = reinterpret_cast<Direct3DCreate9ExFunc>(GetProcAddress(mD3d9Module, "Direct3DCreate9Ex"));
128
129 // Use Direct3D9Ex if available. Among other things, this version is less
130 // inclined to report a lost context, for example when the user switches
131 // desktop. Direct3D9Ex is available in Windows Vista and later if suitable drivers are available.
baustin@google.com250f06c2011-06-06 16:59:53 +0000132 if (ANGLE_ENABLE_D3D9EX && Direct3DCreate9ExPtr && SUCCEEDED(Direct3DCreate9ExPtr(D3D_SDK_VERSION, &mD3d9Ex)))
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000133 {
apatrick@chromium.org9e83b592011-02-10 22:04:34 +0000134 ASSERT(mD3d9Ex);
135 mD3d9Ex->QueryInterface(IID_IDirect3D9, reinterpret_cast<void**>(&mD3d9));
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000136 ASSERT(mD3d9);
137 }
138 else
139 {
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000140 mD3d9 = Direct3DCreate9(D3D_SDK_VERSION);
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000141 }
142
143 if (mD3d9)
144 {
145 if (mDc != NULL)
146 {
147 // UNIMPLEMENTED(); // FIXME: Determine which adapter index the device context corresponds to
148 }
149
150 HRESULT result;
151
apatrick@chromium.org1c768012010-10-07 00:35:24 +0000152 // Give up on getting device caps after about one second.
153 for (int i = 0; i < 10; ++i)
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000154 {
155 result = mD3d9->GetDeviceCaps(mAdapter, mDeviceType, &mDeviceCaps);
apatrick@chromium.org1c768012010-10-07 00:35:24 +0000156
157 if (SUCCEEDED(result))
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000158 {
apatrick@chromium.org1c768012010-10-07 00:35:24 +0000159 break;
160 }
161 else if (result == D3DERR_NOTAVAILABLE)
162 {
163 Sleep(100); // Give the driver some time to initialize/recover
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000164 }
165 else if (FAILED(result)) // D3DERR_OUTOFVIDEOMEMORY, E_OUTOFMEMORY, D3DERR_INVALIDDEVICE, or another error we can't recover from
166 {
apatrick@chromium.org1c768012010-10-07 00:35:24 +0000167 terminate();
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000168 return error(EGL_BAD_ALLOC, false);
169 }
170 }
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000171
172 if (mDeviceCaps.PixelShaderVersion < D3DPS_VERSION(2, 0))
173 {
174 terminate();
175 return error(EGL_NOT_INITIALIZED, false);
176 }
177
apatrick@chromium.org1c768012010-10-07 00:35:24 +0000178 // When DirectX9 is running with an older DirectX8 driver, a StretchRect from a regular texture to a render target texture is not supported.
179 // This is required by Texture2D::convertToRenderTarget.
180 if ((mDeviceCaps.DevCaps2 & D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES) == 0)
181 {
182 terminate();
183 return error(EGL_NOT_INITIALIZED, false);
184 }
185
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000186 mMinSwapInterval = 4;
187 mMaxSwapInterval = 0;
188
189 if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) {mMinSwapInterval = std::min(mMinSwapInterval, 0); mMaxSwapInterval = std::max(mMaxSwapInterval, 0);}
190 if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_ONE) {mMinSwapInterval = std::min(mMinSwapInterval, 1); mMaxSwapInterval = std::max(mMaxSwapInterval, 1);}
191 if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO) {mMinSwapInterval = std::min(mMinSwapInterval, 2); mMaxSwapInterval = std::max(mMaxSwapInterval, 2);}
192 if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_THREE) {mMinSwapInterval = std::min(mMinSwapInterval, 3); mMaxSwapInterval = std::max(mMaxSwapInterval, 3);}
193 if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_FOUR) {mMinSwapInterval = std::min(mMinSwapInterval, 4); mMaxSwapInterval = std::max(mMaxSwapInterval, 4);}
194
jbauman@chromium.org03208d52011-06-15 01:15:24 +0000195 mD3d9->GetAdapterIdentifier(mAdapter, 0, &mAdapterIdentifier);
196
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000197 const D3DFORMAT renderTargetFormats[] =
198 {
199 D3DFMT_A1R5G5B5,
200 // D3DFMT_A2R10G10B10, // The color_ramp conformance test uses ReadPixels with UNSIGNED_BYTE causing it to think that rendering skipped a colour value.
201 D3DFMT_A8R8G8B8,
202 D3DFMT_R5G6B5,
daniel@transgaming.com73a5db62010-10-15 17:58:13 +0000203 // D3DFMT_X1R5G5B5, // Has no compatible OpenGL ES renderbuffer format
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000204 D3DFMT_X8R8G8B8
205 };
206
207 const D3DFORMAT depthStencilFormats[] =
208 {
daniel@transgaming.coma114c272011-04-22 04:18:50 +0000209 D3DFMT_UNKNOWN,
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000210 // D3DFMT_D16_LOCKABLE,
211 D3DFMT_D32,
212 // D3DFMT_D15S1,
213 D3DFMT_D24S8,
214 D3DFMT_D24X8,
215 // D3DFMT_D24X4S4,
216 D3DFMT_D16,
217 // D3DFMT_D32F_LOCKABLE,
218 // D3DFMT_D24FS8
219 };
220
221 D3DDISPLAYMODE currentDisplayMode;
222 mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
223
224 ConfigSet configSet;
225
226 for (int formatIndex = 0; formatIndex < sizeof(renderTargetFormats) / sizeof(D3DFORMAT); formatIndex++)
227 {
228 D3DFORMAT renderTargetFormat = renderTargetFormats[formatIndex];
229
230 HRESULT result = mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, renderTargetFormat);
231
232 if (SUCCEEDED(result))
233 {
234 for (int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(D3DFORMAT); depthStencilIndex++)
235 {
236 D3DFORMAT depthStencilFormat = depthStencilFormats[depthStencilIndex];
daniel@transgaming.coma114c272011-04-22 04:18:50 +0000237 HRESULT result = D3D_OK;
238
239 if(depthStencilFormat != D3DFMT_UNKNOWN)
240 {
241 result = mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, depthStencilFormat);
242 }
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000243
244 if (SUCCEEDED(result))
245 {
daniel@transgaming.coma114c272011-04-22 04:18:50 +0000246 if(depthStencilFormat != D3DFMT_UNKNOWN)
247 {
248 result = mD3d9->CheckDepthStencilMatch(mAdapter, mDeviceType, currentDisplayMode.Format, renderTargetFormat, depthStencilFormat);
249 }
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000250
251 if (SUCCEEDED(result))
252 {
253 // FIXME: enumerate multi-sampling
254
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +0000255 configSet.add(currentDisplayMode, mMinSwapInterval, mMaxSwapInterval, renderTargetFormat, depthStencilFormat, 0,
256 mDeviceCaps.MaxTextureWidth, mDeviceCaps.MaxTextureHeight);
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000257 }
258 }
259 }
260 }
261 }
262
263 // Give the sorted configs a unique ID and store them internally
264 EGLint index = 1;
265 for (ConfigSet::Iterator config = configSet.mSet.begin(); config != configSet.mSet.end(); config++)
266 {
267 Config configuration = *config;
268 configuration.mConfigID = index;
269 index++;
270
271 mConfigSet.mSet.insert(configuration);
272 }
273 }
274
275 if (!isInitialized())
276 {
277 terminate();
278
279 return false;
280 }
281
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +0000282 initExtensionString();
283
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000284 static const TCHAR windowName[] = TEXT("AngleHiddenWindow");
285 static const TCHAR className[] = TEXT("STATIC");
286
287 mDeviceWindow = CreateWindowEx(WS_EX_NOACTIVATE, className, windowName, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, HWND_MESSAGE, NULL, GetModuleHandle(NULL), NULL);
288
289 return true;
290}
291
292void Display::terminate()
293{
294 while (!mSurfaceSet.empty())
295 {
296 destroySurface(*mSurfaceSet.begin());
297 }
298
299 while (!mContextSet.empty())
300 {
301 destroyContext(*mContextSet.begin());
302 }
303
304 if (mDevice)
305 {
306 // If the device is lost, reset it first to prevent leaving the driver in an unstable state
apatrick@chromium.org9e83b592011-02-10 22:04:34 +0000307 if (isDeviceLost())
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000308 {
309 resetDevice();
310 }
311
312 mDevice->Release();
313 mDevice = NULL;
314 }
315
apatrick@chromium.org9e83b592011-02-10 22:04:34 +0000316 if (mDeviceEx)
317 {
318 mDeviceEx->Release();
319 mDeviceEx = NULL;
320 }
321
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000322 if (mD3d9)
323 {
324 mD3d9->Release();
325 mD3d9 = NULL;
326 }
327
328 if (mDeviceWindow)
329 {
330 DestroyWindow(mDeviceWindow);
331 mDeviceWindow = NULL;
332 }
333
apatrick@chromium.org9e83b592011-02-10 22:04:34 +0000334 if (mD3d9Ex)
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000335 {
apatrick@chromium.org9e83b592011-02-10 22:04:34 +0000336 mD3d9Ex->Release();
337 mD3d9Ex = NULL;
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000338 }
339
340 if (mD3d9Module)
341 {
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000342 mD3d9Module = NULL;
343 }
344}
345
346void Display::startScene()
347{
348 if (!mSceneStarted)
349 {
350 long result = mDevice->BeginScene();
kbr@chromium.org1a2cd262011-07-08 17:30:18 +0000351 if (SUCCEEDED(result)) {
352 // This is defensive checking against the device being
353 // lost at unexpected times.
354 mSceneStarted = true;
355 }
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000356 }
357}
358
359void Display::endScene()
360{
361 if (mSceneStarted)
362 {
kbr@chromium.org1a2cd262011-07-08 17:30:18 +0000363 // EndScene can fail if the device was lost, for example due
364 // to a TDR during a draw call.
365 mDevice->EndScene();
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000366 mSceneStarted = false;
367 }
368}
369
370bool Display::getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig)
371{
372 return mConfigSet.getConfigs(configs, attribList, configSize, numConfig);
373}
374
375bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value)
376{
377 const egl::Config *configuration = mConfigSet.get(config);
378
379 switch (attribute)
380 {
381 case EGL_BUFFER_SIZE: *value = configuration->mBufferSize; break;
382 case EGL_ALPHA_SIZE: *value = configuration->mAlphaSize; break;
383 case EGL_BLUE_SIZE: *value = configuration->mBlueSize; break;
384 case EGL_GREEN_SIZE: *value = configuration->mGreenSize; break;
385 case EGL_RED_SIZE: *value = configuration->mRedSize; break;
386 case EGL_DEPTH_SIZE: *value = configuration->mDepthSize; break;
387 case EGL_STENCIL_SIZE: *value = configuration->mStencilSize; break;
388 case EGL_CONFIG_CAVEAT: *value = configuration->mConfigCaveat; break;
389 case EGL_CONFIG_ID: *value = configuration->mConfigID; break;
390 case EGL_LEVEL: *value = configuration->mLevel; break;
391 case EGL_NATIVE_RENDERABLE: *value = configuration->mNativeRenderable; break;
392 case EGL_NATIVE_VISUAL_TYPE: *value = configuration->mNativeVisualType; break;
393 case EGL_SAMPLES: *value = configuration->mSamples; break;
394 case EGL_SAMPLE_BUFFERS: *value = configuration->mSampleBuffers; break;
395 case EGL_SURFACE_TYPE: *value = configuration->mSurfaceType; break;
396 case EGL_TRANSPARENT_TYPE: *value = configuration->mTransparentType; break;
397 case EGL_TRANSPARENT_BLUE_VALUE: *value = configuration->mTransparentBlueValue; break;
398 case EGL_TRANSPARENT_GREEN_VALUE: *value = configuration->mTransparentGreenValue; break;
399 case EGL_TRANSPARENT_RED_VALUE: *value = configuration->mTransparentRedValue; break;
400 case EGL_BIND_TO_TEXTURE_RGB: *value = configuration->mBindToTextureRGB; break;
401 case EGL_BIND_TO_TEXTURE_RGBA: *value = configuration->mBindToTextureRGBA; break;
402 case EGL_MIN_SWAP_INTERVAL: *value = configuration->mMinSwapInterval; break;
403 case EGL_MAX_SWAP_INTERVAL: *value = configuration->mMaxSwapInterval; break;
404 case EGL_LUMINANCE_SIZE: *value = configuration->mLuminanceSize; break;
405 case EGL_ALPHA_MASK_SIZE: *value = configuration->mAlphaMaskSize; break;
406 case EGL_COLOR_BUFFER_TYPE: *value = configuration->mColorBufferType; break;
407 case EGL_RENDERABLE_TYPE: *value = configuration->mRenderableType; break;
408 case EGL_MATCH_NATIVE_PIXMAP: *value = false; UNIMPLEMENTED(); break;
409 case EGL_CONFORMANT: *value = configuration->mConformant; break;
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +0000410 case EGL_MAX_PBUFFER_WIDTH: *value = configuration->mMaxPBufferWidth; break;
411 case EGL_MAX_PBUFFER_HEIGHT: *value = configuration->mMaxPBufferHeight; break;
412 case EGL_MAX_PBUFFER_PIXELS: *value = configuration->mMaxPBufferPixels; break;
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000413 default:
414 return false;
415 }
416
417 return true;
418}
419
420bool Display::createDevice()
421{
422 D3DPRESENT_PARAMETERS presentParameters = getDefaultPresentParameters();
423 DWORD behaviorFlags = D3DCREATE_FPU_PRESERVE | D3DCREATE_NOWINDOWCHANGES;
424
425 HRESULT result = mD3d9->CreateDevice(mAdapter, mDeviceType, mDeviceWindow, behaviorFlags | D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE, &presentParameters, &mDevice);
426
427 if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DEVICELOST)
428 {
429 return error(EGL_BAD_ALLOC, false);
430 }
431
432 if (FAILED(result))
433 {
434 result = mD3d9->CreateDevice(mAdapter, mDeviceType, mDeviceWindow, behaviorFlags | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presentParameters, &mDevice);
435
436 if (FAILED(result))
437 {
438 ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_NOTAVAILABLE || result == D3DERR_DEVICELOST);
439 return error(EGL_BAD_ALLOC, false);
440 }
441 }
442
apatrick@chromium.org9e83b592011-02-10 22:04:34 +0000443 if (mD3d9Ex)
444 {
445 result = mDevice->QueryInterface(IID_IDirect3DDevice9Ex, (void**) &mDeviceEx);
446 ASSERT(SUCCEEDED(result));
447 }
448
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000449 // Permanent non-default states
450 mDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
451
452 mSceneStarted = false;
453
454 return true;
455}
456
457bool Display::resetDevice()
458{
459 D3DPRESENT_PARAMETERS presentParameters = getDefaultPresentParameters();
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000460
daniel@transgaming.com10435352011-11-09 17:44:21 +0000461 HRESULT result = D3D_OK;
462 bool lost = isDeviceLost();
463 int attempts = 3;
daniel@transgaming.com94910c92011-11-09 17:44:15 +0000464
daniel@transgaming.com10435352011-11-09 17:44:21 +0000465 while (lost && attempts > 0)
daniel@transgaming.com94910c92011-11-09 17:44:15 +0000466 {
daniel@transgaming.com10435352011-11-09 17:44:21 +0000467 if (mDeviceEx)
468 {
469 Sleep(500); // Give the graphics driver some CPU time
470 result = mDeviceEx->ResetEx(&presentParameters, NULL);
471 }
472 else
473 {
474 result = mDevice->TestCooperativeLevel();
475
476 while (result == D3DERR_DEVICELOST)
477 {
478 Sleep(100); // Give the graphics driver some CPU time
479 result = mDevice->TestCooperativeLevel();
480 }
481
482 if (result == D3DERR_DEVICENOTRESET)
483 {
484 result = mDevice->Reset(&presentParameters);
485 }
486 }
487
488 lost = isDeviceLost();
489 attempts --;
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000490 }
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000491
492 if (FAILED(result))
493 {
daniel@transgaming.com10435352011-11-09 17:44:21 +0000494 ERR("Reset/ResetEx failed multiple times: 0x%08X", result);
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000495 return error(EGL_BAD_ALLOC, false);
496 }
497
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000498 return true;
499}
500
jbauman@chromium.org06d7a752011-04-30 01:02:52 +0000501EGLSurface Display::createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList)
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000502{
503 const Config *configuration = mConfigSet.get(config);
504
jbauman@chromium.org06d7a752011-04-30 01:02:52 +0000505 if (attribList)
506 {
507 while (*attribList != EGL_NONE)
508 {
509 switch (attribList[0])
510 {
511 case EGL_RENDER_BUFFER:
512 switch (attribList[1])
513 {
514 case EGL_BACK_BUFFER:
515 break;
516 case EGL_SINGLE_BUFFER:
517 return error(EGL_BAD_MATCH, EGL_NO_SURFACE); // Rendering directly to front buffer not supported
518 default:
519 return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
520 }
521 break;
522 case EGL_VG_COLORSPACE:
523 return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
524 case EGL_VG_ALPHA_FORMAT:
525 return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
526 default:
527 return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
528 }
529
530 attribList += 2;
531 }
532 }
533
534 if (hasExistingWindowSurface(window))
535 {
536 return error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
537 }
538
vangelis@google.com8c9c4522011-09-09 18:22:28 +0000539 if (isDeviceLost()) {
540 if (!restoreLostDevice())
541 return EGL_NO_SURFACE;
542 }
543
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000544 Surface *surface = new Surface(this, configuration, window);
jbauman@chromium.org4e297702011-05-12 23:04:07 +0000545
546 if (!surface->initialize())
547 {
548 delete surface;
549 return EGL_NO_SURFACE;
550 }
551
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000552 mSurfaceSet.insert(surface);
553
jbauman@chromium.org06d7a752011-04-30 01:02:52 +0000554 return success(surface);
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000555}
556
jbauman@chromium.org4e297702011-05-12 23:04:07 +0000557EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList)
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +0000558{
jbauman@chromium.org06d7a752011-04-30 01:02:52 +0000559 EGLint width = 0, height = 0;
560 EGLenum textureFormat = EGL_NO_TEXTURE;
561 EGLenum textureTarget = EGL_NO_TEXTURE;
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +0000562 const Config *configuration = mConfigSet.get(config);
563
jbauman@chromium.org06d7a752011-04-30 01:02:52 +0000564 if (attribList)
565 {
566 while (*attribList != EGL_NONE)
567 {
568 switch (attribList[0])
569 {
570 case EGL_WIDTH:
571 width = attribList[1];
572 break;
573 case EGL_HEIGHT:
574 height = attribList[1];
575 break;
576 case EGL_LARGEST_PBUFFER:
577 if (attribList[1] != EGL_FALSE)
578 UNIMPLEMENTED(); // FIXME
579 break;
580 case EGL_TEXTURE_FORMAT:
581 switch (attribList[1])
582 {
583 case EGL_NO_TEXTURE:
584 case EGL_TEXTURE_RGB:
585 case EGL_TEXTURE_RGBA:
586 textureFormat = attribList[1];
587 break;
588 default:
589 return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
590 }
591 break;
592 case EGL_TEXTURE_TARGET:
593 switch (attribList[1])
594 {
595 case EGL_NO_TEXTURE:
596 case EGL_TEXTURE_2D:
597 textureTarget = attribList[1];
598 break;
599 default:
600 return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
601 }
602 break;
603 case EGL_MIPMAP_TEXTURE:
604 if (attribList[1] != EGL_FALSE)
605 return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
606 break;
607 case EGL_VG_COLORSPACE:
608 return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
609 case EGL_VG_ALPHA_FORMAT:
610 return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
611 default:
612 return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
613 }
614
615 attribList += 2;
616 }
617 }
618
619 if (width < 0 || height < 0)
620 {
621 return error(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
622 }
623
624 if (width == 0 || height == 0)
625 {
626 return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
627 }
628
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +0000629 if (textureFormat != EGL_NO_TEXTURE && !getNonPower2TextureSupport() && (!gl::isPow2(width) || !gl::isPow2(height)))
jbauman@chromium.org06d7a752011-04-30 01:02:52 +0000630 {
631 return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
632 }
633
634 if ((textureFormat != EGL_NO_TEXTURE && textureTarget == EGL_NO_TEXTURE) ||
635 (textureFormat == EGL_NO_TEXTURE && textureTarget != EGL_NO_TEXTURE))
636 {
637 return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
638 }
639
640 if (!(configuration->mSurfaceType & EGL_PBUFFER_BIT))
641 {
642 return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
643 }
644
645 if ((textureFormat == EGL_TEXTURE_RGB && configuration->mBindToTextureRGB != EGL_TRUE) ||
646 (textureFormat == EGL_TEXTURE_RGBA && configuration->mBindToTextureRGBA != EGL_TRUE))
647 {
648 return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
649 }
650
vangelis@google.com8c9c4522011-09-09 18:22:28 +0000651 if (isDeviceLost()) {
652 if (!restoreLostDevice())
653 return EGL_NO_SURFACE;
654 }
655
jbauman@chromium.org4e297702011-05-12 23:04:07 +0000656 Surface *surface = new Surface(this, configuration, shareHandle, width, height, textureFormat, textureTarget);
657
658 if (!surface->initialize())
659 {
660 delete surface;
661 return EGL_NO_SURFACE;
662 }
663
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +0000664 mSurfaceSet.insert(surface);
665
jbauman@chromium.org06d7a752011-04-30 01:02:52 +0000666 return success(surface);
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +0000667}
668
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000669EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *shareContext)
670{
671 if (!mDevice)
672 {
673 if (!createDevice())
674 {
675 return NULL;
676 }
677 }
apatrick@chromium.org9e83b592011-02-10 22:04:34 +0000678 else if (isDeviceLost()) // Lost device
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000679 {
vangelis@google.com8c9c4522011-09-09 18:22:28 +0000680 if (!restoreLostDevice())
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000681 return NULL;
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000682 }
683
684 const egl::Config *config = mConfigSet.get(configHandle);
685
686 gl::Context *context = glCreateContext(config, shareContext);
687 mContextSet.insert(context);
688
689 return context;
690}
691
vangelis@google.com8c9c4522011-09-09 18:22:28 +0000692bool Display::restoreLostDevice()
693{
694 // Release surface resources to make the Reset() succeed
695 for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
696 {
697 (*surface)->release();
698 }
699
700 if (!resetDevice())
701 {
702 return false;
703 }
704
705 // Restore any surfaces that may have been lost
706 for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
707 {
708 (*surface)->resetSwapChain();
709 }
710
711 return true;
712}
713
714
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000715void Display::destroySurface(egl::Surface *surface)
716{
daniel@transgaming.comc556fa52011-05-26 14:13:29 +0000717 delete surface;
718 mSurfaceSet.erase(surface);
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000719}
720
721void Display::destroyContext(gl::Context *context)
722{
723 glDestroyContext(context);
724 mContextSet.erase(context);
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000725}
726
daniel@transgaming.com3b1703f2011-05-11 15:36:26 +0000727bool Display::isInitialized() const
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000728{
729 return mD3d9 != NULL && mConfigSet.size() > 0;
730}
731
732bool Display::isValidConfig(EGLConfig config)
733{
734 return mConfigSet.get(config) != NULL;
735}
736
737bool Display::isValidContext(gl::Context *context)
738{
739 return mContextSet.find(context) != mContextSet.end();
740}
741
742bool Display::isValidSurface(egl::Surface *surface)
743{
daniel@transgaming.comc556fa52011-05-26 14:13:29 +0000744 return mSurfaceSet.find(surface) != mSurfaceSet.end();
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000745}
746
747bool Display::hasExistingWindowSurface(HWND window)
748{
749 for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
750 {
751 if ((*surface)->getWindowHandle() == window)
752 {
753 return true;
754 }
755 }
756
757 return false;
758}
759
760EGLint Display::getMinSwapInterval()
761{
762 return mMinSwapInterval;
763}
764
765EGLint Display::getMaxSwapInterval()
766{
767 return mMaxSwapInterval;
768}
769
770IDirect3DDevice9 *Display::getDevice()
771{
772 if (!mDevice)
773 {
774 if (!createDevice())
775 {
776 return NULL;
777 }
778 }
779
780 return mDevice;
781}
782
783D3DCAPS9 Display::getDeviceCaps()
784{
785 return mDeviceCaps;
786}
787
jbauman@chromium.org03208d52011-06-15 01:15:24 +0000788D3DADAPTER_IDENTIFIER9 *Display::getAdapterIdentifier()
789{
790 return &mAdapterIdentifier;
791}
792
apatrick@chromium.org9e83b592011-02-10 22:04:34 +0000793bool Display::isDeviceLost()
794{
795 if (mDeviceEx)
796 {
797 return FAILED(mDeviceEx->CheckDeviceState(NULL));
798 }
daniel@transgaming.comfe4b0c92011-09-13 00:53:11 +0000799 else if(mDevice)
apatrick@chromium.org9e83b592011-02-10 22:04:34 +0000800 {
801 return FAILED(mDevice->TestCooperativeLevel());
802 }
daniel@transgaming.comfe4b0c92011-09-13 00:53:11 +0000803
804 return false; // No device yet, so no reset required
apatrick@chromium.org9e83b592011-02-10 22:04:34 +0000805}
806
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000807void Display::getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray)
808{
809 for (int multiSampleIndex = 0; multiSampleIndex <= D3DMULTISAMPLE_16_SAMPLES; multiSampleIndex++)
810 {
811 HRESULT result = mD3d9->CheckDeviceMultiSampleType(mAdapter, mDeviceType, format,
812 TRUE, (D3DMULTISAMPLE_TYPE)multiSampleIndex, NULL);
813
814 multiSampleArray[multiSampleIndex] = SUCCEEDED(result);
815 }
816}
817
gman@chromium.org50c526d2011-08-10 05:19:44 +0000818bool Display::getDXT1TextureSupport()
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000819{
820 D3DDISPLAYMODE currentDisplayMode;
821 mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
822
823 return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT1));
824}
825
gman@chromium.org50c526d2011-08-10 05:19:44 +0000826bool Display::getDXT3TextureSupport()
827{
828 D3DDISPLAYMODE currentDisplayMode;
829 mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
830
831 return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT3));
832}
833
834bool Display::getDXT5TextureSupport()
835{
836 D3DDISPLAYMODE currentDisplayMode;
837 mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
838
839 return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT5));
840}
841
daniel@transgaming.combbeffbb2011-11-09 17:46:11 +0000842bool Display::getFloat32TextureSupport(bool *filtering, bool *renderable)
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000843{
844 D3DDISPLAYMODE currentDisplayMode;
845 mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
846
847 *filtering = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER,
848 D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F)) &&
849 SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER,
850 D3DRTYPE_CUBETEXTURE, D3DFMT_A32B32G32R32F));
851
852 *renderable = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET,
853 D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F))&&
854 SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET,
855 D3DRTYPE_CUBETEXTURE, D3DFMT_A32B32G32R32F));
856
857 if (!filtering && !renderable)
858 {
859 return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0,
860 D3DRTYPE_TEXTURE, D3DFMT_A32B32G32R32F)) &&
861 SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0,
862 D3DRTYPE_CUBETEXTURE, D3DFMT_A32B32G32R32F));
863 }
864 else
865 {
866 return true;
867 }
868}
869
daniel@transgaming.combbeffbb2011-11-09 17:46:11 +0000870bool Display::getFloat16TextureSupport(bool *filtering, bool *renderable)
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000871{
872 D3DDISPLAYMODE currentDisplayMode;
873 mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
874
875 *filtering = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER,
876 D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F)) &&
877 SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_FILTER,
878 D3DRTYPE_CUBETEXTURE, D3DFMT_A16B16G16R16F));
879
880 *renderable = SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET,
881 D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F)) &&
882 SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET,
883 D3DRTYPE_CUBETEXTURE, D3DFMT_A16B16G16R16F));
884
885 if (!filtering && !renderable)
886 {
887 return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0,
888 D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F)) &&
889 SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0,
890 D3DRTYPE_CUBETEXTURE, D3DFMT_A16B16G16R16F));
891 }
892 else
893 {
894 return true;
895 }
896}
897
daniel@transgaming.comed828e52010-10-15 17:57:30 +0000898bool Display::getLuminanceTextureSupport()
899{
900 D3DDISPLAYMODE currentDisplayMode;
901 mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
902
903 return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_L8));
904}
905
906bool Display::getLuminanceAlphaTextureSupport()
907{
908 D3DDISPLAYMODE currentDisplayMode;
909 mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
910
911 return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_A8L8));
912}
913
daniel@transgaming.comee04e452011-01-08 05:46:27 +0000914D3DPOOL Display::getBufferPool(DWORD usage) const
daniel@transgaming.com37b141e2011-01-08 05:46:13 +0000915{
apatrick@chromium.org9e83b592011-02-10 22:04:34 +0000916 if (mD3d9Ex != NULL)
daniel@transgaming.comee04e452011-01-08 05:46:27 +0000917 {
918 return D3DPOOL_DEFAULT;
919 }
920 else
921 {
922 if (!(usage & D3DUSAGE_DYNAMIC))
923 {
924 return D3DPOOL_MANAGED;
925 }
926 }
927
928 return D3DPOOL_DEFAULT;
daniel@transgaming.com37b141e2011-01-08 05:46:13 +0000929}
930
daniel@transgaming.come979ead2010-09-23 18:03:14 +0000931bool Display::getEventQuerySupport()
932{
933 IDirect3DQuery9 *query;
934 HRESULT result = mDevice->CreateQuery(D3DQUERYTYPE_EVENT, &query);
935 if (SUCCEEDED(result))
936 {
937 query->Release();
938 }
939
940 return result != D3DERR_NOTAVAILABLE;
941}
942
943D3DPRESENT_PARAMETERS Display::getDefaultPresentParameters()
944{
945 D3DPRESENT_PARAMETERS presentParameters = {0};
946
947 // The default swap chain is never actually used. Surface will create a new swap chain with the proper parameters.
948 presentParameters.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
949 presentParameters.BackBufferCount = 1;
950 presentParameters.BackBufferFormat = D3DFMT_UNKNOWN;
951 presentParameters.BackBufferWidth = 1;
952 presentParameters.BackBufferHeight = 1;
953 presentParameters.EnableAutoDepthStencil = FALSE;
954 presentParameters.Flags = 0;
955 presentParameters.hDeviceWindow = mDeviceWindow;
956 presentParameters.MultiSampleQuality = 0;
957 presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE;
958 presentParameters.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
959 presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
960 presentParameters.Windowed = TRUE;
961
962 return presentParameters;
963}
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +0000964
965void Display::initExtensionString()
966{
jbauman@chromium.org84d7cbc2011-07-14 22:53:19 +0000967 HMODULE swiftShader = GetModuleHandle(TEXT("swiftshader_d3d9.dll"));
daniel@transgaming.com1a1fe242011-09-26 18:25:45 +0000968 bool isd3d9ex = isD3d9ExDevice();
969
970 mExtensionString = "";
971
972 if (isd3d9ex) {
973 mExtensionString += "EGL_ANGLE_d3d_share_handle_client_buffer ";
974 }
975
976 mExtensionString += "EGL_ANGLE_query_surface_pointer ";
jbauman@chromium.org84d7cbc2011-07-14 22:53:19 +0000977
978 if (swiftShader)
979 {
980 mExtensionString += "EGL_ANGLE_software_display ";
981 }
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +0000982
daniel@transgaming.com1a1fe242011-09-26 18:25:45 +0000983 if (isd3d9ex) {
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +0000984 mExtensionString += "EGL_ANGLE_surface_d3d_texture_2d_share_handle ";
985 }
986
987 std::string::size_type end = mExtensionString.find_last_not_of(' ');
988 if (end != std::string::npos)
989 {
990 mExtensionString.resize(end+1);
991 }
992}
993
994const char *Display::getExtensionString() const
995{
996 return mExtensionString.c_str();
997}
998
daniel@transgaming.com3b1703f2011-05-11 15:36:26 +0000999// Only Direct3D 10 ready devices support all the necessary vertex texture formats.
1000// We test this using D3D9 by checking support for the R16F format.
1001bool Display::getVertexTextureSupport() const
1002{
daniel@transgaming.com3b1703f2011-05-11 15:36:26 +00001003 if (!isInitialized() || mDeviceCaps.PixelShaderVersion < D3DPS_VERSION(3, 0))
1004 {
1005 return false;
1006 }
1007
1008 D3DDISPLAYMODE currentDisplayMode;
1009 mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
1010
1011 HRESULT result = mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_QUERY_VERTEXTEXTURE, D3DRTYPE_TEXTURE, D3DFMT_R16F);
1012
1013 return SUCCEEDED(result);
1014}
1015
daniel@transgaming.com4f9ef0d2011-05-30 23:51:19 +00001016bool Display::getNonPower2TextureSupport() const
1017{
1018 return !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_POW2) &&
1019 !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP_POW2) &&
1020 !(mDeviceCaps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL);
1021}
1022
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +00001023}