Browse Source

engine: fix hdr to ldr conversion

sanitize
nillerusr 3 years ago
parent
commit
0feeab91dd
  1. 4
      appframework/sdlmgr.cpp
  2. 2
      engine/cmodel_bsp.cpp
  3. 8
      engine/l_studio.cpp
  4. 12
      engine/modelloader.cpp
  5. 2
      game/client/detailobjectsystem.cpp
  6. 2
      game/client/viewpostprocess.cpp
  7. 8
      game/server/portal/portal_player.cpp
  8. 2
      game/server/server_base.vpc
  9. 6
      materialsystem/shaderapidx9/hardwareconfig.cpp
  10. 11
      materialsystem/shaderapidx9/shaderdevicedx8.cpp
  11. 2
      public/shaderapi/ishaderdynamic.h

4
appframework/sdlmgr.cpp

@ -612,10 +612,10 @@ InitReturnVal_t CSDLMgr::Init() @@ -612,10 +612,10 @@ InitReturnVal_t CSDLMgr::Init()
_eglGetDisplay = (t_eglGetDisplay)dlsym(l_egl, "eglGetDisplay");
_eglQueryString = (t_eglQueryString)dlsym(l_egl, "eglQueryString");
if( _eglInitialize && _eglInitialize && _eglQueryString)
if( _eglInitialize && _eglInitialize && _eglQueryString )
{
EGLDisplay display = _eglGetDisplay(EGL_DEFAULT_DISPLAY);
if( _eglInitialize(display, NULL, NULL) != -1
if( _eglInitialize(display, NULL, NULL) != -1
&& strstr(_eglQueryString(display, EGL_EXTENSIONS) ,"EGL_KHR_gl_colorspace") )
SET_GL_ATTR(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1)
}

2
engine/cmodel_bsp.cpp

@ -1110,7 +1110,7 @@ void CollisionBSPData_LoadDispInfo( CCollisionBSPData *pBSPData ) @@ -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->GetHDREnabled() && /*g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE &&*/
CMapLoadHelper::LumpSize( LUMP_FACES_HDR ) > 0 )
{
face_lump_to_load = LUMP_FACES_HDR;

8
engine/l_studio.cpp

@ -3637,7 +3637,7 @@ void CModelRender::ValidateStaticPropColorData( ModelInstanceHandle_t handle ) @@ -3637,7 +3637,7 @@ void CModelRender::ValidateStaticPropColorData( ModelInstanceHandle_t handle )
// fetch the header
CUtlBuffer utlBuf;
char fileName[MAX_PATH];
if ( g_bBakedPropLightingNoSeparateHDR )
if ( !g_pMaterialSystemHardwareConfig->GetHDREnabled() || g_bBakedPropLightingNoSeparateHDR )
{
Q_snprintf( fileName, sizeof( fileName ), "sp_%d%s.vhv", StaticPropMgr()->GetStaticPropIndex( pProp ), GetPlatformExt() );
}
@ -3930,13 +3930,13 @@ bool CModelRender::LoadStaticPropColorData( IHandleEntity *pProp, DataCacheHandl @@ -3930,13 +3930,13 @@ bool CModelRender::LoadStaticPropColorData( IHandleEntity *pProp, DataCacheHandl
// each static prop has its own compiled color mesh
char fileName[MAX_PATH];
if ( g_bBakedPropLightingNoSeparateHDR )
if ( !g_pMaterialSystemHardwareConfig->GetHDREnabled() || 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
{
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() );
}
// mark as invalid, async callback will set upon completion

12
engine/modelloader.cpp

@ -1038,7 +1038,7 @@ bool Map_CheckForHDR( model_t *pModel, const char *pLoadName ) @@ -1038,7 +1038,7 @@ bool Map_CheckForHDR( model_t *pModel, const char *pLoadName )
}
bool bEnableHDR = ( IsX360() && bHasHDR ) ||
( bHasHDR && ( mat_hdr_level.GetInt() >= 2 ) &&
( bHasHDR &&
( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() >= 90 ) );
EnableHDR( bEnableHDR );
@ -1856,7 +1856,7 @@ void Mod_LoadFaces( void ) @@ -1856,7 +1856,7 @@ void Mod_LoadFaces( void )
int ti, di;
int face_lump_to_load = LUMP_FACES;
if ( CMapLoadHelper::LumpSize( LUMP_FACES_HDR ) > 0 )
if ( g_pMaterialSystemHardwareConfig->GetHDREnabled() && CMapLoadHelper::LumpSize( LUMP_FACES_HDR ) > 0 )
{
face_lump_to_load = LUMP_FACES_HDR;
}
@ -2288,7 +2288,7 @@ void Mod_LoadLeafs( void ) @@ -2288,7 +2288,7 @@ void Mod_LoadLeafs( void )
Mod_LoadLeafs_Version_0( lh );
break;
case 1:
if( CMapLoadHelper::LumpSize( LUMP_LEAF_AMBIENT_LIGHTING_HDR ) > 0 )
if( g_pMaterialSystemHardwareConfig->GetHDREnabled() && CMapLoadHelper::LumpSize( LUMP_LEAF_AMBIENT_LIGHTING_HDR ) > 0 )
{
CMapLoadHelper mlh( LUMP_LEAF_AMBIENT_LIGHTING_HDR );
CMapLoadHelper mlhTable( LUMP_LEAF_AMBIENT_INDEX_HDR );
@ -2383,7 +2383,7 @@ void Mod_LoadCubemapSamples( void ) @@ -2383,7 +2383,7 @@ void Mod_LoadCubemapSamples( void )
lh.GetMap()->m_pCubemapSamples = out;
lh.GetMap()->m_nCubemapSamples = count;
bool bHDR = true; //g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE;
bool bHDR = g_pMaterialSystemHardwareConfig->GetHDREnabled(); //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,
@ -4451,7 +4451,7 @@ void CModelLoader::Map_LoadModel( model_t *mod ) @@ -4451,7 +4451,7 @@ void CModelLoader::Map_LoadModel( model_t *mod )
// Until BSP version 19, this must occur after loading texinfo
COM_TimestampedLog( " Mod_LoadLighting" );
if ( CMapLoadHelper::LumpSize( LUMP_LIGHTING_HDR ) > 0 )
if ( g_pMaterialSystemHardwareConfig->GetHDREnabled() && CMapLoadHelper::LumpSize( LUMP_LIGHTING_HDR ) > 0 )
{
CMapLoadHelper mlh( LUMP_LIGHTING_HDR );
Mod_LoadLighting( mlh );
@ -4543,7 +4543,7 @@ void CModelLoader::Map_LoadModel( model_t *mod ) @@ -4543,7 +4543,7 @@ void CModelLoader::Map_LoadModel( model_t *mod )
&m_worldBrushData.m_nAreas );
COM_TimestampedLog( " Mod_LoadWorldlights" );
if ( CMapLoadHelper::LumpSize( LUMP_WORLDLIGHTS_HDR ) > 0 )
if ( g_pMaterialSystemHardwareConfig->GetHDREnabled() && CMapLoadHelper::LumpSize( LUMP_WORLDLIGHTS_HDR ) > 0 )
{
CMapLoadHelper mlh( LUMP_WORLDLIGHTS_HDR );
Mod_LoadWorldlights( mlh, true );

2
game/client/detailobjectsystem.cpp

@ -1491,7 +1491,7 @@ void CDetailObjectSystem::LevelInitPreEntity() @@ -1491,7 +1491,7 @@ void CDetailObjectSystem::LevelInitPreEntity()
}
int detailPropLightingLump;
if( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE )
if( g_pMaterialSystemHardwareConfig->GetHDREnabled() )
{
detailPropLightingLump = GAMELUMP_DETAIL_PROP_LIGHTING_HDR;
}

2
game/client/viewpostprocess.cpp

@ -1460,7 +1460,7 @@ static float GetBloomAmount( void ) @@ -1460,7 +1460,7 @@ static float GetBloomAmount( void )
if ( hdrType == HDR_TYPE_NONE )
{
flBloomAmount *= mat_non_hdr_bloom_scalefactor.GetFloat();
flBloomAmount *= mat_non_hdr_bloom_scalefactor.GetFloat()/2.f;
}
flBloomAmount *= mat_bloom_scalefactor_scalar.GetFloat();

8
game/server/portal/portal_player.cpp

@ -549,15 +549,15 @@ void CPortal_Player::UpdateExpression( void ) @@ -549,15 +549,15 @@ void CPortal_Player::UpdateExpression( void )
GetExpresser()->SetOuter( this );
ClearExpression();
AI_Response response;
bool result = SpeakFindResponse( response, g_pszChellConcepts[iConcept] );
if ( !result )
AI_Response *response = SpeakFindResponse( g_pszChellConcepts[iConcept] );
if ( !response )
{
m_flExpressionLoopTime = gpGlobals->curtime + RandomFloat(30,40);
return;
}
char const *szScene = response.GetResponsePtr();
char const szScene[256];
response->GetResponse( szScene, sizeof(szScene) );
// Ignore updates that choose the same scene
if ( m_iszExpressionScene != NULL_STRING && stricmp( STRING(m_iszExpressionScene), szScene ) == 0 )

2
game/server/server_base.vpc

@ -52,7 +52,7 @@ $Configuration @@ -52,7 +52,7 @@ $Configuration
$Compiler
{
$AdditionalIncludeDirectories "$BASE;.\;$SRCDIR\game\shared;$SRCDIR\utils\common;$SRCDIR\game\shared\econ;$SRCDIR\game\server\NextBot"
$PreprocessorDefinitions "$BASE;GAME_DLL;VECTOR;VERSION_SAFE_STEAM_API_INTERFACES;PROTECTED_THINGS_ENABLE;sprintf=use_Q_snprintf_instead_of_sprintf;strncpy=use_Q_strncpy_instead;_snprintf=use_Q_snprintf_instead"
$PreprocessorDefinitions "$BASE;GAME_DLL;VECTOR;VERSION_SAFE_STEAM_API_INTERFACES;PROTECTED_THINGS_ENABLE;strncpy=use_Q_strncpy_instead;_snprintf=use_Q_snprintf_instead"
$PreprocessorDefinitions "$BASE;SWDS" [$POSIX]
$PreprocessorDefinitions "$BASE;fopen=dont_use_fopen" [$WINDOWS||$X360]
$Create/UsePrecompiledHeader "Use Precompiled Header (/Yu)"

6
materialsystem/shaderapidx9/hardwareconfig.cpp

@ -24,6 +24,8 @@ @@ -24,6 +24,8 @@
static CHardwareConfig s_HardwareConfig;
CHardwareConfig *g_pHardwareConfig = &s_HardwareConfig;
extern ConVar mat_hdr_level;
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CHardwareConfig, IMaterialSystemHardwareConfig,
MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION, s_HardwareConfig )
@ -1238,12 +1240,12 @@ int CHardwareConfig::GetMaxVertexTextureDimension() const @@ -1238,12 +1240,12 @@ int CHardwareConfig::GetMaxVertexTextureDimension() const
HDRType_t CHardwareConfig::GetHDRType() const
{
bool enabled = m_bHDREnabled;
bool enabled = (mat_hdr_level.GetInt() >= 2) && GetHDREnabled();
int dxlev = GetDXSupportLevel();
int dxsupp = dxlev >= 90;
HDRType_t caps_hdr = m_Caps.m_HDRType;
HDRType_t result = HDR_TYPE_NONE;
//printf("\nCHardwareConfig::GetHDRType...");
if (enabled)
{

11
materialsystem/shaderapidx9/shaderdevicedx8.cpp

@ -939,10 +939,6 @@ bool CShaderDeviceMgrDx8::ComputeCapsFromD3D( HardwareCaps_t *pCaps, int nAdapte @@ -939,10 +939,6 @@ 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,
@ -1051,6 +1047,11 @@ bool CShaderDeviceMgrDx8::ComputeCapsFromD3D( HardwareCaps_t *pCaps, int nAdapte @@ -1051,6 +1047,11 @@ bool CShaderDeviceMgrDx8::ComputeCapsFromD3D( HardwareCaps_t *pCaps, int nAdapte
}
}
#ifdef TOGLES
bSupportsInteger16Textures = caps.SupportInt16Format;
#endif
// Do we have everything necessary to run with integer HDR? Note that
// even if we don't support integer 16-bit/component textures, we
// can still run in this mode if fp16 textures are supported.
@ -1058,7 +1059,7 @@ bool CShaderDeviceMgrDx8::ComputeCapsFromD3D( HardwareCaps_t *pCaps, int nAdapte @@ -1058,7 +1059,7 @@ bool CShaderDeviceMgrDx8::ComputeCapsFromD3D( HardwareCaps_t *pCaps, int nAdapte
pCaps->m_SupportsVertexShaders_2_0 &&
// (caps.Caps3 & D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD) &&
// (caps.PrimitiveMiscCaps & D3DPMISCCAPS_SEPARATEALPHABLEND) &&
( bSupportsInteger16Textures || bSupportsFloat16Textures ) &&
bSupportsInteger16Textures &&
pCaps->m_SupportsSRGB;
// Do we have everything necessary to run with float HDR?

2
public/shaderapi/ishaderdynamic.h

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

Loading…
Cancel
Save