|
Packit |
5af8b3 |
/*
|
|
Packit |
5af8b3 |
* Copyright (c) 2016, NVIDIA CORPORATION.
|
|
Packit |
5af8b3 |
*
|
|
Packit |
5af8b3 |
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
Packit |
5af8b3 |
* copy of this software and/or associated documentation files (the
|
|
Packit |
5af8b3 |
* "Materials"), to deal in the Materials without restriction, including
|
|
Packit |
5af8b3 |
* without limitation the rights to use, copy, modify, merge, publish,
|
|
Packit |
5af8b3 |
* distribute, sublicense, and/or sell copies of the Materials, and to
|
|
Packit |
5af8b3 |
* permit persons to whom the Materials are furnished to do so, subject to
|
|
Packit |
5af8b3 |
* the following conditions:
|
|
Packit |
5af8b3 |
*
|
|
Packit |
5af8b3 |
* The above copyright notice and this permission notice shall be included
|
|
Packit |
5af8b3 |
* unaltered in all copies or substantial portions of the Materials.
|
|
Packit |
5af8b3 |
* Any additions, deletions, or changes to the original source files
|
|
Packit |
5af8b3 |
* must be clearly indicated in accompanying documentation.
|
|
Packit |
5af8b3 |
*
|
|
Packit |
5af8b3 |
* If only executable code is distributed, then the accompanying
|
|
Packit |
5af8b3 |
* documentation must state that "this software is based in part on the
|
|
Packit |
5af8b3 |
* work of the Khronos Group."
|
|
Packit |
5af8b3 |
*
|
|
Packit |
5af8b3 |
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
Packit |
5af8b3 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
Packit |
5af8b3 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
Packit |
5af8b3 |
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
Packit |
5af8b3 |
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
Packit |
5af8b3 |
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
Packit |
5af8b3 |
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
|
Packit |
5af8b3 |
*/
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
#include <EGL/egl.h>
|
|
Packit |
5af8b3 |
#include <EGL/eglext.h>
|
|
Packit |
5af8b3 |
#include <stdio.h>
|
|
Packit |
5af8b3 |
#include <stdlib.h>
|
|
Packit |
5af8b3 |
#include <string.h>
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
#include "dummy/EGL_dummy.h"
|
|
Packit |
5af8b3 |
#include "egl_test_utils.h"
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
int main(int argc, char **argv)
|
|
Packit |
5af8b3 |
{
|
|
Packit |
5af8b3 |
EGLDeviceEXT devices[DUMMY_TOTAL_DEVICE_COUNT];
|
|
Packit |
5af8b3 |
EGLDisplay displays[DUMMY_TOTAL_DEVICE_COUNT];
|
|
Packit |
5af8b3 |
EGLint deviceCount = -1;
|
|
Packit |
5af8b3 |
EGLint i, j;
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
loadEGLExtensions();
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
// Make sure the total number of devices is what we expect.
|
|
Packit |
5af8b3 |
printf("Checking device count\n");
|
|
Packit |
5af8b3 |
if (!ptr_eglQueryDevicesEXT(0, NULL, &deviceCount)) {
|
|
Packit |
5af8b3 |
printf("eglQueryDevicesEXT failed\n");
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
if (deviceCount != DUMMY_TOTAL_DEVICE_COUNT) {
|
|
Packit |
5af8b3 |
printf("eglQueryDevicesEXT returned the wrong count\n");
|
|
Packit |
5af8b3 |
printf("Expected %d, but got %d\n", DUMMY_TOTAL_DEVICE_COUNT, deviceCount);
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
printf("Getting device handles.\n");
|
|
Packit |
5af8b3 |
if (!ptr_eglQueryDevicesEXT(DUMMY_TOTAL_DEVICE_COUNT, devices, &deviceCount)) {
|
|
Packit |
5af8b3 |
printf("eglQueryDevicesEXT failed\n");
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
if (deviceCount != DUMMY_TOTAL_DEVICE_COUNT) {
|
|
Packit |
5af8b3 |
printf("eglQueryDevicesEXT returned the wrong count\n");
|
|
Packit |
5af8b3 |
printf("Expected %d, but got %d\n", DUMMY_TOTAL_DEVICE_COUNT, deviceCount);
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
// Check to make sure that there are no duplicates in the device list.
|
|
Packit |
5af8b3 |
for (i=0; i
|
|
Packit |
5af8b3 |
for (j=0; j
|
|
Packit |
5af8b3 |
if (devices[i] == EGL_NO_DEVICE_EXT) {
|
|
Packit |
5af8b3 |
printf("Got EGL_NO_DEVICE_EXT at index %d\n", i);
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
if (devices[i] == devices[j]) {
|
|
Packit |
5af8b3 |
printf("Got duplicate device handles at index %d, %d\n", i, j);
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
for (i=0; i
|
|
Packit |
5af8b3 |
EGLint major, minor;
|
|
Packit |
5af8b3 |
const char *name = DUMMY_VENDOR_NAMES[i / DUMMY_EGL_DEVICE_COUNT];
|
|
Packit |
5af8b3 |
const char *str;
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
// First, test whether an EGL function gets dispatched to the correct
|
|
Packit |
5af8b3 |
// vendor based on this device.
|
|
Packit |
5af8b3 |
str = ptr_eglTestDispatchDevice(devices[i], DUMMY_COMMAND_GET_VENDOR_NAME, 0);
|
|
Packit |
5af8b3 |
if (str == NULL) {
|
|
Packit |
5af8b3 |
printf("eglTestDispatchDevice failed at index %d, error 0x%04x\n", i, eglGetError());
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
if (strcmp(str, name) != 0) {
|
|
Packit |
5af8b3 |
printf("Got the wrong vendor string from device at index %d\n", i);
|
|
Packit |
5af8b3 |
printf("Expected \"%s\", but got \"%s\"\n", name, str);
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
// Create an EGLDisplay from the device.
|
|
Packit |
5af8b3 |
displays[i] = eglGetPlatformDisplay(EGL_PLATFORM_DEVICE_EXT,
|
|
Packit |
5af8b3 |
devices[i], NULL);
|
|
Packit |
5af8b3 |
if (displays[i] == EGL_NO_DISPLAY) {
|
|
Packit |
5af8b3 |
printf("eglGetPlatformDisplay failed at index %d, error 0x%04x\n", i, eglGetError());
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
// Each EGLDeviceEXT handle should give us a different EGLDisplay.
|
|
Packit |
5af8b3 |
for (j=0; j
|
|
Packit |
5af8b3 |
if (displays[i] == displays[j]) {
|
|
Packit |
5af8b3 |
printf("Got duplicate EGLDisplay at index %d, %d\n", i, j);
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
if (!eglInitialize(displays[i], &major, &minor)) {
|
|
Packit |
5af8b3 |
printf("eglInitialize failed at index %d, error 0x%04x\n", i, eglGetError());
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
// Call eglQueryString to make sure that each display belongs to the
|
|
Packit |
5af8b3 |
// correct vendor.
|
|
Packit |
5af8b3 |
str = eglQueryString(displays[i], EGL_VENDOR);
|
|
Packit |
5af8b3 |
if (str == NULL) {
|
|
Packit |
5af8b3 |
printf("eglQueryString failed at index %d, error 0x%04x\n", i, eglGetError());
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
if (strcmp(str, name) != 0) {
|
|
Packit |
5af8b3 |
printf("Got the wrong vendor string from display at index %d\n", i);
|
|
Packit |
5af8b3 |
printf("Expected \"%s\", but got \"%s\"\n", name, str);
|
|
Packit |
5af8b3 |
return 1;
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
}
|
|
Packit |
5af8b3 |
|
|
Packit |
5af8b3 |
return 0;
|
|
Packit |
5af8b3 |
}
|