|
|
@ -55,8 +55,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
|
|
#include "hsWindows.h" |
|
|
|
#include "hsWindows.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <d3d9.h> |
|
|
|
#include <d3d9.h> |
|
|
|
#include <ddraw.h> |
|
|
|
|
|
|
|
#include <d3dx9mesh.h> |
|
|
|
#include <d3dx9mesh.h> |
|
|
|
|
|
|
|
#include "hsGDirect3D.h" |
|
|
|
|
|
|
|
|
|
|
|
#if defined(DX_OLD_SDK) || defined(__MINGW32__) |
|
|
|
#if defined(DX_OLD_SDK) || defined(__MINGW32__) |
|
|
|
#include <dxerr9.h> |
|
|
|
#include <dxerr9.h> |
|
|
@ -78,7 +78,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
|
|
#include "plPipeline/plDebugText.h" |
|
|
|
#include "plPipeline/plDebugText.h" |
|
|
|
#include "plDXEnumerate.h" |
|
|
|
#include "plDXEnumerate.h" |
|
|
|
#include "plPipeline/hsG3DDeviceSelector.h" |
|
|
|
#include "plPipeline/hsG3DDeviceSelector.h" |
|
|
|
#include "plPipeline/hsGDDrawDllLoad.h" |
|
|
|
|
|
|
|
#include "hsResMgr.h" |
|
|
|
#include "hsResMgr.h" |
|
|
|
#include "plPipeline/plStatusLogDrawer.h" |
|
|
|
#include "plPipeline/plStatusLogDrawer.h" |
|
|
|
#include "plQuality.h" |
|
|
|
#include "plQuality.h" |
|
|
@ -625,7 +624,7 @@ plDXPipeline::plDXPipeline( hsWinRef hWnd, const hsG3DDeviceModeRecord *devModeR |
|
|
|
else |
|
|
|
else |
|
|
|
fSettings.fNumAASamples = devMode->GetFSAAType( devRec->GetAASetting() - 1 ); |
|
|
|
fSettings.fNumAASamples = devMode->GetFSAAType( devRec->GetAASetting() - 1 ); |
|
|
|
|
|
|
|
|
|
|
|
hsGDirect3DTnLEnumerate d3dEnum; |
|
|
|
hsGDirect3DTnLEnumerate& d3dEnum = hsGDirect3D::EnumerateTnL(); |
|
|
|
if( d3dEnum.GetEnumeErrorStr()[ 0 ] ) |
|
|
|
if( d3dEnum.GetEnumeErrorStr()[ 0 ] ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IShowErrorMessage( (char *)d3dEnum.GetEnumeErrorStr() ); |
|
|
|
IShowErrorMessage( (char *)d3dEnum.GetEnumeErrorStr() ); |
|
|
@ -638,16 +637,6 @@ plDXPipeline::plDXPipeline( hsWinRef hWnd, const hsG3DDeviceModeRecord *devModeR |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Gotta create this very first, so that the device/driver init works
|
|
|
|
|
|
|
|
if( !fD3DObject ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( ICreateMaster() ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
IShowErrorMessage( "Cannot create D3D master object" ); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Record the requested mode/setup.
|
|
|
|
// Record the requested mode/setup.
|
|
|
|
ISetCurrentDriver( d3dEnum.GetCurrentDriver() ); |
|
|
|
ISetCurrentDriver( d3dEnum.GetCurrentDriver() ); |
|
|
|
ISetCurrentDevice( d3dEnum.GetCurrentDevice() ); |
|
|
|
ISetCurrentDevice( d3dEnum.GetCurrentDevice() ); |
|
|
@ -695,6 +684,8 @@ plDXPipeline::plDXPipeline( hsWinRef hWnd, const hsG3DDeviceModeRecord *devModeR |
|
|
|
plStatusLog::AddLineS("pipeline.log", "%d, %d, %d", temp[i].Width, temp[i].Height, 32); |
|
|
|
plStatusLog::AddLineS("pipeline.log", "%d, %d, %d", temp[i].Width, temp[i].Height, 32); |
|
|
|
}*/ |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// We don't need the TnL enumeration for the lifetime of the game, so say goodbye!
|
|
|
|
|
|
|
|
hsGDirect3D::ReleaseTnLEnum(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Cleanup - Most happens in IReleaseDeviceObject().
|
|
|
|
// Cleanup - Most happens in IReleaseDeviceObject().
|
|
|
@ -722,7 +713,7 @@ plDXPipeline::~plDXPipeline() |
|
|
|
// built from. For example, the fD3DObject pointer is set to nil so that it's safe
|
|
|
|
// built from. For example, the fD3DObject pointer is set to nil so that it's safe
|
|
|
|
// to delete or set to a valid pointer. It must be set to a valid pointer
|
|
|
|
// to delete or set to a valid pointer. It must be set to a valid pointer
|
|
|
|
// before the pipeline can be used for much.
|
|
|
|
// before the pipeline can be used for much.
|
|
|
|
// After the core initialization is done (in ICreateMaster and ICreateDeviceObjects)
|
|
|
|
// After the core initialization is done (in ICreateDeviceObjects)
|
|
|
|
// render state will be initialized in IInitDeviceState.
|
|
|
|
// render state will be initialized in IInitDeviceState.
|
|
|
|
|
|
|
|
|
|
|
|
void plDXPipeline::IClearMembers() |
|
|
|
void plDXPipeline::IClearMembers() |
|
|
@ -774,7 +765,6 @@ void plDXPipeline::IClearMembers() |
|
|
|
fBlurVBuffers[i] = nil; |
|
|
|
fBlurVBuffers[i] = nil; |
|
|
|
fBlurVSHandle = 0; |
|
|
|
fBlurVSHandle = 0; |
|
|
|
|
|
|
|
|
|
|
|
fD3DObject = nil; |
|
|
|
|
|
|
|
fD3DDevice = nil; |
|
|
|
fD3DDevice = nil; |
|
|
|
fD3DBackBuff = nil; |
|
|
|
fD3DBackBuff = nil; |
|
|
|
fD3DDepthSurface = nil; |
|
|
|
fD3DDepthSurface = nil; |
|
|
@ -892,7 +882,6 @@ void plDXGeneralSettings::Reset() |
|
|
|
fNoGammaCorrect = false; |
|
|
|
fNoGammaCorrect = false; |
|
|
|
fMaxUVWSrc = 8; |
|
|
|
fMaxUVWSrc = 8; |
|
|
|
fCantProj = false; |
|
|
|
fCantProj = false; |
|
|
|
fLimitedProj = false; |
|
|
|
|
|
|
|
fBadManaged = false; |
|
|
|
fBadManaged = false; |
|
|
|
fShareDepth = false; |
|
|
|
fShareDepth = false; |
|
|
|
fCurrAnisotropy = false; |
|
|
|
fCurrAnisotropy = false; |
|
|
@ -931,7 +920,7 @@ void plDXPipeline::IInitDeviceState() |
|
|
|
|
|
|
|
|
|
|
|
fD3DDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_ZENABLE, ( fSettings.fD3DCaps & kCapsWBuffer ) ? D3DZB_USEW : D3DZB_TRUE ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_CLIPPING, TRUE );
|
|
|
|
fD3DDevice->SetRenderState( D3DRS_CLIPPING, TRUE );
|
|
|
|
fD3DDevice->SetRenderState( D3DRS_CULLMODE, fCurrCullMode ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_CULLMODE, fCurrCullMode ); |
|
|
|
ISetCullMode(); |
|
|
|
ISetCullMode(); |
|
|
@ -943,7 +932,7 @@ void plDXPipeline::IInitDeviceState() |
|
|
|
fD3DDevice->SetRenderState( D3DRS_MULTISAMPLEANTIALIAS, ( fSettings.fD3DCaps & kCapsFSAntiAlias ) ? TRUE : FALSE ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_MULTISAMPLEANTIALIAS, ( fSettings.fD3DCaps & kCapsFSAntiAlias ) ? TRUE : FALSE ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_ANTIALIASEDLINEENABLE, FALSE ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_ANTIALIASEDLINEENABLE, FALSE ); |
|
|
|
|
|
|
|
|
|
|
|
fD3DDevice->SetRenderState( D3DRS_DITHERENABLE, ( fSettings.fD3DCaps & kCapsDither ) ? TRUE : FALSE ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_DITHERENABLE, FALSE ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE ); |
|
|
|
fD3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
|
|
|
|
fD3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
|
|
|
|
fCurrD3DLiteState = false; |
|
|
|
fCurrD3DLiteState = false; |
|
|
@ -1040,10 +1029,6 @@ void plDXPipeline::ISetCaps() |
|
|
|
fSettings.fD3DCaps |= kCapsMipmap; |
|
|
|
fSettings.fD3DCaps |= kCapsMipmap; |
|
|
|
if (fCurrentDevice->fDDCaps.TextureCaps & D3DPTEXTURECAPS_MIPCUBEMAP) |
|
|
|
if (fCurrentDevice->fDDCaps.TextureCaps & D3DPTEXTURECAPS_MIPCUBEMAP) |
|
|
|
fSettings.fD3DCaps |= kCapsCubicMipmap; |
|
|
|
fSettings.fD3DCaps |= kCapsCubicMipmap; |
|
|
|
if (fCurrentDevice->fDDCaps.RasterCaps & D3DPRASTERCAPS_WBUFFER) |
|
|
|
|
|
|
|
fSettings.fD3DCaps |= kCapsWBuffer; |
|
|
|
|
|
|
|
if (fCurrentDevice->fDDCaps.RasterCaps & D3DPRASTERCAPS_DITHER) |
|
|
|
|
|
|
|
fSettings.fD3DCaps |= kCapsDither; |
|
|
|
|
|
|
|
if (fSettings.fNumAASamples > 0) |
|
|
|
if (fSettings.fNumAASamples > 0) |
|
|
|
fSettings.fD3DCaps |= kCapsFSAntiAlias; |
|
|
|
fSettings.fD3DCaps |= kCapsFSAntiAlias; |
|
|
|
if (fCurrentDevice->fDDCaps.RasterCaps & D3DPRASTERCAPS_WFOG) |
|
|
|
if (fCurrentDevice->fDDCaps.RasterCaps & D3DPRASTERCAPS_WFOG) |
|
|
@ -1167,16 +1152,8 @@ void plDXPipeline::IRestrictCaps( const hsG3DDeviceRecord& devRec ) |
|
|
|
fSettings.fD3DCaps &= ~kCapsMipmap; |
|
|
|
fSettings.fD3DCaps &= ~kCapsMipmap; |
|
|
|
if( !devRec.GetCap( hsG3DDeviceSelector::kCapsCubicMipmap ) ) |
|
|
|
if( !devRec.GetCap( hsG3DDeviceSelector::kCapsCubicMipmap ) ) |
|
|
|
fSettings.fD3DCaps &= ~kCapsCubicMipmap; |
|
|
|
fSettings.fD3DCaps &= ~kCapsCubicMipmap; |
|
|
|
if( !devRec.GetCap( hsG3DDeviceSelector::kCapsWBuffer ) ) |
|
|
|
|
|
|
|
fSettings.fD3DCaps &= ~kCapsWBuffer; |
|
|
|
|
|
|
|
if( !devRec.GetCap( hsG3DDeviceSelector::kCapsZBias ) ) |
|
|
|
if( !devRec.GetCap( hsG3DDeviceSelector::kCapsZBias ) ) |
|
|
|
fSettings.fD3DCaps &= ~kCapsZBias; |
|
|
|
fSettings.fD3DCaps &= ~kCapsZBias; |
|
|
|
// if( !devRec.GetCap( hsG3DDeviceSelector::kCapsHWTransform ) )
|
|
|
|
|
|
|
|
// fSettings.fD3DCaps &= ~kCapsHWTransform;
|
|
|
|
|
|
|
|
if( !devRec.GetCap( hsG3DDeviceSelector::kCapsDither ) ) |
|
|
|
|
|
|
|
fSettings.fD3DCaps &= ~kCapsDither; |
|
|
|
|
|
|
|
// if( devRec.GetAASetting() == 0 )
|
|
|
|
|
|
|
|
// fSettings.fD3DCaps &= ~kCapsFSAntiAlias;
|
|
|
|
|
|
|
|
if( !devRec.GetCap( hsG3DDeviceSelector::kCapsFogExp ) ) |
|
|
|
if( !devRec.GetCap( hsG3DDeviceSelector::kCapsFogExp ) ) |
|
|
|
fSettings.fD3DCaps &= ~kCapsExpFog; |
|
|
|
fSettings.fD3DCaps &= ~kCapsExpFog; |
|
|
|
if( !devRec.GetCap( hsG3DDeviceSelector::kCapsCubicTextures ) ) |
|
|
|
if( !devRec.GetCap( hsG3DDeviceSelector::kCapsCubicTextures ) ) |
|
|
@ -1187,8 +1164,6 @@ void plDXPipeline::IRestrictCaps( const hsG3DDeviceRecord& devRec ) |
|
|
|
|
|
|
|
|
|
|
|
if( devRec.GetCap(hsG3DDeviceSelector::kCapsCantProj) ) |
|
|
|
if( devRec.GetCap(hsG3DDeviceSelector::kCapsCantProj) ) |
|
|
|
fSettings.fCantProj = true; |
|
|
|
fSettings.fCantProj = true; |
|
|
|
if( devRec.GetCap(hsG3DDeviceSelector::kCapsLimitedProj) ) |
|
|
|
|
|
|
|
fSettings.fLimitedProj = true; |
|
|
|
|
|
|
|
if( devRec.GetCap(hsG3DDeviceSelector::kCapsBadManaged) ) |
|
|
|
if( devRec.GetCap(hsG3DDeviceSelector::kCapsBadManaged) ) |
|
|
|
fSettings.fBadManaged = true; |
|
|
|
fSettings.fBadManaged = true; |
|
|
|
if( devRec.GetCap(hsG3DDeviceSelector::kCapsShareDepth) ) |
|
|
|
if( devRec.GetCap(hsG3DDeviceSelector::kCapsShareDepth) ) |
|
|
@ -1204,11 +1179,6 @@ void plDXPipeline::IRestrictCaps( const hsG3DDeviceRecord& devRec ) |
|
|
|
if( devRec.GetCap( hsG3DDeviceSelector::kCapsBadYonStuff ) ) |
|
|
|
if( devRec.GetCap( hsG3DDeviceSelector::kCapsBadYonStuff ) ) |
|
|
|
fSettings.fD3DCaps |= kCapsHasBadYonStuff; |
|
|
|
fSettings.fD3DCaps |= kCapsHasBadYonStuff; |
|
|
|
|
|
|
|
|
|
|
|
/// 10.31.2000 mcn - Flag for can't-handle-under-8-pixel-dimensions-on-textures
|
|
|
|
|
|
|
|
/// (see, isn't the name flag actually better in retrospect? :)
|
|
|
|
|
|
|
|
if( devRec.GetCap( hsG3DDeviceSelector::kCapsNoKindaSmallTexs ) ) |
|
|
|
|
|
|
|
fSettings.fD3DCaps |= kCapsNoKindaSmallTexs; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Note: the following SHOULD be here, but we later detect for texture
|
|
|
|
/// Note: the following SHOULD be here, but we later detect for texture
|
|
|
|
/// formats and reset this flag. It should only be set if it is set already,
|
|
|
|
/// formats and reset this flag. It should only be set if it is set already,
|
|
|
|
/// but that means ensuring it's set beforehand, which it might not be.
|
|
|
|
/// but that means ensuring it's set beforehand, which it might not be.
|
|
|
@ -1270,15 +1240,8 @@ void plDXPipeline::IRestrictCaps( const hsG3DDeviceRecord& devRec ) |
|
|
|
fManagedCutoff = 1; |
|
|
|
fManagedCutoff = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//// Our temp debug flag to force z-buffering...
|
|
|
|
/// Set up the z-bias scale values
|
|
|
|
if( !( fDbgSetupInitFlags & 0x00000001 ) ) |
|
|
|
fTweaks.fDefaultPerspLayerScale = kPerspLayerScale; |
|
|
|
fSettings.fD3DCaps &= ~kCapsWBuffer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Set up the z-bias scale values, based on z- or w-buffering
|
|
|
|
|
|
|
|
if( fSettings.fD3DCaps & kCapsWBuffer ) |
|
|
|
|
|
|
|
fTweaks.fDefaultPerspLayerScale = kPerspLayerScaleW; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
fTweaks.fDefaultPerspLayerScale = kPerspLayerScale; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Less than 4 layers at once means we have to fallback on uv bumpmapping
|
|
|
|
// Less than 4 layers at once means we have to fallback on uv bumpmapping
|
|
|
@ -1417,11 +1380,13 @@ void plDXPipeline::ISetCurrentDriver( D3DEnum_DriverInfo *driv ) |
|
|
|
fCurrentDriver->fCurrentDevice = nil; |
|
|
|
fCurrentDriver->fCurrentDevice = nil; |
|
|
|
|
|
|
|
|
|
|
|
/// Go looking for an adapter to match this one
|
|
|
|
/// Go looking for an adapter to match this one
|
|
|
|
|
|
|
|
IDirect3D9* d3d = hsGDirect3D::GetDirect3D(); |
|
|
|
UINT iAdapter; |
|
|
|
UINT iAdapter; |
|
|
|
for( fCurrentAdapter = 0, iAdapter = 0; iAdapter < fD3DObject->GetAdapterCount(); iAdapter++ ) |
|
|
|
|
|
|
|
|
|
|
|
for( fCurrentAdapter = 0, iAdapter = 0; iAdapter < d3d->GetAdapterCount(); iAdapter++ ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
D3DADAPTER_IDENTIFIER9 adapterInfo; |
|
|
|
D3DADAPTER_IDENTIFIER9 adapterInfo; |
|
|
|
fD3DObject->GetAdapterIdentifier( iAdapter, 0, &adapterInfo ); |
|
|
|
d3d->GetAdapterIdentifier( iAdapter, 0, &adapterInfo ); |
|
|
|
|
|
|
|
|
|
|
|
if( adapterInfo.DeviceIdentifier == fCurrentDriver->fAdapterInfo.DeviceIdentifier ) |
|
|
|
if( adapterInfo.DeviceIdentifier == fCurrentDriver->fAdapterInfo.DeviceIdentifier ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1498,9 +1463,9 @@ bool plDXPipeline::IFindCompressedFormats() |
|
|
|
|
|
|
|
|
|
|
|
for( i = 0; toCheckFor[ i ] != D3DFMT_UNKNOWN; i++ ) |
|
|
|
for( i = 0; toCheckFor[ i ] != D3DFMT_UNKNOWN; i++ ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( FAILED( fD3DObject->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, |
|
|
|
if( FAILED( hsGDirect3D::GetDirect3D()->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, |
|
|
|
fCurrentMode->fDDmode.Format, |
|
|
|
fCurrentMode->fDDmode.Format, |
|
|
|
0, D3DRTYPE_TEXTURE, toCheckFor[ i ] ) ) ) |
|
|
|
0, D3DRTYPE_TEXTURE, toCheckFor[ i ] ) ) ) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1520,9 +1485,9 @@ bool plDXPipeline::IFindLuminanceFormats() |
|
|
|
|
|
|
|
|
|
|
|
for( i = 0; toCheckFor[ i ] != D3DFMT_UNKNOWN; i++ ) |
|
|
|
for( i = 0; toCheckFor[ i ] != D3DFMT_UNKNOWN; i++ ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( FAILED( fD3DObject->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, |
|
|
|
if (FAILED(hsGDirect3D::GetDirect3D()->CheckDeviceFormat(fCurrentAdapter, fCurrentDevice->fDDType, |
|
|
|
fCurrentMode->fDDmode.Format, |
|
|
|
fCurrentMode->fDDmode.Format, |
|
|
|
0, D3DRTYPE_TEXTURE, toCheckFor[ i ] ) ) ) |
|
|
|
0, D3DRTYPE_TEXTURE, toCheckFor[ i ] ) ) ) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1537,9 +1502,9 @@ bool plDXPipeline::IFindLuminanceFormats() |
|
|
|
|
|
|
|
|
|
|
|
bool plDXPipeline::ITextureFormatAllowed( D3DFORMAT format ) |
|
|
|
bool plDXPipeline::ITextureFormatAllowed( D3DFORMAT format ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( FAILED( fD3DObject->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, |
|
|
|
if (FAILED( hsGDirect3D::GetDirect3D()->CheckDeviceFormat(fCurrentAdapter, fCurrentDevice->fDDType, |
|
|
|
fCurrentMode->fDDmode.Format, |
|
|
|
fCurrentMode->fDDmode.Format, |
|
|
|
0, D3DRTYPE_TEXTURE, format ) ) ) |
|
|
|
0, D3DRTYPE_TEXTURE, format ) ) ) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -1584,32 +1549,6 @@ bool plDXPipeline::IsDebugFlagSet( uint32_t flag ) const |
|
|
|
//// Device Creation //////////////////////////////////////////////////////////
|
|
|
|
//// Device Creation //////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
//// ICreateMaster ////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Creates the master Direct3D objects. I guess just in case you want
|
|
|
|
|
|
|
|
// multiple Direct3D devices.... :~
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool plDXPipeline::ICreateMaster() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
hsAssert( !fD3DObject, "ICreateMaster() should only be called for Master Direct3DDevice" ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The new DirectX Way: Create a Direct3D object, out of which everything else springs
|
|
|
|
|
|
|
|
if( hsGDDrawDllLoad::GetD3DDll() == nil ) |
|
|
|
|
|
|
|
return ICreateFail( "Cannot load Direct3D driver!" ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Direct3DCreateProc procPtr; |
|
|
|
|
|
|
|
procPtr = (Direct3DCreateProc)GetProcAddress( hsGDDrawDllLoad::GetD3DDll(), "Direct3DCreate9" ); |
|
|
|
|
|
|
|
if( procPtr == nil ) |
|
|
|
|
|
|
|
return ICreateFail( "Cannot load D3D Create Proc!" ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create a D3D object to use
|
|
|
|
|
|
|
|
fD3DObject = procPtr( D3D_SDK_VERSION ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( fD3DObject == nil ) |
|
|
|
|
|
|
|
return ICreateFail( "Cannot create Direct3D object" ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//// ICreateDevice ////////////////////////////////////////////////////
|
|
|
|
//// ICreateDevice ////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Creates the device. Surfaces, buffers, etc. created separately (in case of lost device).
|
|
|
|
// Creates the device. Surfaces, buffers, etc. created separately (in case of lost device).
|
|
|
@ -1625,7 +1564,11 @@ bool plDXPipeline::ICreateDevice(bool windowed) |
|
|
|
char msg[ 256 ]; |
|
|
|
char msg[ 256 ]; |
|
|
|
#endif // DBG_WRITE_FORMATS
|
|
|
|
#endif // DBG_WRITE_FORMATS
|
|
|
|
|
|
|
|
|
|
|
|
INIT_ERROR_CHECK( fD3DObject->GetAdapterDisplayMode( fCurrentAdapter, &dispMode ), |
|
|
|
IDirect3D9* d3d = hsGDirect3D::GetDirect3D(); |
|
|
|
|
|
|
|
if (!d3d) |
|
|
|
|
|
|
|
return ICreateFail("Failed to get Direct3D Object"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INIT_ERROR_CHECK( d3d->GetAdapterDisplayMode( fCurrentAdapter, &dispMode ), |
|
|
|
"Cannot get desktop display mode" ); |
|
|
|
"Cannot get desktop display mode" ); |
|
|
|
|
|
|
|
|
|
|
|
// save desktop properties
|
|
|
|
// save desktop properties
|
|
|
@ -1722,10 +1665,10 @@ bool plDXPipeline::ICreateDevice(bool windowed) |
|
|
|
|
|
|
|
|
|
|
|
#ifndef PLASMA_EXTERNAL_RELEASE |
|
|
|
#ifndef PLASMA_EXTERNAL_RELEASE |
|
|
|
UINT adapter; |
|
|
|
UINT adapter; |
|
|
|
for (adapter = 0; adapter < fD3DObject->GetAdapterCount(); adapter++) |
|
|
|
for (adapter = 0; adapter < d3d->GetAdapterCount(); adapter++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
D3DADAPTER_IDENTIFIER9 id; |
|
|
|
D3DADAPTER_IDENTIFIER9 id; |
|
|
|
fD3DObject->GetAdapterIdentifier(adapter, 0, &id); |
|
|
|
d3d->GetAdapterIdentifier(adapter, 0, &id); |
|
|
|
|
|
|
|
|
|
|
|
// We should be matching against "NVIDIA NVPerfHUD", but the space
|
|
|
|
// We should be matching against "NVIDIA NVPerfHUD", but the space
|
|
|
|
// in the description seems to be bogus. This seems to be a fair
|
|
|
|
// in the description seems to be bogus. This seems to be a fair
|
|
|
@ -1743,9 +1686,9 @@ bool plDXPipeline::ICreateDevice(bool windowed) |
|
|
|
} |
|
|
|
} |
|
|
|
#endif // PLASMA_EXTERNAL_RELEASE
|
|
|
|
#endif // PLASMA_EXTERNAL_RELEASE
|
|
|
|
|
|
|
|
|
|
|
|
INIT_ERROR_CHECK( fD3DObject->CreateDevice( fCurrentAdapter, fCurrentDevice->fDDType,
|
|
|
|
INIT_ERROR_CHECK( d3d->CreateDevice( fCurrentAdapter, fCurrentDevice->fDDType, |
|
|
|
fSettings.fHWnd, fCurrentMode->fDDBehavior, |
|
|
|
fSettings.fHWnd, fCurrentMode->fDDBehavior, |
|
|
|
¶ms, &fD3DDevice ), |
|
|
|
¶ms, &fD3DDevice ), |
|
|
|
"Cannot create primary display surface via CreateDevice()" ); |
|
|
|
"Cannot create primary display surface via CreateDevice()" ); |
|
|
|
|
|
|
|
|
|
|
|
fSettings.fPresentParams = params; |
|
|
|
fSettings.fPresentParams = params; |
|
|
@ -1774,6 +1717,8 @@ bool plDXPipeline::ICreateDevice(bool windowed) |
|
|
|
// will work.
|
|
|
|
// will work.
|
|
|
|
bool plDXPipeline::IFindDepthFormat(D3DPRESENT_PARAMETERS& params) |
|
|
|
bool plDXPipeline::IFindDepthFormat(D3DPRESENT_PARAMETERS& params) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
IDirect3D9* d3d = hsGDirect3D::GetDirect3D(); |
|
|
|
|
|
|
|
|
|
|
|
// Okay, we're not using the stencil buffer right now, and it's bringing out
|
|
|
|
// Okay, we're not using the stencil buffer right now, and it's bringing out
|
|
|
|
// some painful driver bugs on the GeForce2. So rather than go out of our way
|
|
|
|
// some painful driver bugs on the GeForce2. So rather than go out of our way
|
|
|
|
// looking for trouble, we're going to look for a depth buffer with NO STENCIL.
|
|
|
|
// looking for trouble, we're going to look for a depth buffer with NO STENCIL.
|
|
|
@ -1785,11 +1730,11 @@ bool plDXPipeline::IFindDepthFormat(D3DPRESENT_PARAMETERS& params) |
|
|
|
||(fmt == D3DFMT_D24X8) |
|
|
|
||(fmt == D3DFMT_D24X8) |
|
|
|
||(fmt == D3DFMT_D16) ) |
|
|
|
||(fmt == D3DFMT_D16) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
HRESULT hr = fD3DObject->CheckDeviceMultiSampleType(fCurrentAdapter,
|
|
|
|
HRESULT hr = d3d->CheckDeviceMultiSampleType(fCurrentAdapter, |
|
|
|
fCurrentDevice->fDDType, |
|
|
|
fCurrentDevice->fDDType, |
|
|
|
fmt,
|
|
|
|
fmt, |
|
|
|
fCurrentMode->fWindowed ? TRUE : FALSE, |
|
|
|
fCurrentMode->fWindowed ? TRUE : FALSE, |
|
|
|
params.MultiSampleType, NULL); |
|
|
|
params.MultiSampleType, NULL); |
|
|
|
if( !FAILED(hr) ) |
|
|
|
if( !FAILED(hr) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
params.AutoDepthStencilFormat = fmt; |
|
|
|
params.AutoDepthStencilFormat = fmt; |
|
|
@ -1805,11 +1750,11 @@ bool plDXPipeline::IFindDepthFormat(D3DPRESENT_PARAMETERS& params) |
|
|
|
D3DFORMAT fmt = fCurrentMode->fDepthFormats[ i ]; |
|
|
|
D3DFORMAT fmt = fCurrentMode->fDepthFormats[ i ]; |
|
|
|
if( fmt == D3DFMT_D15S1 || fmt == D3DFMT_D24X4S4 || fmt == D3DFMT_D24S8 ) |
|
|
|
if( fmt == D3DFMT_D15S1 || fmt == D3DFMT_D24X4S4 || fmt == D3DFMT_D24S8 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
HRESULT hr = fD3DObject->CheckDeviceMultiSampleType(fCurrentAdapter,
|
|
|
|
HRESULT hr = d3d->CheckDeviceMultiSampleType(fCurrentAdapter, |
|
|
|
fCurrentDevice->fDDType, |
|
|
|
fCurrentDevice->fDDType, |
|
|
|
fmt,
|
|
|
|
fmt, |
|
|
|
fCurrentMode->fWindowed ? TRUE : FALSE, |
|
|
|
fCurrentMode->fWindowed ? TRUE : FALSE, |
|
|
|
params.MultiSampleType, NULL); |
|
|
|
params.MultiSampleType, NULL); |
|
|
|
if( !FAILED(hr) ) |
|
|
|
if( !FAILED(hr) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
params.AutoDepthStencilFormat = fmt; |
|
|
|
params.AutoDepthStencilFormat = fmt; |
|
|
@ -2071,16 +2016,6 @@ void plDXPipeline::IReleaseDeviceObjects() |
|
|
|
fD3DDevice = nil; |
|
|
|
fD3DDevice = nil; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if( fD3DObject != nil ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LONG ret; |
|
|
|
|
|
|
|
while( ret = fD3DObject->Release() ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
hsStatusMessageF("%d - Error releasing Direct3D Object", ret); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
fD3DObject = nil; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fManagedAlloced = false; |
|
|
|
fManagedAlloced = false; |
|
|
|
fAllocUnManaged = false; |
|
|
|
fAllocUnManaged = false; |
|
|
|
} |
|
|
|
} |
|
|
@ -2579,13 +2514,10 @@ void plDXPipeline::Resize( uint32_t width, uint32_t height ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Recreate
|
|
|
|
// Recreate
|
|
|
|
if( !fD3DObject ) |
|
|
|
if( hsGDirect3D::GetDirect3D(true) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( ICreateMaster() ) |
|
|
|
IShowErrorMessage( "Cannot create D3D master object" ); |
|
|
|
{ |
|
|
|
return; |
|
|
|
IShowErrorMessage( "Cannot create D3D master object" ); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Go recreate surfaces and DX-dependent objects
|
|
|
|
// Go recreate surfaces and DX-dependent objects
|
|
|
@ -3920,9 +3852,7 @@ bool plDXPipeline::BeginRender() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Superfluous setting of Z state.
|
|
|
|
// Superfluous setting of Z state.
|
|
|
|
fD3DDevice->SetRenderState( D3DRS_ZENABLE,
|
|
|
|
fD3DDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE ); |
|
|
|
( fView.IsPerspective() && ( fSettings.fD3DCaps & kCapsWBuffer ) )
|
|
|
|
|
|
|
|
? D3DZB_USEW : D3DZB_TRUE ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// If we have a renderTarget active, use its viewport
|
|
|
|
/// If we have a renderTarget active, use its viewport
|
|
|
|
ISetViewport(); |
|
|
|
ISetViewport(); |
|
|
@ -4820,6 +4750,7 @@ bool plDXPipeline::IPrepRenderTargetInfo( plRenderTarget *owner, D3DFORMAT &sur |
|
|
|
uint16_t flags, width, height; |
|
|
|
uint16_t flags, width, height; |
|
|
|
int8_t bitDepth, zDepth, stencilDepth, stencilIndex; |
|
|
|
int8_t bitDepth, zDepth, stencilDepth, stencilIndex; |
|
|
|
D3DFORMAT depthFormats[] = { D3DFMT_D24X8, D3DFMT_D24X4S4, D3DFMT_D24S8 }; |
|
|
|
D3DFORMAT depthFormats[] = { D3DFMT_D24X8, D3DFMT_D24X4S4, D3DFMT_D24S8 }; |
|
|
|
|
|
|
|
IDirect3D9* d3d = hsGDirect3D::GetDirect3D(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flags = owner->GetFlags(); |
|
|
|
flags = owner->GetFlags(); |
|
|
@ -4886,8 +4817,8 @@ bool plDXPipeline::IPrepRenderTargetInfo( plRenderTarget *owner, D3DFORMAT &sur |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Check the device format
|
|
|
|
/// Check the device format
|
|
|
|
if( FAILED( fSettings.fDXError = fD3DObject->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, fCurrentMode->fDDmode.Format, |
|
|
|
if( FAILED( fSettings.fDXError = d3d->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, fCurrentMode->fDDmode.Format, |
|
|
|
D3DUSAGE_RENDERTARGET, resType, surfFormat ) ) ) |
|
|
|
D3DUSAGE_RENDERTARGET, resType, surfFormat ) ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( bitDepth == 16 ) |
|
|
|
if( bitDepth == 16 ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -4899,8 +4830,8 @@ bool plDXPipeline::IPrepRenderTargetInfo( plRenderTarget *owner, D3DFORMAT &sur |
|
|
|
bitDepth = 16; |
|
|
|
bitDepth = 16; |
|
|
|
surfFormat = D3DFMT_A4R4G4B4; |
|
|
|
surfFormat = D3DFMT_A4R4G4B4; |
|
|
|
} |
|
|
|
} |
|
|
|
if( FAILED( fSettings.fDXError = fD3DObject->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, fCurrentMode->fDDmode.Format, |
|
|
|
if( FAILED( fSettings.fDXError = d3d->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, fCurrentMode->fDDmode.Format, |
|
|
|
D3DUSAGE_RENDERTARGET, resType, surfFormat ) ) ) |
|
|
|
D3DUSAGE_RENDERTARGET, resType, surfFormat ) ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IGetD3DError(); |
|
|
|
IGetD3DError(); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -4909,8 +4840,8 @@ bool plDXPipeline::IPrepRenderTargetInfo( plRenderTarget *owner, D3DFORMAT &sur |
|
|
|
|
|
|
|
|
|
|
|
if( zDepth ) |
|
|
|
if( zDepth ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
while( FAILED( fSettings.fDXError = fD3DObject->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, fCurrentMode->fDDmode.Format, |
|
|
|
while( FAILED( fSettings.fDXError = d3d->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, fCurrentMode->fDDmode.Format, |
|
|
|
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, depthFormat ) ) ) |
|
|
|
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, depthFormat ) ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( stencilIndex < sizeof( depthFormats ) / sizeof( depthFormats[ 0 ] ) - 1 ) |
|
|
|
if( stencilIndex < sizeof( depthFormats ) / sizeof( depthFormats[ 0 ] ) - 1 ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -4924,8 +4855,8 @@ bool plDXPipeline::IPrepRenderTargetInfo( plRenderTarget *owner, D3DFORMAT &sur |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if( FAILED( fSettings.fDXError = fD3DObject->CheckDepthStencilMatch( fCurrentAdapter, fCurrentDevice->fDDType, fCurrentMode->fDDmode.Format, |
|
|
|
if( FAILED( fSettings.fDXError = d3d->CheckDepthStencilMatch( fCurrentAdapter, fCurrentDevice->fDDType, fCurrentMode->fDDmode.Format, |
|
|
|
surfFormat, depthFormat ) ) ) |
|
|
|
surfFormat, depthFormat ) ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IGetD3DError(); |
|
|
|
IGetD3DError(); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -4952,6 +4883,7 @@ bool plDXPipeline::IFindRenderTargetInfo( plRenderTarget *owner, D3DFORMAT &sur |
|
|
|
height = owner->GetHeight(); |
|
|
|
height = owner->GetHeight(); |
|
|
|
bitDepth = owner->GetPixelSize(); |
|
|
|
bitDepth = owner->GetPixelSize(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IDirect3D9* d3d = hsGDirect3D::GetDirect3D(); |
|
|
|
if( flags != 0 ) |
|
|
|
if( flags != 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( flags & plRenderTarget::kIsTexture ) |
|
|
|
if( flags & plRenderTarget::kIsTexture ) |
|
|
@ -4972,8 +4904,8 @@ bool plDXPipeline::IFindRenderTargetInfo( plRenderTarget *owner, D3DFORMAT &sur |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Check the device format
|
|
|
|
/// Check the device format
|
|
|
|
if( FAILED( fSettings.fDXError = fD3DObject->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, fCurrentMode->fDDmode.Format, |
|
|
|
if( FAILED( fSettings.fDXError = d3d->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, fCurrentMode->fDDmode.Format, |
|
|
|
D3DUSAGE_RENDERTARGET, resType, surfFormat ) ) ) |
|
|
|
D3DUSAGE_RENDERTARGET, resType, surfFormat ) ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( bitDepth == 16 ) |
|
|
|
if( bitDepth == 16 ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -4985,8 +4917,8 @@ bool plDXPipeline::IFindRenderTargetInfo( plRenderTarget *owner, D3DFORMAT &sur |
|
|
|
bitDepth = 16; |
|
|
|
bitDepth = 16; |
|
|
|
surfFormat = D3DFMT_A4R4G4B4; |
|
|
|
surfFormat = D3DFMT_A4R4G4B4; |
|
|
|
} |
|
|
|
} |
|
|
|
if( FAILED( fSettings.fDXError = fD3DObject->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, fCurrentMode->fDDmode.Format, |
|
|
|
if( FAILED( fSettings.fDXError = d3d->CheckDeviceFormat( fCurrentAdapter, fCurrentDevice->fDDType, fCurrentMode->fDDmode.Format, |
|
|
|
D3DUSAGE_RENDERTARGET, resType, surfFormat ) ) ) |
|
|
|
D3DUSAGE_RENDERTARGET, resType, surfFormat ) ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IGetD3DError(); |
|
|
|
IGetD3DError(); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -8702,11 +8634,6 @@ bool plDXPipeline::IProcessMipmapLevels( plMipmap *mipmap, uint32_t &numLevels, |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint32_t sizeMask = 0x03; |
|
|
|
uint32_t sizeMask = 0x03; |
|
|
|
|
|
|
|
|
|
|
|
/// 10.31.2000 - If we have this flag set, we really have to cut out
|
|
|
|
|
|
|
|
/// sizes under 8x8. So far only true on the KYRO...
|
|
|
|
|
|
|
|
if( fSettings.fD3DCaps & kCapsNoKindaSmallTexs ) |
|
|
|
|
|
|
|
sizeMask = 0x07; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int maxLevel = mipmap->GetNumLevels() - 1; |
|
|
|
int maxLevel = mipmap->GetNumLevels() - 1; |
|
|
|
|
|
|
|
|
|
|
|
/// 9.7.2000 - Also do this test if the card doesn't support
|
|
|
|
/// 9.7.2000 - Also do this test if the card doesn't support
|
|
|
@ -9722,34 +9649,15 @@ hsMatrix44 plDXPipeline::IGetCameraToNDC() |
|
|
|
// is [x/w, y/w, z/w + t/s, 1/sw]
|
|
|
|
// is [x/w, y/w, z/w + t/s, 1/sw]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( fSettings.fD3DCaps & kCapsWBuffer ) |
|
|
|
float scale = 1.f - float(fCurrRenderLayer) * fTweaks.fPerspLayerScale; |
|
|
|
{ |
|
|
|
float zTrans = -scale * float(fCurrRenderLayer) * fTweaks.fPerspLayerTrans; |
|
|
|
// W-buffering is only true w-buffering on 3dfx cards. On everything else,
|
|
|
|
|
|
|
|
// they REALLY base it off the Z value. So we want to scale (but NOT translate)
|
|
|
|
|
|
|
|
// the Z...
|
|
|
|
|
|
|
|
// Note: the base value for perspLayerScale should be 0.001 for w-buffering,
|
|
|
|
|
|
|
|
// not the normal 0.00001
|
|
|
|
|
|
|
|
float scale = 1.f - float(fCurrRenderLayer) * fTweaks.fPerspLayerScale; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cam2ndc.fMap[0][0] *= scale; |
|
|
|
|
|
|
|
cam2ndc.fMap[1][1] *= scale; |
|
|
|
|
|
|
|
cam2ndc.fMap[2][2] *= scale; |
|
|
|
|
|
|
|
cam2ndc.fMap[3][2] *= scale; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Z-buffering, so do it the traditional way
|
|
|
|
|
|
|
|
float scale = 1.f - float(fCurrRenderLayer) * fTweaks.fPerspLayerScale; |
|
|
|
|
|
|
|
// scale = -1.f;
|
|
|
|
|
|
|
|
float zTrans = -scale * float(fCurrRenderLayer) * fTweaks.fPerspLayerTrans; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cam2ndc.fMap[0][0] *= scale; |
|
|
|
cam2ndc.fMap[0][0] *= scale; |
|
|
|
cam2ndc.fMap[1][1] *= scale; |
|
|
|
cam2ndc.fMap[1][1] *= scale; |
|
|
|
|
|
|
|
|
|
|
|
cam2ndc.fMap[2][2] *= scale; |
|
|
|
cam2ndc.fMap[2][2] *= scale; |
|
|
|
cam2ndc.fMap[2][2] += zTrans * cam2ndc.fMap[3][2]; |
|
|
|
cam2ndc.fMap[2][2] += zTrans * cam2ndc.fMap[3][2]; |
|
|
|
cam2ndc.fMap[3][2] *= scale; |
|
|
|
cam2ndc.fMap[3][2] *= scale; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -11417,9 +11325,6 @@ void plDXPipeline::IRenderProjectionEach(const plRenderPrimFunc& render, hsGMate |
|
|
|
|
|
|
|
|
|
|
|
int iNextPass = iPass + fCurrNumLayers; |
|
|
|
int iNextPass = iPass + fCurrNumLayers; |
|
|
|
|
|
|
|
|
|
|
|
if( fSettings.fLimitedProj && (material->GetLayer(iPass)->GetUVWSrc() & ~plLayerInterface::kUVWIdxMask) ) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// For each projector:
|
|
|
|
// For each projector:
|
|
|
|
int k; |
|
|
|
int k; |
|
|
|
for( k = 0; k < fLights.fProjEach.GetCount(); k++ ) |
|
|
|
for( k = 0; k < fLights.fProjEach.GetCount(); k++ ) |
|
|
@ -12248,12 +12153,6 @@ void plDXPipeline::SubmitShadowSlave(plShadowSlave* slave) |
|
|
|
if( !(slave && slave->fCaster && slave->fCaster->GetKey()) ) |
|
|
|
if( !(slave && slave->fCaster && slave->fCaster->GetKey()) ) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// A board with limited projection capability (i.e. GeForce1) can't
|
|
|
|
|
|
|
|
// do perspective shadows (from point source lights) because it
|
|
|
|
|
|
|
|
// requires a count3 uvw on 2 texture units (0,1) simultaneously. Just skip.
|
|
|
|
|
|
|
|
if( (fSettings.fLimitedProj || fSettings.fCantProj) && slave->fView.GetPerspective() ) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ref the shadow caster so we're sure it will still be around when we go to
|
|
|
|
// Ref the shadow caster so we're sure it will still be around when we go to
|
|
|
|
// render it.
|
|
|
|
// render it.
|
|
|
|
slave->fCaster->GetKey()->RefObject(); |
|
|
|
slave->fCaster->GetKey()->RefObject(); |
|
|
|