diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.I b/panda/src/dxgsg8/dxGraphicsStateGuardian8.I index 9553cd9fd5..8a0507eb69 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.I +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.I @@ -157,15 +157,13 @@ INLINE void DXGraphicsStateGuardian:: set_color_writemask(UINT color_writemask) { if (_color_writemask != color_writemask) { _color_writemask = color_writemask; - if(scrn.d3dcaps.PrimitiveMiscCaps & D3DPMISCCAPS_COLORWRITEENABLE) { + if(scrn.bCanDirectDisableColorWrites) { // only newer HW supports this rstate scrn.pD3DDevice->SetRenderState(D3DRS_COLORWRITEENABLE, (DWORD)color_writemask); } else { + // blending can only handle on/off 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); } } } diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index 57cacff025..c21fcb358a 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/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 scrn.pD3DDevice->SetRenderState(D3DRS_LIGHTING, false); @@ -4388,14 +4390,17 @@ set_blend_mode(ColorWriteAttrib::Mode color_write_mode, ColorBlendAttrib::Mode color_blend_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; } -#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? switch (color_blend_mode) { diff --git a/panda/src/dxgsg8/dxgsg8base.h b/panda/src/dxgsg8/dxgsg8base.h index 31f2210bd4..48a0d97447 100644 --- a/panda/src/dxgsg8/dxgsg8base.h +++ b/panda/src/dxgsg8/dxgsg8base.h @@ -190,6 +190,7 @@ typedef struct { DWORD MaxAvailVidMem; ushort CardIDNum; // adapter ID 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 bIsTNLDevice; bool bCanUseHWVertexShaders;