1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-19 03:56:10 +08:00

Sync with upstream (Issue #30).

Recompiled tier1 and mathlib  for all platforms will come in next commit.
This commit is contained in:
Nicholas Hastings
2016-11-30 10:01:15 -05:00
parent 98fe5b5a34
commit 3957adff10
491 changed files with 29846 additions and 10698 deletions

View File

@ -21,8 +21,9 @@
// it's not 256, because you can't use all 256 slots in 10.5.x.
// use this constant everywhere you might normally use "256" in reference to a parameter array size.
// The highest shader constant is c218, plus we allocate c219 and c220 for two clip planes
#define DXABSTRACT_VS_PARAM_SLOTS 219
#define DXABSTRACT_VS_PARAM_SLOTS 228
#define DXABSTRACT_VS_FIRST_BONE_SLOT VERTEX_SHADER_MODEL
#define DXABSTRACT_VS_LAST_BONE_SLOT (VERTEX_SHADER_SHADER_SPECIFIC_CONST_13-1)
// user clip plane 0 goes in DXABSTRACT_VS_CLIP_PLANE_BASE... plane 1 goes in the slot after that
// dxabstract uses these constants to check plane index limit and to deliver planes to shader for DP4 -> oCLP[n]
@ -33,6 +34,8 @@
#include "materialsystem/imaterialsystem.h"
#include "materialsystem/ishaderapi.h"
#include "materialsystem/ishadersystem_declarations.h"
//-----------------------------------------------------------------------------
// forward declarations
@ -43,24 +46,6 @@ class IShaderDynamicAPI;
class IShaderInit;
class CBasePerMaterialContextData;
//-----------------------------------------------------------------------------
// Shader flags
//-----------------------------------------------------------------------------
enum ShaderFlags_t
{
SHADER_NOT_EDITABLE = 0x1
};
//-----------------------------------------------------------------------------
// Shader parameter flags
//-----------------------------------------------------------------------------
enum ShaderParamFlags_t
{
SHADER_PARAM_NOT_EDITABLE = 0x1
};
//-----------------------------------------------------------------------------
// Information about each shader parameter
//-----------------------------------------------------------------------------
@ -74,72 +59,10 @@ struct ShaderParamInfo_t
};
//-----------------------------------------------------------------------------
// Standard vertex shader constants
//-----------------------------------------------------------------------------
enum
{
// Standard vertex shader constants
VERTEX_SHADER_MATH_CONSTANTS0 = 0,
VERTEX_SHADER_MATH_CONSTANTS1 = 1,
VERTEX_SHADER_CAMERA_POS = 2,
VERTEX_SHADER_FLEXSCALE = 3, // used by DX9 only!
VERTEX_SHADER_LIGHT_INDEX = 3, // used by DX8 only!
VERTEX_SHADER_MODELVIEWPROJ = 4,
VERTEX_SHADER_VIEWPROJ = 8,
VERTEX_SHADER_MODELVIEWPROJ_THIRD_ROW = 12,
VERTEX_SHADER_VIEWPROJ_THIRD_ROW = 13,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_10 = 14,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_11 = 15,
VERTEX_SHADER_FOG_PARAMS = 16,
VERTEX_SHADER_VIEWMODEL = 17,
VERTEX_SHADER_AMBIENT_LIGHT = 21,
VERTEX_SHADER_LIGHTS = 27,
VERTEX_SHADER_LIGHT0_POSITION = 29,
VERTEX_SHADER_MODULATION_COLOR = 47,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_0 = 48,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_1 = 49,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_2 = 50,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_3 = 51,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_4 = 52,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_5 = 53,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_6 = 54,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_7 = 55,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_8 = 56,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_9 = 57,
VERTEX_SHADER_MODEL = 58,
//
// We reserve up through 216 for the 53 bones
//
// 219 ClipPlane0 |------ OpenGL will jam clip planes into these two
// 220 ClipPlane1 |
VERTEX_SHADER_FLEX_WEIGHTS = 1024,
VERTEX_SHADER_MAX_FLEX_WEIGHT_COUNT = 512,
};
#define VERTEX_SHADER_BONE_TRANSFORM( k ) ( VERTEX_SHADER_MODEL + 3 * (k) )
//-----------------------------------------------------------------------------
// Standard vertex shader constants
//-----------------------------------------------------------------------------
enum
{
// Standard vertex shader constants
VERTEX_SHADER_LIGHT_ENABLE_BOOL_CONST = 0,
VERTEX_SHADER_LIGHT_ENABLE_BOOL_CONST_COUNT = 4,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_0 = 4,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_1 = 5,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_2 = 6,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_3 = 7,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_4 = 8,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_5 = 9,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_6 = 10,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_7 = 11,
};
// The public methods exposed by each shader
//-----------------------------------------------------------------------------
abstract_class IShader
@ -179,27 +102,4 @@ public:
// virtual const ShaderParamInfo_t& GetParamInfo( int paramIndex ) const = 0;
};
//-----------------------------------------------------------------------------
// Shader dictionaries defined in DLLs
//-----------------------------------------------------------------------------
enum PrecompiledShaderType_t
{
PRECOMPILED_VERTEX_SHADER = 0,
PRECOMPILED_PIXEL_SHADER,
PRECOMPILED_SHADER_TYPE_COUNT,
};
//-----------------------------------------------------------------------------
// Flags field of PrecompiledShader_t
//-----------------------------------------------------------------------------
enum
{
// runtime flags
SHADER_DYNAMIC_COMPILE_IS_HLSL = 0x1,
SHADER_FAILED_LOAD = 0x2,
};
#endif // ISHADER_H

