Browse Source

fix decal prob with cards that use blending to disable colorwrites

cxgeorge 23 years ago
parent
commit
835a318c2b

+ 3 - 5
panda/src/dxgsg8/dxGraphicsStateGuardian8.I

@@ -157,15 +157,13 @@ INLINE void DXGraphicsStateGuardian::
 set_color_writemask(UINT color_writemask) {
 set_color_writemask(UINT color_writemask) {
   if (_color_writemask != color_writemask) {
   if (_color_writemask != color_writemask) {
     _color_writemask = color_writemask;
     _color_writemask = color_writemask;
-    if(scrn.d3dcaps.PrimitiveMiscCaps & D3DPMISCCAPS_COLORWRITEENABLE) {
+    if(scrn.bCanDirectDisableColorWrites) {
         // only newer HW supports this rstate
         // only newer HW supports this rstate
         scrn.pD3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, (DWORD)color_writemask);
         scrn.pD3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, (DWORD)color_writemask);
     } else {
     } else {
+        // blending can only handle on/off
         assert((color_writemask==0x0)||(color_writemask==0xFFFFFFFF));
         assert((color_writemask==0x0)||(color_writemask==0xFFFFFFFF));
-        if(color_writemask==0x0) {
-            enable_blend(true);
-            call_dxBlendFunc(D3DBLEND_ZERO, D3DBLEND_ONE);
-        } else enable_blend(false);
+        set_blend_mode(_color_write_mode, _color_blend_mode, _transparency_mode);        
     }
     }
   }
   }
 }
 }

+ 11 - 6
panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx

@@ -762,6 +762,8 @@ dx_init(HCURSOR hMouseCursor) {
         }
         }
     }
     }
 
 
+    scrn.bCanDirectDisableColorWrites=((scrn.d3dcaps.PrimitiveMiscCaps & D3DPMISCCAPS_COLORWRITEENABLE)!=0);
+
     // Lighting, let's turn it off by default
     // Lighting, let's turn it off by default
     scrn.pD3DDevice->SetRenderState(D3DRS_LIGHTING, false);
     scrn.pD3DDevice->SetRenderState(D3DRS_LIGHTING, false);
 
 
@@ -4388,14 +4390,17 @@ set_blend_mode(ColorWriteAttrib::Mode color_write_mode,
                ColorBlendAttrib::Mode color_blend_mode,
                ColorBlendAttrib::Mode color_blend_mode,
                TransparencyAttrib::Mode transparency_mode) {
                TransparencyAttrib::Mode transparency_mode) {
 
 
-  // should never get here, since our dxgsg8 issue_color_write() should be called instead
-  nassertv(color_write_mode == _color_write_mode);
-#if 0
-  if(color_write_mode == ColorWriteAttrib::M_off) {
-    set_color_writemask(0x0);
+  if((color_write_mode == ColorWriteAttrib::M_off) && !scrn.bCanDirectDisableColorWrites) {
+    // need !scrn.bCanDirectDisableColorWrites guard because other issue_colorblend,issue_transp
+    // will come this way, and they should ignore the colorwriteattrib value since it's been 
+    // handled separately in set_color_writemask
+    enable_blend(true);
+    call_dxBlendFunc(D3DBLEND_ZERO, D3DBLEND_ONE);
     return;
     return;
   }
   }
-#endif
+
+  // if ColorWriteAttrib::M_on, need to check other transp modes to see if they
+  // need blending before we use blending
 
 
   // Is there a color blend set?
   // Is there a color blend set?
   switch (color_blend_mode) {
   switch (color_blend_mode) {

+ 1 - 0
panda/src/dxgsg8/dxgsg8base.h

@@ -190,6 +190,7 @@ typedef struct {
       DWORD             MaxAvailVidMem;
       DWORD             MaxAvailVidMem;
       ushort            CardIDNum;  // adapter ID
       ushort            CardIDNum;  // adapter ID
       ushort            depth_buffer_bitdepth;  //GetSurfaceDesc is not reliable so must store this explicitly
       ushort            depth_buffer_bitdepth;  //GetSurfaceDesc is not reliable so must store this explicitly
+      bool              bCanDirectDisableColorWrites;  // if true, dont need blending for this
       bool              bIsLowVidMemCard;
       bool              bIsLowVidMemCard;
       bool              bIsTNLDevice;
       bool              bIsTNLDevice;
       bool              bCanUseHWVertexShaders;
       bool              bCanUseHWVertexShaders;