Explorar o código

fix depth bias

David Rose %!s(int64=17) %!d(string=hai) anos
pai
achega
a64839ca3c

+ 8 - 0
panda/src/dxgsg9/config_dxgsg9.cxx

@@ -72,6 +72,14 @@ ConfigVariableBool dx_broken_max_index
           "this should work around this bug, at the cost of some additional "
           "rendering overhead on the GPU."));
 
+ConfigVariableBool dx_broken_depth_bias
+("dx-broken-depth-bias", true,
+ PRC_DESC("Configure this true if your graphics driver claims to support "
+          "D3DPRASTERCAPS_DEPTHBIAS, but doesn't appear to do anything "
+          "useful when you set it.  In fact, there's not much reason not "
+          "to just leave this set, since the workaround seems to be "
+          "sufficient for all cases."));
+
 #ifndef NDEBUG
 // debugging flag
 // values are same as D3DCULL enumtype, 0 - no force, 1 - force none, 2 - force CW, 3 - force CCW

+ 1 - 0
panda/src/dxgsg9/config_dxgsg9.h

@@ -33,6 +33,7 @@ extern ConfigVariableBool link_tristrips;
 extern ConfigVariableInt dx_multisample_antialiasing_level;
 extern ConfigVariableBool dx_use_triangle_mipgen_filter;
 extern ConfigVariableBool dx_broken_max_index;
+extern ConfigVariableBool dx_broken_depth_bias;
 
 // debug flags we might want to use in full optimized build
 extern ConfigVariableBool dx_ignore_mipmaps;

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

@@ -2489,7 +2489,7 @@ reset() {
 
   _maximum_simultaneous_render_targets = d3d_caps.NumSimultaneousRTs;
 
-  _supports_depth_bias = ((d3d_caps.RasterCaps & D3DPRASTERCAPS_DEPTHBIAS) != 0);
+  _supports_depth_bias = ((d3d_caps.RasterCaps & (D3DPRASTERCAPS_DEPTHBIAS | D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS)) == (D3DPRASTERCAPS_DEPTHBIAS | D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS));
 
   _supports_gamma_calibration = ((d3d_caps.Caps2 & D3DCAPS2_CANCALIBRATEGAMMA) != 0);
 
@@ -3135,8 +3135,9 @@ do_issue_depth_offset() {
   const DepthOffsetAttrib *target_depth_offset = DCAST(DepthOffsetAttrib, _target_rs->get_attrib_def(DepthOffsetAttrib::get_class_slot()));
   int offset = target_depth_offset->get_offset();
 
-  if (_supports_depth_bias) {
+  if (_supports_depth_bias && !dx_broken_depth_bias) {
     set_render_state(D3DRS_DEPTHBIAS, offset);
+    set_render_state(D3DRS_SLOPESCALEDEPTHBIAS, offset);
 
   } else {
     // DirectX depth bias isn't directly supported by the driver.