Merge branch 'master' into windows

This commit is contained in:
HappyDOGE
2022-07-27 12:58:56 +03:00
3089 changed files with 38639 additions and 844820 deletions
@@ -237,7 +237,7 @@ EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CVBAllocTracker, IVBAllocTracker,
UtlHashFixedHandle_t CVBAllocTracker::TrackAlloc( void * buffer, int bufferSize, VertexFormat_t fmt, int numVerts, short allocatorHash )
{
AllocData newData( buffer, bufferSize, fmt, numVerts, allocatorHash );
UtlHashFixedHandle_t handle = m_VBAllocTable.Insert( (int)buffer, newData );
UtlHashFixedHandle_t handle = m_VBAllocTable.Insert( (intp)buffer, newData );
if ( handle == m_VBAllocTable.InvalidHandle() )
{
Warning( "[VBMEM] VBMemAllocTable hash collision (grow table).\n" );
@@ -247,7 +247,7 @@ UtlHashFixedHandle_t CVBAllocTracker::TrackAlloc( void * buffer, int bufferSize,
bool CVBAllocTracker::KillAlloc( void * buffer, int & bufferSize, VertexFormat_t & fmt, int & numVerts, short & allocatorHash )
{
UtlHashFixedHandle_t handle = m_VBAllocTable.Find( (int)buffer );
UtlHashFixedHandle_t handle = m_VBAllocTable.Find( (intp)buffer );
if ( handle != m_VBAllocTable.InvalidHandle() )
{
AllocData & data = m_VBAllocTable.Element( handle );
@@ -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
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)
{
+5 -3
View File
@@ -12,6 +12,8 @@
#pragma once
#endif
#include "tier0/platform.h"
#if defined( DX10 ) && !defined( DX_TO_GL_ABSTRACTION )
#include <d3d10.h>
@@ -113,13 +115,13 @@ typedef void *HardwareShader_t;
//-----------------------------------------------------------------------------
// The vertex and pixel shader type
//-----------------------------------------------------------------------------
typedef int VertexShader_t;
typedef int PixelShader_t;
typedef intp VertexShader_t;
typedef intp PixelShader_t;
//-----------------------------------------------------------------------------
// Bitpattern for an invalid shader
//-----------------------------------------------------------------------------
#define INVALID_SHADER ( 0xFFFFFFFF )
#define INVALID_SHADER (-1) // ( 0xFFFFFFFF )
#define INVALID_HARDWARE_SHADER ( NULL )
#define D3DSAMP_NOTSUPPORTED D3DSAMP_FORCE_DWORD
+31 -33
View File
@@ -42,7 +42,6 @@ mat_fullbright 1 doesn't work properly on alpha materials in testroom_standards
#include "colorformatdx8.h"
#include "texturedx8.h"
#include "textureheap.h"
#include <malloc.h>
#include "interface.h"
#include "utlrbtree.h"
#include "utlsymbol.h"
@@ -3499,7 +3498,8 @@ void CShaderAPIDx8::ResetRenderState( bool bFullReset )
SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
// No shade mode yet
m_DynamicState.m_ShadeMode = (D3DSHADEMODE)NULL;
const D3DSHADEMODE D3DSHADE_NONE = (D3DSHADEMODE)0;
m_DynamicState.m_ShadeMode = D3DSHADE_NONE;
ShadeMode( SHADER_SMOOTH );
m_DynamicState.m_bHWMorphingEnabled = false;
@@ -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 )
@@ -184,7 +184,7 @@ protected:
int m_nWindowWidth;
int m_nWindowHeight;
uint32 m_dwThreadId;
uintp m_dwThreadId;
};
@@ -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
@@ -1047,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.
@@ -1054,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?
@@ -1072,7 +1077,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;
+14 -14
View File
@@ -163,15 +163,10 @@ static FILE *GetDebugFileHandle( void )
// mat_autosave_glshaders instructs the engine to save out the shader table at key points
// to the filename glshaders.cfg
//
#ifdef ANDROID
ConVar mat_autosave_glshaders( "mat_autosave_glshaders", "0" );
ConVar mat_autoload_glshaders( "mat_autoload_glshaders", "0" );
#else
ConVar mat_autosave_glshaders( "mat_autosave_glshaders", "1" );
ConVar mat_autoload_glshaders( "mat_autoload_glshaders", "1" );
#endif
#endif
//-----------------------------------------------------------------------------
// Explicit instantiation of shader buffer implementation
//-----------------------------------------------------------------------------
@@ -620,7 +615,7 @@ private:
ShaderStaticCombos_t m_ShaderStaticCombos;
DWORD m_Flags;
int m_nRefCount;
unsigned int m_hShaderFileCache;
uintp m_hShaderFileCache;
// for queued loading, bias an aligned optimal buffer forward to correct location
int m_nDataOffset;
@@ -943,7 +938,8 @@ void CShaderManager::Shutdown()
}
#endif
#ifdef DX_TO_GL_ABSTRACTION
#if defined (DX_TO_GL_ABSTRACTION) && !defined (ANDROID)
if (mat_autosave_glshaders.GetInt())
{
SaveShaderCache("glshaders.cfg");
@@ -1021,7 +1017,7 @@ void CShaderManager::DestroyVertexShader( VertexShaderHandle_t hShader )
if ( hShader == VERTEX_SHADER_HANDLE_INVALID )
return;
VertexShaderIndex_t i = (VertexShaderIndex_t)hShader;
VertexShaderIndex_t i = (VertexShaderIndex_t)(uintp)hShader;
IDirect3DVertexShader9 *pVertexShader = m_RawVertexShaderDict[ i ];
UnregisterVS( pVertexShader );
@@ -1057,7 +1053,7 @@ void CShaderManager::DestroyPixelShader( PixelShaderHandle_t hShader )
if ( hShader == PIXEL_SHADER_HANDLE_INVALID )
return;
PixelShaderIndex_t i = (PixelShaderIndex_t)hShader;
PixelShaderIndex_t i = (PixelShaderIndex_t)(uintp)hShader;
IDirect3DPixelShader9 *pPixelShader = m_RawPixelShaderDict[ i ];
UnregisterPS( pPixelShader );
@@ -2526,7 +2522,7 @@ bool CShaderManager::LoadAndCreateShaders( ShaderLookup_t &lookup, bool bVertexS
ShaderFileCache_t fileCacheLookup;
fileCacheLookup.m_Name = lookup.m_Name;
fileCacheLookup.m_bVertexShader = bVertexShader;
int fileCacheIndex = m_ShaderFileCache.Find( fileCacheLookup );
intp fileCacheIndex = m_ShaderFileCache.Find( fileCacheLookup );
if ( fileCacheIndex == m_ShaderFileCache.InvalidIndex() )
{
// not found, create a new entry
@@ -3290,7 +3286,7 @@ void CShaderManager::SetVertexShaderState( HardwareShader_t shader, DataCacheHan
void CShaderManager::BindVertexShader( VertexShaderHandle_t hVertexShader )
{
HardwareShader_t hHardwareShader = m_RawVertexShaderDict[ (VertexShaderIndex_t)hVertexShader] ;
HardwareShader_t hHardwareShader = m_RawVertexShaderDict[ (VertexShaderIndex_t)(uintp)hVertexShader] ;
SetVertexShaderState( hHardwareShader );
}
@@ -3399,7 +3395,7 @@ void CShaderManager::SetPixelShaderState( HardwareShader_t shader, DataCacheHand
void CShaderManager::BindPixelShader( PixelShaderHandle_t hPixelShader )
{
HardwareShader_t hHardwareShader = m_RawPixelShaderDict[ (PixelShaderIndex_t)hPixelShader ];
HardwareShader_t hHardwareShader = m_RawPixelShaderDict[ (PixelShaderIndex_t)(uintp)hPixelShader ];
SetPixelShaderState( hHardwareShader );
}
@@ -3598,7 +3594,7 @@ void CShaderManager::SpewVertexAndPixelShaders( void )
{
// only spew a populated shader file cache
Msg( "\nShader File Cache:\n" );
for ( int cacheIndex = m_ShaderFileCache.Head();
for ( intp cacheIndex = m_ShaderFileCache.Head();
cacheIndex != m_ShaderFileCache.InvalidIndex();
cacheIndex = m_ShaderFileCache.Next( cacheIndex ) )
{
@@ -3757,6 +3753,10 @@ CON_COMMAND( mat_shadercount, "display count of all shaders and reset that count
#if defined( DX_TO_GL_ABSTRACTION )
void CShaderManager::DoStartupShaderPreloading()
{
#ifdef ANDROID // Too slow
return;
#endif
if (mat_autoload_glshaders.GetInt())
{
double flStartTime = Plat_FloatTime();
+1 -1
View File
@@ -14,7 +14,7 @@
#include <comdef.h>
#pragma warning( disable : 4127 ) // VS 2010 warning?
#pragma warning( disable : 4805 ) // VS 2013 warning: warning C4805: '==' : unsafe mix of type 'INT' and type 'bool' in operation
#include <atlcomtime.h>
// #include <atlcomtime.h>
#pragma warning( default : 4805 )
#pragma warning( default : 4127 )
#include <wbemidl.h>