engine: hdr to ldr conversion for HDR_TYPE_NONE

This commit is contained in:
nillerusr 2022-03-26 03:24:41 +03:00
parent 312fdb9576
commit 24366ef9a8
9 changed files with 22 additions and 20 deletions

View File

@ -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++ ) for( i = 0; i < pWorldModel->brush.pShared->m_nCubemapSamples; i++ )
{ {
@ -1080,7 +1080,7 @@ void R_BuildCubemapSamples( int numIterations )
return; 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 ); iBSPPack->LoadBSPFile( g_pFileSystem, cl.m_szLevelFileName );

View File

@ -1110,7 +1110,7 @@ void CollisionBSPData_LoadDispInfo( CCollisionBSPData *pBSPData )
// get face data // get face data
// //
int face_lump_to_load = LUMP_FACES; 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 ) CMapLoadHelper::LumpSize( LUMP_FACES_HDR ) > 0 )
{ {
face_lump_to_load = LUMP_FACES_HDR; face_lump_to_load = LUMP_FACES_HDR;

View File

@ -3637,12 +3637,12 @@ void CModelRender::ValidateStaticPropColorData( ModelInstanceHandle_t handle )
// fetch the header // fetch the header
CUtlBuffer utlBuf; CUtlBuffer utlBuf;
char fileName[MAX_PATH]; 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() ); Q_snprintf( fileName, sizeof( fileName ), "sp_%d%s.vhv", StaticPropMgr()->GetStaticPropIndex( pProp ), GetPlatformExt() );
} }
else else
{ {
Q_snprintf( fileName, sizeof( fileName ), "sp_hdr_%d%s.vhv", StaticPropMgr()->GetStaticPropIndex( pProp ), GetPlatformExt() ); 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 // each static prop has its own compiled color mesh
char fileName[MAX_PATH]; 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() ); Q_snprintf( fileName, sizeof( fileName ), "sp_%d%s.vhv", StaticPropMgr()->GetStaticPropIndex( pProp ), GetPlatformExt() );
} }

View File

