瀏覽代碼

add backfacing-culling dbg toggle

cxgeorge 24 年之前
父節點
當前提交
4bbf01b805
共有 3 個文件被更改,包括 14 次插入1 次删除
  1. 4 1
      panda/src/dxgsg/config_dxgsg.cxx
  2. 3 0
      panda/src/dxgsg/config_dxgsg.h
  3. 7 0
      panda/src/dxgsg/dxGraphicsStateGuardian.cxx

+ 4 - 1
panda/src/dxgsg/config_dxgsg.cxx

@@ -55,12 +55,15 @@ bool dx_force_16bpp_screenbuffers = config_dxgsg.GetBool("dx-force-16bpp-screenb
 bool dx_show_fps_meter = config_dxgsg.GetBool("show-fps-meter", false);
 float dx_fps_meter_update_interval = max(0.5,config_dxgsg.GetFloat("fps-meter-update-interval", 1.7));
 
+// debugging flag
+// values are same as D3DCULL enumtype, 0 - no force, 1 - force none, 2 - force CW, 3 - force CCW
+int dx_force_backface_culling = config_dxgsg.GetInt("dx-force-backface-culling", 0);
+
 #ifdef _DEBUG
 bool dx_debug_view_mipmaps = config_dxgsg.GetBool("dx-debug-view-mipmaps", false);
 bool dx_force_16bpptextures = config_dxgsg.GetBool("dx-force-16bpptextures", false);
 bool dx_mipmap_everything = config_dxgsg.GetBool("dx-mipmap-everything", false);
 bool dx_force_anisotropic_filtering = config_dxgsg.GetBool("dx-force-anisotropic-filtering", false);
-
 #endif
 
 // note:  offset currently disabled since it wasnt working properly

+ 3 - 0
panda/src/dxgsg/config_dxgsg.h

@@ -35,6 +35,9 @@ extern bool dx_no_vertex_fog;
 extern bool dx_full_screen_antialiasing;
 extern float dx_fps_meter_update_interval;
 
+// this is really a debug flag, but I need at Opt4 for perf-measurement
+extern int dx_force_backface_culling;
+
 #ifdef _DEBUG
 extern float dx_global_miplevel_bias;
 extern bool dx_debug_view_mipmaps;

+ 7 - 0
panda/src/dxgsg/dxGraphicsStateGuardian.cxx

@@ -431,6 +431,10 @@ init_dx(  LPDIRECTDRAW7     context,
         dxgsg_cat.debug() << "device doesnt support full-screen anti-aliasing\n";
       }
     }
+
+    if(dx_force_backface_culling!=0) {
+      _d3dDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, dx_force_backface_culling);
+    }
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -4519,6 +4523,9 @@ issue_stencil(const StencilAttribute *attrib) {
 void DXGraphicsStateGuardian::
 issue_cull_face(const CullFaceAttribute *attrib) {
     
+    if(dx_force_backface_culling!=0) {
+        return;  // leave as initially set
+    }
 
     CullFaceProperty::Mode mode = attrib->get_mode();