View File

@ -0,0 +1,29 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef COMBINEOPERATIONS_H
#define COMBINEOPERATIONS_H
#pragma once
// New combines can be written in the middle (and generally should be written before Error).
// Keep these in sync with cCombineMaterialName in ctexturecompositor.cpp
enum ECombineOperation
{
ECO_Multiply = 0,
ECO_Add,
ECO_Lerp,
ECO_Select,
ECO_Legacy_Lerp_FirstPass,
ECO_Legacy_Lerp_SecondPass,
ECO_Error,
ECO_COUNT
};
#endif /* COMBINEOPERATIONS_H */

View File

@ -43,6 +43,7 @@ struct MaterialSystem_Config_t;
class VMatrix;
struct matrix3x4_t;
class ITexture;
class ITextureCompositor;
struct MaterialSystemHardwareIdentifier_t;
class KeyValues;
class IShader;
@ -88,6 +89,7 @@ enum ShaderParamType_t
SHADER_PARAM_TYPE_MATRIX,
SHADER_PARAM_TYPE_MATERIAL,
SHADER_PARAM_TYPE_STRING,
SHADER_PARAM_TYPE_MATRIX4X2
};
enum MaterialMatrixMode_t
@ -289,7 +291,6 @@ private:
#define CREATERENDERTARGETFLAGS_NOEDRAM 0x00000008 // inhibit allocation in 360 EDRAM
#define CREATERENDERTARGETFLAGS_TEMP 0x00000010 // only allocates memory upon first resolve, destroyed at level end
//-----------------------------------------------------------------------------
// allowed stencil operations. These match the d3d operations
//-----------------------------------------------------------------------------
@ -478,6 +479,21 @@ private:
int m_nBottom;
};
// Passed as the callback object to Async functions in the material system
// so that callers don't have to worry about memory going out of scope before the
// results return.
abstract_class IAsyncTextureOperationReceiver : public IRefCounted
{
public:
virtual void OnAsyncCreateComplete( ITexture* pTex, void* pExtraArgs ) = 0;
virtual void OnAsyncFindComplete( ITexture* pTex, void* pExtraArgs ) = 0;
virtual void OnAsyncMapComplete( ITexture* pTex, void* pExtraArgs, void* pMemory, int nPitch ) = 0;
virtual void OnAsyncReadbackBegin( ITexture* pDst, ITexture* pSrc, void* pExtraArgs ) = 0;
virtual int GetRefCount() const = 0;
};
//-----------------------------------------------------------------------------
// Flags to be used with the Init call
//-----------------------------------------------------------------------------
@ -525,7 +541,9 @@ enum RenderTargetSizeMode_t
RT_SIZE_OFFSCREEN=5, // Target of specified size, don't mess with dimensions
RT_SIZE_FULL_FRAME_BUFFER_ROUNDED_UP=6, // Same size as the frame buffer, rounded up if necessary for systems that can't do non-power of two textures.
RT_SIZE_REPLAY_SCREENSHOT = 7, // Rounded down to power of 2, essentially...
RT_SIZE_LITERAL = 8 // Use the size passed in. Don't clamp it to the frame buffer size. Really.
RT_SIZE_LITERAL = 8, // Use the size passed in. Don't clamp it to the frame buffer size. Really.
RT_SIZE_LITERAL_PICMIP = 9 // Use the size passed in, don't clamp to the frame buffer size, but do apply picmip restrictions.
};
typedef void (*MaterialBufferReleaseFunc_t)( );
@ -1043,6 +1061,23 @@ public:
// creates a texture suitable for use with materials from a raw stream of bits.
// The bits will be retained by the material system and can be freed upon return.
virtual ITexture* CreateTextureFromBits(int w, int h, int mips, ImageFormat fmt, int srcBufferSize, byte* srcBits) = 0;
// Lie to the material system to pretend to be in render target allocation mode at the beginning of time.
// This was a thing that mattered a lot to old hardware, but doesn't matter at all to new hardware,
// where new is defined to be "anything from the last decade." However, we want to preserve legacy behavior
// for the old games because it's easier than testing them.
virtual void OverrideRenderTargetAllocation( bool rtAlloc ) = 0;
// creates a texture compositor that will attempt to composite a new textuer from the steps of the specified KeyValues.
virtual ITextureCompositor* NewTextureCompositor( int w, int h, const char* pCompositeName, int nTeamNum, uint64 randomSeed, KeyValues* stageDesc, uint32 texCompositeCreateFlags = 0 ) = 0;
// Loads the texture with the specified name, calls pRecipient->OnAsyncFindComplete with the result from the main thread.
// once the texture load is complete. If the texture cannot be found, the returned texture will return true for IsError().
virtual void AsyncFindTexture( const char* pFilename, const char *pTextureGroupName, IAsyncTextureOperationReceiver* pRecipient, void* pExtraArgs, bool bComplain = true, int nAdditionalCreationFlags = 0 ) = 0;
// creates a texture suitable for use with materials from a raw stream of bits.
// The bits will be retained by the material system and can be freed upon return.
virtual ITexture* CreateNamedTextureFromBitsEx( const char* pName, const char *pTextureGroupName, int w, int h, int mips, ImageFormat fmt, int srcBufferSize, byte* srcBits, int nFlags ) = 0;
};
@ -1504,6 +1539,11 @@ public:
virtual void OverrideColorWriteEnable( bool bOverrideEnable, bool bColorWriteEnable ) = 0;
virtual void ClearBuffersObeyStencilEx( bool bClearColor, bool bClearAlpha, bool bClearDepth ) = 0;
// Create a texture from the specified src render target, then call pRecipient->OnAsyncCreateComplete from the main thread.
// The texture will be created using the destination format, and will optionally have mipmaps generated.
// In case of error, the provided callback function will be called with the error texture.
virtual void AsyncCreateTextureFromRenderTarget( ITexture* pSrcRt, const char* pDstName, ImageFormat dstFmt, bool bGenMips, int nAdditionalCreationFlags, IAsyncTextureOperationReceiver* pRecipient, void* pExtraArgs ) = 0;
};
template< class E > inline E* IMatRenderContext::LockRenderDataTyped( int nCount, const E* pSrcData )

