acinclude/ax_gcc_x86_cpuid.m4.htm
author Sam Lantinga
Tue, 10 Jan 2017 08:54:33 -0800
changeset 10806 36f40b8cc979
parent 5029 5d7d48157be7
permissions -rw-r--r--
Fixed bugs 2570, 3145, improved OpenGL ES context support on Windows and X11

Mark Callow

The attached patch does the following for the X11 and Windows platforms, the only ones where SDL attempts to use context_create_es_profile:

- Adds SDL_HINT_OPENGL_ES_DRIVER by which the application can
say to use the OpenGL ES driver & EGL rather than the Open GL
driver. (For bug #2570)
- Adds code to {WIN,X11}_GL_InitExtensions to determine the maximum
OpenGL ES version supported by the OpenGL driver (for bug #3145)
- Modifies the test that determines whether to use the OpenGL
driver or the real OpenGL ES driver to take into account the
hint, the requested and supported ES version and whether ES 1.X
is being requested. (For bug #2570 & bug #3145)
- Enables the testgles2 test for __WINDOWS__ and __LINUX__ and adds
the test to the VisualC projects.

With the fix in place I have run testdraw2, testgl and testgles2 without any issues and have run my own apps that use OpenGL, OpenGL ES 3 and OpenGL ES 1.1.
     1 # ===========================================================================
     2 #     http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html
     3 # ===========================================================================
     4 #
     5 # SYNOPSIS
     6 #
     7 #   AX_GCC_X86_CPUID(OP)
     8 #
     9 # DESCRIPTION
    10 #
    11 #   On Pentium and later x86 processors, with gcc or a compiler that has a
    12 #   compatible syntax for inline assembly instructions, run a small program
    13 #   that executes the cpuid instruction with input OP. This can be used to
    14 #   detect the CPU type.
    15 #
    16 #   On output, the values of the eax, ebx, ecx, and edx registers are stored
    17 #   as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable
    18 #   ax_cv_gcc_x86_cpuid_OP.
    19 #
    20 #   If the cpuid instruction fails (because you are running a
    21 #   cross-compiler, or because you are not using gcc, or because you are on
    22 #   a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP
    23 #   is set to the string "unknown".
    24 #
    25 #   This macro mainly exists to be used in AX_GCC_ARCHFLAG.
    26 #
    27 # LICENSE
    28 #
    29 #   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
    30 #   Copyright (c) 2008 Matteo Frigo
    31 #
    32 #   This program is free software: you can redistribute it and/or modify it
    33 #   under the terms of the GNU General Public License as published by the
    34 #   Free Software Foundation, either version 3 of the License, or (at your
    35 #   option) any later version.
    36 #
    37 #   This program is distributed in the hope that it will be useful, but
    38 #   WITHOUT ANY WARRANTY; without even the implied warranty of
    39 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
    40 #   Public License for more details.
    41 #
    42 #   You should have received a copy of the GNU General Public License along
    43 #   with this program. If not, see <http://www.gnu.org/licenses/>.
    44 #
    45 #   As a special exception, the respective Autoconf Macro's copyright owner
    46 #   gives unlimited permission to copy, distribute and modify the configure
    47 #   scripts that are the output of Autoconf when processing the Macro. You
    48 #   need not follow the terms of the GNU General Public License when using
    49 #   or distributing such scripts, even though portions of the text of the
    50 #   Macro appear in them. The GNU General Public License (GPL) does govern
    51 #   all other use of the material that constitutes the Autoconf Macro.
    52 #
    53 #   This special exception to the GPL applies to versions of the Autoconf
    54 #   Macro released by the Autoconf Archive. When you make and distribute a
    55 #   modified version of the Autoconf Macro, you may extend this special
    56 #   exception to the GPL to apply to your modified version as well.
    57 
    58 #serial 7
    59 
    60 AC_DEFUN([AX_GCC_X86_CPUID],
    61 [AC_REQUIRE([AC_PROG_CC])
    62 AC_LANG_PUSH([C])
    63 AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
    64  [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
    65      int op = $1, eax, ebx, ecx, edx;
    66      FILE *f;
    67       __asm__("cpuid"
    68         : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
    69         : "a" (op));
    70      f = fopen("conftest_cpuid", "w"); if (!f) return 1;
    71      fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
    72      fclose(f);
    73      return 0;
    74 ])],
    75      [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid],
    76      [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid],
    77      [ax_cv_gcc_x86_cpuid_$1=unknown])])
    78 AC_LANG_POP([C])
    79 ])