mirror of
https://github.com/celisej567/source-engine.git
synced 2026-01-03 05:49:41 +03:00
fix address sanitizer issues #2
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
class CMaterial_QueueFriendly : public IMaterialInternal //wraps a CMaterial with queue friendly functions for game/engine code. materialsystem/shaderapi code should use CMaterial directly.
|
||||
{
|
||||
public:
|
||||
CMaterial_QueueFriendly() : m_pRealTimeVersion(NULL) {}
|
||||
|
||||
virtual const char * GetName() const;
|
||||
virtual const char * GetTextureGroupName() const;
|
||||
virtual PreviewImageRetVal_t GetPreviewImageProperties( int *width, int *height, ImageFormat *imageFormat, bool* isTranslucent ) const;
|
||||
|
||||
@@ -6301,27 +6301,16 @@ int CShaderAPIDx8::GetCurrentDynamicVBSize( void )
|
||||
|
||||
FORCEINLINE void CShaderAPIDx8::SetVertexShaderConstantInternal( int var, float const* pVec, int numVecs, bool bForce )
|
||||
{
|
||||
Assert( numVecs > 0 );
|
||||
Assert( pVec );
|
||||
|
||||
// DX8 asm shaders use a constant mapping which has transforms and vertex shader
|
||||
// specific constants shifted down by 10 constants (two 5-constant light structures)
|
||||
if ( IsPC() )
|
||||
if ( IsPC() || IsPS3() )
|
||||
{
|
||||
if ( (g_pHardwareConfig->Caps().m_nDXSupportLevel < 90) && (var >= VERTEX_SHADER_MODULATION_COLOR) )
|
||||
{
|
||||
var -= 10;
|
||||
}
|
||||
Assert( var + numVecs <= g_pHardwareConfig->NumVertexShaderConstants() );
|
||||
|
||||
if ( !bForce )
|
||||
{
|
||||
int skip = 0;
|
||||
numVecs = AdjustUpdateRange( pVec, &m_DesiredState.m_pVectorVertexShaderConstant[var], numVecs, &skip );
|
||||
if ( !numVecs )
|
||||
return;
|
||||
var += skip;
|
||||
pVec += skip * 4;
|
||||
}
|
||||
if ( !bForce && memcmp( pVec, &m_DynamicState.m_pVectorVertexShaderConstant[var], numVecs * 4 * sizeof( float ) ) == 0 )
|
||||
return;
|
||||
|
||||
Dx9Device()->SetVertexShaderConstantF( var, pVec, numVecs );
|
||||
memcpy( &m_DynamicState.m_pVectorVertexShaderConstant[var], pVec, numVecs * 4 * sizeof(float) );
|
||||
}
|
||||
@@ -6330,12 +6319,10 @@ FORCEINLINE void CShaderAPIDx8::SetVertexShaderConstantInternal( int var, float
|
||||
Assert( var + numVecs <= g_pHardwareConfig->NumVertexShaderConstants() );
|
||||
}
|
||||
|
||||
memcpy( &m_DesiredState.m_pVectorVertexShaderConstant[var], pVec, numVecs * 4 * sizeof(float) );
|
||||
if ( IsX360() && var + numVecs > m_MaxVectorVertexShaderConstant )
|
||||
m_MaxVectorVertexShaderConstant = var + numVecs;
|
||||
|
||||
if ( IsX360() )
|
||||
{
|
||||
m_MaxVectorVertexShaderConstant = max( m_MaxVectorVertexShaderConstant, var + numVecs );
|
||||
}
|
||||
memcpy( &m_DesiredState.m_pVectorVertexShaderConstant[var], pVec, numVecs * 4 * sizeof(float) );
|
||||
}
|
||||
|
||||
|
||||
@@ -6417,29 +6404,40 @@ FORCEINLINE void CShaderAPIDx8::SetPixelShaderConstantInternal( int nStartConst,
|
||||
{
|
||||
Assert( nStartConst + nNumConsts <= g_pHardwareConfig->NumPixelShaderConstants() );
|
||||
|
||||
if ( IsPC() )
|
||||
if ( IsPC() || IsPS3() )
|
||||
{
|
||||
if ( ! bForce )
|
||||
if ( !bForce )
|
||||
{
|
||||
int skip = 0;
|
||||
nNumConsts = AdjustUpdateRange( pValues, &m_DesiredState.m_pVectorPixelShaderConstant[nStartConst], nNumConsts, &skip );
|
||||
DWORD* pSrc = (DWORD*)pValues;
|
||||
DWORD* pDst = (DWORD*)&m_DesiredState.m_pVectorPixelShaderConstant[nStartConst];
|
||||
while( nNumConsts && ( pSrc[0] == pDst[0] ) && ( pSrc[1] == pDst[1] ) && ( pSrc[2] == pDst[2] ) && ( pSrc[3] == pDst[3] ) )
|
||||
{
|
||||
pSrc += 4;
|
||||
pDst += 4;
|
||||
nNumConsts--;
|
||||
nStartConst++;
|
||||
}
|
||||
if ( !nNumConsts )
|
||||
return;
|
||||
nStartConst += skip;
|
||||
pValues += skip * 4;
|
||||
pValues = reinterpret_cast< float const * >( pSrc );
|
||||
}
|
||||
|
||||
Dx9Device()->SetPixelShaderConstantF( nStartConst, pValues, nNumConsts );
|
||||
memcpy( &m_DynamicState.m_pVectorPixelShaderConstant[nStartConst], pValues, nNumConsts * 4 * sizeof(float) );
|
||||
}
|
||||
|
||||
memcpy( &m_DesiredState.m_pVectorPixelShaderConstant[nStartConst], pValues, nNumConsts * 4 * sizeof(float) );
|
||||
|
||||
if ( IsX360() )
|
||||
if ( IsX360() && nStartConst + nNumConsts > m_MaxVectorPixelShaderConstant )
|
||||
{
|
||||
m_MaxVectorPixelShaderConstant = max( m_MaxVectorPixelShaderConstant, nStartConst + nNumConsts );
|
||||
m_MaxVectorPixelShaderConstant = nStartConst + nNumConsts;
|
||||
Assert( m_MaxVectorPixelShaderConstant <= 32 );
|
||||
if ( m_MaxVectorPixelShaderConstant > 32 )
|
||||
{
|
||||
// NOTE! There really are 224 pixel shader constants on the 360, but we do an optimization that only blasts the first 32 always.
|
||||
Error( "Don't use more then the first 32 pixel shader constants on the 360!" );
|
||||
}
|
||||
}
|
||||
|
||||
memcpy( &m_DesiredState.m_pVectorPixelShaderConstant[nStartConst], pValues, nNumConsts * 4 * sizeof(float) );
|
||||
}
|
||||
|
||||
void CShaderAPIDx8::SetPixelShaderConstant( int var, float const* pVec, int numVecs, bool bForce )
|
||||
|
||||
@@ -562,7 +562,7 @@ void CShaderDeviceMgrDx8::CheckVendorDependentAlphaToCoverage( HardwareCaps_t *p
|
||||
ConVar mat_hdr_level( "mat_hdr_level", "2", FCVAR_ARCHIVE );
|
||||
ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT );
|
||||
#ifdef DX_TO_GL_ABSTRACTION
|
||||
ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "20", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
|
||||
ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "40", FCVAR_CHEAT );
|
||||
#else
|
||||
ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.0005", FCVAR_CHEAT );
|
||||
#endif
|
||||
|
||||
@@ -198,7 +198,7 @@ BEGIN_VS_SHADER_FLAGS( DepthWrite, "Help for Depth Write", SHADER_NOT_EDITABLE )
|
||||
vParms.y = 4000.0f; // arbitrary far
|
||||
vParms.z = 0.0f;
|
||||
vParms.w = 0.0f;
|
||||
pShaderAPI->SetPixelShaderConstant( 1, vParms.Base(), 2 );
|
||||
pShaderAPI->SetPixelShaderConstant( 1, vParms.Base(), 1 );
|
||||
|
||||
} // DYNAMIC_STATE
|
||||
|
||||
|
||||
@@ -132,15 +132,16 @@ BEGIN_VS_SHADER_FLAGS( ParticleSphere_DX9, "Help for BumpmappedEnvMap", SHADER_N
|
||||
// (It does this by seeing if the intensity*1/distSqr is > 1. If so, then it scales it so
|
||||
// it is equal to 1).
|
||||
const float *f = params[LIGHT_COLOR]->GetVecValue();
|
||||
Vector vLightColor( f[0], f[1], f[2] );
|
||||
Vector4D vLightColor( f[0], f[1], f[2], 0.f );
|
||||
float flScale = max( vLightColor.x, max( vLightColor.y, vLightColor.z ) );
|
||||
if ( flScale < 0.01f )
|
||||
flScale = 0.01f;
|
||||
float vScaleVec[3] = { flScale, flScale, flScale };
|
||||
|
||||
Vector4D vScaleVec = { flScale, flScale, flScale, 0.f };
|
||||
vLightColor /= flScale;
|
||||
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_1, vLightColor.Base() );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, vScaleVec );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, vScaleVec.Base() );
|
||||
|
||||
pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user