From 24366ef9a8e42008e978b5d201733148be7b1b9c Mon Sep 17 00:00:00 2001 From: nillerusr Date: Sat, 26 Mar 2022 03:24:41 +0300 Subject: [PATCH] engine: hdr to ldr conversion for HDR_TYPE_NONE --- engine/buildcubemaps.cpp | 4 ++-- engine/cmodel_bsp.cpp | 2 +- engine/l_studio.cpp | 6 +++--- engine/modelloader.cpp | 14 +++++--------- materialsystem/cmaterial.cpp | 6 +++--- materialsystem/shaderapidx9/shaderdevicedx8.cpp | 6 +++++- public/shaderapi/ishaderdynamic.h | 2 +- public/togles/linuxwin/dxabstract_types.h | 1 + togles/linuxwin/dxabstract.cpp | 1 + 9 files changed, 22 insertions(+), 20 deletions(-) diff --git a/engine/buildcubemaps.cpp b/engine/buildcubemaps.cpp index d53caf53..ac064f91 100644 --- a/engine/buildcubemaps.cpp +++ b/engine/buildcubemaps.cpp @@ -1042,7 +1042,7 @@ void R_BuildCubemapSamples( int numIterations ) } } - bool bSupportsHDR = g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE; + bool bSupportsHDR = true; //g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE; for( i = 0; i < pWorldModel->brush.pShared->m_nCubemapSamples; i++ ) { @@ -1080,7 +1080,7 @@ void R_BuildCubemapSamples( int numIterations ) return; } - iBSPPack->SetHDRMode( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE ); + iBSPPack->SetHDRMode( true /*g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE*/ ); iBSPPack->LoadBSPFile( g_pFileSystem, cl.m_szLevelFileName ); diff --git a/engine/cmodel_bsp.cpp b/engine/cmodel_bsp.cpp index 81e96220..8dfff86a 100644 --- a/engine/cmodel_bsp.cpp +++ b/engine/cmodel_bsp.cpp @@ -1110,7 +1110,7 @@ void CollisionBSPData_LoadDispInfo( CCollisionBSPData *pBSPData ) // get face data // int face_lump_to_load = LUMP_FACES; - if ( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE && + if ( /*g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE &&*/ CMapLoadHelper::LumpSize( LUMP_FACES_HDR ) > 0 ) { face_lump_to_load = LUMP_FACES_HDR; diff --git a/engine/l_studio.cpp b/engine/l_studio.cpp index ef96ab92..c0da11cd 100644 --- a/engine/l_studio.cpp +++ b/engine/l_studio.cpp @@ -3637,12 +3637,12 @@ void CModelRender::ValidateStaticPropColorData( ModelInstanceHandle_t handle ) // fetch the header CUtlBuffer utlBuf; char fileName[MAX_PATH]; - if ( g_pMaterialSystemHardwareConfig->GetHDRType() == HDR_TYPE_NONE || g_bBakedPropLightingNoSeparateHDR ) + if ( g_bBakedPropLightingNoSeparateHDR ) { Q_snprintf( fileName, sizeof( fileName ), "sp_%d%s.vhv", StaticPropMgr()->GetStaticPropIndex( pProp ), GetPlatformExt() ); } else - { + { Q_snprintf( fileName, sizeof( fileName ), "sp_hdr_%d%s.vhv", StaticPropMgr()->GetStaticPropIndex( pProp ), GetPlatformExt() ); } @@ -3930,7 +3930,7 @@ bool CModelRender::LoadStaticPropColorData( IHandleEntity *pProp, DataCacheHandl // each static prop has its own compiled color mesh char fileName[MAX_PATH]; - if ( g_pMaterialSystemHardwareConfig->GetHDRType() == HDR_TYPE_NONE || g_bBakedPropLightingNoSeparateHDR ) + if ( g_bBakedPropLightingNoSeparateHDR ) { Q_snprintf( fileName, sizeof( fileName ), "sp_%d%s.vhv", StaticPropMgr()->GetStaticPropIndex( pProp ), GetPlatformExt() ); } diff --git a/engine/modelloader.cpp b/engine/modelloader.cpp index a8fc1f19..6bb5d2c8 100644 --- a/engine/modelloader.cpp +++ b/engine/modelloader.cpp @@ -1856,8 +1856,7 @@ void Mod_LoadFaces( void ) int ti, di; int face_lump_to_load = LUMP_FACES; - if ( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE && - CMapLoadHelper::LumpSize( LUMP_FACES_HDR ) > 0 ) + if ( CMapLoadHelper::LumpSize( LUMP_FACES_HDR ) > 0 ) { face_lump_to_load = LUMP_FACES_HDR; } @@ -2289,8 +2288,7 @@ void Mod_LoadLeafs( void ) Mod_LoadLeafs_Version_0( lh ); break; case 1: - if( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE && - CMapLoadHelper::LumpSize( LUMP_LEAF_AMBIENT_LIGHTING_HDR ) > 0 ) + if( CMapLoadHelper::LumpSize( LUMP_LEAF_AMBIENT_LIGHTING_HDR ) > 0 ) { CMapLoadHelper mlh( LUMP_LEAF_AMBIENT_LIGHTING_HDR ); CMapLoadHelper mlhTable( LUMP_LEAF_AMBIENT_INDEX_HDR ); @@ -2385,7 +2383,7 @@ void Mod_LoadCubemapSamples( void ) lh.GetMap()->m_pCubemapSamples = out; lh.GetMap()->m_nCubemapSamples = count; - bool bHDR = g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE; + bool bHDR = true; //g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE; int nCreateFlags = bHDR ? 0 : TEXTUREFLAGS_SRGB; // We have separate HDR versions of the textures. In order to deal with this, @@ -4453,8 +4451,7 @@ void CModelLoader::Map_LoadModel( model_t *mod ) // Until BSP version 19, this must occur after loading texinfo COM_TimestampedLog( " Mod_LoadLighting" ); - if ( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE && - CMapLoadHelper::LumpSize( LUMP_LIGHTING_HDR ) > 0 ) + if ( CMapLoadHelper::LumpSize( LUMP_LIGHTING_HDR ) > 0 ) { CMapLoadHelper mlh( LUMP_LIGHTING_HDR ); Mod_LoadLighting( mlh ); @@ -4546,8 +4543,7 @@ void CModelLoader::Map_LoadModel( model_t *mod ) &m_worldBrushData.m_nAreas ); COM_TimestampedLog( " Mod_LoadWorldlights" ); - if ( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE && - CMapLoadHelper::LumpSize( LUMP_WORLDLIGHTS_HDR ) > 0 ) + if ( CMapLoadHelper::LumpSize( LUMP_WORLDLIGHTS_HDR ) > 0 ) { CMapLoadHelper mlh( LUMP_WORLDLIGHTS_HDR ); Mod_LoadWorldlights( mlh, true ); diff --git a/materialsystem/cmaterial.cpp b/materialsystem/cmaterial.cpp index faf2540e..6c6ebe85 100644 --- a/materialsystem/cmaterial.cpp +++ b/materialsystem/cmaterial.cpp @@ -1177,7 +1177,7 @@ bool CMaterial::ShouldSkipVar( KeyValues *pVar, bool *pWasConditional ) } else if ( ! stricmp( pCond, "hdr" ) ) { - bShouldSkip = ( HardwareConfig()->GetHDRType() == HDR_TYPE_NONE ); + bShouldSkip = false; //( HardwareConfig()->GetHDRType() == HDR_TYPE_NONE ); } else if ( ! stricmp( pCond, "srgb" ) ) { @@ -1400,7 +1400,7 @@ static KeyValues *FindBuiltinFallbackBlock( char const *pShaderName, KeyValues * if ( pRet ) return pRet; } - if ( HardwareConfig()->GetHDRType() != HDR_TYPE_NONE ) +// if ( HardwareConfig()->GetHDRType() != HDR_TYPE_NONE ) { KeyValues *pRet = CheckConditionalFakeShaderName( pShaderName,"hdr_dx9", pKeyValues ); if ( pRet ) @@ -1409,7 +1409,7 @@ static KeyValues *FindBuiltinFallbackBlock( char const *pShaderName, KeyValues * if ( pRet ) return pRet; } - else + if( HardwareConfig()->GetHDRType() == HDR_TYPE_NONE ) { KeyValues *pRet = CheckConditionalFakeShaderName( pShaderName,"ldr", pKeyValues ); if ( pRet ) diff --git a/materialsystem/shaderapidx9/shaderdevicedx8.cpp b/materialsystem/shaderapidx9/shaderdevicedx8.cpp index db11d217..cdd59c50 100644 --- a/materialsystem/shaderapidx9/shaderdevicedx8.cpp +++ b/materialsystem/shaderapidx9/shaderdevicedx8.cpp @@ -939,6 +939,10 @@ bool CShaderDeviceMgrDx8::ComputeCapsFromD3D( HardwareCaps_t *pCaps, int nAdapte D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16 ) == S_OK ); +#ifdef TOGLES + bSupportsInteger16Textures = caps.SupportInt16Format; +#endif + // Does the device support filterable fp16 textures? bool bSupportsFloat16Textures = ( D3D()->CheckDeviceFormat( nAdapter, DX8_DEVTYPE, @@ -1072,7 +1076,7 @@ bool CShaderDeviceMgrDx8::ComputeCapsFromD3D( HardwareCaps_t *pCaps, int nAdapte else if ( bSupportsIntegerHDR ) pCaps->m_MaxHDRType = HDR_TYPE_INTEGER; - + if ( bSupportsFloatHDR && ( mat_hdr_level.GetInt() == 3 ) ) { pCaps->m_HDRType = HDR_TYPE_FLOAT; diff --git a/public/shaderapi/ishaderdynamic.h b/public/shaderapi/ishaderdynamic.h index b78942d2..d8718c42 100644 --- a/public/shaderapi/ishaderdynamic.h +++ b/public/shaderapi/ishaderdynamic.h @@ -36,8 +36,8 @@ struct LightState_t { int m_nNumLights; bool m_bAmbientLight; + bool m_bStaticLight; bool m_bStaticLightVertex; - bool m_bStaticLightTexel; inline int HasDynamicLight() { return (m_bAmbientLight || (m_nNumLights > 0)) ? 1 : 0; } }; diff --git a/public/togles/linuxwin/dxabstract_types.h b/public/togles/linuxwin/dxabstract_types.h index aa3013f3..37818c2d 100644 --- a/public/togles/linuxwin/dxabstract_types.h +++ b/public/togles/linuxwin/dxabstract_types.h @@ -1339,6 +1339,7 @@ typedef struct _D3DCAPS9 DWORD FakeSRGBWrite; // 1 for parts which can't support SRGB writes due to driver issues - 0 for others DWORD MixedSizeTargets; // 1 for parts which can mix attachment sizes (RT's color vs depth) DWORD CanDoSRGBReadFromRTs; // 0 when we're on Leopard, 1 when on Snow Leopard + DWORD SupportInt16Format; } D3DCAPS9; typedef struct _D3DDISPLAYMODE diff --git a/togles/linuxwin/dxabstract.cpp b/togles/linuxwin/dxabstract.cpp index 5b341395..796ac60e 100644 --- a/togles/linuxwin/dxabstract.cpp +++ b/togles/linuxwin/dxabstract.cpp @@ -1204,6 +1204,7 @@ static void FillD3DCaps9( const GLMRendererInfoFields &glmRendererInfo, D3DCAPS9 pCaps->FakeSRGBWrite = true;//!glmRendererInfo.m_hasGammaWrites; pCaps->CanDoSRGBReadFromRTs = true;//!glmRendererInfo.m_cantAttachSRGB; pCaps->MixedSizeTargets = glmRendererInfo.m_hasMixedAttachmentSizes; + pCaps->SupportInt16Format = gGL->m_bHave_GL_EXT_texture_norm16; #endif }