arb_program_interface_query: set vs_input2[1][0] as valid name
[piglit.git] / tests / egl / spec / egl_mesa_device_software / egl_mesa_device_software.c
blobcdfa94680c0895cb22328ecd27930e44770ea019
1 /*
2 * Copyright © 2016 Red Hat, Inc.
3 * Copyright 2015 Intel Corporation
4 * Copyright 2018 Collabora, Ltd.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 * IN THE SOFTWARE.
26 #include "piglit-util.h"
27 #include "piglit-util-egl.h"
29 #define NDEVS 1024
31 int
32 main(void)
34 enum piglit_result result = PIGLIT_PASS;
35 EGLDeviceEXT devs[NDEVS];
36 EGLint i, numdevs, swdevs = 0;
37 EGLDeviceEXT device = EGL_NO_DEVICE_EXT;
38 EGLAttrib attr;
39 const char *devstring = NULL;
40 PFNEGLQUERYDEVICESEXTPROC queryDevices;
41 PFNEGLQUERYDEVICESTRINGEXTPROC queryDeviceString;
42 PFNEGLQUERYDEVICEATTRIBEXTPROC queryDeviceAttrib;
44 const char *client_exts = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
45 bool has_client_ext =
46 client_exts &&
47 ((piglit_is_extension_in_string(client_exts,
48 "EGL_EXT_device_query") &&
49 piglit_is_extension_in_string(client_exts,
50 "EGL_EXT_device_enumeration")) ||
51 piglit_is_extension_in_string(client_exts,
52 "EGL_EXT_device_base"));
54 if (!has_client_ext) {
55 printf("EGL_EXT_device_query not supported\n");
56 piglit_report_result(PIGLIT_SKIP);
59 queryDevices = (void *)eglGetProcAddress("eglQueryDevicesEXT");
61 queryDeviceString =
62 (void *)eglGetProcAddress("eglQueryDeviceStringEXT");
63 queryDeviceAttrib =
64 (void *)eglGetProcAddress("eglQueryDeviceAttribEXT");
66 if (!queryDevices|| !queryDeviceString || !queryDeviceAttrib) {
67 printf("No device query/enumeration entrypoints\n");
68 piglit_report_result(PIGLIT_SKIP);
71 if (!queryDevices(0, NULL, &numdevs)) {
72 printf("Failed to get device count\n");
73 piglit_report_result(PIGLIT_FAIL);
76 if (numdevs > NDEVS) {
77 printf("More than %d devices, please fix this test\n", NDEVS);
78 result = PIGLIT_WARN;
79 numdevs = NDEVS;
82 memset(devs, 0, sizeof devs);
83 if (!queryDevices(numdevs, devs, &numdevs)) {
84 printf("Failed to enumerate devices\n");
85 piglit_report_result(PIGLIT_FAIL);
88 if (!numdevs) {
89 printf("Zero devices enumerated\n");
90 piglit_report_result(PIGLIT_FAIL);
93 for (i = 0; i < numdevs; i++) {
94 device = devs[i];
95 devstring = queryDeviceString(device, EGL_EXTENSIONS);
96 if (devstring == NULL) {
97 printf("Empty device extension string\n");
98 continue;
101 if (!piglit_is_extension_in_string(devstring,
102 "EGL_MESA_device_software")) {
103 printf("Device is not a software one\n");
104 continue;
106 swdevs++;
108 /* Extension does not define any attrib/string tokens.
110 * Double-check we don't expose claim to support other
111 * extension's tokens
113 queryDeviceAttrib(device, 0xbad1dea, &attr);
114 if (!piglit_check_egl_error(EGL_BAD_ATTRIBUTE))
115 piglit_report_result(PIGLIT_FAIL);
117 #ifndef EGL_DRM_DEVICE_FILE_EXT
118 #define EGL_DRM_DEVICE_FILE_EXT 0x3233
119 #endif
120 devstring = queryDeviceString(device, EGL_DRM_DEVICE_FILE_EXT);
121 if (!piglit_check_egl_error(EGL_BAD_PARAMETER))
122 piglit_report_result(PIGLIT_FAIL);
125 /* SKIP if we fetched all devices with none supporting the extension */
126 if (result == PIGLIT_PASS && !swdevs)
127 result = PIGLIT_SKIP;
129 piglit_report_result(result);