mirror of
https://github.com/nillerusr/source-engine.git
synced 2025-04-02 13:32:37 +00:00
887 lines
28 KiB
C++
887 lines
28 KiB
C++
#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 |