View File

@ -0,0 +1,131 @@
//===== Copyright <20> Valve Corporation, All rights reserved. ======//
#ifndef ISHADER_DECLARATIONS_HDR
#define ISHADER_DECLARATIONS_HDR
//-----------------------------------------------------------------------------
// Standard vertex shader constants
//-----------------------------------------------------------------------------
enum
{
// Standard vertex shader constants
VERTEX_SHADER_MATH_CONSTANTS0 = 0,
VERTEX_SHADER_MATH_CONSTANTS1 = 1,
VERTEX_SHADER_CAMERA_POS = 2,
VERTEX_SHADER_FLEXSCALE = 3, // DX9 only
VERTEX_SHADER_LIGHT_INDEX = 3, // DX8 only
VERTEX_SHADER_MODELVIEWPROJ = 4,
VERTEX_SHADER_VIEWPROJ = 8,
VERTEX_SHADER_MODELVIEWPROJ_THIRD_ROW = 12,
VERTEX_SHADER_VIEWPROJ_THIRD_ROW = 13,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_10 = 14,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_11 = 15,
VERTEX_SHADER_FOG_PARAMS = 16,
VERTEX_SHADER_VIEWMODEL = 17,
VERTEX_SHADER_AMBIENT_LIGHT = 21,
VERTEX_SHADER_LIGHTS = 27,
VERTEX_SHADER_LIGHT0_POSITION = 29,
VERTEX_SHADER_MODULATION_COLOR = 47,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_0 = 48,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_1 = 49,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_2 = 50,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_3 = 51,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_4 = 52,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_5 = 53,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_6 = 54,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_7 = 55,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_8 = 56,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_9 = 57,
VERTEX_SHADER_MODEL = 58,
//
// We reserve up through 216 for the 53 bones supported on DX9
//
VERTEX_SHADER_SHADER_SPECIFIC_CONST_13 = 217,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_14 = 218,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_15 = 219,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_16 = 220,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_17 = 221,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_18 = 222,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_19 = 223,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_12 = 224,
// 226 ClipPlane0 |------ OpenGL will jam clip planes into these two
// 227 ClipPlane1 |
VERTEX_SHADER_FLEX_WEIGHTS = 1024,
VERTEX_SHADER_MAX_FLEX_WEIGHT_COUNT = 512,
};
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
class IMaterialVar;
class IShaderShadow;
class IShaderDynamicAPI;
class IShaderInit;
class CBasePerMaterialContextData;
//-----------------------------------------------------------------------------
// Shader flags
//-----------------------------------------------------------------------------
enum ShaderFlags_t
{
SHADER_NOT_EDITABLE = 0x1
};
//-----------------------------------------------------------------------------
// Shader parameter flags
//-----------------------------------------------------------------------------
enum ShaderParamFlags_t
{
SHADER_PARAM_NOT_EDITABLE = 0x1
};
//-----------------------------------------------------------------------------
// Standard vertex shader constants
//-----------------------------------------------------------------------------
enum
{
// Standard vertex shader constants
VERTEX_SHADER_LIGHT_ENABLE_BOOL_CONST = 0,
VERTEX_SHADER_LIGHT_ENABLE_BOOL_CONST_COUNT = 4,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_0 = 4,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_1 = 5,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_2 = 6,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_3 = 7,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_4 = 8,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_5 = 9,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_6 = 10,
VERTEX_SHADER_SHADER_SPECIFIC_BOOL_CONST_7 = 11,
};
//-----------------------------------------------------------------------------
// Shader dictionaries defined in DLLs
//-----------------------------------------------------------------------------
enum PrecompiledShaderType_t
{
PRECOMPILED_VERTEX_SHADER = 0,
PRECOMPILED_PIXEL_SHADER,
PRECOMPILED_SHADER_TYPE_COUNT,
};
//-----------------------------------------------------------------------------
// Flags field of PrecompiledShader_t
//-----------------------------------------------------------------------------
enum
{
// runtime flags
SHADER_IS_ASM = 0x1,
SHADER_FAILED_LOAD = 0x2,
};
#endif

