diff --git a/COPYING b/COPYING index 251da25383db9fd60a36807fb684a609f8671b30..adad141956b17c9df24f323dd20f9a19b37a05d0 100644 --- a/COPYING +++ b/COPYING @@ -24,7 +24,3 @@ The shared library is under the MIT/X11 license: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Separate helper executables in the helpers/ directory are under various -licenses including MIT/X11 and GPL-2.0-or-later. See COPYING.GPL-2 for -the complete text of the GNU General Public License. diff --git a/COPYING.GPL-2 b/COPYING.GPL-2 deleted file mode 100644 index d159169d1050894d3ea3b98e1c965c4058208fe1..0000000000000000000000000000000000000000 --- a/COPYING.GPL-2 +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/bin/system-info.c b/bin/system-info.c index 642cc84da9fe5319c45dab9d9b36948a0e79c8f4..3c9a2b61e84ea042e6f5132aaf7df9fc8dfbed6b 100644 --- a/bin/system-info.c +++ b/bin/system-info.c @@ -73,6 +73,11 @@ * provided by @library but were available with a different version. * This object will be available only if there are some misversioned * symbols. + * + * graphics: + * An object. The keys are multiarch tuples like %SRT_ABI_I386, + * as used in Debian and the freedesktop.org SDK runtime. + * The values are objects with more details of the graphics results: */ #include <steam-runtime-tools/steam-runtime-tools.h> @@ -190,6 +195,20 @@ jsonify_library_issues (JsonBuilder *builder, json_builder_add_string_value (builder, "unknown-expectations"); } +static void +jsonify_graphics_issues (JsonBuilder *builder, + SrtGraphicsIssues issues) +{ + if ((issues & SRT_GRAPHICS_ISSUES_CANNOT_LOAD) != 0) + json_builder_add_string_value (builder, "cannot-load"); + + if ((issues & SRT_GRAPHICS_ISSUES_INTERNAL_ERROR) != 0) + json_builder_add_string_value (builder, "internal-error"); + + if ((issues & SRT_GRAPHICS_ISSUES_SOFTWARE_RENDERING) != 0) + json_builder_add_string_value (builder, "software-rendering"); +} + static void jsonify_steam_issues (JsonBuilder *builder, SrtSteamIssues issues) @@ -293,6 +312,37 @@ print_libraries_details (JsonBuilder *builder, return; } +static void +print_graphics_details(JsonBuilder *builder, + GList *graphics_list) +{ + json_builder_set_member_name (builder, "graphics-details"); + json_builder_begin_object (builder); + for (GList *g = graphics_list; g != NULL; g = g->next) + { + gchar *parameters = srt_graphics_dup_parameters_string (g->data); + + json_builder_set_member_name (builder, parameters); + json_builder_begin_object (builder); + + json_builder_set_member_name (builder, "renderer"); + json_builder_add_string_value (builder, srt_graphics_get_renderer_string (g->data)); + json_builder_set_member_name (builder, "version"); + json_builder_add_string_value (builder, srt_graphics_get_version_string (g->data)); + + if (srt_graphics_get_issues (g->data) != SRT_GRAPHICS_ISSUES_NONE) + { + json_builder_set_member_name (builder, "issues"); + json_builder_begin_array (builder); + jsonify_graphics_issues (builder, srt_graphics_get_issues (g->data)); + json_builder_end_array (builder); + } + json_builder_end_object (builder); // End object for parameters + g_free (parameters); + } + json_builder_end_object (builder); // End garphics-details +} + int main (int argc, char **argv) @@ -414,12 +464,19 @@ main (int argc, if (libraries != NULL && (library_issues != SRT_LIBRARY_ISSUES_NONE || verbose)) print_libraries_details (builder, libraries, verbose); - json_builder_end_object (builder); + GList *graphics_list = srt_system_info_check_all_graphics (info, + multiarch_tuples[i]); + + print_graphics_details (builder, graphics_list); + + json_builder_end_object (builder); // End multiarch_tuple object g_list_free_full (libraries, g_object_unref); + g_list_free_full (graphics_list, g_object_unref); } json_builder_end_object (builder); - json_builder_end_object (builder); + + json_builder_end_object (builder); // End global object JsonNode *root = json_builder_get_root (builder); generator = json_generator_new (); diff --git a/debian/control b/debian/control index 3e77d791496162bf122d2b821f80098c225b696a..18472fb1ea7a889db2c5588ff9ce5ba2bd087041 100644 --- a/debian/control +++ b/debian/control @@ -6,13 +6,8 @@ Standards-Version: 4.3.0 Build-Depends: debhelper, gtk-doc-tools <!nodoc>, - libegl1-mesa-dev, - libgl1-mesa-dev, - libgles2-mesa-dev, libglib2.0-dev, libjson-glib-dev (>= 1.0), - libx11-dev, - libxcomposite-dev, meson, zlib1g <!nocheck>, Build-Depends-Indep: diff --git a/debian/copyright b/debian/copyright index 367d7cd6df22af1de6a3df75d0ce561b0883d405..38d987b76095431a60c1eeac4fc380ed73b5d3bd 100644 --- a/debian/copyright +++ b/debian/copyright @@ -10,18 +10,6 @@ Copyright: © 2019 Collabora Ltd. License: Expat -Files: - helpers/check-gl.c - helpers/check-gles.c - helpers/gnome-session-check-accelerated-common.h -Copyright: - © 2006-2009 Red Hat, Inc. - © 2010 Novell, Inc. - © 2013 SUSE LINUX Products GmbH - © 2016 Endless Mobile, Inc - © 2019 Collabora Ltd. -License: GPL-2+ - License: Expat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -44,19 +32,3 @@ License: Expat Comment: SPDX-License-Identifier: MIT -License: GPL-2+ - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - . - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. -Comment: - SPDX-License-Identifier: GPL-2.0-or-later - . - On Debian systems, a copy of the GPL can be found in - /usr/share/common-licenses/GPL-2. In the Steam Runtime, a copy of the - GPL can be found in steam-runtime/common-licenses/GPL-2. diff --git a/helpers/check-gl.c b/helpers/check-gl.c deleted file mode 100644 index b2ac307f980ee27d2ff02988bd711aeec71b8a78..0000000000000000000000000000000000000000 --- a/helpers/check-gl.c +++ /dev/null @@ -1,384 +0,0 @@ -/* - * check-gl - OpenGL functional check helper for steam-runtime-tools - * Based on gnome-session-check-accelerated-gl-helper from gnome-session. - * - * Copyright (C) 2019 Collabora Ltd. - * Copyright (C) 2010 Novell, Inc. - * Copyright (C) 2006-2009 Red Hat, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: - * Vincent Untz <vuntz@gnome.org> - * - * Most of the code comes from desktop-effects [1], released under GPLv2+. - * desktop-effects was written by: - * Soren Sandmann <sandmann@redhat.com> - * - * [1] http://git.fedorahosted.org/git/?p=desktop-effects.git;a=blob_plain;f=desktop-effects.c;hb=HEAD - */ - -/* - * Here's the rationale behind this helper, quoting Owen, in his mail to the - * release team: - * (http://mail.gnome.org/archives/release-team/2010-June/msg00079.html) - * - * """ - * There are some limits to what we can do here automatically without - * knowing anything about the driver situation on the system. The basic - * problem is that there are all sorts of suck: - * - * * No GL at all. This typically only happens if a system is - * misconfigured. - * - * * Only software GL. This one is easy to detect. We have code in - * the Fedora desktop-effects tool, etc. - * - * * GL that isn't featureful enough. (Tiny texture size limits, no - * texture-from-pixmap, etc.) Possible to detect with more work, but - * largely a fringe case. - * - * * Buggy GL. This isn't possible to detect. Except for the case where - * all GL programs crash. For that reason, we probably don't want - * gnome-session to directly try and do any GL detection; better to - * use a helper binary. - * - * * Horribly slow hardware GL. We could theoretically develop some sort - * of benchmark, but it's a tricky area. And how slow is too slow? - * """ - * - * Some other tools are doing similar checks: - * - desktop-effects (Fedora Config Tool) [1] - * - drak3d (Mandriva Config Tool) [2] - * - compiz-manager (Compiz wrapper) [3] - * - * [1] http://git.fedorahosted.org/git/?p=desktop-effects.git;a=blob_plain;f=desktop-effects.c;hb=HEAD - * [2] http://svn.mandriva.com/cgi-bin/viewvc.cgi/soft/drak3d/trunk/lib/Xconfig/glx.pm?view=markup - * [3] http://git.compiz.org/fusion/misc/compiz-manager/tree/compiz-manager - */ - -#include <ctype.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <glib.h> - -#include <regex.h> - -#ifdef __FreeBSD__ -#include <kenv.h> -#endif - -#include <X11/Xlib.h> -#include <X11/Xatom.h> -#include <X11/extensions/Xcomposite.h> -#include <GL/gl.h> -#include <GL/glx.h> - -#include "steam-runtime-tools/glib-compat.h" - -#include "gnome-session-check-accelerated-common.h" - -#define SIZE_UNSET 0 -#define SIZE_ERROR -1 -static int max_texture_size = SIZE_UNSET; -static int max_renderbuffer_size = SIZE_UNSET; -static gboolean has_llvmpipe = FALSE; - -static inline void -_print_error (const char *str) -{ - fprintf (stderr, "gnome-session-is-accelerated: %s\n", str); -} - -#if 0 -static gboolean -_is_comment (const char *line) -{ - while (*line && isspace(*line)) - line++; - - if (*line == '#' || *line == '\0') - return TRUE; - return FALSE; -} -#endif - -static gboolean -_is_gl_renderer_blacklisted (const char *renderer) -{ - return FALSE; -#if 0 - FILE *blacklist; - char *line = NULL; - size_t line_len = 0; - gboolean ret = TRUE; - - blacklist = fopen(PKGDATADIR "/hardware-compatibility", "r"); - if (blacklist == NULL) - goto out; - - while (getline (&line, &line_len, blacklist) != -1) { - int whitelist = 0; - const char *re_str; - regex_t re; - int status; - - if (line == NULL) - break; - - /* Drop trailing \n */ - line[strlen(line) - 1] = '\0'; - - if (_is_comment (line)) { - free (line); - line = NULL; - continue; - } - - if (line[0] == '+') - whitelist = 1; - else if (line[0] == '-') - whitelist = 0; - else { - _print_error ("Invalid syntax in this line for hardware compatibility:"); - _print_error (line); - free (line); - line = NULL; - continue; - } - - re_str = line + 1; - - if (regcomp (&re, re_str, REG_EXTENDED|REG_ICASE|REG_NOSUB) != 0) { - _print_error ("Cannot use this regular expression for hardware compatibility:"); - _print_error (re_str); - } else { - status = regexec (&re, renderer, 0, NULL, 0); - regfree(&re); - - if (status == 0) { - if (whitelist) - ret = FALSE; - goto out; - } - } - - free (line); - line = NULL; - } - - ret = FALSE; - -out: - if (line != NULL) - free (line); - - if (blacklist != NULL) - fclose (blacklist); - - return ret; -#endif -} - -static char * -_get_hardware_gl (Display *display) -{ - int screen; - Window root; - XVisualInfo *visual = NULL; - GLXContext context = NULL; - XSetWindowAttributes cwa = { 0 }; - Window window = None; - char *renderer = NULL; - - int attrlist[] = { - GLX_RGBA, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_DOUBLEBUFFER, - None - }; - - screen = DefaultScreen (display); - root = RootWindow (display, screen); - - visual = glXChooseVisual (display, screen, attrlist); - if (!visual) - goto out; - - context = glXCreateContext (display, visual, NULL, True); - if (!context) - goto out; - - cwa.colormap = XCreateColormap (display, root, - visual->visual, AllocNone); - cwa.background_pixel = 0; - cwa.border_pixel = 0; - window = XCreateWindow (display, root, - 0, 0, 1, 1, 0, - visual->depth, InputOutput, visual->visual, - CWColormap | CWBackPixel | CWBorderPixel, - &cwa); - - if (!glXMakeCurrent (display, window, context)) - goto out; - - renderer = g_strdup ((const char *) glGetString (GL_RENDERER)); - if (_is_gl_renderer_blacklisted (renderer)) { - g_clear_pointer (&renderer, g_free); - goto out; - } - if (renderer && strcasestr (renderer, "llvmpipe")) - has_llvmpipe = TRUE; - - /* we need to get the max texture and renderbuffer sizes while we have - * a context, but we'll check their values later */ - - glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_texture_size); - if (glGetError() != GL_NO_ERROR) - max_texture_size = SIZE_ERROR; - - glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE_EXT, &max_renderbuffer_size); - if (glGetError() != GL_NO_ERROR) - max_renderbuffer_size = SIZE_ERROR; - -out: - glXMakeCurrent (display, None, None); - if (context) - glXDestroyContext (display, context); - if (window) - XDestroyWindow (display, window); - if (cwa.colormap) - XFreeColormap (display, cwa.colormap); - - return renderer; -} - -#if 0 -static gboolean -_has_extension (const char *extension_list, - const char *extension) -{ - char **extensions; - guint i; - gboolean ret; - - g_return_val_if_fail (extension != NULL, TRUE); - - /* Extension_list is one big string, containing extensions - * separated by spaces. */ - if (extension_list == NULL) - return FALSE; - - ret = FALSE; - - extensions = g_strsplit (extension_list, " ", -1); - if (extensions == NULL) - return FALSE; - - for (i = 0; extensions[i] != NULL; i++) { - if (g_str_equal (extensions[i], extension)) { - ret = TRUE; - break; - } - } - - g_strfreev (extensions); - - return ret; -} - -static gboolean -_display_has_extension (Display *display, const char *extension) -{ - int screen; - const char *server_extensions; - const char *client_extensions; - gboolean ret = FALSE; - - screen = DefaultScreen (display); - - server_extensions = glXQueryServerString (display, screen, - GLX_EXTENSIONS); - if (!_has_extension (server_extensions, - extension)) - goto out; - - client_extensions = glXGetClientString (display, GLX_EXTENSIONS); - if (!_has_extension (client_extensions, - extension)) - goto out; - - ret = TRUE; - -out: - return ret; -} -#endif - -static gboolean print_renderer = FALSE; - -static const GOptionEntry entries[] = { - { "print-renderer", 'p', 0, G_OPTION_ARG_NONE, &print_renderer, "Print GL renderer name", NULL }, - { NULL }, -}; - -int -main (int argc, char **argv) -{ - Display *display = NULL; - int ret = HELPER_NO_ACCEL; - GOptionContext *context; - GError *error = NULL; - char *renderer = NULL; - - setlocale (LC_ALL, ""); - - context = g_option_context_new (NULL); - g_option_context_add_main_entries (context, entries, NULL); - - if (!g_option_context_parse (context, &argc, &argv, &error)) { - g_error ("Can't parse command line: %s\n", error->message); - g_error_free (error); - goto out; - } - - display = XOpenDisplay (NULL); - if (!display) { - _print_error ("No X display."); - goto out; - } - - renderer = _get_hardware_gl (display); - if (!renderer) { - _print_error ("No hardware 3D support."); - goto out; - } - - ret = has_llvmpipe ? HELPER_SOFTWARE_RENDERING : HELPER_ACCEL; - - if (print_renderer) - g_print ("%s", renderer); - -out: - if (display) - XCloseDisplay (display); - g_free (renderer); - - return ret; -} diff --git a/helpers/check-gles.c b/helpers/check-gles.c deleted file mode 100644 index 39192c8d2a025fddbad1a54c83e88c410ed0178c..0000000000000000000000000000000000000000 --- a/helpers/check-gles.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * check-gles OpenGLES functional check helper for steam-runtime-tools - * Based on gnome-session-check-accelerated-gles-heper from gnome-session. - * - * Copyright (C) 2019 Collabora Ltd. - * Copyright (C) 2016 Endless Mobile, Inc - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Author: - * Cosimo Cecchi <cosimo@endlessm.com> - */ - -#include <locale.h> -#include <stdlib.h> -#include <string.h> - -#include <glib.h> -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> -#include <EGL/egl.h> - -#include "steam-runtime-tools/glib-compat.h" - -#include "gnome-session-check-accelerated-common.h" - -static char * -get_gles_renderer (void) -{ - /* Select GLESv2 config */ - EGLint attribs[] = { - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_RED_SIZE, 1, - EGL_GREEN_SIZE, 1, - EGL_BLUE_SIZE, 1, - EGL_NONE - }; - - EGLint ctx_attribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; - - gboolean egl_inited = FALSE; - Display *display; - Window win = None; - EGLContext egl_ctx = NULL; - EGLDisplay egl_dpy = NULL; - EGLSurface egl_surf = NULL; - char *renderer = NULL; - - display = XOpenDisplay (NULL); - egl_dpy = eglGetDisplay (display); - if (!egl_dpy) { - g_warning ("eglGetDisplay() failed"); - goto out; - } - - EGLint egl_major, egl_minor; - if (!eglInitialize (egl_dpy, &egl_major, &egl_minor)) { - g_warning ("eglInitialize() failed"); - goto out; - } - - egl_inited = TRUE; - - EGLint num_configs; - EGLConfig config; - if (!eglChooseConfig (egl_dpy, attribs, &config, 1, &num_configs)) { - g_warning ("Failed to get EGL configuration"); - goto out; - } - - EGLint vid; - if (!eglGetConfigAttrib (egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { - g_warning ("Failed to get EGL visual"); - goto out; - } - - /* The X window visual must match the EGL config */ - XVisualInfo *vis_info, vis_template; - int num_visuals; - vis_template.visualid = vid; - vis_info = XGetVisualInfo (display, VisualIDMask, &vis_template, &num_visuals); - if (!vis_info) { - g_warning ("Failed to get X visual"); - goto out; - } - - XSetWindowAttributes attr; - attr.colormap = XCreateColormap (display, DefaultRootWindow (display), - vis_info->visual, AllocNone); - win = XCreateWindow (display, DefaultRootWindow (display), - 0, 0, /* x, y */ - 1, 1, /* width, height */ - 0, /* border_width */ - vis_info->depth, InputOutput, - vis_info->visual, CWColormap, &attr); - XFree (vis_info); - - eglBindAPI (EGL_OPENGL_ES_API); - - egl_ctx = eglCreateContext (egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs); - if (!egl_ctx) { - g_warning ("Failed to create EGL context"); - goto out; - } - - egl_surf = eglCreateWindowSurface (egl_dpy, config, win, NULL); - if (!egl_surf) { - g_warning ("Failed to create EGL surface"); - goto out; - } - - if (!eglMakeCurrent (egl_dpy, egl_surf, egl_surf, egl_ctx)) { - g_warning ("eglMakeCurrent() failed"); - goto out; - } - - renderer = g_strdup ((const char *) glGetString (GL_RENDERER)); - - out: - if (egl_ctx) - eglDestroyContext (egl_dpy, egl_ctx); - if (egl_surf) - eglDestroySurface (egl_dpy, egl_surf); - if (egl_inited) - eglTerminate (egl_dpy); - if (win != None) - XDestroyWindow (display, win); - - return renderer; -} - -static gboolean print_renderer = FALSE; - -static const GOptionEntry entries[] = { - { "print-renderer", 'p', 0, G_OPTION_ARG_NONE, &print_renderer, "Print EGL renderer name", NULL }, - { NULL }, -}; - -int -main (int argc, - char **argv) -{ - char *renderer = NULL; - GOptionContext *context; - int ret = HELPER_NO_ACCEL; - GError *error = NULL; - - setlocale (LC_ALL, ""); - - context = g_option_context_new (NULL); - g_option_context_add_main_entries (context, entries, NULL); - - if (!g_option_context_parse (context, &argc, &argv, &error)) { - g_error ("Can't parse command line: %s\n", error->message); - g_error_free (error); - goto out; - } - - renderer = get_gles_renderer (); - - if (renderer != NULL) { - if (print_renderer) - g_print ("%s", renderer); - if (strcasestr (renderer, "llvmpipe")) - ret = HELPER_SOFTWARE_RENDERING; - else - ret = HELPER_ACCEL; - } - -out: - return ret; -} - diff --git a/helpers/gnome-session-check-accelerated-common.h b/helpers/gnome-session-check-accelerated-common.h deleted file mode 100644 index 59631d9ccb6301bd6c905099ac7c71a48ff8d034..0000000000000000000000000000000000000000 --- a/helpers/gnome-session-check-accelerated-common.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- mode:c; c-basic-offset: 8; indent-tabs-mode: nil; -*- */ -/* Tool to set the property _GNOME_SESSION_ACCELERATED on the root window */ -/* - * Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: - * Frederic Crozat <fcrozat@suse.com> - */ - -/* Exit value for helper */ -#define HELPER_ACCEL 0 -#define HELPER_NO_ACCEL 1 -#define HELPER_SOFTWARE_RENDERING 2 - diff --git a/helpers/meson.build b/helpers/meson.build index 1e94285861befeafde76801ca04481cfdbdde85e..ec7829f4c9022f84a168204c40aeccb12337f6a4 100644 --- a/helpers/meson.build +++ b/helpers/meson.build @@ -42,39 +42,4 @@ executable( ) ) -glib_dep = dependency('glib-2.0') -x11_dep = dependency('x11') - -executable( - multiarch + '-check-gl', - 'check-gl.c', - include_directories : project_include_dirs, - install : true, - install_dir : join_paths( - get_option('libexecdir'), - 'steam-runtime-tools-' + api_major, - ), - dependencies : [ glib_dep, - x11_dep, - dependency('gl'), - dependency('xcomposite') - ] -) - -executable( - multiarch + '-check-gles', - 'check-gles.c', - include_directories : project_include_dirs, - install : true, - install_dir : join_paths( - get_option('libexecdir'), - 'steam-runtime-tools-' + api_major, - ), - dependencies: [ glib_dep, - x11_dep, - dependency('egl'), - dependency('glesv2') - ] -) - # vim:set sw=2 sts=2 et: diff --git a/steam-runtime-tools/graphics-internal.h b/steam-runtime-tools/graphics-internal.h new file mode 100644 index 0000000000000000000000000000000000000000..0d4af625cb40ec1acd49daeaccec11cf5c256f06 --- /dev/null +++ b/steam-runtime-tools/graphics-internal.h @@ -0,0 +1,123 @@ +/*< internal_header >*/ +/* + * Copyright © 2019 Collabora Ltd. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#pragma once + +#include "steam-runtime-tools/steam-runtime-tools.h" + +/* + * _srt_graphics_new: + * @multiarch_tuple: A multiarch tuple like %SRT_ABI_I386, + * representing an ABI + * @window_system: The window system to check, + * @rendering_interface: The renderint interface to check, + * @issues: Problems found when checking @multiarch_tuple with + * the given @winsys and @renderer. + * + * Inline convenience function to create a new SrtGraphics. + * This is not part of the public API. + * + * Returns: (transfer full): A new #SrtGraphics + */ +static inline SrtGraphics *_srt_graphics_new (const char *multiarch_tuple, + SrtWindowSystem window_system, + SrtRenderingInterface rendering_interface, + const gchar *renderer_string, + const gchar *version_string, + SrtGraphicsIssues issues); + +/* + * _srt_graphics_hash_key: + * @window_system: The window system, + * @rendering_interface: The rendering interface, + * + * Generate an int hash key from a window system and rendering interface, used + * in SrtSystemInfo to cache SrtGraphics objects and results based on window + * system and rendering interface used + * + * Returns: A unique integer for each combination of window system and renderer. + */ +static inline int _srt_graphics_hash_key(SrtWindowSystem winsys, SrtRenderingInterface renderer); + +#ifndef __GTK_DOC_IGNORE__ + +G_GNUC_INTERNAL SrtGraphicsIssues _srt_check_graphics (const char *helpers_path, + const char *multiarch_tuple, + SrtWindowSystem window_system, + SrtRenderingInterface rendering_interface, + SrtGraphics **details_out); + +static inline SrtGraphics * +_srt_graphics_new (const char *multiarch_tuple, + SrtWindowSystem window_system, + SrtRenderingInterface rendering_interface, + const gchar *renderer_string, + const gchar *version_string, + SrtGraphicsIssues issues) +{ + g_return_val_if_fail (multiarch_tuple != NULL, NULL); + return g_object_new (SRT_TYPE_GRAPHICS, + "multiarch-tuple", multiarch_tuple, + "issues", issues, + "window-system", window_system, + "rendering-interface", rendering_interface, + "renderer-string", renderer_string, + "version-string", version_string, + NULL); +} + +static inline int _srt_graphics_hash_key(SrtWindowSystem window_system, + SrtRenderingInterface rendering_interface) +{ + /* This allows us to have up to 100 unique renderers, we won't need nearly that + many, but setting to 100 just to allow room to grow */ + return (int)window_system * 100 + (int)rendering_interface; +} + +static inline const gchar * +_srt_graphics_window_system_string (SrtWindowSystem window_system) +{ + if (window_system == SRT_WINDOW_SYSTEM_X11) + return "x11"; + else if (window_system == SRT_WINDOW_SYSTEM_GLX) + return "glx"; + else if (window_system == SRT_WINDOW_SYSTEM_EGL_X11) + return "egl_x11"; + return "unknown window system"; +} + +static inline const gchar * +_srt_graphics_rendering_interface_string (SrtRenderingInterface rendering_interface) +{ + if (rendering_interface == SRT_RENDERING_INTERFACE_GL) + return "gl"; + else if (rendering_interface == SRT_RENDERING_INTERFACE_GLESV2) + return "glesv2"; + return "unknown rendering interface"; +} + +#endif + diff --git a/steam-runtime-tools/graphics-test-defines.h b/steam-runtime-tools/graphics-test-defines.h new file mode 100644 index 0000000000000000000000000000000000000000..708deb66619f1ed2299b9a976c57535664155980 --- /dev/null +++ b/steam-runtime-tools/graphics-test-defines.h @@ -0,0 +1,34 @@ +/*< internal_header >*/ +/* + * Copyright © 2019 Collabora Ltd. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#pragma once + +// Test strings for use in mock and graphics test +#define SRT_TEST_GOOD_GRAPHICS_RENDERER "Mesa DRI Intel(R) Haswell Desktop " +#define SRT_TEST_SOFTWARE_GRAPHICS_RENDERER "llvmpipe (LLVM 8.0, 256 bits)" +#define SRT_TEST_GOOD_GRAPHICS_VERSION "3.0 Mesa 19.1.3" +#define SRT_TEST_SOFTWARE_GRAPHICS_VERSION "3.1 Mesa 19.1.3" + diff --git a/steam-runtime-tools/graphics.c b/steam-runtime-tools/graphics.c new file mode 100644 index 0000000000000000000000000000000000000000..601d6ada4446c0dabaa939ac3b4fa6979ac12d26 --- /dev/null +++ b/steam-runtime-tools/graphics.c @@ -0,0 +1,547 @@ +/* + * Copyright © 2019 Collabora Ltd. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "steam-runtime-tools/graphics.h" + +#include "steam-runtime-tools/architecture.h" +#include "steam-runtime-tools/enums.h" +#include "steam-runtime-tools/graphics-internal.h" +#include "steam-runtime-tools/utils-internal.h" + +#include <json-glib/json-glib.h> + +/** + * SECTION:graphics + * @title: Graphics compatibility check + * @short_description: Get information about system's graphics capabilities + * @include: steam-runtime-tools/steam-runtime-tools.h + * + * #SrtGraphics is an opaque object representing a graphics capabilities. + * This is a reference-counted object: use g_object_ref() and + * g_object_unref() to manage its lifecycle. + */ + +struct _SrtGraphics +{ + /*< private >*/ + GObject parent; + GQuark multiarch_tuple; + SrtWindowSystem window_system; + SrtRenderingInterface rendering_interface; + SrtGraphicsIssues issues; + gchar *renderer_string; + gchar *version_string; +}; + +struct _SrtGraphicsClass +{ + /*< private >*/ + GObjectClass parent_class; +}; + +enum { + PROP_0, + PROP_ISSUES, + PROP_MULTIARCH_TUPLE, + PROP_WINDOW_SYSTEM, + PROP_RENDERING_INTERFACE, + PROP_RENDERER_STRING, + PROP_VERSION_STRING, + N_PROPERTIES +}; + +G_DEFINE_TYPE (SrtGraphics, srt_graphics, G_TYPE_OBJECT) + +static void +srt_graphics_init (SrtGraphics *self) +{ +} + +static void +srt_graphics_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + SrtGraphics *self = SRT_GRAPHICS (object); + + switch (prop_id) + { + case PROP_ISSUES: + g_value_set_flags (value, self->issues); + break; + + case PROP_MULTIARCH_TUPLE: + g_value_set_string (value, g_quark_to_string (self->multiarch_tuple)); + break; + + case PROP_WINDOW_SYSTEM: + g_value_set_enum (value, self->window_system); + break; + + case PROP_RENDERING_INTERFACE: + g_value_set_enum (value, self->rendering_interface); + break; + + case PROP_RENDERER_STRING: + g_value_set_string (value, self->renderer_string); + break; + + case PROP_VERSION_STRING: + g_value_set_string (value, self->version_string); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +srt_graphics_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + SrtGraphics *self = SRT_GRAPHICS (object); + + switch (prop_id) + { + case PROP_ISSUES: + /* Construct-only */ + g_return_if_fail (self->issues == 0); + self->issues = g_value_get_flags (value); + break; + + case PROP_MULTIARCH_TUPLE: + /* Construct-only */ + g_return_if_fail (self->multiarch_tuple == 0); + /* Intern the string since we only expect to deal with a few values */ + self->multiarch_tuple = g_quark_from_string (g_value_get_string (value)); + break; + + case PROP_WINDOW_SYSTEM: + /* Construct-only */ + g_return_if_fail (self->window_system == 0); + self->window_system = g_value_get_enum (value); + break; + + case PROP_RENDERING_INTERFACE: + /* Construct-only */ + g_return_if_fail (self->rendering_interface == 0); + self->rendering_interface = g_value_get_enum (value); + break; + + case PROP_RENDERER_STRING: + /* Construct only */ + g_return_if_fail (self->renderer_string == NULL); + + self->renderer_string = g_value_dup_string (value); + break; + + case PROP_VERSION_STRING: + /* Construct only */ + g_return_if_fail (self->version_string == NULL); + + self->version_string = g_value_dup_string (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +srt_graphics_finalize (GObject *object) +{ + SrtGraphics *self = SRT_GRAPHICS (object); + + g_free (self->renderer_string); + g_free (self->version_string); + + G_OBJECT_CLASS (srt_graphics_parent_class)->finalize (object); +} + +static GParamSpec *properties[N_PROPERTIES] = { NULL }; + +static void +srt_graphics_class_init (SrtGraphicsClass *cls) +{ + GObjectClass *object_class = G_OBJECT_CLASS (cls); + + object_class->get_property = srt_graphics_get_property; + object_class->set_property = srt_graphics_set_property; + object_class->finalize = srt_graphics_finalize; + + properties[PROP_ISSUES] = + g_param_spec_flags ("issues", "Issues", "Problems with the graphics stack", + SRT_TYPE_GRAPHICS_ISSUES, SRT_GRAPHICS_ISSUES_NONE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + properties[PROP_MULTIARCH_TUPLE] = + g_param_spec_string ("multiarch-tuple", "Multiarch tuple", + "Which multiarch tuple we are checking, for example " + "x86_64-linux-gnu", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + properties[PROP_WINDOW_SYSTEM] = + g_param_spec_enum ("window-system", "Window System", "Which window system we are checking.", + SRT_TYPE_WINDOW_SYSTEM, SRT_WINDOW_SYSTEM_GLX, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + properties[PROP_RENDERING_INTERFACE] = + g_param_spec_enum ("rendering-interface", "Rendering Interface", "Which rendering interface we are checking.", + SRT_TYPE_RENDERING_INTERFACE, SRT_RENDERING_INTERFACE_GL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + properties[PROP_RENDERER_STRING] = + g_param_spec_string ("renderer-string", "Found Renderer", "Which renderer was found by checking.", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + properties[PROP_VERSION_STRING] = + g_param_spec_string ("version-string", "Found version", "Which version of graphics renderer was found from check.", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, N_PROPERTIES, properties); +} + +/** + * _srt_check_graphics: + * @helpers_path: An optional path to find wflinfo helpers, PATH is used if null. + * @multiarch_tuple: A multiarch tuple to check e.g. i386-linux-gnu + * @winsys: The window system to check. + * @renderer: The graphics renderer to check. + * @details_out: The SrtGraphics object containing the details of the check. + * + * Return the problems found when checking the graphics stack given. + * + * Returns: A bitfield containing problems, or %SRT_GRAPHICS_ISSUES_NONE + * if no problems were found + */ +G_GNUC_INTERNAL SrtGraphicsIssues +_srt_check_graphics (const char *helpers_path, + const char *multiarch_tuple, + SrtWindowSystem window_system, + SrtRenderingInterface rendering_interface, + SrtGraphics **details_out) +{ + GPtrArray *argv = NULL; + gchar *output = NULL; + int exit_status = -1; + JsonParser *parser = NULL; + JsonNode *node = NULL; + JsonObject *object = NULL; + JsonNode *sub_node = NULL; + JsonObject *sub_object = NULL; + const gchar *version_string = NULL; + const gchar *renderer_string = NULL; + GError *error = NULL; + SrtGraphicsIssues issues = SRT_GRAPHICS_ISSUES_NONE; + GStrv my_environ = NULL; + const gchar *ld_preload; + gchar *filtered_preload = NULL; + + g_return_val_if_fail (details_out == NULL || *details_out == NULL, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); + + gchar *platformstring = NULL; + + argv = g_ptr_array_new_with_free_func (g_free); + + if (window_system == SRT_WINDOW_SYSTEM_GLX) + { + platformstring = g_strdup ("glx"); + } + else if (window_system == SRT_WINDOW_SYSTEM_X11) + { + if (rendering_interface == SRT_RENDERING_INTERFACE_GL) + { + platformstring = g_strdup ("glx"); + window_system = SRT_WINDOW_SYSTEM_GLX; + } + else + { + platformstring = g_strdup ("x11_egl"); + window_system = SRT_WINDOW_SYSTEM_EGL_X11; + } + } + else if (window_system == SRT_WINDOW_SYSTEM_EGL_X11) + { + platformstring = g_strdup ("x11_egl"); + } + else + { + g_return_val_if_reached (SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); + } + + if (rendering_interface == SRT_RENDERING_INTERFACE_GL) + { + if (helpers_path != NULL) + { + g_ptr_array_add (argv, g_strdup_printf ("%s/%s-wflinfo", helpers_path, multiarch_tuple)); + } + else + { + g_ptr_array_add (argv, g_strdup_printf ("%s-wflinfo", multiarch_tuple)); + } + g_ptr_array_add (argv, g_strdup_printf ("--platform=%s", platformstring)); + g_ptr_array_add (argv, g_strdup ("--api=gl")); + g_ptr_array_add (argv, g_strdup ("--format=json")); + } + else if (rendering_interface == SRT_RENDERING_INTERFACE_GLESV2) + { + if (helpers_path != NULL) + { + g_ptr_array_add (argv, g_strdup_printf ("%s/%s-wflinfo", helpers_path, multiarch_tuple)); + } + else + { + g_ptr_array_add (argv, g_strdup_printf ("%s-wflinfo", multiarch_tuple)); + } + g_ptr_array_add (argv, g_strdup_printf ("--platform=%s", platformstring)); + g_ptr_array_add (argv, g_strdup ("--api=gles2")); + g_ptr_array_add (argv, g_strdup ("--format=json")); + } + else + { + g_return_val_if_reached (SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); + } + g_ptr_array_add (argv, NULL); + + my_environ = g_get_environ (); + ld_preload = g_environ_getenv (my_environ, "LD_PRELOAD"); + if (ld_preload != NULL) + { + filtered_preload = _srt_filter_gameoverlayrenderer (ld_preload); + my_environ = g_environ_setenv (my_environ, "LD_PRELOAD", filtered_preload, TRUE); + } + + if (!g_spawn_sync (NULL, /* working directory */ + (gchar **) argv->pdata, + my_environ, /* envp */ + G_SPAWN_SEARCH_PATH, /* flags */ + NULL, /* child setup */ + NULL, /* user data */ + &output, /* stdout */ + NULL, /* stderr */ + &exit_status, + &error)) + { + g_debug ("An error occurred calling the helper: %s", error->message); + issues |= SRT_GRAPHICS_ISSUES_CANNOT_LOAD; + goto out; + } + + if (exit_status != 0) + { + g_debug ("... wait status %d", exit_status); + issues |= SRT_GRAPHICS_ISSUES_CANNOT_LOAD; + goto out; + } + + /* We can't use `json_from_string()` directly because we are targeting an + * older json-glib version */ + parser = json_parser_new (); + + if (!json_parser_load_from_data (parser, output, -1, &error)) + { + g_debug ("The helper output is not a valid JSON: %s", error->message); + issues |= SRT_GRAPHICS_ISSUES_CANNOT_LOAD; + goto out; + } + + node = json_parser_get_root (parser); + object = json_node_get_object (node); + + /* Process json output */ + if (!json_object_has_member (object, "OpenGL")) + { + g_debug ("The json output doesn't contain an OpenGL object"); + issues |= SRT_GRAPHICS_ISSUES_CANNOT_LOAD; + goto out; + } + + sub_node = json_object_get_member (object, "OpenGL"); + sub_object = json_node_get_object (sub_node); + + if (!json_object_has_member (sub_object, "version string") || + !json_object_has_member (sub_object, "renderer string")) + { + g_debug ("Json output is missing version or renderer"); + issues |= SRT_GRAPHICS_ISSUES_CANNOT_LOAD; + goto out; + } + + version_string = json_object_get_string_member (sub_object, "version string"); + renderer_string = json_object_get_string_member (sub_object, "renderer string"); + + /* Check renderer to see if we are using software rendering */ + if (strstr (renderer_string, "llvmpipe") != NULL || + strstr (renderer_string, "software rasterizer") != NULL || + strstr (renderer_string, "softpipe") != NULL) + { + issues |= SRT_GRAPHICS_ISSUES_SOFTWARE_RENDERING; + } + +out: + if (details_out != NULL) + *details_out = _srt_graphics_new (multiarch_tuple, + window_system, + rendering_interface, + renderer_string, + version_string, + issues); + + if (parser != NULL) + g_object_unref (parser); + + g_ptr_array_unref (argv); + g_free (output); + g_clear_error (&error); + return issues; +} + +/** + * srt_graphics_get_issues: + * @self: a SrtGraphics object + * + * Return the problems found when loading @self. + * + * Returns: A bitfield containing problems, or %SRT_GRAPHICS_ISSUES_NONE + * if no problems were found + */ +SrtGraphicsIssues +srt_graphics_get_issues (SrtGraphics *self) +{ + g_return_val_if_fail (SRT_IS_GRAPHICS (self), SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); + return self->issues; +} + +/** + * srt_graphics_get_multiarch_tuple: + * @self: a graphics object + * + * Return the multiarch tuple representing the ABI of @self. + * + * Returns: A Debian-style multiarch tuple, usually %SRT_ABI_I386 + * or %SRT_ABI_X86_64 + */ +const char * +srt_graphics_get_multiarch_tuple (SrtGraphics *self) +{ + g_return_val_if_fail (SRT_IS_GRAPHICS (self), NULL); + return g_quark_to_string (self->multiarch_tuple); +} + +/** + * srt_graphics_get_window_system: + * @self: a graphics object + * + * Return the window system tested on the given graphics object. + * + * Returns: An enumeration of #SrtWindowSystem which window system was tested. + */ +SrtWindowSystem +srt_graphics_get_window_system (SrtGraphics *self) +{ + // Not sure what to return if self is not a SrtGraphics object, maybe need + // to add a SRT_WINDOW_SYSTEM_NONE ? + g_return_val_if_fail (SRT_IS_GRAPHICS (self), 0); + return self->window_system; +} + +/** + * srt_graphics_get_rendering_interface: + * @self: a graphics object + * + * Return the rendering interface which was tested on the given graphics object. + * + * Returns: An enumeration of #SrtRenderingInterface indicating which rendering + * interface was tested. + */ +SrtRenderingInterface +srt_graphics_get_rendering_interface (SrtGraphics *self) +{ + g_return_val_if_fail (SRT_IS_GRAPHICS (self), 0); + return self->rendering_interface; +} + +/** + * srt_graphics_get_version_string: + * @self: a graphics object + * + * Return the version string found when testing the given graphics. + * + * Returns: A string indicating the version found when testing graphics. + */ +const char * +srt_graphics_get_version_string (SrtGraphics *self) +{ + g_return_val_if_fail (SRT_IS_GRAPHICS (self), NULL); + return self->version_string; +} + +/** + * srt_graphics_get_renderer_string: + * @self: a graphics object + * + * Return the renderer string found when testing the given graphics. + * + * Returns: A string indicating the renderer found when testing graphics. + */ +const char * +srt_graphics_get_renderer_string (SrtGraphics *self) +{ + g_return_val_if_fail (SRT_IS_GRAPHICS (self), NULL); + return self->renderer_string; +} + +/** + * srt_graphics_dup_parameters_string: + * @self: a graphics object + * + * Return a string indicating which window system and rendering interface were + * tested, for example "glx/gl" for "desktop" OpenGL on X11 via GLX, or + * "egl_x11/glesv2" for OpenGLES v2 on X11 via the Khronos Native Platform + * Graphics Interface (EGL). + * + * Returns: (transfer full): sA string indicating which parameters were tested. + * Free with g_free(). + */ +gchar * +srt_graphics_dup_parameters_string (SrtGraphics *self) +{ + g_return_val_if_fail (SRT_IS_GRAPHICS (self), NULL); + return g_strdup_printf ("%s/%s", + _srt_graphics_window_system_string (self->window_system), + _srt_graphics_rendering_interface_string (self->rendering_interface)); +} diff --git a/steam-runtime-tools/graphics.h b/steam-runtime-tools/graphics.h new file mode 100644 index 0000000000000000000000000000000000000000..32194e68d1da90ac232472d45a1c2dee2975483a --- /dev/null +++ b/steam-runtime-tools/graphics.h @@ -0,0 +1,106 @@ +/* + * Copyright © 2019 Collabora Ltd. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#pragma once + +#if !defined(_SRT_IN_SINGLE_HEADER) && !defined(_SRT_COMPILATION) +#error "Do not include directly, use <steam-runtime-tools/steam-runtime-tools.h>" +#endif + +#include <glib.h> +#include <glib-object.h> + +typedef struct _SrtGraphics SrtGraphics; +typedef struct _SrtGraphicsClass SrtGraphicsClass; + +#define SRT_TYPE_GRAPHICS srt_graphics_get_type () +#define SRT_GRAPHICS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SRT_TYPE_GRAPHICS, SrtGraphics)) +#define SRT_GRAPHICS_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST ((cls), SRT_TYPE_GRAPHICS, SrtGraphicsClass)) +#define SRT_IS_GRAPHICS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SRT_TYPE_GRAPHICS)) +#define SRT_IS_GRAPHICS_CLASS(cls) (G_TYPE_CHECK_CLASS_TYPE ((cls), SRT_TYPE_GRAPHICS)) +#define SRT_GRAPHICS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), SRT_TYPE_GRAPHICS, SrtGraphicsClass) + +GType srt_graphics_get_type (void); + +/** + * SrtGraphicsIssues: + * @SRT_GRAPHICS_ISSUES_NONE: There are no problems + * @SRT_GRAPHICS_ISSUES_INTERNAL_ERROR: An internal error of some kind has occurred + * @SRT_GRAPHICS_ISSUES_CANNOT_LOAD: Unable to load the necessary libraries and create rendering context + * @SRT_GRAPHICS_ISSUES_SOFTWARE_RENDERING: The graphics renderer is software based + * + * A bitfield with flags representing problems with the graphics stack, or + * %SRT_GRAPHICS_ISSUES_NONE (which is numerically zero) if no problems + * were detected. + * + * In general, more bits set means more problems. + */ +typedef enum +{ + SRT_GRAPHICS_ISSUES_NONE = 0, + SRT_GRAPHICS_ISSUES_INTERNAL_ERROR = (1 << 0), + SRT_GRAPHICS_ISSUES_CANNOT_LOAD = (1 << 1), + SRT_GRAPHICS_ISSUES_SOFTWARE_RENDERING = (1 << 2), +} SrtGraphicsIssues; + +/** + * SrtWindowSystem: + * @SRT_WINDOW_SYSTEM_X11: X11 window system, with GL: equivalent to GLX; with GLES: equivalent to EGL_X11; with Vulkan: use X11 + * @SRT_WINDOW_SYSTEM_GLX: GLX window system, only possible with GL + * @SRT_WINDOW_SYSTEM_EGL_X11: EGL_X11 window system, only possible with GL/GLES + */ +typedef enum +{ + SRT_WINDOW_SYSTEM_X11, + SRT_WINDOW_SYSTEM_GLX, + SRT_WINDOW_SYSTEM_EGL_X11, +} SrtWindowSystem; + +#define SRT_N_WINDOW_SYSTEMS (SRT_WINDOW_SYSTEM_EGL_X11 + 1) + +/** + * SrtRenderingInterface: + * @SRT_RENDERING_INTERFACE_GL: GL rendering interface + * @SRT_RENDERING_INTERFACE_GLESV2: GLESv2 rendering interfaces + */ +typedef enum +{ + SRT_RENDERING_INTERFACE_GL, + SRT_RENDERING_INTERFACE_GLESV2, + /* ... possible future additions: GLESV1, GLESV3? */ +} SrtRenderingInterface; + +#define SRT_N_RENDERING_INTERFACES (SRT_RENDERING_INTERFACE_GLESV2 + 1) + +G_STATIC_ASSERT (SRT_N_RENDERING_INTERFACES < 100); + +const char *srt_graphics_get_multiarch_tuple (SrtGraphics *self); +SrtGraphicsIssues srt_graphics_get_issues (SrtGraphics *self); +SrtWindowSystem srt_graphics_get_window_system (SrtGraphics *self); +SrtRenderingInterface srt_graphics_get_rendering_interface (SrtGraphics *self); +const char *srt_graphics_get_version_string (SrtGraphics *self); +const char *srt_graphics_get_renderer_string (SrtGraphics *self); +gchar *srt_graphics_dup_parameters_string (SrtGraphics *self); + diff --git a/steam-runtime-tools/meson.build b/steam-runtime-tools/meson.build index 852b880db65d1999b002e0c03d6ccc58675eb1c0..ffbaa6211e1dbf02c1918e57ac5a06216f24ded3 100644 --- a/steam-runtime-tools/meson.build +++ b/steam-runtime-tools/meson.build @@ -24,6 +24,8 @@ libsteamrt_sources = [ 'architecture-internal.h', 'architecture.c', + 'graphics-internal.h', + 'graphics.c', 'library-internal.h', 'library.c', 'runtime-internal.h', @@ -37,6 +39,7 @@ libsteamrt_sources = [ libsteamrt_public_headers = [ 'architecture.h', + 'graphics.h', 'library.h', 'runtime.h', 'steam-runtime-tools.h', diff --git a/steam-runtime-tools/steam-runtime-tools.h b/steam-runtime-tools/steam-runtime-tools.h index bc51b02fb1a10e63acf1915f73aaed3d1eff8b5c..b942c650251dc9a4e7c639b06cf6c13af7f61e0c 100644 --- a/steam-runtime-tools/steam-runtime-tools.h +++ b/steam-runtime-tools/steam-runtime-tools.h @@ -29,6 +29,7 @@ #include <steam-runtime-tools/architecture.h> #include <steam-runtime-tools/enums.h> +#include <steam-runtime-tools/graphics.h> #include <steam-runtime-tools/library.h> #include <steam-runtime-tools/runtime.h> #include <steam-runtime-tools/steam.h> diff --git a/steam-runtime-tools/system-info.c b/steam-runtime-tools/system-info.c index ddeea76962fbb99ff91ffeb5f3a6db8bfdb20402..dd0ceceb9fc9c9f377ca5bb4b1567a59e03bdf4f 100644 --- a/steam-runtime-tools/system-info.c +++ b/steam-runtime-tools/system-info.c @@ -28,6 +28,8 @@ #include "steam-runtime-tools/architecture.h" #include "steam-runtime-tools/architecture-internal.h" #include "steam-runtime-tools/glib-compat.h" +#include "steam-runtime-tools/graphics.h" +#include "steam-runtime-tools/graphics-internal.h" #include "steam-runtime-tools/library-internal.h" #include "steam-runtime-tools/runtime-internal.h" #include "steam-runtime-tools/steam-internal.h" @@ -128,6 +130,10 @@ typedef struct GHashTable *cached_results; SrtLibraryIssues cached_combined_issues; gboolean libraries_cache_available; + + GHashTable *cached_graphics_results; + SrtGraphicsIssues cached_combined_graphics_issues; + gboolean graphics_cache_available; } Abi; static Abi * @@ -154,6 +160,9 @@ ensure_abi (SrtSystemInfo *self, abi->cached_results = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); abi->cached_combined_issues = SRT_LIBRARY_ISSUES_NONE; abi->libraries_cache_available = FALSE; + abi->cached_graphics_results = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref); + abi->cached_combined_graphics_issues = SRT_GRAPHICS_ISSUES_NONE; + /* transfer ownership to self->abis */ g_ptr_array_add (self->abis, abi); return abi; @@ -166,6 +175,9 @@ abi_free (gpointer self) if (abi->cached_results != NULL) g_hash_table_unref (abi->cached_results); + if (abi->cached_graphics_results != NULL) + g_hash_table_unref (abi->cached_graphics_results); + g_slice_free (Abi, self); } @@ -402,6 +414,16 @@ library_compare (SrtLibrary *a, SrtLibrary *b) return g_strcmp0 (srt_library_get_soname (a), srt_library_get_soname (b)); } +static gint +graphics_compare (SrtGraphics *a, SrtGraphics *b) +{ + int aKey = _srt_graphics_hash_key (srt_graphics_get_window_system (a), + srt_graphics_get_rendering_interface (a)); + int bKey = _srt_graphics_hash_key (srt_graphics_get_window_system (b), + srt_graphics_get_rendering_interface (b)); + return (aKey < bKey) ? -1 : (aKey > bKey); +} + static gchar ** get_environ (SrtSystemInfo *self) { @@ -742,6 +764,153 @@ forget_libraries (SrtSystemInfo *self) } } +/* + * Forget cached graphics results. + */ +static void +forget_graphics_results (SrtSystemInfo *self) +{ + gsize i; + + for (i = 0; i < self->abis->len; i++) + { + Abi *abi = g_ptr_array_index (self->abis, i); + + g_hash_table_remove_all (abi->cached_graphics_results); + abi->cached_combined_graphics_issues = SRT_GRAPHICS_ISSUES_NONE; + abi->graphics_cache_available = FALSE; + } +} + +/** + * srt_system_info_check_graphics: + * @self: The #SrtSystemInfo object to use. + * @multiarch_tuple: A multiarch tuple like %SRT_ABI_I386, representing an ABI. + * @window_system: The window system to check. + * @rendering_interface: The graphics renderng interface to check. + * @details_out: (out) (optional) (transfer full): Used to return an + * #SrtGraphics object representing the items tested and results. + * Free with `g_object_unref()`. + * + * Returns: A bitfield containing problems, or %SRT_GRAPHICS_ISSUES_NONE + * if no problems were found. + */ +SrtGraphicsIssues +srt_system_info_check_graphics (SrtSystemInfo *self, + const char *multiarch_tuple, + SrtWindowSystem window_system, + SrtRenderingInterface rendering_interface, + SrtGraphics **details_out) +{ + Abi *abi = NULL; + SrtGraphicsIssues issues; + + g_return_val_if_fail (SRT_IS_SYSTEM_INFO (self), SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); + g_return_val_if_fail (multiarch_tuple != NULL, SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); + g_return_val_if_fail (details_out == NULL || *details_out == NULL, + SRT_GRAPHICS_ISSUES_INTERNAL_ERROR); + + abi = ensure_abi (self, multiarch_tuple); + + /* If we have the result already in cache, we return it */ + int hash_key = _srt_graphics_hash_key (window_system, rendering_interface); + SrtGraphics *graphics = g_hash_table_lookup (abi->cached_graphics_results, GINT_TO_POINTER(hash_key)); + if (graphics != NULL) + { + if (details_out != NULL) + *details_out = g_object_ref (graphics); + return srt_graphics_get_issues (graphics); + } + + graphics = NULL; + issues = _srt_check_graphics (self->helpers_path, + multiarch_tuple, + window_system, + rendering_interface, + &graphics); + g_hash_table_insert (abi->cached_graphics_results, GINT_TO_POINTER(hash_key), graphics); + abi->cached_combined_graphics_issues |= issues; + if (details_out != NULL) + *details_out = g_object_ref (graphics); + + return issues; +} + +/** + * srt_system_info_check_all_graphics: + * @self: The #SrtSystemInfo object to use. + * @multiarch_tuple: A multiarch tuple like %SRT_ABI_I386, representing an ABI. +* + * Check whether various combinations of rendering interface and windowing + * system are available. The specific combinations of rendering interface and + * windowing system that are returned are not guaranteed, but will include at + * least %SRT_RENDERER_GL on %SRT_WINDOW_SYSTEM_GLX. Additional combinations + * will be added in future versions of this library. + * + * Returns: (transfer full): A list of #SrtGraphics objects representing the + * items tested and results. Free with 'glist_free_full(list, g_object_unref)`. + */ +GList * srt_system_info_check_all_graphics (SrtSystemInfo *self, + const char *multiarch_tuple) +{ + Abi *abi = NULL; + + g_return_val_if_fail (SRT_IS_SYSTEM_INFO (self), NULL); + g_return_val_if_fail (multiarch_tuple != NULL, NULL); + + abi = ensure_abi (self, multiarch_tuple); + GList *list = NULL; + + /* If we cached already the result, we return it */ + if (abi->graphics_cache_available) + { + list = g_list_sort (g_hash_table_get_values (abi->cached_graphics_results), + (GCompareFunc) graphics_compare); + g_list_foreach (list, (GFunc) G_CALLBACK (g_object_ref), NULL); + + return list; + } + + // Try each of glx and gles + // Try each window system + + abi->cached_combined_issues |= + srt_system_info_check_graphics (self, + multiarch_tuple, + SRT_WINDOW_SYSTEM_GLX, + SRT_RENDERING_INTERFACE_GL, + NULL); + + abi->cached_combined_issues |= + srt_system_info_check_graphics (self, + multiarch_tuple, + SRT_WINDOW_SYSTEM_EGL_X11, + SRT_RENDERING_INTERFACE_GL, + NULL); + + abi->cached_combined_issues |= + srt_system_info_check_graphics (self, + multiarch_tuple, + SRT_WINDOW_SYSTEM_GLX, + SRT_RENDERING_INTERFACE_GLESV2, + NULL); + + abi->cached_combined_issues |= + srt_system_info_check_graphics (self, + multiarch_tuple, + SRT_WINDOW_SYSTEM_EGL_X11, + SRT_RENDERING_INTERFACE_GLESV2, + NULL); + + abi->graphics_cache_available = TRUE; + + list = g_list_sort (g_hash_table_get_values (abi->cached_graphics_results), + (GCompareFunc) graphics_compare); + g_list_foreach (list, (GFunc) G_CALLBACK (g_object_ref), NULL); + + return list; +} + /** * srt_system_info_set_environ: * @self: The #SrtSystemInfo @@ -760,6 +929,7 @@ srt_system_info_set_environ (SrtSystemInfo *self, g_return_if_fail (SRT_IS_SYSTEM_INFO (self)); forget_libraries (self); + forget_graphics_results (self); g_strfreev (self->env); self->env = g_strdupv ((gchar **) env); @@ -964,6 +1134,7 @@ srt_system_info_set_helpers_path (SrtSystemInfo *self, g_return_if_fail (SRT_IS_SYSTEM_INFO (self)); forget_libraries (self); + forget_graphics_results (self); free (self->helpers_path); self->helpers_path = g_strdup (path); } diff --git a/steam-runtime-tools/system-info.h b/steam-runtime-tools/system-info.h index e03289feccdc0a31ad225a374a50b9ccf8690dc1..7c807348e6b8e6ef13342444f9c701b4977968ff 100644 --- a/steam-runtime-tools/system-info.h +++ b/steam-runtime-tools/system-info.h @@ -32,6 +32,7 @@ #include <glib.h> #include <glib-object.h> +#include <steam-runtime-tools/graphics.h> #include <steam-runtime-tools/library.h> #include <steam-runtime-tools/runtime.h> #include <steam-runtime-tools/steam.h> @@ -61,6 +62,15 @@ SrtLibraryIssues srt_system_info_check_library (SrtSystemInfo *self, const gchar *soname, SrtLibrary **more_details_out); +SrtGraphicsIssues srt_system_info_check_graphics (SrtSystemInfo *self, + const char *multiarch_tuple, + SrtWindowSystem window_system, + SrtRenderingInterface rendering_interface, + SrtGraphics **details_out); + +GList * srt_system_info_check_all_graphics (SrtSystemInfo *self, + const char *multiarch_tuple); + void srt_system_info_set_environ (SrtSystemInfo *self, gchar * const *env); void srt_system_info_set_helpers_path (SrtSystemInfo *self, diff --git a/tests/graphics.c b/tests/graphics.c new file mode 100644 index 0000000000000000000000000000000000000000..37070a084ccb9580d125dc998d436c74aefcabf0 --- /dev/null +++ b/tests/graphics.c @@ -0,0 +1,259 @@ +/* + * Copyright © 2019 Collabora Ltd. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include <steam-runtime-tools/steam-runtime-tools.h> + +#include <string.h> +#include <unistd.h> + +#include <glib.h> +#include <glib/gstdio.h> + +#include "steam-runtime-tools/graphics-internal.h" +#include "steam-runtime-tools/graphics-test-defines.h" +#include "steam-runtime-tools/system-info.h" +#include "test-utils.h" + +static const char *argv0; + +typedef struct +{ + int unused; + gchar *builddir; +} Fixture; + +typedef struct +{ + int unused; +} Config; + +static void +setup (Fixture *f, + gconstpointer context) +{ + G_GNUC_UNUSED const Config *config = context; + f->builddir = g_strdup (g_getenv ("G_TEST_BUILDDIR")); + + if (f->builddir == NULL) + f->builddir = g_path_get_dirname (argv0); +} + +static void +teardown (Fixture *f, + gconstpointer context) +{ + G_GNUC_UNUSED const Config *config = context; + + g_free (f->builddir); +} + +/* + * Test basic functionality of the SrtGraphics object. + */ +static void +test_object (Fixture *f, + gconstpointer context) +{ + SrtGraphics *graphics; + SrtGraphicsIssues issues; + gchar *tuple; + gchar *renderer; + gchar *version; + + graphics = _srt_graphics_new("mock-good", + SRT_WINDOW_SYSTEM_GLX, + SRT_RENDERING_INTERFACE_GL, + SRT_TEST_GOOD_GRAPHICS_RENDERER, + SRT_TEST_GOOD_GRAPHICS_VERSION, + SRT_GRAPHICS_ISSUES_NONE); + g_assert_cmpint (srt_graphics_get_issues (graphics), ==, + SRT_GRAPHICS_ISSUES_NONE); + g_assert_cmpstr (srt_graphics_get_multiarch_tuple (graphics), ==, + "mock-good"); + g_assert_cmpstr (srt_graphics_get_renderer_string (graphics), ==, + SRT_TEST_GOOD_GRAPHICS_RENDERER); + g_assert_cmpstr (srt_graphics_get_version_string (graphics), ==, + SRT_TEST_GOOD_GRAPHICS_VERSION); + g_object_get (graphics, + "multiarch-tuple", &tuple, + "issues", &issues, + "renderer-string", &renderer, + "version-string", &version, + NULL); + g_assert_cmpint (issues, ==, SRT_GRAPHICS_ISSUES_NONE); + g_assert_cmpstr (tuple, ==, "mock-good"); + g_assert_cmpstr (renderer, ==, SRT_TEST_GOOD_GRAPHICS_RENDERER); + g_assert_cmpstr (version, ==, SRT_TEST_GOOD_GRAPHICS_VERSION); + g_free (tuple); + g_object_unref (graphics); +} + +/* + * Test a mock system with hardware graphics stack + */ +static void +test_good_graphics (Fixture *f, + gconstpointer context) +{ + SrtGraphics *graphics = NULL; + SrtGraphicsIssues issues; + gchar *tuple; + gchar *renderer; + gchar *version; + + SrtSystemInfo *info = srt_system_info_new (NULL); + srt_system_info_set_helpers_path (info, f->builddir); + + issues = srt_system_info_check_graphics (info, + "mock-good", + SRT_WINDOW_SYSTEM_GLX, + SRT_RENDERING_INTERFACE_GL, + &graphics); + g_assert_cmpint (issues, ==, SRT_GRAPHICS_ISSUES_NONE); + g_assert_cmpstr (srt_graphics_get_renderer_string (graphics), ==, + SRT_TEST_GOOD_GRAPHICS_RENDERER); + g_assert_cmpstr (srt_graphics_get_version_string (graphics), ==, + SRT_TEST_GOOD_GRAPHICS_VERSION); + g_object_get (graphics, + "multiarch-tuple", &tuple, + "issues", &issues, + "renderer-string", &renderer, + "version-string", &version, + NULL); + g_assert_cmpint (issues, ==, SRT_GRAPHICS_ISSUES_NONE); + g_assert_cmpstr (tuple, ==, "mock-good"); + g_assert_cmpstr (renderer, ==, SRT_TEST_GOOD_GRAPHICS_RENDERER); + g_assert_cmpstr (version, ==, SRT_TEST_GOOD_GRAPHICS_VERSION); + g_free (tuple); + g_free (renderer); + g_free (version); + + g_object_unref (graphics); +} + +/* + * Test a mock system with no graphics stack + */ +static void +test_bad_graphics (Fixture *f, + gconstpointer context) +{ + SrtGraphics *graphics = NULL; + SrtGraphicsIssues issues; + gchar *tuple; + gchar *renderer; + gchar *version; + + SrtSystemInfo *info = srt_system_info_new (NULL); + srt_system_info_set_helpers_path (info, f->builddir); + + issues = srt_system_info_check_graphics (info, + "mock-bad", + SRT_WINDOW_SYSTEM_GLX, + SRT_RENDERING_INTERFACE_GL, + &graphics); + g_assert_cmpint (issues, ==, SRT_GRAPHICS_ISSUES_CANNOT_LOAD); + g_assert_cmpstr (srt_graphics_get_renderer_string (graphics), ==, + NULL); + g_assert_cmpstr (srt_graphics_get_version_string (graphics), ==, + NULL); + g_object_get (graphics, + "multiarch-tuple", &tuple, + "issues", &issues, + "renderer-string", &renderer, + "version-string", &version, + NULL); + g_assert_cmpint (issues, ==, SRT_GRAPHICS_ISSUES_CANNOT_LOAD); + g_assert_cmpstr (tuple, ==, "mock-bad"); + g_assert_cmpstr (renderer, ==, NULL); + g_assert_cmpstr (version, ==, NULL); + g_free (tuple); + g_free (renderer); + g_free (version); + + g_object_unref (graphics); +} + +/* + * Test a mock system with software rendering + */ +static void +test_software_rendering (Fixture *f, + gconstpointer context) +{ + SrtGraphics *graphics = NULL; + SrtGraphicsIssues issues; + gchar *tuple; + gchar *renderer; + gchar *version; + + SrtSystemInfo *info = srt_system_info_new (NULL); + srt_system_info_set_helpers_path (info, f->builddir); + + issues = srt_system_info_check_graphics (info, + "mock-software", + SRT_WINDOW_SYSTEM_GLX, + SRT_RENDERING_INTERFACE_GL, + &graphics); + g_assert_cmpint (issues, ==, SRT_GRAPHICS_ISSUES_SOFTWARE_RENDERING); + g_assert_cmpstr (srt_graphics_get_renderer_string (graphics), ==, + SRT_TEST_SOFTWARE_GRAPHICS_RENDERER); + g_assert_cmpstr (srt_graphics_get_version_string (graphics), ==, + SRT_TEST_SOFTWARE_GRAPHICS_VERSION); + g_object_get (graphics, + "multiarch-tuple", &tuple, + "issues", &issues, + "renderer-string", &renderer, + "version-string", &version, + NULL); + g_assert_cmpint (issues, ==, SRT_GRAPHICS_ISSUES_SOFTWARE_RENDERING); + g_assert_cmpstr (tuple, ==, "mock-software"); + g_assert_cmpstr (renderer, ==, SRT_TEST_SOFTWARE_GRAPHICS_RENDERER); + g_assert_cmpstr (version, ==, SRT_TEST_SOFTWARE_GRAPHICS_VERSION); + g_free (tuple); + g_free (renderer); + g_free (version); + + g_object_unref (graphics); +} + +int +main (int argc, + char **argv) +{ + argv0 = argv[0]; + + g_test_init (&argc, &argv, NULL); + g_test_add ("/object", Fixture, NULL, + setup, test_object, teardown); + g_test_add ("/good", Fixture, NULL, + setup, test_good_graphics, teardown); + g_test_add ("/bad", Fixture, NULL, + setup, test_bad_graphics, teardown); + g_test_add ("/software", Fixture, NULL, + setup, test_software_rendering, teardown); + + return g_test_run (); +} diff --git a/tests/meson.build b/tests/meson.build index 5e5f11f2e056c8baa2687c21b0adb043fce6f699..5ac44fb8bf7a34a5886027a79ccdc8246ce20d67 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -29,6 +29,7 @@ test_env.prepend('PATH', join_paths(meson.current_build_dir(), '..', 'bin')) tests = [ 'architecture', + 'graphics', 'library', 'system-info', 'system-info-cli', @@ -93,4 +94,25 @@ foreach test_name : tests endif endforeach +executable( + 'mock-good-wflinfo', + 'mock-good-wflinfo.c', + install: true, + install_dir : tests_dir +) + +executable( + 'mock-bad-wflinfo', + 'mock-bad-wflinfo.c', + install: true, + install_dir : tests_dir +) + +executable( + 'mock-software-wflinfo', + 'mock-software-wflinfo.c', + install: true, + install_dir : tests_dir +) + # vim:set sw=2 sts=2 et: diff --git a/tests/mock-bad-wflinfo.c b/tests/mock-bad-wflinfo.c new file mode 100644 index 0000000000000000000000000000000000000000..2311ddb839299f78c4b8e9421152b2b03e0a5067 --- /dev/null +++ b/tests/mock-bad-wflinfo.c @@ -0,0 +1,36 @@ +/* + * Copyright © 2019 Collabora Ltd. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include <stdio.h> + +int +main (int argc, + char **argv) +{ + // Give bad output + fprintf (stderr, "Waffle error: 0x2 WAFFLE_ERROR_UNKNOWN: XOpenDisplay failed\n"); + return 1; +} + diff --git a/tests/mock-good-wflinfo.c b/tests/mock-good-wflinfo.c new file mode 100644 index 0000000000000000000000000000000000000000..eec8d5da2c1b2640bf2d5bbf74d9650686080b8c --- /dev/null +++ b/tests/mock-good-wflinfo.c @@ -0,0 +1,45 @@ +/* + * Copyright © 2019 Collabora Ltd. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include <stdio.h> + +#include "../steam-runtime-tools/graphics-test-defines.h" + +int +main (int argc, + char **argv) +{ + // Give good output + printf ("{\n\t\"waffle\": {\n\t\t\"platform\": \"glx\",\n\t\t\"api\": \"gl\"\n\t},\n\t\"OpenGL\": {\n\t\t\"vendor string\": \"Intel Open Source Technology Center\",\n" + "\t\t\"renderer string\": \"" + SRT_TEST_GOOD_GRAPHICS_RENDERER + "\",\n\t\t\"version string\": \"" + SRT_TEST_GOOD_GRAPHICS_VERSION + "\",\n\t\t\"shading language version string\": \"1.30\",\n" + "\t\t\"extensions\": [\n" + "\t\t]\n\t}\n}\n"); + return 0; +} + diff --git a/tests/mock-software-wflinfo.c b/tests/mock-software-wflinfo.c new file mode 100644 index 0000000000000000000000000000000000000000..ed03f69a087a4e1b149f733de3e7199ee475d3d1 --- /dev/null +++ b/tests/mock-software-wflinfo.c @@ -0,0 +1,45 @@ +/* + * Copyright © 2019 Collabora Ltd. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include <stdio.h> + +#include "../steam-runtime-tools/graphics-test-defines.h" + +int +main (int argc, + char **argv) +{ + // Give software renderer output + printf ("{\n\t\"waffle\": {\n\t\t\"platform\": \"glx\",\n\t\t\"api\": \"gl\"\n\t\t},\n\t\"OpenGL\": {\n\t\t\"vendor string\": \"VMware, Inc.\",\n" + "\t\t\"renderer string\": \"" + SRT_TEST_SOFTWARE_GRAPHICS_RENDERER + "\",\n\t\t\"version string\": \"" + SRT_TEST_SOFTWARE_GRAPHICS_VERSION + "\",\n\t\t\"shading language version string\": \"1.40\",\n" + "\t\t\"extensions\": [\n" + "\t\t]\n\t}\n}\n"); + return 0; +} +