فهرست منبع

dxgsg9: Robustify initialization with no devices

rdb 1 ماه پیش
والد
کامیت
021ea25f42
2فایلهای تغییر یافته به همراه17 افزوده شده و 2 حذف شده
  1. 8 2
      panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx
  2. 9 0
      panda/src/dxgsg9/wdxGraphicsPipe9.cxx

+ 8 - 2
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -2333,12 +2333,18 @@ reset() {
   // TransformState::make_identity()); want gsg to pass all state settings
   // down so any non-matching defaults we set here get overwritten
 
-  nassertv(_screen->_d3d9 != nullptr);
+  _shader_model = SM_00;
+  _supports_hlsl = false;
+  _supported_shader_caps = 0;
+  _supports_geometry_instancing = false;
+  _max_vertex_shader_parameter_vectors = 0;
 
-  if (_d3d_device == nullptr) {
+  if (_screen == nullptr || _d3d_device == nullptr) {
     return;
   }
 
+  nassertv(_screen->_d3d9 != nullptr);
+
   D3DCAPS9 d3d_caps;
   _d3d_device->GetDeviceCaps(&d3d_caps);
 

+ 9 - 0
panda/src/dxgsg9/wdxGraphicsPipe9.cxx

@@ -127,6 +127,9 @@ make_output(const std::string &name,
   // Second thing to try: a wdxGraphicsBuffer9
 
   if (retry == 1) {
+    if (wdxgsg == nullptr) {
+      return nullptr;
+    }
     if ((!support_render_texture)||
         ((flags&BF_require_parasite)!=0)||
         ((flags&BF_require_window)!=0)||
@@ -203,6 +206,12 @@ init() {
 
   Init_D3DFORMAT_map();
 
+  if (__d3d9->GetAdapterCount() == 0) {
+    wdxdisplay9_cat.error()
+      << "No available D3D9 devices found.\n";
+    goto error;
+  }
+
   if (dx_count_all_cards_memory){
     return find_all_card_memavails();
   }