diff --git a/panda/src/dxgsg9/config_dxgsg9.cxx b/panda/src/dxgsg9/config_dxgsg9.cxx index 9b09965271..e63b49bee6 100755 --- a/panda/src/dxgsg9/config_dxgsg9.cxx +++ b/panda/src/dxgsg9/config_dxgsg9.cxx @@ -120,6 +120,15 @@ ConfigVariableBool dx_preserve_fpu_state ConfigVariableInt dx_preferred_device_id ("dx-preferred-device-id", -1); +ConfigVariableBool dx_intel_compressed_texture_bug +("dx-intel-compressed-texture-bug", true, + PRC_DESC("Set this true to work around a bug in the Intel driver " + "igdumd32.dll, for at least the 965 Express chipset family, " + "which breaks compressed texture images smaller " + "than about 256x256 (even mipmap levels). The workaround is " + "simply to disable compressed texture support when this " + "driver is detected.")); + #ifdef _DEBUG ConfigVariableDouble dx_global_miplevel_bias ("dx-global-miplevel-bias", 0.0); diff --git a/panda/src/dxgsg9/config_dxgsg9.h b/panda/src/dxgsg9/config_dxgsg9.h index 0e4493a6dd..a27e74a2af 100755 --- a/panda/src/dxgsg9/config_dxgsg9.h +++ b/panda/src/dxgsg9/config_dxgsg9.h @@ -47,6 +47,8 @@ extern ConfigVariableBool dx_do_vidmemsize_check; extern ConfigVariableBool dx_preserve_fpu_state; extern ConfigVariableInt dx_preferred_device_id; +extern ConfigVariableBool dx_intel_compressed_texture_bug; + #ifndef NDEBUG extern ConfigVariableInt dx_force_backface_culling; #endif diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 8e488ee1b1..8a5464d40f 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -2678,12 +2678,21 @@ reset() { _compressed_texture_formats.set_bit(Texture::CM_dxt##num);\ } - CHECK_FOR_DXTVERSION(1) - CHECK_FOR_DXTVERSION(2) - CHECK_FOR_DXTVERSION(3) - CHECK_FOR_DXTVERSION(4) - CHECK_FOR_DXTVERSION(5) - + if (_screen->_intel_compressed_texture_bug) { + dxgsg9_cat.info() + << "Buggy Intel driver detected; disabling compressed textures.\n"; + _screen->_supported_tex_formats_mask &= + ~(DXT1_FLAG | DXT2_FLAG | DXT3_FLAG | DXT4_FLAG | DXT5_FLAG); + + } else { + // Check for available compressed formats normally. + CHECK_FOR_DXTVERSION(1); + CHECK_FOR_DXTVERSION(2); + CHECK_FOR_DXTVERSION(3); + CHECK_FOR_DXTVERSION(4); + CHECK_FOR_DXTVERSION(5); + } + #undef CHECK_FOR_DXTVERSION _screen->_supports_rgba16f_texture_format = false; diff --git a/panda/src/dxgsg9/dxgsg9base.h b/panda/src/dxgsg9/dxgsg9base.h index 80497b8c75..dbcfc31797 100755 --- a/panda/src/dxgsg9/dxgsg9base.h +++ b/panda/src/dxgsg9/dxgsg9base.h @@ -210,6 +210,7 @@ struct DXScreenData { bool _supports_dynamic_textures; bool _supports_automatic_mipmap_generation; + bool _intel_compressed_texture_bug; }; diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx index ea22b1d16a..474f75f646 100755 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx @@ -930,6 +930,7 @@ choose_device() { MAX_DEVICE_IDENTIFIER_STRING); devinfo.VendorID = adapter_info.VendorId; devinfo.DeviceID = adapter_info.DeviceId; + devinfo._driver_version = adapter_info.DriverVersion; devinfo._monitor = _monitor; devinfo.cardID = i; @@ -1136,6 +1137,15 @@ consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { _wcontext._display_mode.RefreshRate = D3DPRESENT_RATE_DEFAULT; _wcontext._monitor = device_info->_monitor; + if (strcmp(device_info->szDriver, "igdumd32.dll") == 0 && + device_info->_driver_version.QuadPart <= 0x0007000e000a0531LL && + dx_intel_compressed_texture_bug) { + // Disable compressed textures for this buggy driver (7.14.10.1329 + // and earlier--I don't know whether any other drivers also + // exhibit the bug). + _wcontext._intel_compressed_texture_bug = true; + } + return true; } diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.h b/panda/src/dxgsg9/wdxGraphicsWindow9.h index 9b8502de72..43f8783171 100755 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.h +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.h @@ -61,6 +61,7 @@ private: char szDescription[MAX_DEVICE_IDENTIFIER_STRING]; GUID guidDeviceIdentifier; DWORD VendorID, DeviceID; + LARGE_INTEGER _driver_version; HMONITOR _monitor; }; typedef pvector DXDeviceInfoVec;