1 //
2 // Copyright 2015 The ANGLE Project Authors. All rights reserved.
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 #ifndef ANGLE_ENABLE_D3D9
8 # define ANGLE_ENABLE_D3D9
9 #endif
10
11 #ifndef ANGLE_ENABLE_D3D11
12 # define ANGLE_ENABLE_D3D11
13 #endif
14
15 #include <d3d11.h>
16
17 #include "test_utils/ANGLETest.h"
18 #include "util/EGLWindow.h"
19 #include "util/OSWindow.h"
20 #include "util/com_utils.h"
21 #include "util/gles_loader_autogen.h"
22
23 using namespace angle;
24
25 class EGLDeviceCreationTest : public ANGLETest
26 {
27 protected:
EGLDeviceCreationTest()28 EGLDeviceCreationTest()
29 : mD3D11Module(nullptr),
30 mD3D11CreateDevice(nullptr),
31 mDevice(nullptr),
32 mDeviceContext(nullptr),
33 mDeviceCreationD3D11ExtAvailable(false),
34 mOSWindow(nullptr),
35 mDisplay(EGL_NO_DISPLAY),
36 mSurface(EGL_NO_SURFACE),
37 mContext(EGL_NO_CONTEXT),
38 mConfig(0)
39 {}
40
testSetUp()41 void testSetUp() override
42 {
43 ASSERT_TRUE(isD3D11Renderer());
44
45 mD3D11Module = LoadLibrary(TEXT("d3d11.dll"));
46 if (mD3D11Module == nullptr)
47 {
48 std::cout << "Unable to LoadLibrary D3D11" << std::endl;
49 return;
50 }
51
52 mD3D11CreateDevice = reinterpret_cast<PFN_D3D11_CREATE_DEVICE>(
53 GetProcAddress(mD3D11Module, "D3D11CreateDevice"));
54 if (mD3D11CreateDevice == nullptr)
55 {
56 std::cout << "Could not retrieve D3D11CreateDevice from d3d11.dll" << std::endl;
57 return;
58 }
59
60 const char *extensionString =
61 static_cast<const char *>(eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS));
62 if (strstr(extensionString, "EGL_ANGLE_device_creation"))
63 {
64 if (strstr(extensionString, "EGL_ANGLE_device_creation_d3d11"))
65 {
66 mDeviceCreationD3D11ExtAvailable = true;
67 }
68 }
69 }
70
testTearDown()71 void testTearDown() override
72 {
73 SafeRelease(mDevice);
74 SafeRelease(mDeviceContext);
75
76 OSWindow::Delete(&mOSWindow);
77
78 if (mSurface != EGL_NO_SURFACE)
79 {
80 eglDestroySurface(mDisplay, mSurface);
81 mSurface = EGL_NO_SURFACE;
82 }
83
84 if (mContext != EGL_NO_CONTEXT)
85 {
86 eglDestroyContext(mDisplay, mContext);
87 mContext = EGL_NO_CONTEXT;
88 }
89
90 if (mDisplay != EGL_NO_DISPLAY)
91 {
92 eglTerminate(mDisplay);
93 mDisplay = EGL_NO_DISPLAY;
94 }
95 }
96
CreateD3D11Device()97 void CreateD3D11Device()
98 {
99 ASSERT_EQ(nullptr, mDevice); // The device shouldn't be created twice
100
101 HRESULT hr =
102 mD3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, 0, 0, nullptr, 0,
103 D3D11_SDK_VERSION, &mDevice, &mFeatureLevel, &mDeviceContext);
104
105 ASSERT_TRUE(SUCCEEDED(hr));
106 ASSERT_GE(mFeatureLevel, D3D_FEATURE_LEVEL_9_3);
107 }
108
CreateD3D11FL9_3Device()109 void CreateD3D11FL9_3Device()
110 {
111 ASSERT_EQ(nullptr, mDevice);
112
113 D3D_FEATURE_LEVEL fl93 = D3D_FEATURE_LEVEL_9_3;
114
115 HRESULT hr =
116 mD3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, 0, 0, &fl93, 1, D3D11_SDK_VERSION,
117 &mDevice, &mFeatureLevel, &mDeviceContext);
118
119 ASSERT_TRUE(SUCCEEDED(hr));
120 }
121
CreateWindowSurface()122 void CreateWindowSurface()
123 {
124 EGLint majorVersion, minorVersion;
125 ASSERT_EGL_TRUE(eglInitialize(mDisplay, &majorVersion, &minorVersion));
126
127 eglBindAPI(EGL_OPENGL_ES_API);
128 ASSERT_EGL_SUCCESS();
129
130 // Choose a config
131 const EGLint configAttributes[] = {EGL_NONE};
132 EGLint configCount = 0;
133 ASSERT_EGL_TRUE(eglChooseConfig(mDisplay, configAttributes, &mConfig, 1, &configCount));
134
135 // Create an OS Window
136 mOSWindow = OSWindow::New();
137 mOSWindow->initialize("EGLSurfaceTest", 64, 64);
138
139 // Create window surface
140 mSurface = eglCreateWindowSurface(mDisplay, mConfig, mOSWindow->getNativeWindow(), nullptr);
141 ASSERT_EGL_SUCCESS();
142
143 // Create EGL context
144 EGLint contextAttibutes[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
145 mContext = eglCreateContext(mDisplay, mConfig, nullptr, contextAttibutes);
146 ASSERT_EGL_SUCCESS();
147
148 // Make the surface current
149 eglMakeCurrent(mDisplay, mSurface, mSurface, mContext);
150 ASSERT_EGL_SUCCESS();
151 }
152
153 // This triggers a D3D device lost on current Windows systems
154 // This behavior could potentially change in the future
trigger9_3DeviceLost()155 void trigger9_3DeviceLost()
156 {
157 ID3D11Buffer *gsBuffer = nullptr;
158 D3D11_BUFFER_DESC bufferDesc = {0};
159 bufferDesc.ByteWidth = 64;
160 bufferDesc.Usage = D3D11_USAGE_DEFAULT;
161 bufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
162
163 HRESULT result = mDevice->CreateBuffer(&bufferDesc, nullptr, &gsBuffer);
164 ASSERT_TRUE(SUCCEEDED(result));
165
166 mDeviceContext->GSSetConstantBuffers(0, 1, &gsBuffer);
167 SafeRelease(gsBuffer);
168 gsBuffer = nullptr;
169
170 result = mDevice->GetDeviceRemovedReason();
171 ASSERT_TRUE(FAILED(result));
172 }
173
174 HMODULE mD3D11Module;
175 PFN_D3D11_CREATE_DEVICE mD3D11CreateDevice;
176
177 ID3D11Device *mDevice;
178 ID3D11DeviceContext *mDeviceContext;
179 D3D_FEATURE_LEVEL mFeatureLevel;
180
181 bool mDeviceCreationD3D11ExtAvailable;
182
183 OSWindow *mOSWindow;
184
185 EGLDisplay mDisplay;
186 EGLSurface mSurface;
187 EGLContext mContext;
188 EGLConfig mConfig;
189 };
190
191 // Test that creating a EGLDeviceEXT from D3D11 device works, and it can be queried to retrieve
192 // D3D11 device
TEST_P(EGLDeviceCreationTest,BasicD3D11Device)193 TEST_P(EGLDeviceCreationTest, BasicD3D11Device)
194 {
195 ANGLE_SKIP_TEST_IF(!mDeviceCreationD3D11ExtAvailable);
196
197 CreateD3D11Device();
198
199 EGLDeviceEXT eglDevice =
200 eglCreateDeviceANGLE(EGL_D3D11_DEVICE_ANGLE, reinterpret_cast<void *>(mDevice), nullptr);
201 ASSERT_NE(EGL_NO_DEVICE_EXT, eglDevice);
202 ASSERT_EGL_SUCCESS();
203
204 EGLAttrib deviceAttrib;
205 eglQueryDeviceAttribEXT(eglDevice, EGL_D3D11_DEVICE_ANGLE, &deviceAttrib);
206 ASSERT_EGL_SUCCESS();
207
208 ID3D11Device *queriedDevice = reinterpret_cast<ID3D11Device *>(deviceAttrib);
209 ASSERT_EQ(mFeatureLevel, queriedDevice->GetFeatureLevel());
210
211 eglReleaseDeviceANGLE(eglDevice);
212 }
213
214 // Test that creating a EGLDeviceEXT from D3D11 device works, and it can be queried to retrieve
215 // D3D11 device
TEST_P(EGLDeviceCreationTest,BasicD3D11DeviceViaFuncPointer)216 TEST_P(EGLDeviceCreationTest, BasicD3D11DeviceViaFuncPointer)
217 {
218 ANGLE_SKIP_TEST_IF(!mDeviceCreationD3D11ExtAvailable);
219
220 CreateD3D11Device();
221
222 EGLDeviceEXT eglDevice =
223 eglCreateDeviceANGLE(EGL_D3D11_DEVICE_ANGLE, reinterpret_cast<void *>(mDevice), nullptr);
224 ASSERT_NE(EGL_NO_DEVICE_EXT, eglDevice);
225 ASSERT_EGL_SUCCESS();
226
227 EGLAttrib deviceAttrib;
228 eglQueryDeviceAttribEXT(eglDevice, EGL_D3D11_DEVICE_ANGLE, &deviceAttrib);
229 ASSERT_EGL_SUCCESS();
230
231 ID3D11Device *queriedDevice = reinterpret_cast<ID3D11Device *>(deviceAttrib);
232 ASSERT_EQ(mFeatureLevel, queriedDevice->GetFeatureLevel());
233
234 eglReleaseDeviceANGLE(eglDevice);
235 }
236
237 // Test that creating a EGLDeviceEXT from D3D11 device works, and can be used for rendering
TEST_P(EGLDeviceCreationTest,RenderingUsingD3D11Device)238 TEST_P(EGLDeviceCreationTest, RenderingUsingD3D11Device)
239 {
240 CreateD3D11Device();
241
242 EGLDeviceEXT eglDevice =
243 eglCreateDeviceANGLE(EGL_D3D11_DEVICE_ANGLE, reinterpret_cast<void *>(mDevice), nullptr);
244 ASSERT_EGL_SUCCESS();
245
246 // Create an EGLDisplay using the EGLDevice
247 mDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, eglDevice, nullptr);
248 ASSERT_NE(EGL_NO_DISPLAY, mDisplay);
249
250 // Create a surface using the display
251 CreateWindowSurface();
252
253 // Perform some very basic rendering
254 glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
255 glClear(GL_COLOR_BUFFER_BIT);
256 EXPECT_PIXEL_EQ(32, 32, 255, 0, 255, 255);
257
258 // Note that we must call TearDown() before we release the EGL device, since the display
259 // depends on the device
260 testTearDown();
261
262 eglReleaseDeviceANGLE(eglDevice);
263 }
264
265 // Test that ANGLE doesn't try to recreate a D3D11 device if the inputted one is lost
TEST_P(EGLDeviceCreationTest,D3D11DeviceRecovery)266 TEST_P(EGLDeviceCreationTest, D3D11DeviceRecovery)
267 {
268 // Force Feature Level 9_3 so we can easily trigger a device lost later
269 CreateD3D11FL9_3Device();
270
271 EGLDeviceEXT eglDevice =
272 eglCreateDeviceANGLE(EGL_D3D11_DEVICE_ANGLE, reinterpret_cast<void *>(mDevice), nullptr);
273 ASSERT_EGL_SUCCESS();
274
275 // Create an EGLDisplay using the EGLDevice
276 mDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, eglDevice, nullptr);
277 ASSERT_TRUE(mDisplay != EGL_NO_DISPLAY);
278
279 // Create a surface using the display
280 CreateWindowSurface();
281
282 // Perform some very basic rendering
283 glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
284 glClear(GL_COLOR_BUFFER_BIT);
285 EXPECT_PIXEL_EQ(32, 32, 255, 0, 255, 255);
286 ASSERT_GL_NO_ERROR();
287
288 // ANGLE's SwapChain11::initPassThroughResources doesn't handle device lost before
289 // eglSwapBuffers, so we must call eglSwapBuffers before we lose the device.
290 ASSERT_EGL_TRUE(eglSwapBuffers(mDisplay, mSurface));
291
292 // Trigger a lost device
293 trigger9_3DeviceLost();
294
295 // Destroy the old EGL Window Surface
296 if (mSurface != EGL_NO_SURFACE)
297 {
298 eglDestroySurface(mDisplay, mSurface);
299 mSurface = EGL_NO_SURFACE;
300 }
301
302 // Try to create a new window surface. In certain configurations this will recreate the D3D11
303 // device. We want to test that it doesn't recreate the D3D11 device when EGLDeviceEXT is
304 // used. The window surface creation should fail if a new D3D11 device isn't created.
305 mSurface = eglCreateWindowSurface(mDisplay, mConfig, mOSWindow->getNativeWindow(), nullptr);
306 ASSERT_EQ(EGL_NO_SURFACE, mSurface);
307 ASSERT_EGL_ERROR(EGL_BAD_ALLOC);
308
309 // Get the D3D11 device out of the EGLDisplay again. It should be the same one as above.
310 EGLAttrib device = 0;
311 EGLAttrib newEglDevice = 0;
312 ASSERT_EGL_TRUE(eglQueryDisplayAttribEXT(mDisplay, EGL_DEVICE_EXT, &newEglDevice));
313 ASSERT_EGL_TRUE(eglQueryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(newEglDevice),
314 EGL_D3D11_DEVICE_ANGLE, &device));
315 ID3D11Device *newDevice = reinterpret_cast<ID3D11Device *>(device);
316
317 ASSERT_EQ(reinterpret_cast<EGLDeviceEXT>(newEglDevice), eglDevice);
318 ASSERT_EQ(newDevice, mDevice);
319
320 // Note that we must call TearDown() before we release the EGL device, since the display
321 // depends on the device
322 testTearDown();
323
324 eglReleaseDeviceANGLE(eglDevice);
325 }
326
327 // Test that calling eglGetPlatformDisplayEXT with the same device returns the same display
TEST_P(EGLDeviceCreationTest,GetPlatformDisplayTwice)328 TEST_P(EGLDeviceCreationTest, GetPlatformDisplayTwice)
329 {
330 CreateD3D11Device();
331
332 EGLDeviceEXT eglDevice =
333 eglCreateDeviceANGLE(EGL_D3D11_DEVICE_ANGLE, reinterpret_cast<void *>(mDevice), nullptr);
334 ASSERT_EGL_SUCCESS();
335
336 // Create an EGLDisplay using the EGLDevice
337 EGLDisplay display1 = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, eglDevice, nullptr);
338 ASSERT_NE(EGL_NO_DISPLAY, display1);
339
340 EGLDisplay display2 = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, eglDevice, nullptr);
341 ASSERT_NE(EGL_NO_DISPLAY, display2);
342
343 ASSERT_EQ(display1, display2);
344
345 eglTerminate(display1);
346 eglReleaseDeviceANGLE(eglDevice);
347 }
348
349 // Test that creating a EGLDeviceEXT from an invalid D3D11 device fails
TEST_P(EGLDeviceCreationTest,InvalidD3D11Device)350 TEST_P(EGLDeviceCreationTest, InvalidD3D11Device)
351 {
352 ANGLE_SKIP_TEST_IF(!mDeviceCreationD3D11ExtAvailable);
353
354 CreateD3D11Device();
355
356 // Use mDeviceContext instead of mDevice
357 EGLDeviceEXT eglDevice = eglCreateDeviceANGLE(
358 EGL_D3D11_DEVICE_ANGLE, reinterpret_cast<void *>(mDeviceContext), nullptr);
359 EXPECT_EQ(EGL_NO_DEVICE_EXT, eglDevice);
360 EXPECT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
361 }
362
363 // Test that EGLDeviceEXT holds a ref to the D3D11 device
TEST_P(EGLDeviceCreationTest,D3D11DeviceReferenceCounting)364 TEST_P(EGLDeviceCreationTest, D3D11DeviceReferenceCounting)
365 {
366 ANGLE_SKIP_TEST_IF(!mDeviceCreationD3D11ExtAvailable);
367
368 CreateD3D11Device();
369
370 EGLDeviceEXT eglDevice =
371 eglCreateDeviceANGLE(EGL_D3D11_DEVICE_ANGLE, reinterpret_cast<void *>(mDevice), nullptr);
372 ASSERT_NE(EGL_NO_DEVICE_EXT, eglDevice);
373 ASSERT_EGL_SUCCESS();
374
375 // Now release our D3D11 device/context
376 SafeRelease(mDevice);
377 SafeRelease(mDeviceContext);
378
379 EGLAttrib deviceAttrib;
380 eglQueryDeviceAttribEXT(eglDevice, EGL_D3D11_DEVICE_ANGLE, &deviceAttrib);
381 ASSERT_EGL_SUCCESS();
382
383 ID3D11Device *queriedDevice = reinterpret_cast<ID3D11Device *>(deviceAttrib);
384 ASSERT_EQ(mFeatureLevel, queriedDevice->GetFeatureLevel());
385
386 eglReleaseDeviceANGLE(eglDevice);
387 }
388
389 // Test that creating a EGLDeviceEXT from a D3D9 device fails
TEST_P(EGLDeviceCreationTest,AnyD3D9Device)390 TEST_P(EGLDeviceCreationTest, AnyD3D9Device)
391 {
392 ANGLE_SKIP_TEST_IF(!mDeviceCreationD3D11ExtAvailable);
393
394 std::string fakeD3DDevice = "This is a string, not a D3D device";
395
396 EGLDeviceEXT eglDevice = eglCreateDeviceANGLE(
397 EGL_D3D9_DEVICE_ANGLE, reinterpret_cast<void *>(&fakeD3DDevice), nullptr);
398 EXPECT_EQ(EGL_NO_DEVICE_EXT, eglDevice);
399 EXPECT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
400 }
401
402 class EGLDeviceQueryTest : public ANGLETest
403 {
404 protected:
EGLDeviceQueryTest()405 EGLDeviceQueryTest() {}
406
testSetUp()407 void testSetUp() override
408 {
409 const char *extensionString =
410 static_cast<const char *>(eglQueryString(getEGLWindow()->getDisplay(), EGL_EXTENSIONS));
411
412 if (!eglQueryDeviceStringEXT)
413 {
414 FAIL() << "ANGLE extension EGL_EXT_device_query export eglQueryDeviceStringEXT was not "
415 "found";
416 }
417
418 if (!eglQueryDisplayAttribEXT)
419 {
420 FAIL() << "ANGLE extension EGL_EXT_device_query export eglQueryDisplayAttribEXT was "
421 "not found";
422 }
423
424 if (!eglQueryDeviceAttribEXT)
425 {
426 FAIL() << "ANGLE extension EGL_EXT_device_query export eglQueryDeviceAttribEXT was not "
427 "found";
428 }
429
430 EGLAttrib angleDevice = 0;
431 EXPECT_EGL_TRUE(
432 eglQueryDisplayAttribEXT(getEGLWindow()->getDisplay(), EGL_DEVICE_EXT, &angleDevice));
433 extensionString = static_cast<const char *>(
434 eglQueryDeviceStringEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice), EGL_EXTENSIONS));
435 if (strstr(extensionString, "EGL_ANGLE_device_d3d") == nullptr)
436 {
437 FAIL() << "ANGLE extension EGL_ANGLE_device_d3d was not found";
438 }
439 }
440 };
441
442 // This test attempts to obtain a D3D11 device and a D3D9 device using the eglQueryDeviceAttribEXT
443 // function.
444 // If the test is configured to use D3D11 then it should succeed to obtain a D3D11 device.
445 // If the test is confitured to use D3D9, then it should succeed to obtain a D3D9 device.
TEST_P(EGLDeviceQueryTest,QueryDevice)446 TEST_P(EGLDeviceQueryTest, QueryDevice)
447 {
448 EGLAttrib device = 0;
449 EGLAttrib angleDevice = 0;
450 if (getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
451 {
452 EXPECT_EGL_TRUE(
453 eglQueryDisplayAttribEXT(getEGLWindow()->getDisplay(), EGL_DEVICE_EXT, &angleDevice));
454 EXPECT_EGL_TRUE(eglQueryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice),
455 EGL_D3D11_DEVICE_ANGLE, &device));
456 ID3D11Device *d3d11Device = reinterpret_cast<ID3D11Device *>(device);
457 IDXGIDevice *dxgiDevice = DynamicCastComObject<IDXGIDevice>(d3d11Device);
458 EXPECT_TRUE(dxgiDevice != nullptr);
459 SafeRelease(dxgiDevice);
460 }
461
462 if (getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE)
463 {
464 EXPECT_EGL_TRUE(
465 eglQueryDisplayAttribEXT(getEGLWindow()->getDisplay(), EGL_DEVICE_EXT, &angleDevice));
466 EXPECT_EGL_TRUE(eglQueryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice),
467 EGL_D3D9_DEVICE_ANGLE, &device));
468 IDirect3DDevice9 *d3d9Device = reinterpret_cast<IDirect3DDevice9 *>(device);
469 IDirect3D9 *d3d9 = nullptr;
470 EXPECT_EQ(S_OK, d3d9Device->GetDirect3D(&d3d9));
471 EXPECT_TRUE(d3d9 != nullptr);
472 SafeRelease(d3d9);
473 }
474 }
475
476 // This test attempts to obtain a D3D11 device from a D3D9 configured system and a D3D9 device from
477 // a D3D11 configured system using the eglQueryDeviceAttribEXT function.
478 // If the test is configured to use D3D11 then it should fail to obtain a D3D11 device.
479 // If the test is confitured to use D3D9, then it should fail to obtain a D3D9 device.
TEST_P(EGLDeviceQueryTest,QueryDeviceBadAttribute)480 TEST_P(EGLDeviceQueryTest, QueryDeviceBadAttribute)
481 {
482 EGLAttrib device = 0;
483 EGLAttrib angleDevice = 0;
484 if (getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
485 {
486 EXPECT_EGL_TRUE(
487 eglQueryDisplayAttribEXT(getEGLWindow()->getDisplay(), EGL_DEVICE_EXT, &angleDevice));
488 EXPECT_EGL_FALSE(eglQueryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice),
489 EGL_D3D9_DEVICE_ANGLE, &device));
490 }
491
492 if (getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE)
493 {
494 EXPECT_EGL_TRUE(
495 eglQueryDisplayAttribEXT(getEGLWindow()->getDisplay(), EGL_DEVICE_EXT, &angleDevice));
496 EXPECT_EGL_FALSE(eglQueryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice),
497 EGL_D3D11_DEVICE_ANGLE, &device));
498 }
499 }
500
501 // Ensure that:
502 // - calling getPlatformDisplayEXT using ANGLE_Platform with some parameters
503 // - extracting the EGLDeviceEXT from the EGLDisplay
504 // - calling getPlatformDisplayEXT with this EGLDeviceEXT
505 // results in the same EGLDisplay being returned from getPlatformDisplayEXT both times
TEST_P(EGLDeviceQueryTest,GetPlatformDisplayDeviceReuse)506 TEST_P(EGLDeviceQueryTest, GetPlatformDisplayDeviceReuse)
507 {
508 EGLAttrib eglDevice = 0;
509 EXPECT_EGL_TRUE(
510 eglQueryDisplayAttribEXT(getEGLWindow()->getDisplay(), EGL_DEVICE_EXT, &eglDevice));
511
512 EGLDisplay display2 = eglGetPlatformDisplayEXT(
513 EGL_PLATFORM_DEVICE_EXT, reinterpret_cast<EGLDeviceEXT>(eglDevice), nullptr);
514 EXPECT_EQ(getEGLWindow()->getDisplay(), display2);
515 }
516
517 // Use this to select which configurations (e.g. which renderer, which GLES major version) these
518 // tests should be run against.
519 ANGLE_INSTANTIATE_TEST(EGLDeviceCreationTest, WithNoFixture(ES2_D3D11()));
520 ANGLE_INSTANTIATE_TEST(EGLDeviceQueryTest, ES2_D3D9(), ES2_D3D11());
521