@ -1856,8 +1856,7 @@ void Mod_LoadFaces( void )
int ti, di; int ti, di;
int face_lump_to_load = LUMP_FACES; int face_lump_to_load = LUMP_FACES;
if ( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE && if ( CMapLoadHelper::LumpSize( LUMP_FACES_HDR ) > 0 )
CMapLoadHelper::LumpSize( LUMP_FACES_HDR ) > 0 )
{ {
face_lump_to_load = LUMP_FACES_HDR; face_lump_to_load = LUMP_FACES_HDR;
} }
@ -2289,8 +2288,7 @@ void Mod_LoadLeafs( void )
Mod_LoadLeafs_Version_0( lh ); Mod_LoadLeafs_Version_0( lh );
break; break;
case 1: case 1:
if( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE && if( CMapLoadHelper::LumpSize( LUMP_LEAF_AMBIENT_LIGHTING_HDR ) > 0 )
CMapLoadHelper::LumpSize( LUMP_LEAF_AMBIENT_LIGHTING_HDR ) > 0 )
{ {
CMapLoadHelper mlh( LUMP_LEAF_AMBIENT_LIGHTING_HDR ); CMapLoadHelper mlh( LUMP_LEAF_AMBIENT_LIGHTING_HDR );
CMapLoadHelper mlhTable( LUMP_LEAF_AMBIENT_INDEX_HDR ); CMapLoadHelper mlhTable( LUMP_LEAF_AMBIENT_INDEX_HDR );
@ -2385,7 +2383,7 @@ void Mod_LoadCubemapSamples( void )
lh.GetMap()->m_pCubemapSamples = out; lh.GetMap()->m_pCubemapSamples = out;
lh.GetMap()->m_nCubemapSamples = count; 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; int nCreateFlags = bHDR ? 0 : TEXTUREFLAGS_SRGB;
// We have separate HDR versions of the textures. In order to deal with this, // 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 // Until BSP version 19, this must occur after loading texinfo
COM_TimestampedLog( " Mod_LoadLighting" ); COM_TimestampedLog( " Mod_LoadLighting" );
if ( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE && if ( CMapLoadHelper::LumpSize( LUMP_LIGHTING_HDR ) > 0 )
CMapLoadHelper::LumpSize( LUMP_LIGHTING_HDR ) > 0 )
{ {
CMapLoadHelper mlh( LUMP_LIGHTING_HDR ); CMapLoadHelper mlh( LUMP_LIGHTING_HDR );
Mod_LoadLighting( mlh ); Mod_LoadLighting( mlh );
@ -4546,8 +4543,7 @@ void CModelLoader::Map_LoadModel( model_t *mod )
&m_worldBrushData.m_nAreas ); &m_worldBrushData.m_nAreas );
COM_TimestampedLog( " Mod_LoadWorldlights" ); COM_TimestampedLog( " Mod_LoadWorldlights" );
if ( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE && if ( CMapLoadHelper::LumpSize( LUMP_WORLDLIGHTS_HDR ) > 0 )
CMapLoadHelper::LumpSize( LUMP_WORLDLIGHTS_HDR ) > 0 )
{ {
CMapLoadHelper mlh( LUMP_WORLDLIGHTS_HDR ); CMapLoadHelper mlh( LUMP_WORLDLIGHTS_HDR );
Mod_LoadWorldlights( mlh, true ); Mod_LoadWorldlights( mlh, true );

View File

@ -1177,7 +1177,7 @@ bool CMaterial::ShouldSkipVar( KeyValues *pVar, bool *pWasConditional )
} }
else if ( ! stricmp( pCond, "hdr" ) ) else if ( ! stricmp( pCond, "hdr" ) )
{ {
bShouldSkip = ( HardwareConfig()->GetHDRType() == HDR_TYPE_NONE ); bShouldSkip = false; //( HardwareConfig()->GetHDRType() == HDR_TYPE_NONE );
} }
else if ( ! stricmp( pCond, "srgb" ) ) else if ( ! stricmp( pCond, "srgb" ) )
{ {
@ -1400,7 +1400,7 @@ static KeyValues *FindBuiltinFallbackBlock( char const *pShaderName, KeyValues *
if ( pRet ) if ( pRet )
return pRet; return pRet;
} }
if ( HardwareConfig()->GetHDRType() != HDR_TYPE_NONE ) // if ( HardwareConfig()->GetHDRType() != HDR_TYPE_NONE )
{ {
KeyValues *pRet = CheckConditionalFakeShaderName( pShaderName,"hdr_dx9", pKeyValues ); KeyValues *pRet = CheckConditionalFakeShaderName( pShaderName,"hdr_dx9", pKeyValues );
if ( pRet ) if ( pRet )
@ -1409,7 +1409,7 @@ static KeyValues *FindBuiltinFallbackBlock( char const *pShaderName, KeyValues *
if ( pRet ) if ( pRet )
return pRet; return pRet;
} }
else if( HardwareConfig()->GetHDRType() == HDR_TYPE_NONE )
{ {
KeyValues *pRet = CheckConditionalFakeShaderName( pShaderName,"ldr", pKeyValues ); KeyValues *pRet = CheckConditionalFakeShaderName( pShaderName,"ldr", pKeyValues );
if ( pRet ) if ( pRet )

View File

@ -939,6 +939,10 @@ bool CShaderDeviceMgrDx8::ComputeCapsFromD3D( HardwareCaps_t *pCaps, int nAdapte
D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_FILTER, D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_FILTER,
D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16 ) == S_OK ); D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16 ) == S_OK );
#ifdef TOGLES
bSupportsInteger16Textures = caps.SupportInt16Format;
#endif
// Does the device support filterable fp16 textures? // Does the device support filterable fp16 textures?
bool bSupportsFloat16Textures = bool bSupportsFloat16Textures =
( D3D()->CheckDeviceFormat( nAdapter, DX8_DEVTYPE, ( D3D()->CheckDeviceFormat( nAdapter, DX8_DEVTYPE,
@ -1072,7 +1076,7 @@ bool CShaderDeviceMgrDx8::ComputeCapsFromD3D( HardwareCaps_t *pCaps, int nAdapte
else else
if ( bSupportsIntegerHDR ) if ( bSupportsIntegerHDR )
pCaps->m_MaxHDRType = HDR_TYPE_INTEGER; pCaps->m_MaxHDRType = HDR_TYPE_INTEGER;
if ( bSupportsFloatHDR && ( mat_hdr_level.GetInt() == 3 ) ) if ( bSupportsFloatHDR && ( mat_hdr_level.GetInt() == 3 ) )
{ {
pCaps->m_HDRType = HDR_TYPE_FLOAT; pCaps->m_HDRType = HDR_TYPE_FLOAT;

View File

@ -36,8 +36,8 @@ struct LightState_t
{ {
int m_nNumLights; int m_nNumLights;
bool m_bAmbientLight; bool m_bAmbientLight;
bool m_bStaticLight;
bool m_bStaticLightVertex; bool m_bStaticLightVertex;
bool m_bStaticLightTexel;
inline int HasDynamicLight() { return (m_bAmbientLight || (m_nNumLights > 0)) ? 1 : 0; } inline int HasDynamicLight() { return (m_bAmbientLight || (m_nNumLights > 0)) ? 1 : 0; }
}; };

View File

@ -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 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 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 CanDoSRGBReadFromRTs; // 0 when we're on Leopard, 1 when on Snow Leopard
DWORD SupportInt16Format;
} D3DCAPS9; } D3DCAPS9;
typedef struct _D3DDISPLAYMODE typedef struct _D3DDISPLAYMODE

View File

@ -1204,6 +1204,7 @@ static void FillD3DCaps9( const GLMRendererInfoFields &glmRendererInfo, D3DCAPS9
pCaps->FakeSRGBWrite = true;//!glmRendererInfo.m_hasGammaWrites; pCaps->FakeSRGBWrite = true;//!glmRendererInfo.m_hasGammaWrites;
pCaps->CanDoSRGBReadFromRTs = true;//!glmRendererInfo.m_cantAttachSRGB; pCaps->CanDoSRGBReadFromRTs = true;//!glmRendererInfo.m_cantAttachSRGB;
pCaps->MixedSizeTargets = glmRendererInfo.m_hasMixedAttachmentSizes; pCaps->MixedSizeTargets = glmRendererInfo.m_hasMixedAttachmentSizes;
pCaps->SupportInt16Format = gGL->m_bHave_GL_EXT_texture_norm16;
#endif #endif
} }