mirror of
https://github.com/celisej567/source-engine.git
synced 2025-12-31 21:48:22 +03:00
Compare commits
16 Commits
musl-port
...
shaderapig
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5a0314f33 | ||
|
|
523f4e9eaa | ||
|
|
697a9f34f9 | ||
|
|
3b1b08fd93 | ||
|
|
271c9993da | ||
|
|
1a584655d9 | ||
|
|
965ef97212 | ||
|
|
30f1e02cda | ||
|
|
657f59ada3 | ||
|
|
e3edbc2d96 | ||
|
|
7ceba77616 | ||
|
|
823e437005 | ||
|
|
a63138347b | ||
|
|
852f4052be | ||
|
|
38fdbf18c2 | ||
|
|
d9eacc4db7 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -37,5 +37,3 @@ waf3*/
|
||||
.vscode/
|
||||
.depproj/
|
||||
source-engine.sln
|
||||
hl2/
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ CAI_PolicingBehavior::CAI_PolicingBehavior( void )
|
||||
m_bEnabled = false;
|
||||
m_nNumWarnings = 0;
|
||||
m_bTargetIsHostile = false;
|
||||
m_hPoliceGoal = NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -43,17 +43,8 @@ def build(bld):
|
||||
|
||||
if bld.env.DEST_OS == 'win32':
|
||||
libs += ['USER32']
|
||||
|
||||
install_path = bld.env.LIBDIR
|
||||
|
||||
# Copy SDL2 dependency
|
||||
if bld.env.DEST_OS == 'win32':
|
||||
bld(
|
||||
rule=(('cp' if 'MSYSTEM' in os.environ or sys.platform != 'win32' else 'copy')+' ${SRC} ${TGT}'),
|
||||
source='../lib/win32/'+bld.env.DEST_CPU+'/SDL2.dll',
|
||||
target='SDL2.dll',
|
||||
install_path=install_path,
|
||||
)
|
||||
install_path = bld.env.LIBDIR
|
||||
|
||||
bld.shlib(
|
||||
source = source,
|
||||
|
||||
@@ -752,6 +752,12 @@ bool CSourceAppSystemGroup::Create()
|
||||
// Load up the appropriate shader DLL
|
||||
// This has to be done before connection.
|
||||
char const* pDLLName = "shaderapidx9" DLL_EXT_STRING;
|
||||
|
||||
if ( CommandLine()->FindParm( "-gl" ) )
|
||||
{
|
||||
pDLLName = "shaderapigl" DLL_EXT_STRING;
|
||||
}
|
||||
|
||||
if ( CommandLine()->FindParm( "-noshaderapi" ) )
|
||||
{
|
||||
pDLLName = "shaderapiempty" DLL_EXT_STRING;
|
||||
|
||||
@@ -31,9 +31,9 @@ public:
|
||||
{
|
||||
MEM_ALLOC_CREDIT_( "CMatCallQueue.m_Allocator" );
|
||||
#ifdef SWDS
|
||||
m_Allocator.Init( 2*1024, 0, 0, 4 );
|
||||
m_Allocator.Init( 2*1024, 0, 0, 16 );
|
||||
#else
|
||||
m_Allocator.Init( IsX360() ? 2*1024*1024 : 8*1024*1024, 64*1024, 256*1024, 4 );
|
||||
m_Allocator.Init( IsX360() ? 2*1024*1024 : 8*1024*1024, 64*1024, 256*1024, 16 );
|
||||
#endif
|
||||
m_FunctorFactory.SetAllocator( &m_Allocator );
|
||||
m_pHead = m_pTail = NULL;
|
||||
|
||||
171
materialsystem/shaderapigl/meshgl.cpp
Normal file
171
materialsystem/shaderapigl/meshgl.cpp
Normal file
@@ -0,0 +1,171 @@
|
||||
#include "meshgl.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// The empty mesh...
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
CGLMesh::CGLMesh( bool bIsDynamic ) : m_bIsDynamic( bIsDynamic )
|
||||
{
|
||||
m_pVertexMemory = new unsigned char[VERTEX_BUFFER_SIZE];
|
||||
}
|
||||
|
||||
CGLMesh::~CGLMesh()
|
||||
{
|
||||
delete[] m_pVertexMemory;
|
||||
}
|
||||
|
||||
bool CGLMesh::Lock( int nMaxIndexCount, bool bAppend, IndexDesc_t& desc )
|
||||
{
|
||||
static int s_BogusIndex;
|
||||
desc.m_pIndices = (unsigned short*)&s_BogusIndex;
|
||||
desc.m_nIndexSize = 0;
|
||||
desc.m_nFirstIndex = 0;
|
||||
desc.m_nOffset = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGLMesh::Unlock( int nWrittenIndexCount, IndexDesc_t& desc )
|
||||
{
|
||||
}
|
||||
|
||||
void CGLMesh::ModifyBegin( bool bReadOnly, int nFirstIndex, int nIndexCount, IndexDesc_t& desc )
|
||||
{
|
||||
Lock( nIndexCount, false, desc );
|
||||
}
|
||||
|
||||
void CGLMesh::ModifyEnd( IndexDesc_t& desc )
|
||||
{
|
||||
}
|
||||
|
||||
void CGLMesh::Spew( int nIndexCount, const IndexDesc_t & desc )
|
||||
{
|
||||
}
|
||||
|
||||
void CGLMesh::ValidateData( int nIndexCount, const IndexDesc_t &desc )
|
||||
{
|
||||
}
|
||||
|
||||
bool CGLMesh::Lock( int nVertexCount, bool bAppend, VertexDesc_t &desc )
|
||||
{
|
||||
// Who cares about the data?
|
||||
desc.m_pPosition = (float*)m_pVertexMemory;
|
||||
desc.m_pNormal = (float*)m_pVertexMemory;
|
||||
desc.m_pColor = m_pVertexMemory;
|
||||
|
||||
int i;
|
||||
for ( i = 0; i < VERTEX_MAX_TEXTURE_COORDINATES; ++i)
|
||||
{
|
||||
desc.m_pTexCoord[i] = (float*)m_pVertexMemory;
|
||||
}
|
||||
|
||||
desc.m_pBoneWeight = (float*)m_pVertexMemory;
|
||||
desc.m_pBoneMatrixIndex = (unsigned char*)m_pVertexMemory;
|
||||
desc.m_pTangentS = (float*)m_pVertexMemory;
|
||||
desc.m_pTangentT = (float*)m_pVertexMemory;
|
||||
desc.m_pUserData = (float*)m_pVertexMemory;
|
||||
desc.m_NumBoneWeights = 2;
|
||||
|
||||
desc.m_VertexSize_Position = 0;
|
||||
desc.m_VertexSize_BoneWeight = 0;
|
||||
desc.m_VertexSize_BoneMatrixIndex = 0;
|
||||
desc.m_VertexSize_Normal = 0;
|
||||
desc.m_VertexSize_Color = 0;
|
||||
for( i=0; i < VERTEX_MAX_TEXTURE_COORDINATES; i++ )
|
||||
{
|
||||
desc.m_VertexSize_TexCoord[i] = 0;
|
||||
}
|
||||
desc.m_VertexSize_TangentS = 0;
|
||||
desc.m_VertexSize_TangentT = 0;
|
||||
desc.m_VertexSize_UserData = 0;
|
||||
desc.m_ActualVertexSize = 0; // Size of the vertices.. Some of the m_VertexSize_ elements above
|
||||
|
||||
desc.m_nFirstVertex = 0;
|
||||
desc.m_nOffset = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGLMesh::Unlock( int nVertexCount, VertexDesc_t &desc )
|
||||
{
|
||||
}
|
||||
|
||||
void CGLMesh::Spew( int nVertexCount, const VertexDesc_t &desc )
|
||||
{
|
||||
}
|
||||
|
||||
void CGLMesh::ValidateData( int nVertexCount, const VertexDesc_t & desc )
|
||||
{
|
||||
}
|
||||
|
||||
void CGLMesh::LockMesh( int numVerts, int numIndices, MeshDesc_t& desc )
|
||||
{
|
||||
Lock( numVerts, false, *static_cast<VertexDesc_t*>( &desc ) );
|
||||
Lock( numIndices, false, *static_cast<IndexDesc_t*>( &desc ) );
|
||||
}
|
||||
|
||||
void CGLMesh::UnlockMesh( int numVerts, int numIndices, MeshDesc_t& desc )
|
||||
{
|
||||
}
|
||||
|
||||
void CGLMesh::ModifyBeginEx( bool bReadOnly, int firstVertex, int numVerts, int firstIndex, int numIndices, MeshDesc_t& desc )
|
||||
{
|
||||
Lock( numVerts, false, *static_cast<VertexDesc_t*>( &desc ) );
|
||||
Lock( numIndices, false, *static_cast<IndexDesc_t*>( &desc ) );
|
||||
}
|
||||
|
||||
void CGLMesh::ModifyBegin( int firstVertex, int numVerts, int firstIndex, int numIndices, MeshDesc_t& desc )
|
||||
{
|
||||
ModifyBeginEx( false, firstVertex, numVerts, firstIndex, numIndices, desc );
|
||||
}
|
||||
|
||||
void CGLMesh::ModifyEnd( MeshDesc_t& desc )
|
||||
{
|
||||
}
|
||||
|
||||
// returns the # of vertices (static meshes only)
|
||||
int CGLMesh::VertexCount() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Sets the primitive type
|
||||
void CGLMesh::SetPrimitiveType( MaterialPrimitiveType_t type )
|
||||
{
|
||||
}
|
||||
|
||||
// Draws the entire mesh
|
||||
void CGLMesh::Draw( int firstIndex, int numIndices )
|
||||
{
|
||||
}
|
||||
|
||||
void CGLMesh::Draw(CPrimList *pPrims, int nPrims)
|
||||
{
|
||||
}
|
||||
|
||||
// Copy verts and/or indices to a mesh builder. This only works for temp meshes!
|
||||
void CGLMesh::CopyToMeshBuilder(
|
||||
int iStartVert, // Which vertices to copy.
|
||||
int nVerts,
|
||||
int iStartIndex, // Which indices to copy.
|
||||
int nIndices,
|
||||
int indexOffset, // This is added to each index.
|
||||
CMeshBuilder &builder )
|
||||
{
|
||||
}
|
||||
|
||||
// Spews the mesh data
|
||||
void CGLMesh::Spew( int numVerts, int numIndices, const MeshDesc_t & desc )
|
||||
{
|
||||
}
|
||||
|
||||
void CGLMesh::ValidateData( int numVerts, int numIndices, const MeshDesc_t & desc )
|
||||
{
|
||||
}
|
||||
|
||||
// gets the associated material
|
||||
IMaterial* CGLMesh::GetMaterial()
|
||||
{
|
||||
// umm. this don't work none
|
||||
Assert(0);
|
||||
return 0;
|
||||
}
|
||||
109
materialsystem/shaderapigl/meshgl.h
Normal file
109
materialsystem/shaderapigl/meshgl.h
Normal file
@@ -0,0 +1,109 @@
|
||||
#ifndef MESHGL_H
|
||||
#define MESHGL_H
|
||||
|
||||
#include "utlvector.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "shaderapi/ishaderutil.h"
|
||||
#include "shaderapi/ishaderapi.h"
|
||||
#include "materialsystem/imesh.h"
|
||||
#include "materialsystem/idebugtextureinfo.h"
|
||||
#include "materialsystem/deformations.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The empty mesh
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGLMesh : public IMesh
|
||||
{
|
||||
public:
|
||||
CGLMesh( bool bIsDynamic );
|
||||
virtual ~CGLMesh();
|
||||
|
||||
// FIXME: Make this work! Unsupported methods of IIndexBuffer + IVertexBuffer
|
||||
virtual bool Lock( int nMaxIndexCount, bool bAppend, IndexDesc_t& desc );
|
||||
virtual void Unlock( int nWrittenIndexCount, IndexDesc_t& desc );
|
||||
virtual void ModifyBegin( bool bReadOnly, int nFirstIndex, int nIndexCount, IndexDesc_t& desc );
|
||||
virtual void ModifyEnd( IndexDesc_t& desc );
|
||||
virtual void Spew( int nIndexCount, const IndexDesc_t & desc );
|
||||
virtual void ValidateData( int nIndexCount, const IndexDesc_t &desc );
|
||||
virtual bool Lock( int nVertexCount, bool bAppend, VertexDesc_t &desc );
|
||||
virtual void Unlock( int nVertexCount, VertexDesc_t &desc );
|
||||
virtual void Spew( int nVertexCount, const VertexDesc_t &desc );
|
||||
virtual void ValidateData( int nVertexCount, const VertexDesc_t & desc );
|
||||
virtual bool IsDynamic() const { return m_bIsDynamic; }
|
||||
virtual void BeginCastBuffer( VertexFormat_t format ) {}
|
||||
virtual void BeginCastBuffer( MaterialIndexFormat_t format ) {}
|
||||
virtual void EndCastBuffer( ) {}
|
||||
virtual int GetRoomRemaining() const { return 0; }
|
||||
virtual MaterialIndexFormat_t IndexFormat() const { return MATERIAL_INDEX_FORMAT_UNKNOWN; }
|
||||
|
||||
void LockMesh( int numVerts, int numIndices, MeshDesc_t& desc );
|
||||
void UnlockMesh( int numVerts, int numIndices, MeshDesc_t& desc );
|
||||
|
||||
void ModifyBeginEx( bool bReadOnly, int firstVertex, int numVerts, int firstIndex, int numIndices, MeshDesc_t& desc );
|
||||
void ModifyBegin( int firstVertex, int numVerts, int firstIndex, int numIndices, MeshDesc_t& desc );
|
||||
void ModifyEnd( MeshDesc_t& desc );
|
||||
|
||||
// returns the # of vertices (static meshes only)
|
||||
int VertexCount() const;
|
||||
|
||||
// Sets the primitive type
|
||||
void SetPrimitiveType( MaterialPrimitiveType_t type );
|
||||
|
||||
// Draws the entire mesh
|
||||
void Draw(int firstIndex, int numIndices);
|
||||
|
||||
void Draw(CPrimList *pPrims, int nPrims);
|
||||
|
||||
// Copy verts and/or indices to a mesh builder. This only works for temp meshes!
|
||||
virtual void CopyToMeshBuilder(
|
||||
int iStartVert, // Which vertices to copy.
|
||||
int nVerts,
|
||||
int iStartIndex, // Which indices to copy.
|
||||
int nIndices,
|
||||
int indexOffset, // This is added to each index.
|
||||
CMeshBuilder &builder );
|
||||
|
||||
// Spews the mesh data
|
||||
void Spew( int numVerts, int numIndices, const MeshDesc_t & desc );
|
||||
|
||||
void ValidateData( int numVerts, int numIndices, const MeshDesc_t & desc );
|
||||
|
||||
// gets the associated material
|
||||
IMaterial* GetMaterial();
|
||||
|
||||
void SetColorMesh( IMesh *pColorMesh, int nVertexOffset )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual int IndexCount() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void SetFlexMesh( IMesh *pMesh, int nVertexOffset ) {}
|
||||
|
||||
virtual void DisableFlexMesh() {}
|
||||
|
||||
virtual void MarkAsDrawn() {}
|
||||
|
||||
virtual unsigned ComputeMemoryUsed() { return 0; }
|
||||
|
||||
virtual VertexFormat_t GetVertexFormat() const { return VERTEX_POSITION; }
|
||||
|
||||
virtual IMesh *GetMesh()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
VERTEX_BUFFER_SIZE = 1024 * 1024
|
||||
};
|
||||
|
||||
unsigned char* m_pVertexMemory;
|
||||
bool m_bIsDynamic;
|
||||
};
|
||||
|
||||
#endif
|
||||
0
materialsystem/shaderapigl/shaderapidevicegl.cp
Normal file
0
materialsystem/shaderapigl/shaderapidevicegl.cp
Normal file
223
materialsystem/shaderapigl/shaderapidevicegl.cpp
Normal file
223
materialsystem/shaderapigl/shaderapidevicegl.cpp
Normal file
@@ -0,0 +1,223 @@
|
||||
#include "utlvector.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "shaderapi/ishaderutil.h"
|
||||
#include "shaderapi/ishaderapi.h"
|
||||
#include "materialsystem/imesh.h"
|
||||
#include "materialsystem/idebugtextureinfo.h"
|
||||
#include "materialsystem/deformations.h"
|
||||
#include "meshgl.h"
|
||||
#include "shaderapigl.h"
|
||||
#include "shaderapidevicegl.h"
|
||||
#include "shadershadowgl.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The main GL Shader util interface
|
||||
//-----------------------------------------------------------------------------
|
||||
IShaderUtil* g_pShaderUtil;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Factory to return from SetMode
|
||||
//-----------------------------------------------------------------------------
|
||||
static void* ShaderInterfaceFactory( const char *pInterfaceName, int *pReturnCode )
|
||||
{
|
||||
if ( pReturnCode )
|
||||
{
|
||||
*pReturnCode = IFACE_OK;
|
||||
}
|
||||
if ( !Q_stricmp( pInterfaceName, SHADER_DEVICE_INTERFACE_VERSION ) )
|
||||
return static_cast< IShaderDevice* >( &s_ShaderDeviceGL );
|
||||
if ( !Q_stricmp( pInterfaceName, SHADERAPI_INTERFACE_VERSION ) )
|
||||
return static_cast< IShaderAPI* >( &g_ShaderAPIGL );
|
||||
if ( !Q_stricmp( pInterfaceName, SHADERSHADOW_INTERFACE_VERSION ) )
|
||||
return static_cast< IShaderShadow* >( &g_ShaderShadow );
|
||||
|
||||
if ( pReturnCode )
|
||||
{
|
||||
*pReturnCode = IFACE_FAILED;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Shader device empty
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void CShaderDeviceGL::GetWindowSize( int &width, int &height ) const
|
||||
{
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
|
||||
void CShaderDeviceGL::GetBackBufferDimensions( int& width, int& height ) const
|
||||
{
|
||||
width = 1600;
|
||||
height = 900;
|
||||
}
|
||||
|
||||
// Use this to spew information about the 3D layer
|
||||
void CShaderDeviceGL::SpewDriverInfo() const
|
||||
{
|
||||
Warning("GL shader\n");
|
||||
}
|
||||
|
||||
// Creates/ destroys a child window
|
||||
bool CShaderDeviceGL::AddView( void* hwnd )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CShaderDeviceGL::RemoveView( void* hwnd )
|
||||
{
|
||||
}
|
||||
|
||||
// Activates a view
|
||||
void CShaderDeviceGL::SetView( void* hwnd )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderDeviceGL::ReleaseResources()
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderDeviceGL::ReacquireResources()
|
||||
{
|
||||
}
|
||||
|
||||
// Creates/destroys Mesh
|
||||
IMesh* CShaderDeviceGL::CreateStaticMesh( VertexFormat_t fmt, const char *pTextureBudgetGroup, IMaterial * pMaterial )
|
||||
{
|
||||
return &m_Mesh;
|
||||
}
|
||||
|
||||
void CShaderDeviceGL::DestroyStaticMesh( IMesh* mesh )
|
||||
{
|
||||
}
|
||||
|
||||
// Creates/destroys static vertex + index buffers
|
||||
IVertexBuffer *CShaderDeviceGL::CreateVertexBuffer( ShaderBufferType_t type, VertexFormat_t fmt, int nVertexCount, const char *pTextureBudgetGroup )
|
||||
{
|
||||
return ( type == SHADER_BUFFER_TYPE_STATIC || type == SHADER_BUFFER_TYPE_STATIC_TEMP ) ? &m_Mesh : &m_DynamicMesh;
|
||||
}
|
||||
|
||||
void CShaderDeviceGL::DestroyVertexBuffer( IVertexBuffer *pVertexBuffer )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
IIndexBuffer *CShaderDeviceGL::CreateIndexBuffer( ShaderBufferType_t bufferType, MaterialIndexFormat_t fmt, int nIndexCount, const char *pTextureBudgetGroup )
|
||||
{
|
||||
switch( bufferType )
|
||||
{
|
||||
case SHADER_BUFFER_TYPE_STATIC:
|
||||
case SHADER_BUFFER_TYPE_STATIC_TEMP:
|
||||
return &m_Mesh;
|
||||
default:
|
||||
Assert( 0 );
|
||||
case SHADER_BUFFER_TYPE_DYNAMIC:
|
||||
case SHADER_BUFFER_TYPE_DYNAMIC_TEMP:
|
||||
return &m_DynamicMesh;
|
||||
}
|
||||
}
|
||||
|
||||
void CShaderDeviceGL::DestroyIndexBuffer( IIndexBuffer *pIndexBuffer )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
IVertexBuffer *CShaderDeviceGL::GetDynamicVertexBuffer( int streamID, VertexFormat_t vertexFormat, bool bBuffered )
|
||||
{
|
||||
return &m_DynamicMesh;
|
||||
}
|
||||
|
||||
IIndexBuffer *CShaderDeviceGL::GetDynamicIndexBuffer( MaterialIndexFormat_t fmt, bool bBuffered )
|
||||
{
|
||||
return &m_Mesh;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// CShaderDeviceMgrGL
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CShaderDeviceMgrGL::Connect( CreateInterfaceFn factory )
|
||||
{
|
||||
// So others can access it
|
||||
g_pShaderUtil = (IShaderUtil*)factory( SHADER_UTIL_INTERFACE_VERSION, NULL );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CShaderDeviceMgrGL::Disconnect()
|
||||
{
|
||||
g_pShaderUtil = NULL;
|
||||
}
|
||||
|
||||
void *CShaderDeviceMgrGL::QueryInterface( const char *pInterfaceName )
|
||||
{
|
||||
if ( !Q_stricmp( pInterfaceName, SHADER_DEVICE_MGR_INTERFACE_VERSION ) )
|
||||
return static_cast< IShaderDeviceMgr* >( this );
|
||||
if ( !Q_stricmp( pInterfaceName, MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION ) )
|
||||
return static_cast< IMaterialSystemHardwareConfig* >( &g_ShaderAPIGL );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
InitReturnVal_t CShaderDeviceMgrGL::Init()
|
||||
{
|
||||
return INIT_OK;
|
||||
}
|
||||
|
||||
void CShaderDeviceMgrGL::Shutdown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Sets the adapter
|
||||
bool CShaderDeviceMgrGL::SetAdapter( int nAdapter, int nFlags )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: Is this a public interface? Might only need to be private to shaderapi
|
||||
CreateInterfaceFn CShaderDeviceMgrGL::SetMode( void *hWnd, int nAdapter, const ShaderDeviceInfo_t& mode )
|
||||
{
|
||||
return ShaderInterfaceFactory;
|
||||
}
|
||||
|
||||
// Gets the number of adapters...
|
||||
int CShaderDeviceMgrGL::GetAdapterCount() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CShaderDeviceMgrGL::GetRecommendedConfigurationInfo( int nAdapter, int nDXLevel, KeyValues *pKeyValues )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns info about each adapter
|
||||
void CShaderDeviceMgrGL::GetAdapterInfo( int adapter, MaterialAdapterInfo_t& info ) const
|
||||
{
|
||||
memset( &info, 0, sizeof( info ) );
|
||||
info.m_nDXSupportLevel = 90;
|
||||
}
|
||||
|
||||
// Returns the number of modes
|
||||
int CShaderDeviceMgrGL::GetModeCount( int nAdapter ) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Returns mode information..
|
||||
void CShaderDeviceMgrGL::GetModeInfo( ShaderDisplayMode_t *pInfo, int nAdapter, int nMode ) const
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderDeviceMgrGL::GetCurrentModeInfo( ShaderDisplayMode_t* pInfo, int nAdapter ) const
|
||||
{
|
||||
}
|
||||
99
materialsystem/shaderapigl/shaderapidevicegl.h
Normal file
99
materialsystem/shaderapigl/shaderapidevicegl.h
Normal file
@@ -0,0 +1,99 @@
|
||||
#ifndef SHADERAPIDEVICEGL_H
|
||||
#define SHADERAPIDEVICEGL_H
|
||||
|
||||
extern IShaderUtil* g_pShaderUtil;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The GL implementation of the shader device
|
||||
//-----------------------------------------------------------------------------
|
||||
class CShaderDeviceGL : public IShaderDevice
|
||||
{
|
||||
public:
|
||||
CShaderDeviceGL() : m_DynamicMesh( true ), m_Mesh( false ) {}
|
||||
|
||||
// Methods of IShaderDevice
|
||||
virtual int GetCurrentAdapter() const { return 0; }
|
||||
virtual bool IsUsingGraphics() const { return false; }
|
||||
virtual void SpewDriverInfo() const;
|
||||
virtual ImageFormat GetBackBufferFormat() const { return IMAGE_FORMAT_RGB888; }
|
||||
virtual void GetBackBufferDimensions( int& width, int& height ) const;
|
||||
virtual int StencilBufferBits() const { return 0; }
|
||||
virtual bool IsAAEnabled() const { return false; }
|
||||
virtual void Present( ) {}
|
||||
virtual void GetWindowSize( int &width, int &height ) const;
|
||||
virtual bool AddView( void* hwnd );
|
||||
virtual void RemoveView( void* hwnd );
|
||||
virtual void SetView( void* hwnd );
|
||||
virtual void ReleaseResources();
|
||||
virtual void ReacquireResources();
|
||||
virtual IMesh* CreateStaticMesh( VertexFormat_t fmt, const char *pTextureBudgetGroup, IMaterial * pMaterial = NULL );
|
||||
virtual void DestroyStaticMesh( IMesh* mesh );
|
||||
virtual IShaderBuffer* CompileShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion ) { return NULL; }
|
||||
virtual VertexShaderHandle_t CreateVertexShader( IShaderBuffer* pShaderBuffer ) { return VERTEX_SHADER_HANDLE_INVALID; }
|
||||
virtual void DestroyVertexShader( VertexShaderHandle_t hShader ) {}
|
||||
virtual GeometryShaderHandle_t CreateGeometryShader( IShaderBuffer* pShaderBuffer ) { return GEOMETRY_SHADER_HANDLE_INVALID; }
|
||||
virtual void DestroyGeometryShader( GeometryShaderHandle_t hShader ) {}
|
||||
virtual PixelShaderHandle_t CreatePixelShader( IShaderBuffer* pShaderBuffer ) { return PIXEL_SHADER_HANDLE_INVALID; }
|
||||
virtual void DestroyPixelShader( PixelShaderHandle_t hShader ) {}
|
||||
virtual IVertexBuffer *CreateVertexBuffer( ShaderBufferType_t type, VertexFormat_t fmt, int nVertexCount, const char *pBudgetGroup );
|
||||
virtual void DestroyVertexBuffer( IVertexBuffer *pVertexBuffer );
|
||||
virtual IIndexBuffer *CreateIndexBuffer( ShaderBufferType_t bufferType, MaterialIndexFormat_t fmt, int nIndexCount, const char *pBudgetGroup );
|
||||
virtual void DestroyIndexBuffer( IIndexBuffer *pIndexBuffer );
|
||||
virtual IVertexBuffer *GetDynamicVertexBuffer( int streamID, VertexFormat_t vertexFormat, bool bBuffered );
|
||||
virtual IIndexBuffer *GetDynamicIndexBuffer( MaterialIndexFormat_t fmt, bool bBuffered );
|
||||
virtual void SetHardwareGammaRamp( float fGamma, float fGammaTVRangeMin, float fGammaTVRangeMax, float fGammaTVExponent, bool bTVEnabled ) {}
|
||||
virtual void EnableNonInteractiveMode( MaterialNonInteractiveMode_t mode, ShaderNonInteractiveInfo_t *pInfo ) {}
|
||||
virtual void RefreshFrontBufferNonInteractive( ) {}
|
||||
virtual void HandleThreadEvent( uint32 threadEvent ) {}
|
||||
|
||||
#ifdef DX_TO_GL_ABSTRACTION
|
||||
virtual void DoStartupShaderPreloading( void ) {}
|
||||
#endif
|
||||
|
||||
virtual char *GetDisplayDeviceName() OVERRIDE { return ""; }
|
||||
|
||||
private:
|
||||
CGLMesh m_Mesh;
|
||||
CGLMesh m_DynamicMesh;
|
||||
};
|
||||
|
||||
static CShaderDeviceGL s_ShaderDeviceGL;
|
||||
|
||||
// FIXME: Remove; it's for backward compat with the materialsystem only for now
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderDeviceGL, IShaderDevice,
|
||||
SHADER_DEVICE_INTERFACE_VERSION, s_ShaderDeviceGL )
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The DX8 implementation of the shader device
|
||||
//-----------------------------------------------------------------------------
|
||||
class CShaderDeviceMgrGL : public IShaderDeviceMgr
|
||||
{
|
||||
public:
|
||||
// Methods of IAppSystem
|
||||
virtual bool Connect( CreateInterfaceFn factory );
|
||||
virtual void Disconnect();
|
||||
virtual void *QueryInterface( const char *pInterfaceName );
|
||||
virtual InitReturnVal_t Init();
|
||||
virtual void Shutdown();
|
||||
|
||||
public:
|
||||
// Methods of IShaderDeviceMgr
|
||||
virtual int GetAdapterCount() const;
|
||||
virtual void GetAdapterInfo( int adapter, MaterialAdapterInfo_t& info ) const;
|
||||
virtual bool GetRecommendedConfigurationInfo( int nAdapter, int nDXLevel, KeyValues *pKeyValues );
|
||||
virtual int GetModeCount( int adapter ) const;
|
||||
virtual void GetModeInfo( ShaderDisplayMode_t *pInfo, int nAdapter, int mode ) const;
|
||||
virtual void GetCurrentModeInfo( ShaderDisplayMode_t* pInfo, int nAdapter ) const;
|
||||
virtual bool SetAdapter( int nAdapter, int nFlags );
|
||||
virtual CreateInterfaceFn SetMode( void *hWnd, int nAdapter, const ShaderDeviceInfo_t& mode );
|
||||
virtual void AddModeChangeCallback( ShaderModeChangeCallbackFunc_t func ) {}
|
||||
virtual void RemoveModeChangeCallback( ShaderModeChangeCallbackFunc_t func ) {}
|
||||
};
|
||||
|
||||
static CShaderDeviceMgrGL s_ShaderDeviceMgrGL;
|
||||
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderDeviceMgrGL, IShaderDeviceMgr,
|
||||
SHADER_DEVICE_MGR_INTERFACE_VERSION, s_ShaderDeviceMgrGL )
|
||||
|
||||
|
||||
#endif
|
||||
1142
materialsystem/shaderapigl/shaderapigl.cpp
Normal file
1142
materialsystem/shaderapigl/shaderapigl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
887
materialsystem/shaderapigl/shaderapigl.h
Normal file
887
materialsystem/shaderapigl/shaderapigl.h
Normal file
@@ -0,0 +1,887 @@
|
||||
#ifndef SHADERAPIGL_H
|
||||
#define SHADERAPIGL_H
|
||||
|
||||
#include "IHardwareConfigInternal.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The DX8 implementation of the shader API
|
||||
//-----------------------------------------------------------------------------
|
||||
class CShaderAPIGL : public IShaderAPI, public IHardwareConfigInternal, public IDebugTextureInfo
|
||||
{
|
||||
public:
|
||||
// constructor, destructor
|
||||
CShaderAPIGL( );
|
||||
virtual ~CShaderAPIGL();
|
||||
|
||||
// IDebugTextureInfo implementation.
|
||||
public:
|
||||
|
||||
virtual bool IsDebugTextureListFresh( int numFramesAllowed = 1 ) { return false; }
|
||||
virtual bool SetDebugTextureRendering( bool bEnable ) { return false; }
|
||||
virtual void EnableDebugTextureList( bool bEnable ) {}
|
||||
virtual void EnableGetAllTextures( bool bEnable ) {}
|
||||
virtual KeyValues* GetDebugTextureList() { return NULL; }
|
||||
virtual int GetTextureMemoryUsed( TextureMemoryType eTextureMemory ) { return 0; }
|
||||
|
||||
// Methods of IShaderDynamicAPI
|
||||
virtual void GetBackBufferDimensions( int& width, int& height ) const;
|
||||
virtual void GetCurrentColorCorrection( ShaderColorCorrectionInfo_t* pInfo );
|
||||
|
||||
// Methods of IShaderAPI
|
||||
public:
|
||||
virtual void SetViewports( int nCount, const ShaderViewport_t* pViewports );
|
||||
virtual int GetViewports( ShaderViewport_t* pViewports, int nMax ) const;
|
||||
virtual void ClearBuffers( bool bClearColor, bool bClearDepth, bool bClearStencil, int renderTargetWidth, int renderTargetHeight );
|
||||
virtual void ClearColor3ub( unsigned char r, unsigned char g, unsigned char b );
|
||||
virtual void ClearColor4ub( unsigned char r, unsigned char g, unsigned char b, unsigned char a );
|
||||
virtual void BindVertexShader( VertexShaderHandle_t hVertexShader ) {}
|
||||
virtual void BindGeometryShader( GeometryShaderHandle_t hGeometryShader ) {}
|
||||
virtual void BindPixelShader( PixelShaderHandle_t hPixelShader ) {}
|
||||
virtual void SetRasterState( const ShaderRasterState_t& state ) {}
|
||||
virtual void MarkUnusedVertexFields( unsigned int nFlags, int nTexCoordCount, bool *pUnusedTexCoords ) {}
|
||||
virtual bool OwnGPUResources( bool bEnable ) { return false; }
|
||||
|
||||
virtual bool DoRenderTargetsNeedSeparateDepthBuffer() const;
|
||||
|
||||
// Used to clear the transition table when we know it's become invalid.
|
||||
void ClearSnapshots();
|
||||
|
||||
// Sets the mode...
|
||||
bool SetMode( void* hwnd, int nAdapter, const ShaderDeviceInfo_t &info )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChangeVideoMode( const ShaderDeviceInfo_t &info )
|
||||
{
|
||||
}
|
||||
|
||||
// Called when the dx support level has changed
|
||||
virtual void DXSupportLevelChanged() {}
|
||||
|
||||
virtual void EnableUserClipTransformOverride( bool bEnable ) {}
|
||||
virtual void UserClipTransform( const VMatrix &worldToView ) {}
|
||||
|
||||
// Sets the default *dynamic* state
|
||||
void SetDefaultState( );
|
||||
|
||||
// Returns the snapshot id for the shader state
|
||||
StateSnapshot_t TakeSnapshot( );
|
||||
|
||||
// Returns true if the state snapshot is transparent
|
||||
bool IsTranslucent( StateSnapshot_t id ) const;
|
||||
bool IsAlphaTested( StateSnapshot_t id ) const;
|
||||
bool UsesVertexAndPixelShaders( StateSnapshot_t id ) const;
|
||||
virtual bool IsDepthWriteEnabled( StateSnapshot_t id ) const;
|
||||
|
||||
// Gets the vertex format for a set of snapshot ids
|
||||
VertexFormat_t ComputeVertexFormat( int numSnapshots, StateSnapshot_t* pIds ) const;
|
||||
|
||||
// Gets the vertex format for a set of snapshot ids
|
||||
VertexFormat_t ComputeVertexUsage( int numSnapshots, StateSnapshot_t* pIds ) const;
|
||||
|
||||
// Begins a rendering pass that uses a state snapshot
|
||||
void BeginPass( StateSnapshot_t snapshot );
|
||||
|
||||
// Uses a state snapshot
|
||||
void UseSnapshot( StateSnapshot_t snapshot );
|
||||
|
||||
// Use this to get the mesh builder that allows us to modify vertex data
|
||||
CMeshBuilder* GetVertexModifyBuilder();
|
||||
|
||||
// Sets the color to modulate by
|
||||
void Color3f( float r, float g, float b );
|
||||
void Color3fv( float const* pColor );
|
||||
void Color4f( float r, float g, float b, float a );
|
||||
void Color4fv( float const* pColor );
|
||||
|
||||
// Faster versions of color
|
||||
void Color3ub( unsigned char r, unsigned char g, unsigned char b );
|
||||
void Color3ubv( unsigned char const* rgb );
|
||||
void Color4ub( unsigned char r, unsigned char g, unsigned char b, unsigned char a );
|
||||
void Color4ubv( unsigned char const* rgba );
|
||||
|
||||
// Sets the lights
|
||||
void SetLight( int lightNum, const LightDesc_t& desc );
|
||||
void SetLightingOrigin( Vector vLightingOrigin );
|
||||
void SetAmbientLight( float r, float g, float b );
|
||||
void SetAmbientLightCube( Vector4D cube[6] );
|
||||
|
||||
// Get the lights
|
||||
int GetMaxLights( void ) const;
|
||||
const LightDesc_t& GetLight( int lightNum ) const;
|
||||
|
||||
// Render state for the ambient light cube (vertex shaders)
|
||||
void SetVertexShaderStateAmbientLightCube();
|
||||
void SetPixelShaderStateAmbientLightCube( int pshReg, bool bForceToBlack = false )
|
||||
{
|
||||
}
|
||||
|
||||
float GetAmbientLightCubeLuminance(void)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void SetSkinningMatrices();
|
||||
|
||||
// Lightmap texture binding
|
||||
void BindLightmap( TextureStage_t stage );
|
||||
void BindLightmapAlpha( TextureStage_t stage )
|
||||
{
|
||||
}
|
||||
void BindBumpLightmap( TextureStage_t stage );
|
||||
void BindFullbrightLightmap( TextureStage_t stage );
|
||||
void BindWhite( TextureStage_t stage );
|
||||
void BindBlack( TextureStage_t stage );
|
||||
void BindGrey( TextureStage_t stage );
|
||||
void BindFBTexture( TextureStage_t stage, int textureIdex );
|
||||
void CopyRenderTargetToTexture( ShaderAPITextureHandle_t texID )
|
||||
{
|
||||
}
|
||||
|
||||
void CopyRenderTargetToTextureEx( ShaderAPITextureHandle_t texID, int nRenderTargetID, Rect_t *pSrcRect, Rect_t *pDstRect )
|
||||
{
|
||||
}
|
||||
|
||||
void CopyTextureToRenderTargetEx( int nRenderTargetID, ShaderAPITextureHandle_t textureHandle, Rect_t *pSrcRect, Rect_t *pDstRect )
|
||||
{
|
||||
}
|
||||
|
||||
// Special system flat normal map binding.
|
||||
void BindFlatNormalMap( TextureStage_t stage );
|
||||
void BindNormalizationCubeMap( TextureStage_t stage );
|
||||
void BindSignedNormalizationCubeMap( TextureStage_t stage );
|
||||
|
||||
// Set the number of bone weights
|
||||
void SetNumBoneWeights( int numBones );
|
||||
void EnableHWMorphing( bool bEnable );
|
||||
|
||||
// Flushes any primitives that are buffered
|
||||
void FlushBufferedPrimitives();
|
||||
|
||||
// Gets the dynamic mesh; note that you've got to render the mesh
|
||||
// before calling this function a second time. Clients should *not*
|
||||
// call DestroyStaticMesh on the mesh returned by this call.
|
||||
IMesh* GetDynamicMesh( IMaterial* pMaterial, int nHWSkinBoneCount, bool buffered, IMesh* pVertexOverride, IMesh* pIndexOverride );
|
||||
IMesh* GetDynamicMeshEx( IMaterial* pMaterial, VertexFormat_t fmt, int nHWSkinBoneCount, bool buffered, IMesh* pVertexOverride, IMesh* pIndexOverride );
|
||||
|
||||
IMesh* GetFlexMesh();
|
||||
|
||||
// Renders a single pass of a material
|
||||
void RenderPass( int nPass, int nPassCount );
|
||||
|
||||
// stuff related to matrix stacks
|
||||
void MatrixMode( MaterialMatrixMode_t matrixMode );
|
||||
void PushMatrix();
|
||||
void PopMatrix();
|
||||
void LoadMatrix( float *m );
|
||||
void LoadBoneMatrix( int boneIndex, const float *m ) {}
|
||||
void MultMatrix( float *m );
|
||||
void MultMatrixLocal( float *m );
|
||||
void GetMatrix( MaterialMatrixMode_t matrixMode, float *dst );
|
||||
void LoadIdentity( void );
|
||||
void LoadCameraToWorld( void );
|
||||
void Ortho( double left, double top, double right, double bottom, double zNear, double zFar );
|
||||
void PerspectiveX( double fovx, double aspect, double zNear, double zFar );
|
||||
void PerspectiveOffCenterX( double fovx, double aspect, double zNear, double zFar, double bottom, double top, double left, double right );
|
||||
void PickMatrix( int x, int y, int width, int height );
|
||||
void Rotate( float angle, float x, float y, float z );
|
||||
void Translate( float x, float y, float z );
|
||||
void Scale( float x, float y, float z );
|
||||
void ScaleXY( float x, float y );
|
||||
|
||||
// Fog methods...
|
||||
void FogMode( MaterialFogMode_t fogMode );
|
||||
void FogStart( float fStart );
|
||||
void FogEnd( float fEnd );
|
||||
void SetFogZ( float fogZ );
|
||||
void FogMaxDensity( float flMaxDensity );
|
||||
void GetFogDistances( float *fStart, float *fEnd, float *fFogZ );
|
||||
void FogColor3f( float r, float g, float b );
|
||||
void FogColor3fv( float const* rgb );
|
||||
void FogColor3ub( unsigned char r, unsigned char g, unsigned char b );
|
||||
void FogColor3ubv( unsigned char const* rgb );
|
||||
|
||||
virtual void SceneFogColor3ub( unsigned char r, unsigned char g, unsigned char b );
|
||||
virtual void SceneFogMode( MaterialFogMode_t fogMode );
|
||||
virtual void GetSceneFogColor( unsigned char *rgb );
|
||||
virtual MaterialFogMode_t GetSceneFogMode( );
|
||||
virtual int GetPixelFogCombo( );
|
||||
|
||||
void SetHeightClipZ( float z );
|
||||
void SetHeightClipMode( enum MaterialHeightClipMode_t heightClipMode );
|
||||
|
||||
void SetClipPlane( int index, const float *pPlane );
|
||||
void EnableClipPlane( int index, bool bEnable );
|
||||
|
||||
void SetFastClipPlane( const float *pPlane );
|
||||
void EnableFastClip( bool bEnable );
|
||||
|
||||
// We use smaller dynamic VBs during level transitions, to free up memory
|
||||
virtual int GetCurrentDynamicVBSize( void );
|
||||
virtual void DestroyVertexBuffers( bool bExitingLevel = false );
|
||||
|
||||
// Sets the vertex and pixel shaders
|
||||
void SetVertexShaderIndex( int vshIndex );
|
||||
void SetPixelShaderIndex( int pshIndex );
|
||||
|
||||
// Sets the constant register for vertex and pixel shaders
|
||||
void SetVertexShaderConstant( int var, float const* pVec, int numConst = 1, bool bForce = false );
|
||||
void SetBooleanVertexShaderConstant( int var, BOOL const* pVec, int numConst = 1, bool bForce = false );
|
||||
void SetIntegerVertexShaderConstant( int var, int const* pVec, int numConst = 1, bool bForce = false );
|
||||
void SetPixelShaderConstant( int var, float const* pVec, int numConst = 1, bool bForce = false );
|
||||
void SetBooleanPixelShaderConstant( int var, BOOL const* pVec, int numBools = 1, bool bForce = false );
|
||||
void SetIntegerPixelShaderConstant( int var, int const* pVec, int numIntVecs = 1, bool bForce = false );
|
||||
|
||||
void InvalidateDelayedShaderConstants( void );
|
||||
|
||||
// Gamma<->Linear conversions according to the video hardware we're running on
|
||||
float GammaToLinear_HardwareSpecific( float fGamma ) const;
|
||||
float LinearToGamma_HardwareSpecific( float fLinear ) const;
|
||||
|
||||
//Set's the linear->gamma conversion textures to use for this hardware for both srgb writes enabled and disabled(identity)
|
||||
void SetLinearToGammaConversionTextures( ShaderAPITextureHandle_t hSRGBWriteEnabledTexture, ShaderAPITextureHandle_t hIdentityTexture );
|
||||
|
||||
// Cull mode
|
||||
void CullMode( MaterialCullMode_t cullMode );
|
||||
|
||||
// Force writes only when z matches. . . useful for stenciling things out
|
||||
// by rendering the desired Z values ahead of time.
|
||||
void ForceDepthFuncEquals( bool bEnable );
|
||||
|
||||
// Forces Z buffering on or off
|
||||
void OverrideDepthEnable( bool bEnable, bool bDepthEnable );
|
||||
void OverrideAlphaWriteEnable( bool bOverrideEnable, bool bAlphaWriteEnable );
|
||||
void OverrideColorWriteEnable( bool bOverrideEnable, bool bColorWriteEnable );
|
||||
|
||||
// Sets the shade mode
|
||||
void ShadeMode( ShaderShadeMode_t mode );
|
||||
|
||||
// Binds a particular material to render with
|
||||
void Bind( IMaterial* pMaterial );
|
||||
|
||||
// Returns the nearest supported format
|
||||
ImageFormat GetNearestSupportedFormat( ImageFormat fmt, bool bFilteringRequired = true ) const;
|
||||
ImageFormat GetNearestRenderTargetFormat( ImageFormat fmt ) const;
|
||||
|
||||
// Sets the texture state
|
||||
void BindTexture( Sampler_t stage, ShaderAPITextureHandle_t textureHandle );
|
||||
|
||||
void SetRenderTarget( ShaderAPITextureHandle_t colorTextureHandle, ShaderAPITextureHandle_t depthTextureHandle )
|
||||
{
|
||||
}
|
||||
|
||||
void SetRenderTargetEx( int nRenderTargetID, ShaderAPITextureHandle_t colorTextureHandle, ShaderAPITextureHandle_t depthTextureHandle )
|
||||
{
|
||||
}
|
||||
|
||||
// Indicates we're going to be modifying this texture
|
||||
// TexImage2D, TexSubImage2D, TexWrap, TexMinFilter, and TexMagFilter
|
||||
// all use the texture specified by this function.
|
||||
void ModifyTexture( ShaderAPITextureHandle_t textureHandle );
|
||||
|
||||
// Texture management methods
|
||||
void TexImage2D( int level, int cubeFace, ImageFormat dstFormat, int zOffset, int width, int height,
|
||||
ImageFormat srcFormat, bool bSrcIsTiled, void *imageData );
|
||||
void TexSubImage2D( int level, int cubeFace, int xOffset, int yOffset, int zOffset, int width, int height,
|
||||
ImageFormat srcFormat, int srcStride, bool bSrcIsTiled, void *imageData );
|
||||
|
||||
void TexImageFromVTF( IVTFTexture *pVTF, int iVTFFrame );
|
||||
|
||||
bool TexLock( int level, int cubeFaceID, int xOffset, int yOffset,
|
||||
int width, int height, CPixelWriter& writer );
|
||||
void TexUnlock( );
|
||||
|
||||
// These are bound to the texture, not the texture environment
|
||||
void TexMinFilter( ShaderTexFilterMode_t texFilterMode );
|
||||
void TexMagFilter( ShaderTexFilterMode_t texFilterMode );
|
||||
void TexWrap( ShaderTexCoordComponent_t coord, ShaderTexWrapMode_t wrapMode );
|
||||
void TexSetPriority( int priority );
|
||||
|
||||
ShaderAPITextureHandle_t CreateTexture(
|
||||
int width,
|
||||
int height,
|
||||
int depth,
|
||||
ImageFormat dstImageFormat,
|
||||
int numMipLevels,
|
||||
int numCopies,
|
||||
int flags,
|
||||
const char *pDebugName,
|
||||
const char *pTextureGroupName );
|
||||
// Create a multi-frame texture (equivalent to calling "CreateTexture" multiple times, but more efficient)
|
||||
void CreateTextures(
|
||||
ShaderAPITextureHandle_t *pHandles,
|
||||
int count,
|
||||
int width,
|
||||
int height,
|
||||
int depth,
|
||||
ImageFormat dstImageFormat,
|
||||
int numMipLevels,
|
||||
int numCopies,
|
||||
int flags,
|
||||
const char *pDebugName,
|
||||
const char *pTextureGroupName );
|
||||
ShaderAPITextureHandle_t CreateDepthTexture( ImageFormat renderFormat, int width, int height, const char *pDebugName, bool bTexture );
|
||||
void DeleteTexture( ShaderAPITextureHandle_t textureHandle );
|
||||
bool IsTexture( ShaderAPITextureHandle_t textureHandle );
|
||||
bool IsTextureResident( ShaderAPITextureHandle_t textureHandle );
|
||||
|
||||
// stuff that isn't to be used from within a shader
|
||||
void ClearBuffersObeyStencil( bool bClearColor, bool bClearDepth );
|
||||
void ClearBuffersObeyStencilEx( bool bClearColor, bool bClearAlpha, bool bClearDepth );
|
||||
void PerformFullScreenStencilOperation( void );
|
||||
void ReadPixels( int x, int y, int width, int height, unsigned char *data, ImageFormat dstFormat );
|
||||
virtual void ReadPixels( Rect_t *pSrcRect, Rect_t *pDstRect, unsigned char *data, ImageFormat dstFormat, int nDstStride );
|
||||
|
||||
// Selection mode methods
|
||||
int SelectionMode( bool selectionMode );
|
||||
void SelectionBuffer( unsigned int* pBuffer, int size );
|
||||
void ClearSelectionNames( );
|
||||
void LoadSelectionName( int name );
|
||||
void PushSelectionName( int name );
|
||||
void PopSelectionName();
|
||||
|
||||
void FlushHardware();
|
||||
void ResetRenderState( bool bFullReset = true );
|
||||
|
||||
void SetScissorRect( const int nLeft, const int nTop, const int nRight, const int nBottom, const bool bEnableScissor );
|
||||
|
||||
// Can we download textures?
|
||||
virtual bool CanDownloadTextures() const;
|
||||
|
||||
// Board-independent calls, here to unify how shaders set state
|
||||
// Implementations should chain back to IShaderUtil->BindTexture(), etc.
|
||||
|
||||
// Use this to begin and end the frame
|
||||
void BeginFrame();
|
||||
void EndFrame();
|
||||
|
||||
// returns current time
|
||||
double CurrentTime() const;
|
||||
|
||||
// Get the current camera position in world space.
|
||||
void GetWorldSpaceCameraPosition( float * pPos ) const;
|
||||
|
||||
// Members of IMaterialSystemHardwareConfig
|
||||
bool HasDestAlphaBuffer() const;
|
||||
bool HasStencilBuffer() const;
|
||||
virtual int MaxViewports() const;
|
||||
virtual void OverrideStreamOffsetSupport( bool bOverrideEnabled, bool bEnableSupport ) {}
|
||||
virtual int GetShadowFilterMode() const;
|
||||
int StencilBufferBits() const;
|
||||
int GetFrameBufferColorDepth() const;
|
||||
int GetSamplerCount() const;
|
||||
bool HasSetDeviceGammaRamp() const;
|
||||
bool SupportsCompressedTextures() const;
|
||||
VertexCompressionType_t SupportsCompressedVertices() const;
|
||||
bool SupportsVertexAndPixelShaders() const;
|
||||
bool SupportsPixelShaders_1_4() const;
|
||||
bool SupportsPixelShaders_2_0() const;
|
||||
bool SupportsPixelShaders_2_b() const;
|
||||
bool ActuallySupportsPixelShaders_2_b() const;
|
||||
bool SupportsStaticControlFlow() const;
|
||||
bool SupportsVertexShaders_2_0() const;
|
||||
bool SupportsShaderModel_3_0() const;
|
||||
int MaximumAnisotropicLevel() const;
|
||||
int MaxTextureWidth() const;
|
||||
int MaxTextureHeight() const;
|
||||
int MaxTextureAspectRatio() const;
|
||||
int GetDXSupportLevel() const;
|
||||
const char *GetShaderDLLName() const
|
||||
{
|
||||
return "GL";
|
||||
}
|
||||
int TextureMemorySize() const;
|
||||
bool SupportsOverbright() const;
|
||||
bool SupportsCubeMaps() const;
|
||||
bool SupportsMipmappedCubemaps() const;
|
||||
bool SupportsNonPow2Textures() const;
|
||||
int GetTextureStageCount() const;
|
||||
int NumVertexShaderConstants() const;
|
||||
int NumBooleanVertexShaderConstants() const;
|
||||
int NumIntegerVertexShaderConstants() const;
|
||||
int NumPixelShaderConstants() const;
|
||||
int MaxNumLights() const;
|
||||
bool SupportsHardwareLighting() const;
|
||||
int MaxBlendMatrices() const;
|
||||
int MaxBlendMatrixIndices() const;
|
||||
int MaxVertexShaderBlendMatrices() const;
|
||||
int MaxUserClipPlanes() const;
|
||||
bool UseFastClipping() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool SpecifiesFogColorInLinearSpace() const;
|
||||
virtual bool SupportsSRGB() const;
|
||||
virtual bool FakeSRGBWrite() const;
|
||||
virtual bool CanDoSRGBReadFromRTs() const;
|
||||
virtual bool SupportsGLMixedSizeTargets() const;
|
||||
|
||||
const char *GetHWSpecificShaderDLLName() const;
|
||||
bool NeedsAAClamp() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool SupportsSpheremapping() const;
|
||||
virtual int MaxHWMorphBatchCount() const { return 0; }
|
||||
|
||||
// This is the max dx support level supported by the card
|
||||
virtual int GetMaxDXSupportLevel() const;
|
||||
|
||||
bool ReadPixelsFromFrontBuffer() const;
|
||||
bool PreferDynamicTextures() const;
|
||||
virtual bool PreferReducedFillrate() const;
|
||||
bool HasProjectedBumpEnv() const;
|
||||
void ForceHardwareSync( void );
|
||||
|
||||
int GetCurrentNumBones( void ) const;
|
||||
bool IsHWMorphingEnabled( void ) const;
|
||||
int GetCurrentLightCombo( void ) const;
|
||||
void GetDX9LightState( LightState_t *state ) const;
|
||||
MaterialFogMode_t GetCurrentFogType( void ) const;
|
||||
|
||||
void RecordString( const char *pStr );
|
||||
|
||||
void EvictManagedResources();
|
||||
|
||||
void SetTextureTransformDimension( TextureStage_t textureStage, int dimension, bool projected );
|
||||
void DisableTextureTransform( TextureStage_t textureStage )
|
||||
{
|
||||
}
|
||||
void SetBumpEnvMatrix( TextureStage_t textureStage, float m00, float m01, float m10, float m11 );
|
||||
|
||||
// Gets the lightmap dimensions
|
||||
virtual void GetLightmapDimensions( int *w, int *h );
|
||||
|
||||
virtual void SyncToken( const char *pToken );
|
||||
|
||||
// Setup standard vertex shader constants (that don't change)
|
||||
// This needs to be called anytime that overbright changes.
|
||||
virtual void SetStandardVertexShaderConstants( float fOverbright )
|
||||
{
|
||||
}
|
||||
|
||||
// Level of anisotropic filtering
|
||||
virtual void SetAnisotropicLevel( int nAnisotropyLevel );
|
||||
|
||||
bool SupportsHDR() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
HDRType_t GetHDRType() const
|
||||
{
|
||||
return HDR_TYPE_NONE;
|
||||
}
|
||||
HDRType_t GetHardwareHDRType() const
|
||||
{
|
||||
return HDR_TYPE_NONE;
|
||||
}
|
||||
virtual bool NeedsATICentroidHack() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool SupportsColorOnSecondStream() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool SupportsStaticPlusDynamicLighting() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool SupportsStreamOffset() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void SetDefaultDynamicState()
|
||||
{
|
||||
}
|
||||
virtual void CommitPixelShaderLighting( int pshReg )
|
||||
{
|
||||
}
|
||||
|
||||
ShaderAPIOcclusionQuery_t CreateOcclusionQueryObject( void )
|
||||
{
|
||||
return INVALID_SHADERAPI_OCCLUSION_QUERY_HANDLE;
|
||||
}
|
||||
|
||||
void DestroyOcclusionQueryObject( ShaderAPIOcclusionQuery_t handle )
|
||||
{
|
||||
}
|
||||
|
||||
void BeginOcclusionQueryDrawing( ShaderAPIOcclusionQuery_t handle )
|
||||
{
|
||||
}
|
||||
|
||||
void EndOcclusionQueryDrawing( ShaderAPIOcclusionQuery_t handle )
|
||||
{
|
||||
}
|
||||
|
||||
int OcclusionQuery_GetNumPixelsRendered( ShaderAPIOcclusionQuery_t handle, bool bFlush )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void AcquireThreadOwnership() {}
|
||||
virtual void ReleaseThreadOwnership() {}
|
||||
|
||||
virtual bool SupportsBorderColor() const { return false; }
|
||||
virtual bool SupportsFetch4() const { return false; }
|
||||
virtual bool CanStretchRectFromTextures( void ) const { return false; }
|
||||
virtual void EnableBuffer2FramesAhead( bool bEnable ) {}
|
||||
|
||||
virtual void SetPSNearAndFarZ( int pshReg ) { }
|
||||
|
||||
virtual void SetDepthFeatheringPixelShaderConstant( int iConstant, float fDepthBlendScale ) {}
|
||||
|
||||
void SetPixelShaderFogParams( int reg )
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool InFlashlightMode() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool InEditorMode() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// What fields in the morph do we actually use?
|
||||
virtual MorphFormat_t ComputeMorphFormat( int numSnapshots, StateSnapshot_t* pIds ) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Gets the bound morph's vertex format; returns 0 if no morph is bound
|
||||
virtual MorphFormat_t GetBoundMorphFormat()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Binds a standard texture
|
||||
virtual void BindStandardTexture( Sampler_t stage, StandardTextureId_t id )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void BindStandardVertexTexture( VertexTextureSampler_t stage, StandardTextureId_t id )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void GetStandardTextureDimensions( int *pWidth, int *pHeight, StandardTextureId_t id )
|
||||
{
|
||||
*pWidth = *pHeight = 0;
|
||||
}
|
||||
|
||||
|
||||
virtual void SetFlashlightState( const FlashlightState_t &state, const VMatrix &worldToTexture )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void SetFlashlightStateEx( const FlashlightState_t &state, const VMatrix &worldToTexture, ITexture *pFlashlightDepthTexture )
|
||||
{
|
||||
}
|
||||
|
||||
virtual const FlashlightState_t &GetFlashlightState( VMatrix &worldToTexture ) const
|
||||
{
|
||||
static FlashlightState_t blah;
|
||||
return blah;
|
||||
}
|
||||
|
||||
virtual const FlashlightState_t &GetFlashlightStateEx( VMatrix &worldToTexture, ITexture **pFlashlightDepthTexture ) const
|
||||
{
|
||||
static FlashlightState_t blah;
|
||||
return blah;
|
||||
}
|
||||
|
||||
virtual void ClearVertexAndPixelShaderRefCounts()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void PurgeUnusedVertexAndPixelShaders()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool IsAAEnabled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual int GetVertexTextureCount() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int GetMaxVertexTextureDimension() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int MaxTextureDepth() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Binds a vertex texture to a particular texture stage in the vertex pipe
|
||||
virtual void BindVertexTexture( VertexTextureSampler_t nSampler, ShaderAPITextureHandle_t hTexture )
|
||||
{
|
||||
}
|
||||
|
||||
// Sets morph target factors
|
||||
virtual void SetFlexWeights( int nFirstWeight, int nCount, const MorphWeight_t* pWeights )
|
||||
{
|
||||
}
|
||||
|
||||
// NOTE: Stuff after this is added after shipping HL2.
|
||||
ITexture *GetRenderTargetEx( int nRenderTargetID )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void SetToneMappingScaleLinear( const Vector &scale )
|
||||
{
|
||||
}
|
||||
|
||||
const Vector &GetToneMappingScaleLinear( void ) const
|
||||
{
|
||||
static Vector dummy;
|
||||
return dummy;
|
||||
}
|
||||
|
||||
virtual float GetLightMapScaleFactor( void ) const
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
|
||||
// For dealing with device lost in cases where SwapBuffers isn't called all the time (Hammer)
|
||||
virtual void HandleDeviceLost()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void EnableLinearColorSpaceFrameBuffer( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
// Lets the shader know about the full-screen texture so it can
|
||||
virtual void SetFullScreenTextureHandle( ShaderAPITextureHandle_t h )
|
||||
{
|
||||
}
|
||||
|
||||
void SetFloatRenderingParameter(int parm_number, float value)
|
||||
{
|
||||
}
|
||||
|
||||
void SetIntRenderingParameter(int parm_number, int value)
|
||||
{
|
||||
}
|
||||
void SetVectorRenderingParameter(int parm_number, Vector const &value)
|
||||
{
|
||||
}
|
||||
|
||||
float GetFloatRenderingParameter(int parm_number) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetIntRenderingParameter(int parm_number) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Vector GetVectorRenderingParameter(int parm_number) const
|
||||
{
|
||||
return Vector(0,0,0);
|
||||
}
|
||||
|
||||
// Methods related to stencil
|
||||
void SetStencilEnable(bool onoff)
|
||||
{
|
||||
}
|
||||
|
||||
void SetStencilFailOperation(StencilOperation_t op)
|
||||
{
|
||||
}
|
||||
|
||||
void SetStencilZFailOperation(StencilOperation_t op)
|
||||
{
|
||||
}
|
||||
|
||||
void SetStencilPassOperation(StencilOperation_t op)
|
||||
{
|
||||
}
|
||||
|
||||
void SetStencilCompareFunction(StencilComparisonFunction_t cmpfn)
|
||||
{
|
||||
}
|
||||
|
||||
void SetStencilReferenceValue(int ref)
|
||||
{
|
||||
}
|
||||
|
||||
void SetStencilTestMask(uint32 msk)
|
||||
{
|
||||
}
|
||||
|
||||
void SetStencilWriteMask(uint32 msk)
|
||||
{
|
||||
}
|
||||
|
||||
void ClearStencilBufferRectangle( int xmin, int ymin, int xmax, int ymax,int value)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void GetDXLevelDefaults(uint &max_dxlevel,uint &recommended_dxlevel)
|
||||
{
|
||||
max_dxlevel=recommended_dxlevel=90;
|
||||
}
|
||||
|
||||
virtual void GetMaxToRender( IMesh *pMesh, bool bMaxUntilFlush, int *pMaxVerts, int *pMaxIndices )
|
||||
{
|
||||
*pMaxVerts = 32768;
|
||||
*pMaxIndices = 32768;
|
||||
}
|
||||
|
||||
// Returns the max possible vertices + indices to render in a single draw call
|
||||
virtual int GetMaxVerticesToRender( IMaterial *pMaterial )
|
||||
{
|
||||
return 32768;
|
||||
}
|
||||
|
||||
virtual int GetMaxIndicesToRender( )
|
||||
{
|
||||
return 32768;
|
||||
}
|
||||
virtual int CompareSnapshots( StateSnapshot_t snapshot0, StateSnapshot_t snapshot1 ) { return 0; }
|
||||
|
||||
virtual void DisableAllLocalLights() {}
|
||||
|
||||
virtual bool SupportsMSAAMode( int nMSAAMode ) { return false; }
|
||||
|
||||
virtual bool SupportsCSAAMode( int nNumSamples, int nQualityLevel ) { return false; }
|
||||
|
||||
// Hooks for firing PIX events from outside the Material System...
|
||||
virtual void BeginPIXEvent( unsigned long color, const char *szName ) {}
|
||||
virtual void EndPIXEvent() {}
|
||||
virtual void SetPIXMarker( unsigned long color, const char *szName ) {}
|
||||
|
||||
virtual void ComputeVertexDescription( unsigned char* pBuffer, VertexFormat_t vertexFormat, MeshDesc_t& desc ) const {}
|
||||
|
||||
virtual bool SupportsShadowDepthTextures() { return false; }
|
||||
|
||||
virtual bool SupportsFetch4() { return false; }
|
||||
|
||||
virtual int NeedsShaderSRGBConversion(void) const { return 0; }
|
||||
virtual bool UsesSRGBCorrectBlending() const { return false; }
|
||||
|
||||
virtual bool HasFastVertexTextures() const { return false; }
|
||||
|
||||
virtual void SetShadowDepthBiasFactors( float fShadowSlopeScaleDepthBias, float fShadowDepthBias ) {}
|
||||
|
||||
virtual void SetDisallowAccess( bool ) {}
|
||||
virtual void EnableShaderShaderMutex( bool ) {}
|
||||
virtual void ShaderLock() {}
|
||||
virtual void ShaderUnlock() {}
|
||||
|
||||
// ------------ New Vertex/Index Buffer interface ----------------------------
|
||||
void BindVertexBuffer( int streamID, IVertexBuffer *pVertexBuffer, int nOffsetInBytes, int nFirstVertex, int nVertexCount, VertexFormat_t fmt, int nRepetitions1 )
|
||||
{
|
||||
}
|
||||
void BindIndexBuffer( IIndexBuffer *pIndexBuffer, int nOffsetInBytes )
|
||||
{
|
||||
}
|
||||
void Draw( MaterialPrimitiveType_t primitiveType, int firstIndex, int numIndices )
|
||||
{
|
||||
}
|
||||
// ------------ End ----------------------------
|
||||
|
||||
virtual int GetVertexBufferCompression( void ) const { return 0; };
|
||||
|
||||
virtual bool ShouldWriteDepthToDestAlpha( void ) const { return false; };
|
||||
virtual bool SupportsHDRMode( HDRType_t nHDRMode ) const { return false; };
|
||||
virtual bool IsDX10Card() const { return false; };
|
||||
|
||||
void PushDeformation( const DeformationBase_t *pDeformation )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void PopDeformation( )
|
||||
{
|
||||
}
|
||||
|
||||
int GetNumActiveDeformations( ) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// for shaders to set vertex shader constants. returns a packed state which can be used to set the dynamic combo
|
||||
int GetPackedDeformationInformation( int nMaskOfUnderstoodDeformations,
|
||||
float *pConstantValuesOut,
|
||||
int nBufferSize,
|
||||
int nMaximumDeformations,
|
||||
int *pNumDefsOut ) const
|
||||
{
|
||||
*pNumDefsOut = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SetStandardTextureHandle(StandardTextureId_t,ShaderAPITextureHandle_t)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void ExecuteCommandBuffer( uint8 *pData )
|
||||
{
|
||||
}
|
||||
virtual bool GetHDREnabled( void ) const { return true; }
|
||||
virtual void SetHDREnabled( bool bEnable ) {}
|
||||
|
||||
virtual void CopyRenderTargetToScratchTexture( ShaderAPITextureHandle_t srcRt, ShaderAPITextureHandle_t dstTex, Rect_t *pSrcRect = NULL, Rect_t *pDstRect = NULL )
|
||||
{
|
||||
}
|
||||
|
||||
// Allows locking and unlocking of very specific surface types.
|
||||
virtual void LockRect( void** pOutBits, int* pOutPitch, ShaderAPITextureHandle_t texHandle, int mipmap, int x, int y, int w, int h, bool bWrite, bool bRead )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void UnlockRect( ShaderAPITextureHandle_t texHandle, int mipmap )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void TexLodClamp( int finest ) {}
|
||||
|
||||
virtual void TexLodBias( float bias ) {}
|
||||
|
||||
virtual void CopyTextureToTexture( ShaderAPITextureHandle_t srcTex, ShaderAPITextureHandle_t dstTex ) {}
|
||||
|
||||
void PrintfVA( char *fmt, va_list vargs ) {}
|
||||
void Printf( const char *fmt, ... ) {}
|
||||
float Knob( char *knobname, float *setvalue = NULL ) { return 0.0f; };
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
TRANSLUCENT = 0x1,
|
||||
ALPHATESTED = 0x2,
|
||||
VERTEX_AND_PIXEL_SHADERS = 0x4,
|
||||
DEPTHWRITE = 0x8,
|
||||
};
|
||||
|
||||
CGLMesh m_Mesh;
|
||||
|
||||
void EnableAlphaToCoverage() {} ;
|
||||
void DisableAlphaToCoverage() {} ;
|
||||
|
||||
ImageFormat GetShadowDepthTextureFormat() { return IMAGE_FORMAT_UNKNOWN; };
|
||||
ImageFormat GetNullTextureFormat() { return IMAGE_FORMAT_UNKNOWN; };
|
||||
};
|
||||
|
||||
static CShaderAPIGL g_ShaderAPIGL;
|
||||
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderAPIGL, IMaterialSystemHardwareConfig,
|
||||
MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION, g_ShaderAPIGL )
|
||||
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderAPIGL, IDebugTextureInfo,
|
||||
DEBUG_TEXTURE_INFO_VERSION, g_ShaderAPIGL )
|
||||
|
||||
#endif
|
||||
0
materialsystem/shaderapigl/shaderdevicebase.cpp
Normal file
0
materialsystem/shaderapigl/shaderdevicebase.cpp
Normal file
0
materialsystem/shaderapigl/shaderdevicebase.h
Normal file
0
materialsystem/shaderapigl/shaderdevicebase.h
Normal file
205
materialsystem/shaderapigl/shadershadowgl.cpp
Normal file
205
materialsystem/shaderapigl/shadershadowgl.cpp
Normal file
@@ -0,0 +1,205 @@
|
||||
#include "utlvector.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "shaderapi/ishaderutil.h"
|
||||
#include "shaderapi/ishaderapi.h"
|
||||
#include "materialsystem/imesh.h"
|
||||
#include "materialsystem/idebugtextureinfo.h"
|
||||
#include "materialsystem/deformations.h"
|
||||
#include "meshgl.h"
|
||||
#include "shaderapigl.h"
|
||||
#include "shaderapidevicegl.h"
|
||||
#include "shadershadowgl.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The shader shadow interface
|
||||
//-----------------------------------------------------------------------------
|
||||
CShaderShadowGL::CShaderShadowGL()
|
||||
{
|
||||
m_IsTranslucent = false;
|
||||
m_IsAlphaTested = false;
|
||||
m_bIsDepthWriteEnabled = true;
|
||||
m_bUsesVertexAndPixelShaders = false;
|
||||
}
|
||||
|
||||
CShaderShadowGL::~CShaderShadowGL()
|
||||
{
|
||||
}
|
||||
|
||||
// Sets the default *shadow* state
|
||||
void CShaderShadowGL::SetDefaultState()
|
||||
{
|
||||
m_IsTranslucent = false;
|
||||
m_IsAlphaTested = false;
|
||||
m_bIsDepthWriteEnabled = true;
|
||||
m_bUsesVertexAndPixelShaders = false;
|
||||
}
|
||||
|
||||
// Methods related to depth buffering
|
||||
void CShaderShadowGL::DepthFunc( ShaderDepthFunc_t depthFunc )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderShadowGL::EnableDepthWrites( bool bEnable )
|
||||
{
|
||||
m_bIsDepthWriteEnabled = bEnable;
|
||||
}
|
||||
|
||||
void CShaderShadowGL::EnableDepthTest( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderShadowGL::EnablePolyOffset( PolygonOffsetMode_t nOffsetMode )
|
||||
{
|
||||
}
|
||||
|
||||
// Suppresses/activates color writing
|
||||
void CShaderShadowGL::EnableColorWrites( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
// Suppresses/activates alpha writing
|
||||
void CShaderShadowGL::EnableAlphaWrites( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
// Methods related to alpha blending
|
||||
void CShaderShadowGL::EnableBlending( bool bEnable )
|
||||
{
|
||||
m_IsTranslucent = bEnable;
|
||||
}
|
||||
|
||||
void CShaderShadowGL::BlendFunc( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor )
|
||||
{
|
||||
}
|
||||
|
||||
// A simpler method of dealing with alpha modulation
|
||||
void CShaderShadowGL::EnableAlphaPipe( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderShadowGL::EnableConstantAlpha( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderShadowGL::EnableVertexAlpha( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderShadowGL::EnableTextureAlpha( TextureStage_t stage, bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Alpha testing
|
||||
void CShaderShadowGL::EnableAlphaTest( bool bEnable )
|
||||
{
|
||||
m_IsAlphaTested = bEnable;
|
||||
}
|
||||
|
||||
void CShaderShadowGL::AlphaFunc( ShaderAlphaFunc_t alphaFunc, float alphaRef /* [0-1] */ )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Wireframe/filled polygons
|
||||
void CShaderShadowGL::PolyMode( ShaderPolyModeFace_t face, ShaderPolyMode_t polyMode )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Back face culling
|
||||
void CShaderShadowGL::EnableCulling( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Alpha to coverage
|
||||
void CShaderShadowGL::EnableAlphaToCoverage( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// constant color + transparency
|
||||
void CShaderShadowGL::EnableConstantColor( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
// Indicates the vertex format for use with a vertex shader
|
||||
// The flags to pass in here come from the VertexFormatFlags_t enum
|
||||
// If pTexCoordDimensions is *not* specified, we assume all coordinates
|
||||
// are 2-dimensional
|
||||
void CShaderShadowGL::VertexShaderVertexFormat( unsigned int nFlags,
|
||||
int nTexCoordCount,
|
||||
int* pTexCoordDimensions,
|
||||
int nUserDataSize )
|
||||
{
|
||||
}
|
||||
|
||||
// Indicates we're going to light the model
|
||||
void CShaderShadowGL::EnableLighting( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderShadowGL::EnableSpecular( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
// Activate/deactivate skinning
|
||||
void CShaderShadowGL::EnableVertexBlend( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
// per texture unit stuff
|
||||
void CShaderShadowGL::OverbrightValue( TextureStage_t stage, float value )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderShadowGL::EnableTexture( Sampler_t stage, bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderShadowGL::EnableCustomPixelPipe( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderShadowGL::CustomTextureStages( int stageCount )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderShadowGL::CustomTextureOperation( TextureStage_t stage, ShaderTexChannel_t channel,
|
||||
ShaderTexOp_t op, ShaderTexArg_t arg1, ShaderTexArg_t arg2 )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderShadowGL::EnableTexGen( TextureStage_t stage, bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
void CShaderShadowGL::TexGen( TextureStage_t stage, ShaderTexGenParam_t param )
|
||||
{
|
||||
}
|
||||
|
||||
// Sets the vertex and pixel shaders
|
||||
void CShaderShadowGL::SetVertexShader( const char *pShaderName, int vshIndex )
|
||||
{
|
||||
m_bUsesVertexAndPixelShaders = ( pShaderName != NULL );
|
||||
}
|
||||
|
||||
void CShaderShadowGL::EnableBlendingSeparateAlpha( bool bEnable )
|
||||
{
|
||||
}
|
||||
void CShaderShadowGL::SetPixelShader( const char *pShaderName, int pshIndex )
|
||||
{
|
||||
m_bUsesVertexAndPixelShaders = ( pShaderName != NULL );
|
||||
}
|
||||
|
||||
void CShaderShadowGL::BlendFuncSeparateAlpha( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor )
|
||||
{
|
||||
}
|
||||
// indicates what per-vertex data we're providing
|
||||
void CShaderShadowGL::DrawFlags( unsigned int drawFlags )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
172
materialsystem/shaderapigl/shadershadowgl.h
Normal file
172
materialsystem/shaderapigl/shadershadowgl.h
Normal file
@@ -0,0 +1,172 @@
|
||||
#ifndef SHADERSHADOWGL_H
|
||||
#define SHADERSHADOWGL_H
|
||||
|
||||
#include "shaderapi/ishadershadow.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The empty shader shadow
|
||||
//-----------------------------------------------------------------------------
|
||||
class CShaderShadowGL : public IShaderShadow
|
||||
{
|
||||
public:
|
||||
CShaderShadowGL();
|
||||
virtual ~CShaderShadowGL();
|
||||
|
||||
// Sets the default *shadow* state
|
||||
void SetDefaultState();
|
||||
|
||||
// Methods related to depth buffering
|
||||
void DepthFunc( ShaderDepthFunc_t depthFunc );
|
||||
void EnableDepthWrites( bool bEnable );
|
||||
void EnableDepthTest( bool bEnable );
|
||||
void EnablePolyOffset( PolygonOffsetMode_t nOffsetMode );
|
||||
|
||||
// Suppresses/activates color writing
|
||||
void EnableColorWrites( bool bEnable );
|
||||
void EnableAlphaWrites( bool bEnable );
|
||||
|
||||
// Methods related to alpha blending
|
||||
void EnableBlending( bool bEnable );
|
||||
void BlendFunc( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor );
|
||||
|
||||
// Alpha testing
|
||||
void EnableAlphaTest( bool bEnable );
|
||||
void AlphaFunc( ShaderAlphaFunc_t alphaFunc, float alphaRef /* [0-1] */ );
|
||||
|
||||
// Wireframe/filled polygons
|
||||
void PolyMode( ShaderPolyModeFace_t face, ShaderPolyMode_t polyMode );
|
||||
|
||||
// Back face culling
|
||||
void EnableCulling( bool bEnable );
|
||||
|
||||
// constant color + transparency
|
||||
void EnableConstantColor( bool bEnable );
|
||||
|
||||
// Indicates the vertex format for use with a vertex shader
|
||||
// The flags to pass in here come from the VertexFormatFlags_t enum
|
||||
// If pTexCoordDimensions is *not* specified, we assume all coordinates
|
||||
// are 2-dimensional
|
||||
void VertexShaderVertexFormat( unsigned int nFlags,
|
||||
int nTexCoordCount, int* pTexCoordDimensions, int nUserDataSize );
|
||||
|
||||
// Indicates we're going to light the model
|
||||
void EnableLighting( bool bEnable );
|
||||
void EnableSpecular( bool bEnable );
|
||||
|
||||
// vertex blending
|
||||
void EnableVertexBlend( bool bEnable );
|
||||
|
||||
// per texture unit stuff
|
||||
void OverbrightValue( TextureStage_t stage, float value );
|
||||
void EnableTexture( Sampler_t stage, bool bEnable );
|
||||
void EnableTexGen( TextureStage_t stage, bool bEnable );
|
||||
void TexGen( TextureStage_t stage, ShaderTexGenParam_t param );
|
||||
|
||||
// alternate method of specifying per-texture unit stuff, more flexible and more complicated
|
||||
// Can be used to specify different operation per channel (alpha/color)...
|
||||
void EnableCustomPixelPipe( bool bEnable );
|
||||
void CustomTextureStages( int stageCount );
|
||||
void CustomTextureOperation( TextureStage_t stage, ShaderTexChannel_t channel,
|
||||
ShaderTexOp_t op, ShaderTexArg_t arg1, ShaderTexArg_t arg2 );
|
||||
|
||||
// indicates what per-vertex data we're providing
|
||||
void DrawFlags( unsigned int drawFlags );
|
||||
|
||||
// A simpler method of dealing with alpha modulation
|
||||
void EnableAlphaPipe( bool bEnable );
|
||||
void EnableConstantAlpha( bool bEnable );
|
||||
void EnableVertexAlpha( bool bEnable );
|
||||
void EnableTextureAlpha( TextureStage_t stage, bool bEnable );
|
||||
|
||||
// GR - Separate alpha blending
|
||||
void EnableBlendingSeparateAlpha( bool bEnable );
|
||||
void BlendFuncSeparateAlpha( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor );
|
||||
|
||||
// Sets the vertex and pixel shaders
|
||||
void SetVertexShader( const char *pFileName, int vshIndex );
|
||||
void SetPixelShader( const char *pFileName, int pshIndex );
|
||||
|
||||
// Convert from linear to gamma color space on writes to frame buffer.
|
||||
void EnableSRGBWrite( bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
void EnableSRGBRead( Sampler_t stage, bool bEnable )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void FogMode( ShaderFogMode_t fogMode )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void DisableFogGammaCorrection( bool bDisable )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void SetDiffuseMaterialSource( ShaderMaterialSource_t materialSource )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void SetMorphFormat( MorphFormat_t flags )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void EnableStencil( bool bEnable )
|
||||
{
|
||||
}
|
||||
virtual void StencilFunc( ShaderStencilFunc_t stencilFunc )
|
||||
{
|
||||
}
|
||||
virtual void StencilPassOp( ShaderStencilOp_t stencilOp )
|
||||
{
|
||||
}
|
||||
virtual void StencilFailOp( ShaderStencilOp_t stencilOp )
|
||||
{
|
||||
}
|
||||
virtual void StencilDepthFailOp( ShaderStencilOp_t stencilOp )
|
||||
{
|
||||
}
|
||||
virtual void StencilReference( int nReference )
|
||||
{
|
||||
}
|
||||
virtual void StencilMask( int nMask )
|
||||
{
|
||||
}
|
||||
virtual void StencilWriteMask( int nMask )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void ExecuteCommandBuffer( uint8 *pBuf )
|
||||
{
|
||||
}
|
||||
// Alpha to coverage
|
||||
void EnableAlphaToCoverage( bool bEnable );
|
||||
|
||||
virtual void SetShadowDepthFiltering( Sampler_t stage )
|
||||
{
|
||||
}
|
||||
|
||||
virtual void BlendOp( ShaderBlendOp_t blendOp ) {}
|
||||
virtual void BlendOpSeparateAlpha( ShaderBlendOp_t blendOp ) {}
|
||||
|
||||
bool m_IsTranslucent;
|
||||
bool m_IsAlphaTested;
|
||||
bool m_bIsDepthWriteEnabled;
|
||||
bool m_bUsesVertexAndPixelShaders;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class Factory
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static CShaderShadowGL g_ShaderShadow;
|
||||
|
||||
// FIXME: Remove; it's for backward compat with the materialsystem only for now
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderAPIGL, IShaderAPI,
|
||||
SHADERAPI_INTERFACE_VERSION, g_ShaderAPIGL )
|
||||
|
||||
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CShaderShadowGL, IShaderShadow,
|
||||
SHADERSHADOW_INTERFACE_VERSION, g_ShaderShadow )
|
||||
|
||||
|
||||
#endif
|
||||
56
materialsystem/shaderapigl/wscript
Executable file
56
materialsystem/shaderapigl/wscript
Executable file
@@ -0,0 +1,56 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
from waflib import Utils
|
||||
import os
|
||||
|
||||
top = '.'
|
||||
PROJECT_NAME = 'shaderapigl'
|
||||
|
||||
def options(opt):
|
||||
# stub
|
||||
return
|
||||
|
||||
def configure(conf):
|
||||
conf.env.append_unique('DEFINES',[
|
||||
'SHADER_DLL_EXPORT',
|
||||
'PROTECTED_THINGS_ENABLE'
|
||||
])
|
||||
|
||||
def build(bld):
|
||||
source = [
|
||||
'shaderapigl.cpp',
|
||||
'shaderapidevicegl.cpp',
|
||||
'shadershadowgl.cpp',
|
||||
'meshgl.cpp',
|
||||
'../../public/tier0/memoverride.cpp'
|
||||
]
|
||||
|
||||
includes = [
|
||||
'.',
|
||||
'../../public',
|
||||
'../../public/tier0',
|
||||
'../../public/tier1',
|
||||
'../../common',
|
||||
'../'
|
||||
] + bld.env.INCLUDES_SDL2
|
||||
|
||||
defines = []
|
||||
|
||||
libs = ['tier0','tier1']
|
||||
|
||||
install_path = bld.env.LIBDIR
|
||||
|
||||
bld.shlib(
|
||||
source = source,
|
||||
target = PROJECT_NAME,
|
||||
name = PROJECT_NAME,
|
||||
features = 'c cxx',
|
||||
includes = includes,
|
||||
defines = defines,
|
||||
use = libs,
|
||||
install_path = install_path,
|
||||
subsystem = bld.env.MSVC_SUBSYSTEM,
|
||||
idx = bld.get_taskgen_count()
|
||||
)
|
||||
|
||||
@@ -420,13 +420,6 @@ void MatrixGetColumn( const matrix3x4_t& in, int column, Vector &out )
|
||||
out.z = in[2][column];
|
||||
}
|
||||
|
||||
void MatrixSetColumn( const Vector &in, int column, matrix3x4_t& out )
|
||||
{
|
||||
out[0][column] = in.x;
|
||||
out[1][column] = in.y;
|
||||
out[2][column] = in.z;
|
||||
}
|
||||
|
||||
void MatrixScaleBy ( const float flScale, matrix3x4_t &out )
|
||||
{
|
||||
out[0][0] *= flScale;
|
||||
@@ -1092,57 +1085,6 @@ void SetScaleMatrix( float x, float y, float z, matrix3x4_t &dst )
|
||||
dst[2][0] = 0.0f; dst[2][1] = 0.0f; dst[2][2] = z; dst[2][3] = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Builds the matrix for a counterclockwise rotation about an arbitrary axis.
|
||||
//
|
||||
// | ax2 + (1 - ax2)cosQ axay(1 - cosQ) - azsinQ azax(1 - cosQ) + aysinQ |
|
||||
// Ra(Q) = | axay(1 - cosQ) + azsinQ ay2 + (1 - ay2)cosQ ayaz(1 - cosQ) - axsinQ |
|
||||
// | azax(1 - cosQ) - aysinQ ayaz(1 - cosQ) + axsinQ az2 + (1 - az2)cosQ |
|
||||
//
|
||||
// Input : mat -
|
||||
// vAxisOrRot -
|
||||
// angle -
|
||||
//-----------------------------------------------------------------------------
|
||||
void MatrixBuildRotationAboutAxis( const Vector &vAxisOfRot, float angleDegrees, matrix3x4_t &dst )
|
||||
{
|
||||
float radians;
|
||||
float axisXSquared;
|
||||
float axisYSquared;
|
||||
float axisZSquared;
|
||||
float fSin;
|
||||
float fCos;
|
||||
|
||||
radians = angleDegrees * ( M_PI / 180.0 );
|
||||
fSin = sin( radians );
|
||||
fCos = cos( radians );
|
||||
|
||||
axisXSquared = vAxisOfRot[0] * vAxisOfRot[0];
|
||||
axisYSquared = vAxisOfRot[1] * vAxisOfRot[1];
|
||||
axisZSquared = vAxisOfRot[2] * vAxisOfRot[2];
|
||||
|
||||
// Column 0:
|
||||
dst[0][0] = axisXSquared + (1 - axisXSquared) * fCos;
|
||||
dst[1][0] = vAxisOfRot[0] * vAxisOfRot[1] * (1 - fCos) + vAxisOfRot[2] * fSin;
|
||||
dst[2][0] = vAxisOfRot[2] * vAxisOfRot[0] * (1 - fCos) - vAxisOfRot[1] * fSin;
|
||||
|
||||
// Column 1:
|
||||
dst[0][1] = vAxisOfRot[0] * vAxisOfRot[1] * (1 - fCos) - vAxisOfRot[2] * fSin;
|
||||
dst[1][1] = axisYSquared + (1 - axisYSquared) * fCos;
|
||||
dst[2][1] = vAxisOfRot[1] * vAxisOfRot[2] * (1 - fCos) + vAxisOfRot[0] * fSin;
|
||||
|
||||
// Column 2:
|
||||
dst[0][2] = vAxisOfRot[2] * vAxisOfRot[0] * (1 - fCos) + vAxisOfRot[1] * fSin;
|
||||
dst[1][2] = vAxisOfRot[1] * vAxisOfRot[2] * (1 - fCos) - vAxisOfRot[0] * fSin;
|
||||
dst[2][2] = axisZSquared + (1 - axisZSquared) * fCos;
|
||||
|
||||
// Column 3:
|
||||
dst[0][3] = 0;
|
||||
dst[1][3] = 0;
|
||||
dst[2][3] = 0;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Computes the transpose
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1450,33 +1392,6 @@ void VectorYawRotate( const Vector &in, float flYaw, Vector &out)
|
||||
out.z = in.z;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float Bias( float x, float biasAmt )
|
||||
{
|
||||
// WARNING: not thread safe
|
||||
static float lastAmt = -1;
|
||||
static float lastExponent = 0;
|
||||
if( lastAmt != biasAmt )
|
||||
{
|
||||
lastExponent = log( biasAmt ) * -1.4427f; // (-1.4427 = 1 / log(0.5))
|
||||
}
|
||||
float fRet = pow( x, lastExponent );
|
||||
Assert ( !IS_NAN( fRet ) );
|
||||
return fRet;
|
||||
}
|
||||
|
||||
|
||||
float Gain( float x, float biasAmt )
|
||||
{
|
||||
// WARNING: not thread safe
|
||||
if( x < 0.5 )
|
||||
return 0.5f * Bias( 2*x, 1-biasAmt );
|
||||
else
|
||||
return 1 - 0.5f * Bias( 2 - 2*x, 1-biasAmt );
|
||||
}
|
||||
|
||||
|
||||
float SmoothCurve( float x )
|
||||
{
|
||||
// Actual smooth curve. Visualization:
|
||||
|
||||
1264
mathlib/vmatrix.cpp
1264
mathlib/vmatrix.cpp
File diff suppressed because it is too large
Load Diff
@@ -22,10 +22,16 @@ extern float (*pfFastCos)(float x);
|
||||
|
||||
// The following are not declared as macros because they are often used in limiting situations,
|
||||
// and sometimes the compiler simply refuses to inline them for some reason
|
||||
#define FastSqrt(x) (*pfSqrt)(x)
|
||||
#define FastRSqrt(x) (*pfRSqrt)(x)
|
||||
#define FastRSqrtFast(x) (*pfRSqrtFast)(x)
|
||||
#define FastSqrt(x) sqrtf(x)
|
||||
#define FastRSqrt(x) (1.f/sqrtf(x))
|
||||
#define FastRSqrtFast(x) (1.f/sqrtf(x))
|
||||
|
||||
#ifdef _WIN32
|
||||
#define FastSinCos(x,s,c) (*pfFastSinCos)(x,s,c)
|
||||
#else
|
||||
#define FastSinCos(x,s,c) sincosf(x,s,c)
|
||||
#endif
|
||||
|
||||
#define FastCos(x) (*pfFastCos)(x)
|
||||
|
||||
#if defined(__i386__) || defined(_M_IX86)
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
// FP exception clean so this not a turnkey operation.
|
||||
//#define FP_EXCEPTIONS_ENABLED
|
||||
|
||||
|
||||
#ifdef FP_EXCEPTIONS_ENABLED
|
||||
#include <float.h> // For _clearfp and _controlfp_s
|
||||
#endif
|
||||
@@ -93,37 +92,11 @@ private:
|
||||
FPExceptionEnabler& operator=(const FPExceptionEnabler&);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG // stop crashing edit-and-continue
|
||||
FORCEINLINE float clamp( float val, float minVal, float maxVal )
|
||||
inline float clamp( const float val, const float minVal, const float maxVal )
|
||||
{
|
||||
if ( maxVal < minVal )
|
||||
return maxVal;
|
||||
else if( val < minVal )
|
||||
return minVal;
|
||||
else if( val > maxVal )
|
||||
return maxVal;
|
||||
else
|
||||
return val;
|
||||
const float t = val < minVal ? minVal : val;
|
||||
return t > maxVal ? maxVal : t;
|
||||
}
|
||||
#else // DEBUG
|
||||
FORCEINLINE float clamp( float val, float minVal, float maxVal )
|
||||
{
|
||||
#if defined(__i386__) || defined(_M_IX86)
|
||||
_mm_store_ss( &val,
|
||||
_mm_min_ss(
|
||||
_mm_max_ss(
|
||||
_mm_load_ss(&val),
|
||||
_mm_load_ss(&minVal) ),
|
||||
_mm_load_ss(&maxVal) ) );
|
||||
#else
|
||||
val = fpmax(minVal, val);
|
||||
val = fpmin(maxVal, val);
|
||||
#endif
|
||||
return val;
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
//
|
||||
// Returns a clamped value in the range [min, max].
|
||||
@@ -131,17 +104,10 @@ FORCEINLINE float clamp( float val, float minVal, float maxVal )
|
||||
template< class T >
|
||||
inline T clamp( T const &val, T const &minVal, T const &maxVal )
|
||||
{
|
||||
if ( maxVal < minVal )
|
||||
return maxVal;
|
||||
else if( val < minVal )
|
||||
return minVal;
|
||||
else if( val > maxVal )
|
||||
return maxVal;
|
||||
else
|
||||
return val;
|
||||
const T t = val< minVal ? minVal : val;
|
||||
return t > maxVal ? maxVal : t;
|
||||
}
|
||||
|
||||
|
||||
// plane_t structure
|
||||
// !!! if this is changed, it must be changed in asm code too !!!
|
||||
// FIXME: does the asm code even exist anymore?
|
||||
@@ -237,8 +203,8 @@ bool R_CullBoxSkipNear( const Vector& mins, const Vector& maxs, const Frustum_t
|
||||
|
||||
struct matrix3x4_t
|
||||
{
|
||||
matrix3x4_t() = default;
|
||||
matrix3x4_t(
|
||||
inline matrix3x4_t() = default;
|
||||
inline matrix3x4_t(
|
||||
float m00, float m01, float m02, float m03,
|
||||
float m10, float m11, float m12, float m13,
|
||||
float m20, float m21, float m22, float m23 )
|
||||
@@ -252,7 +218,7 @@ struct matrix3x4_t
|
||||
// Creates a matrix where the X axis = forward
|
||||
// the Y axis = left, and the Z axis = up
|
||||
//-----------------------------------------------------------------------------
|
||||
void Init( const Vector& xAxis, const Vector& yAxis, const Vector& zAxis, const Vector &vecOrigin )
|
||||
inline void Init( const Vector& xAxis, const Vector& yAxis, const Vector& zAxis, const Vector &vecOrigin )
|
||||
{
|
||||
m_flMatVal[0][0] = xAxis.x; m_flMatVal[0][1] = yAxis.x; m_flMatVal[0][2] = zAxis.x; m_flMatVal[0][3] = vecOrigin.x;
|
||||
m_flMatVal[1][0] = xAxis.y; m_flMatVal[1][1] = yAxis.y; m_flMatVal[1][2] = zAxis.y; m_flMatVal[1][3] = vecOrigin.y;
|
||||
@@ -263,26 +229,23 @@ struct matrix3x4_t
|
||||
// Creates a matrix where the X axis = forward
|
||||
// the Y axis = left, and the Z axis = up
|
||||
//-----------------------------------------------------------------------------
|
||||
matrix3x4_t( const Vector& xAxis, const Vector& yAxis, const Vector& zAxis, const Vector &vecOrigin )
|
||||
inline matrix3x4_t( const Vector& xAxis, const Vector& yAxis, const Vector& zAxis, const Vector &vecOrigin )
|
||||
{
|
||||
Init( xAxis, yAxis, zAxis, vecOrigin );
|
||||
}
|
||||
|
||||
inline void Invalidate( void )
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
for( int i=0; i < 12; i++ )
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
m_flMatVal[i][j] = VEC_T_NAN;
|
||||
}
|
||||
((float*)m_flMatVal)[i] = VEC_T_NAN;
|
||||
}
|
||||
}
|
||||
|
||||
float *operator[]( int i ) { Assert(( i >= 0 ) && ( i < 3 )); return m_flMatVal[i]; }
|
||||
const float *operator[]( int i ) const { Assert(( i >= 0 ) && ( i < 3 )); return m_flMatVal[i]; }
|
||||
float *Base() { return &m_flMatVal[0][0]; }
|
||||
const float *Base() const { return &m_flMatVal[0][0]; }
|
||||
inline float *operator[]( int i ) { Assert(( i >= 0 ) && ( i < 3 )); return m_flMatVal[i]; }
|
||||
inline const float *operator[]( int i ) const { Assert(( i >= 0 ) && ( i < 3 )); return m_flMatVal[i]; }
|
||||
inline float *Base() { return &m_flMatVal[0][0]; }
|
||||
inline const float *Base() const { return &m_flMatVal[0][0]; }
|
||||
|
||||
float m_flMatVal[3][4];
|
||||
};
|
||||
@@ -565,7 +528,13 @@ void MatrixInvert( const matrix3x4_t &in, matrix3x4_t &out );
|
||||
bool MatricesAreEqual( const matrix3x4_t &src1, const matrix3x4_t &src2, float flTolerance = 1e-5 );
|
||||
|
||||
void MatrixGetColumn( const matrix3x4_t &in, int column, Vector &out );
|
||||
void MatrixSetColumn( const Vector &in, int column, matrix3x4_t &out );
|
||||
|
||||
inline void MatrixSetColumn( const Vector &in, int column, matrix3x4_t& out )
|
||||
{
|
||||
out[0][column] = in.x;
|
||||
out[1][column] = in.y;
|
||||
out[2][column] = in.z;
|
||||
}
|
||||
|
||||
inline void MatrixGetTranslation( const matrix3x4_t &in, Vector &out )
|
||||
{
|
||||
@@ -1079,7 +1048,19 @@ void VectorYawRotate( const Vector& in, float flYaw, Vector &out);
|
||||
// 0 1
|
||||
//
|
||||
// With a biasAmt of 0.5, Bias returns X.
|
||||
float Bias( float x, float biasAmt );
|
||||
inline float Bias( float x, float biasAmt )
|
||||
{
|
||||
// WARNING: not thread safe
|
||||
static float lastAmt = -1;
|
||||
static float lastExponent = 0;
|
||||
if( lastAmt != biasAmt )
|
||||
{
|
||||
lastExponent = log( biasAmt ) * -1.4427f; // (-1.4427 = 1 / log(0.5))
|
||||
}
|
||||
float fRet = pow( x, lastExponent );
|
||||
Assert ( !IS_NAN( fRet ) );
|
||||
return fRet;
|
||||
}
|
||||
|
||||
|
||||
// Gain is similar to Bias, but biasAmt biases towards or away from 0.5.
|
||||
@@ -1111,9 +1092,14 @@ float Bias( float x, float biasAmt );
|
||||
// |*****
|
||||
// |___________________
|
||||
// 0 1
|
||||
float Gain( float x, float biasAmt );
|
||||
|
||||
|
||||
inline float Gain( float x, float biasAmt )
|
||||
{
|
||||
// WARNING: not thread safe
|
||||
if( x < 0.5 )
|
||||
return 0.5f * Bias( 2*x, 1-biasAmt );
|
||||
else
|
||||
return 1 - 0.5f * Bias( 2 - 2*x, 1-biasAmt );
|
||||
}
|
||||
// SmoothCurve maps a 0-1 value into another 0-1 value based on a cosine wave
|
||||
// where the derivatives of the function at 0 and 1 (and 0.5) are 0. This is useful for
|
||||
// any fadein/fadeout effect where it should start and end smoothly.
|
||||
|
||||
@@ -35,7 +35,7 @@ class Vector2D;
|
||||
// 4D Vector4D
|
||||
//=========================================================
|
||||
|
||||
class Vector4D
|
||||
class alignas(16) Vector4D
|
||||
{
|
||||
public:
|
||||
// Members
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,13 +38,17 @@
|
||||
#define XBOX_CODELINE_ONLY() Error_Compiling_Code_Only_Valid_in_Xbox_Codeline
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(PLATFORM_GLIBC) && defined(LINUX) // fuck musl
|
||||
#ifdef nullptr
|
||||
#undef nullptr
|
||||
#endif
|
||||
#define nullptr 0
|
||||
#endif
|
||||
|
||||
|
||||
// stdio.h
|
||||
#ifdef NULL
|
||||
#if !defined( NULL ) || defined( PLATFORM_BSD )
|
||||
#undef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
@@ -1042,7 +1042,7 @@ typedef enum _D3DSHADER_PARAM_REGISTER_TYPE
|
||||
D3DSPR_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
|
||||
} D3DSHADER_PARAM_REGISTER_TYPE;
|
||||
|
||||
struct D3DMATRIX
|
||||
struct alignas(16) D3DMATRIX
|
||||
{
|
||||
union
|
||||
{
|
||||
|
||||
@@ -1042,7 +1042,7 @@ typedef enum _D3DSHADER_PARAM_REGISTER_TYPE
|
||||
D3DSPR_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
|
||||
} D3DSHADER_PARAM_REGISTER_TYPE;
|
||||
|
||||
struct D3DMATRIX
|
||||
struct alignas(16) D3DMATRIX
|
||||
{
|
||||
union
|
||||
{
|
||||
|
||||
@@ -95,6 +95,8 @@ TextEntry::TextEntry(Panel *parent, const char *panelName) : BaseClass(parent, p
|
||||
|
||||
SetEditable(true);
|
||||
|
||||
_dataChanged = false;
|
||||
|
||||
// initialize the line break array
|
||||
m_LineBreaks.AddToTail(BUFFER_SIZE);
|
||||
|
||||
|
||||
22
wscript
22
wscript
@@ -51,7 +51,7 @@ projects={
|
||||
'launcher',
|
||||
'launcher_main',
|
||||
'materialsystem',
|
||||
# 'materialsystem/shaderapiempty',
|
||||
'materialsystem/shaderapigl',
|
||||
'materialsystem/shaderapidx9',
|
||||
'materialsystem/shaderlib',
|
||||
'materialsystem/stdshaders',
|
||||
@@ -198,6 +198,8 @@ def define_platform(conf):
|
||||
'NO_HOOK_MALLOC',
|
||||
'_DLL_EXT=.so'
|
||||
])
|
||||
conf.env.append_unique('CFLAGS', '-U_FORTIFY_SOURCE')
|
||||
conf.env.append_unique('CXXFLAGS', '-U_FORTIFY_SOURCE')
|
||||
elif conf.env.DEST_OS == 'android':
|
||||
conf.env.append_unique('DEFINES', [
|
||||
'ANDROID=1', '_ANDROID=1',
|
||||
@@ -207,6 +209,7 @@ def define_platform(conf):
|
||||
'NO_HOOK_MALLOC',
|
||||
'_DLL_EXT=.so'
|
||||
])
|
||||
|
||||
elif conf.env.DEST_OS == 'win32':
|
||||
conf.env.append_unique('DEFINES', [
|
||||
'WIN32=1', '_WIN32=1',
|
||||
@@ -511,30 +514,32 @@ def configure(conf):
|
||||
'/TP',
|
||||
'/EHsc'
|
||||
]
|
||||
|
||||
|
||||
if conf.options.BUILD_TYPE == 'debug':
|
||||
linkflags += [
|
||||
'/INCREMENTAL:NO',
|
||||
'/NODEFAULTLIB:libc',
|
||||
'/NODEFAULTLIB:libcd',
|
||||
'/NODEFAULTLIB:libcmt',
|
||||
'/FORCE'
|
||||
'/FORCE',
|
||||
'/LARGEADDRESSAWARE'
|
||||
]
|
||||
else:
|
||||
linkflags += [
|
||||
'/INCREMENTAL',
|
||||
'/NODEFAULTLIB:libc',
|
||||
'/NODEFAULTLIB:libcd',
|
||||
'/NODEFAULTLIB:libcmtd'
|
||||
'/NODEFAULTLIB:libcmtd',
|
||||
'/LARGEADDRESSAWARE'
|
||||
]
|
||||
|
||||
linkflags += [
|
||||
'/LIBPATH:'+os.path.abspath('.')+'/lib/win32/'+conf.env.DEST_CPU+'/',
|
||||
'/LIBPATH:'+os.path.abspath('.')+'/dx9sdk/lib/'+conf.env.DEST_CPU+'/'
|
||||
]
|
||||
|
||||
|
||||
# And here C++ flags starts to be treated separately
|
||||
cxxflags = list(cflags)
|
||||
cxxflags = list(cflags)
|
||||
if conf.env.DEST_OS != 'win32':
|
||||
cxxflags += ['-std=c++11','-fpermissive']
|
||||
|
||||
@@ -588,6 +593,11 @@ def configure(conf):
|
||||
def build(bld):
|
||||
os.environ["CCACHE_DIR"] = os.path.abspath('.ccache/'+bld.env.COMPILER_CC+'/'+bld.env.DEST_OS+'/'+bld.env.DEST_CPU)
|
||||
|
||||
if bld.env.DEST_OS in ['win32', 'android']:
|
||||
sdl_name = 'SDL2.dll' if bld.env.DEST_OS == 'win32' else 'libSDL2.so'
|
||||
sdl_path = os.path.join('lib', bld.env.DEST_OS, bld.env.DEST_CPU, sdl_name)
|
||||
bld.install_files(bld.env.LIBDIR, [sdl_path])
|
||||
|
||||
if bld.env.DEST_OS == 'win32':
|
||||
projects['game'] += ['utils/bzip2']
|
||||
projects['dedicated'] += ['utils/bzip2']
|
||||
|
||||
Reference in New Issue
Block a user