fix decal prob with cards that use blending to disable colorwrites

This commit is contained in:
cxgeorge 2002-05-16 21:28:06 +00:00
parent 749933b6e3
commit 835a318c2b
3 changed files with 15 additions and 11 deletions

View File

@ -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) { set_blend_mode(_color_write_mode, _color_blend_mode, _transparency_mode);
enable_blend(true);
call_dxBlendFunc(D3DBLEND_ZERO, D3DBLEND_ONE);
} else enable_blend(false);
} }
} }
} }

View File

@ -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 if((color_write_mode == ColorWriteAttrib::M_off) && !scrn.bCanDirectDisableColorWrites) {
nassertv(color_write_mode == _color_write_mode); // need !scrn.bCanDirectDisableColorWrites guard because other issue_colorblend,issue_transp
#if 0 // will come this way, and they should ignore the colorwriteattrib value since it's been
if(color_write_mode == ColorWriteAttrib::M_off) { // handled separately in set_color_writemask
set_color_writemask(0x0); 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) {

View File

@ -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;