Ticket #4451: hwdetect.2.patch

File hwdetect.2.patch, 8.0 KB (added by echotangoecho, 7 years ago)

fix some issues with the big conditional for disabling shadows on some intel hardware, and remove unused GL_VENDOR.

  • binaries/data/mods/mod/hwdetect/hwdetect.js

    diff --git a/binaries/data/mods/mod/hwdetect/hwdetect.js b/binaries/data/mods/mod/hwdetect/hwdetect.js
    index 8e9e3291f4..929435eef8 100644
    a b  
    2020 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    2121 */
    2222
    23 /*
    24 
    25 This script is for adjusting the game's default settings based on the
    26 user's system configuration details.
    27 
    28 The game engine itself does some detection of capabilities, so it will
    29 enable certain graphical features only when they are supported.
    30 This script is for the messier task of avoiding performance problems
    31 and driver bugs based on experience of particular system configurations.
    32 
     23/* This script is for adjusting the game's default settings based on the
     24 * user's system configuration details.
     25 * The game engine itself does some detection of capabilities, so it will
     26 * enable certain graphical features only when they are supported.
     27 * This script is for the messier task of avoiding performance problems
     28 * and driver bugs based on experience of particular system configurations.
    3329*/
    3430
    35 var g_IntelMesaChipsets = [
    36     "Intel(R) 845G",
    37     "Intel(R) 830M",
    38     "Intel(R) 852GM/855GM",
    39     "Intel(R) 865G",
    40     "Intel(R) 915G",
    41     "Intel (R) E7221G (i915)",
    42     "Intel(R) 915GM",
    43     "Intel(R) 945G",
    44     "Intel(R) 945GM",
    45     "Intel(R) 945GME",
    46     "Intel(R) G33",
    47     "Intel(R) Q35",
    48     "Intel(R) Q33",
    49     "Intel(R) IGD",
    50     "Intel(R) 965Q",
    51     "Intel(R) 965G",
    52     "Intel(R) 946GZ",
    53     "Intel(R) GMA500", // not in current Mesa
    54     "Intel(R) 965GM",
    55     "Intel(R) 965GME/GLE",
    56     "Mobile Intel\xC2\xAE GM45 Express Chipset", // utf-8 decoded as iso-8859-1
    57     "Intel(R) Integrated Graphics Device",
    58     "Intel(R) G45/G43",
    59     "Intel(R) Q45/Q43",
    60     "Intel(R) G41",
    61     "Intel(R) B43",
    62     "Intel(R) IGDNG_D", // not in current Mesa; looks somewhat like Ironlake
    63     "Intel(R) IGDNG_M", // not in current Mesa; looks somewhat like Ironlake
    64     "Intel(R) Ironlake Desktop",
    65     "Intel(R) Ironlake Mobile",
    66     "Intel(R) Sandybridge Desktop",
    67     "Intel(R) Sandybridge Mobile",
    68     "Intel(R) Sandybridge Server",
    69     "Intel(R) Ivybridge Desktop",
    70     "Intel(R) Ivybridge Mobile",
    71     "Intel(R) Ivybridge Server",
    72     "Intel(R) Haswell Desktop",
    73     "Intel(R) Haswell Mobile",
    74     "Intel(R) Haswell Server",
    75     "Unknown Intel Chipset",
    76     "*", // dummy value to support IsWorseThanIntelMesa("*") to detect all Intel Mesa devices
    77 ];
    78 // Originally generated from Mesa with
    79 //   perl -lne'print "\t$1," if /chipset = (".*")/' src/mesa/drivers/dri/intel/intel_context.c
    80 // Assumed to be roughly ordered by performance.
    81 
    82 var g_IntelWindowsChipsets = [
    83     "Intel 845G",
    84     "Intel 855GM",
    85     "Intel 865G",
    86     "Intel 915G",
    87     "Intel 915GM",
    88     "Intel 945G",
    89     "Intel 945GM",
    90     "Intel 965/963 Graphics Media Accelerator",
    91     "Intel Broadwater G",
    92     "Intel Bear Lake B",
    93     "Intel Pineview Platform",
    94     "Intel Eaglelake",
    95     "Intel(R) G41 Express Chipset", // Eaglelake
    96     "Intel(R) G45/G43 Express Chipset", // Eaglelake
    97     "Intel Cantiga",
    98     "Mobile Intel(R) 4 Series Express Chipset Family", // probably Cantiga
    99     "Intel(R) HD Graphics", // probably Ironlake
    100     "Intel(R) Graphics Media Accelerator HD", // no idea
    101     "*",
    102 ];
    103 // Determined manually from data reports.
    104 // See http://en.wikipedia.org/wiki/Intel_GMA for useful listing.
    105 
    106 var g_IntelMacChipsets = [
    107     "Intel GMA 950",
    108     "Intel GMA X3100",
    109     "Intel HD Graphics",
    110     "Intel HD Graphics 3000",
    111     "Unknown Intel Chipset",
    112     "*",
    113 ];
    114 // Determined manually from data reports.
    115 // See http://support.apple.com/kb/HT3246 for useful listing.
    116 
    117 function IsWorseThanIntelMesa(renderer, chipset)
    118 {
    119     var target = g_IntelMesaChipsets.indexOf(chipset);
    120     if (target == -1)
    121         error("Invalid chipset "+chipset);
    122 
    123     // GL_RENDERER is "Mesa DRI $chipset" or "Mesa DRI $chipset $otherstuff"
    124     for (var i = 0; i < target; ++i)
    125     {
    126         var str = "Mesa DRI " + g_IntelMesaChipsets[i];
    127         if (renderer == str || renderer.substr(0, str.length+1) == str+" ")
    128             return true;
    129     }
    130 
    131     return false;
    132 }
    133 
    134 function IsWorseThanIntelWindows(renderer, chipset)
    135 {
    136     var target = g_IntelWindowsChipsets.indexOf(chipset);
    137     if (target == -1)
    138         error("Invalid chipset "+chipset);
    139 
    140     var match = g_IntelWindowsChipsets.indexOf(renderer);
    141     if (match != -1 && match < target)
    142         return true;
    143 
    144     return false;
    145 }
    146 
    147 function IsWorseThanIntelMac(renderer, chipset)
    148 {
    149     var target = g_IntelMacChipsets.indexOf(chipset);
    150     if (target == -1)
    151         error("Invalid chipset "+chipset);
    152 
    153     // GL_RENDERER is "$chipset OpenGL Engine"
    154     for (var i = 0; i < target; ++i)
    155     {
    156         var str = g_IntelMacChipsets[i]+" OpenGL Engine";
    157         if (renderer == str)
    158             return true;
    159     }
    160 
    161     return false;
    162 }
    163 
    16431function RunDetection(settings)
    16532{
    16633    // This function should have no side effects, it should just
    16734    // set these output properties:
    16835
    169 
    17036    // List of warning strings to display to the user
    17137    // in an ugly GUI dialog box
    17238    var dialog_warnings = [];
    function RunDetection(settings)  
    19056    // TODO: add some mechanism for setting config values
    19157    // (overriding default.cfg, but overridden by local.cfg)
    19258
    193 
    194 
    19559    // Extract all the settings we might use from the argument:
    19660    // (This is less error-prone than referring to "settings.foo" directly
    19761    // since typos in the matching code will be caught as references to
    function RunDetection(settings)  
    20367    var os_macosx = settings.os_macosx;
    20468    var os_win = settings.os_win;
    20569
    206     // Should avoid using these, since they're disabled in quickstart mode
    207     var gfx_card = settings.gfx_card;
    208     var gfx_drv_ver = settings.gfx_drv_ver;
    209     var gfx_mem = settings.gfx_mem;
    210 
    21170    // Values from glGetString
    212     var GL_VENDOR = settings.GL_VENDOR;
    21371    var GL_RENDERER = settings.GL_RENDERER;
    21472    var GL_VERSION = settings.GL_VERSION;
    215     var GL_EXTENSIONS = settings.GL_EXTENSIONS.split(" ");
     73
     74    // Extract the OpenGL API version from the GL_VERSION string.
     75    var gl_major_version = +GL_VERSION.match(/^\d*/)[0];
    21676
    21777    // Enable GLSL on OpenGL 3+, which should be able to properly
    21878    // manage GLSL shaders, needed for effects like windy trees
    219     if (GL_VERSION.match(/^[3-9]/))
     79    if (gl_major_version >= 3)
    22080        enable_glsl = true;
    22181
    22282    // Enable most graphics options on OpenGL 4+, which should be
    22383    // able to properly manage them
    224     if (GL_VERSION.match(/^[4-9]/))
     84    if (gl_major_version >= 4)
    22585    {
    22686        enable_postproc = true;
    22787        enable_smoothlos = true;
    function RunDetection(settings)  
    267127    //   Intel 945
    268128    // Shadows are also known to be quite slow on some others:
    269129    //   Intel 4500MHD
    270     // In the interests of performance, we'll disable them on lots of devices
    271     // (with a fairly arbitrary cutoff for Intels)
    272     if (
    273         (os_unix && GL_RENDERER.match(/^Mesa DRI R[123]00 /)) ||
    274         (os_macosx && IsWorseThanIntelMac(GL_RENDERER, "Intel HD Graphics 3000")) ||
    275         (os_unix && IsWorseThanIntelMesa(GL_RENDERER, "Intel(R) Ironlake Desktop")) ||
    276         (os_win && IsWorseThanIntelWindows(GL_RENDERER, "Intel(R) HD Graphics"))
     130    // In the interests of performance, we'll disable them on lots of devices.
     131    if (os_unix && GL_RENDERER.match(/^Mesa DRI R[123]00 /) || GL_RENDERER.match(/Intel/) &&
     132        ((os_macosx && (GL_RENDERER.match(/GMA/) || gl_major_version < 2) ||
     133        (os_unix || os_win) && gl_major_version < 3 && !GL_RENDERER.match(/Intel(R) HD/)))
    277134    )
    278135    {
    279136        disable_shadows = true;
    function RunDetection(settings)  
    282139
    283140    // Fragment-shader water is really slow on most Intel devices (especially the
    284141    // "use actual depth" option), so disable it on all of them
    285     if (
    286         (os_macosx && IsWorseThanIntelMac(GL_RENDERER, "*")) ||
    287         (os_unix && IsWorseThanIntelMesa(GL_RENDERER, "*")) ||
    288         (os_win && IsWorseThanIntelWindows(GL_RENDERER, "*"))
    289     )
     142    if (GL_RENDERER.match(/Intel/))
    290143    {
    291144        disable_fancywater = true;
    292145        disable_shadowpcf = true;
    function RunDetection(settings)  
    335188
    336189global.RunHardwareDetection = function(settings)
    337190{
    338     //print(JSON.stringify(settings, null, 1)+"\n");
    339 
    340191    var output = RunDetection(settings);
    341192
    342     //print(JSON.stringify(output, null, 1)+"\n");
    343 
    344193    for (var i = 0; i < output.warnings.length; ++i)
    345194        warn(output.warnings[i]);
    346195