View File

@ -39,6 +39,10 @@ public:
// This will be called when the regenerator needs to be deleted
// which will happen when the texture is destroyed
virtual void Release() = 0;
// (erics): This should have a virtual destructor, but would be ABI breaking (non-versioned interface implemented
// by the game)
// virtual ~ITextureRegenerator(){}
};
abstract_class ITexture
@ -120,6 +124,13 @@ public:
// Save texture to a file.
virtual bool SaveToFile( const char *fileName ) = 0;
// Copy this texture, which must be a render target or a renderable texture, to the destination texture,
// which must have been created with the STAGING bit.
virtual void CopyToStagingTexture( ITexture* pDstTex ) = 0;
// Set that this texture should return true for the call "IsError"
virtual void SetErrorTexture( bool bIsErrorTexture ) = 0;
};

View File

@ -0,0 +1,50 @@
//========= Copyright Valve Corporation, All rights reserved. ================================== //
//
// Purpose: Defines a texture compositor infterface which uses simple operations and shaders to
// create complex procedural textures.
//
//============================================================================================== //
#ifndef ITEXTURECOMPOSITOR_H
#define ITEXTURECOMPOSITOR_H
#pragma once
#include "interface.h"
#include "itexture.h"
#define ITEXTURE_COMPOSITOR_INTERFACE_VERSION "_ITextureCompositor000"
enum ECompositeResolveStatus
{
ECRS_Idle,
ECRS_Scheduled,
ECRS_PendingTextureLoads,
ECRS_PendingComposites,
ECRS_Error,
ECRS_Complete
};
enum TextureCompositeCreateFlags_t
{
TEX_COMPOSITE_CREATE_FLAGS_FORCE = 0x00000001,
TEX_COMPOSITE_CREATE_FLAGS_NO_COMPRESSION = 0x00000002,
TEX_COMPOSITE_CREATE_FLAGS_NO_MIPMAPS = 0x00000004,
};
abstract_class ITextureCompositor
{
public:
virtual int AddRef() = 0;
virtual int Release() = 0;
virtual int GetRefCount() const = 0;
virtual void Update() = 0;
virtual ITexture* GetResultTexture() const = 0;
virtual ECompositeResolveStatus GetResolveStatus() const = 0;
virtual void ScheduleResolve() = 0;
protected:
virtual ~ITextureCompositor() {}
};
#endif /* ITEXTURECOMPOSITOR_H */