Fix line endings. WHAMMY.
This commit is contained in:
@@ -1,389 +1,389 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ISHADERDEVICE_H
|
||||
#define ISHADERDEVICE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier1/interface.h"
|
||||
#include "appframework/IAppSystem.h"
|
||||
#include "bitmap/imageformat.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "shaderapi/ishaderdynamic.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
struct MaterialAdapterInfo_t;
|
||||
class IMesh;
|
||||
class KeyValues;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Describes how to set the mode
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADER_DISPLAY_MODE_VERSION 1
|
||||
|
||||
struct ShaderDisplayMode_t
|
||||
{
|
||||
ShaderDisplayMode_t() { memset( this, 0, sizeof(ShaderDisplayMode_t) ); m_nVersion = SHADER_DISPLAY_MODE_VERSION; }
|
||||
|
||||
int m_nVersion;
|
||||
int m_nWidth; // 0 when running windowed means use desktop resolution
|
||||
int m_nHeight;
|
||||
ImageFormat m_Format; // use ImageFormats (ignored for windowed mode)
|
||||
int m_nRefreshRateNumerator; // Refresh rate. Use 0 in numerator + denominator for a default setting.
|
||||
int m_nRefreshRateDenominator; // Refresh rate = numerator / denominator.
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Describes how to set the device
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADER_DEVICE_INFO_VERSION 1
|
||||
|
||||
struct ShaderDeviceInfo_t
|
||||
{
|
||||
ShaderDeviceInfo_t() { memset( this, 0, sizeof(ShaderDeviceInfo_t) ); m_nVersion = SHADER_DEVICE_INFO_VERSION; m_DisplayMode.m_nVersion = SHADER_DISPLAY_MODE_VERSION; }
|
||||
|
||||
int m_nVersion;
|
||||
ShaderDisplayMode_t m_DisplayMode;
|
||||
int m_nBackBufferCount; // valid values are 1 or 2 [2 results in triple buffering]
|
||||
int m_nAASamples; // Number of AA samples to use
|
||||
int m_nAAQuality; // AA quality level
|
||||
int m_nDXLevel; // 0 means use recommended DX level for this adapter
|
||||
int m_nWindowedSizeLimitWidth; // Used if m_bLimitWindowedSize is set, defines max bounds for the back buffer
|
||||
int m_nWindowedSizeLimitHeight;
|
||||
|
||||
bool m_bWindowed : 1;
|
||||
bool m_bResizing : 1; // Only is meaningful when using windowed mode; means the window can be resized.
|
||||
bool m_bUseStencil : 1;
|
||||
bool m_bLimitWindowedSize : 1; // In windowed mode, should we prevent the back buffer from getting too large?
|
||||
bool m_bWaitForVSync : 1; // Would we not present until vsync?
|
||||
bool m_bScaleToOutputResolution : 1; // 360 ONLY: sets up hardware scaling
|
||||
bool m_bProgressive : 1; // 360 ONLY: interlaced or progressive
|
||||
bool m_bUsingMultipleWindows : 1; // Forces D3DPresent to use _COPY instead
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Info for non-interactive mode
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ShaderNonInteractiveInfo_t
|
||||
{
|
||||
ShaderAPITextureHandle_t m_hTempFullscreenTexture;
|
||||
int m_nPacifierCount;
|
||||
ShaderAPITextureHandle_t m_pPacifierTextures[64];
|
||||
float m_flNormalizedX;
|
||||
float m_flNormalizedY;
|
||||
float m_flNormalizedSize;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// For vertex/index buffers. What type is it?
|
||||
// (NOTE: mirror this with a similarly named enum at the material system level for backwards compatability.)
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShaderBufferType_t
|
||||
{
|
||||
SHADER_BUFFER_TYPE_STATIC = 0,
|
||||
SHADER_BUFFER_TYPE_DYNAMIC,
|
||||
SHADER_BUFFER_TYPE_STATIC_TEMP,
|
||||
SHADER_BUFFER_TYPE_DYNAMIC_TEMP,
|
||||
|
||||
SHADER_BUFFER_TYPE_COUNT,
|
||||
};
|
||||
|
||||
inline bool IsDynamicBufferType( ShaderBufferType_t type )
|
||||
{
|
||||
return ( ( type == SHADER_BUFFER_TYPE_DYNAMIC ) || ( type == SHADER_BUFFER_TYPE_DYNAMIC_TEMP ) );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Handle to a vertex, pixel, and geometry shader
|
||||
//-----------------------------------------------------------------------------
|
||||
DECLARE_POINTER_HANDLE( VertexShaderHandle_t );
|
||||
DECLARE_POINTER_HANDLE( GeometryShaderHandle_t );
|
||||
DECLARE_POINTER_HANDLE( PixelShaderHandle_t );
|
||||
|
||||
#define VERTEX_SHADER_HANDLE_INVALID ( (VertexShaderHandle_t)0 )
|
||||
#define GEOMETRY_SHADER_HANDLE_INVALID ( (GeometryShaderHandle_t)0 )
|
||||
#define PIXEL_SHADER_HANDLE_INVALID ( (PixelShaderHandle_t)0 )
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// A shader buffer returns a block of memory which must be released when done with it
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IShaderBuffer
|
||||
{
|
||||
public:
|
||||
virtual size_t GetSize() const = 0;
|
||||
virtual const void* GetBits() const = 0;
|
||||
virtual void Release() = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Mode chance callback
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef void (*ShaderModeChangeCallbackFunc_t)( void );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Methods related to discovering and selecting devices
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADER_DEVICE_MGR_INTERFACE_VERSION "ShaderDeviceMgr001"
|
||||
abstract_class IShaderDeviceMgr : public IAppSystem
|
||||
{
|
||||
public:
|
||||
// Gets the number of adapters...
|
||||
virtual int GetAdapterCount() const = 0;
|
||||
|
||||
// Returns info about each adapter
|
||||
virtual void GetAdapterInfo( int nAdapter, MaterialAdapterInfo_t& info ) const = 0;
|
||||
|
||||
// Gets recommended congifuration for a particular adapter at a particular dx level
|
||||
virtual bool GetRecommendedConfigurationInfo( int nAdapter, int nDXLevel, KeyValues *pConfiguration ) = 0;
|
||||
|
||||
// Returns the number of modes
|
||||
virtual int GetModeCount( int nAdapter ) const = 0;
|
||||
|
||||
// Returns mode information..
|
||||
virtual void GetModeInfo( ShaderDisplayMode_t* pInfo, int nAdapter, int nMode ) const = 0;
|
||||
|
||||
// Returns the current mode info for the requested adapter
|
||||
virtual void GetCurrentModeInfo( ShaderDisplayMode_t* pInfo, int nAdapter ) const = 0;
|
||||
|
||||
// Initialization, shutdown
|
||||
virtual bool SetAdapter( int nAdapter, int nFlags ) = 0;
|
||||
|
||||
// Sets the mode
|
||||
// Use the returned factory to get at an IShaderDevice and an IShaderRender
|
||||
// and any other interfaces we decide to create.
|
||||
// A returned factory of NULL indicates the mode was not set properly.
|
||||
virtual CreateInterfaceFn SetMode( void *hWnd, int nAdapter, const ShaderDeviceInfo_t& mode ) = 0;
|
||||
|
||||
// Installs a callback to get called
|
||||
virtual void AddModeChangeCallback( ShaderModeChangeCallbackFunc_t func ) = 0;
|
||||
virtual void RemoveModeChangeCallback( ShaderModeChangeCallbackFunc_t func ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Methods related to control of the device
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADER_DEVICE_INTERFACE_VERSION "ShaderDevice001"
|
||||
abstract_class IShaderDevice
|
||||
{
|
||||
public:
|
||||
// Releases/reloads resources when other apps want some memory
|
||||
virtual void ReleaseResources() = 0;
|
||||
virtual void ReacquireResources() = 0;
|
||||
|
||||
// returns the backbuffer format and dimensions
|
||||
virtual ImageFormat GetBackBufferFormat() const = 0;
|
||||
virtual void GetBackBufferDimensions( int& width, int& height ) const = 0;
|
||||
|
||||
// Returns the current adapter in use
|
||||
virtual int GetCurrentAdapter() const = 0;
|
||||
|
||||
// Are we using graphics?
|
||||
virtual bool IsUsingGraphics() const = 0;
|
||||
|
||||
// Use this to spew information about the 3D layer
|
||||
virtual void SpewDriverInfo() const = 0;
|
||||
|
||||
// What's the bit depth of the stencil buffer?
|
||||
virtual int StencilBufferBits() const = 0;
|
||||
|
||||
// Are we using a mode that uses MSAA
|
||||
virtual bool IsAAEnabled() const = 0;
|
||||
|
||||
// Does a page flip
|
||||
virtual void Present() = 0;
|
||||
|
||||
// Returns the window size
|
||||
virtual void GetWindowSize( int &nWidth, int &nHeight ) const = 0;
|
||||
|
||||
// Gamma ramp control
|
||||
virtual void SetHardwareGammaRamp( float fGamma, float fGammaTVRangeMin, float fGammaTVRangeMax, float fGammaTVExponent, bool bTVEnabled ) = 0;
|
||||
|
||||
// Creates/ destroys a child window
|
||||
virtual bool AddView( void* hWnd ) = 0;
|
||||
virtual void RemoveView( void* hWnd ) = 0;
|
||||
|
||||
// Activates a view
|
||||
virtual void SetView( void* hWnd ) = 0;
|
||||
|
||||
// Shader compilation
|
||||
virtual IShaderBuffer* CompileShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion ) = 0;
|
||||
|
||||
// Shader creation, destruction
|
||||
virtual VertexShaderHandle_t CreateVertexShader( IShaderBuffer* pShaderBuffer ) = 0;
|
||||
virtual void DestroyVertexShader( VertexShaderHandle_t hShader ) = 0;
|
||||
virtual GeometryShaderHandle_t CreateGeometryShader( IShaderBuffer* pShaderBuffer ) = 0;
|
||||
virtual void DestroyGeometryShader( GeometryShaderHandle_t hShader ) = 0;
|
||||
virtual PixelShaderHandle_t CreatePixelShader( IShaderBuffer* pShaderBuffer ) = 0;
|
||||
virtual void DestroyPixelShader( PixelShaderHandle_t hShader ) = 0;
|
||||
|
||||
// Utility methods to make shader creation simpler
|
||||
// NOTE: For the utlbuffer version, use a binary buffer for a compiled shader
|
||||
// and a text buffer for a source-code (.fxc) shader
|
||||
VertexShaderHandle_t CreateVertexShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion );
|
||||
VertexShaderHandle_t CreateVertexShader( CUtlBuffer &buf, const char *pShaderVersion = NULL );
|
||||
GeometryShaderHandle_t CreateGeometryShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion );
|
||||
GeometryShaderHandle_t CreateGeometryShader( CUtlBuffer &buf, const char *pShaderVersion = NULL );
|
||||
PixelShaderHandle_t CreatePixelShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion );
|
||||
PixelShaderHandle_t CreatePixelShader( CUtlBuffer &buf, const char *pShaderVersion = NULL );
|
||||
|
||||
// NOTE: Deprecated!! Use CreateVertexBuffer/CreateIndexBuffer instead
|
||||
// Creates/destroys Mesh
|
||||
virtual IMesh* CreateStaticMesh( VertexFormat_t vertexFormat, const char *pTextureBudgetGroup, IMaterial * pMaterial = NULL ) = 0;
|
||||
virtual void DestroyStaticMesh( IMesh* mesh ) = 0;
|
||||
|
||||
// Creates/destroys static vertex + index buffers
|
||||
virtual IVertexBuffer *CreateVertexBuffer( ShaderBufferType_t type, VertexFormat_t fmt, int nVertexCount, const char *pBudgetGroup ) = 0;
|
||||
virtual void DestroyVertexBuffer( IVertexBuffer *pVertexBuffer ) = 0;
|
||||
|
||||
virtual IIndexBuffer *CreateIndexBuffer( ShaderBufferType_t bufferType, MaterialIndexFormat_t fmt, int nIndexCount, const char *pBudgetGroup ) = 0;
|
||||
virtual void DestroyIndexBuffer( IIndexBuffer *pIndexBuffer ) = 0;
|
||||
|
||||
// Do we need to specify the stream here in the case of locking multiple dynamic VBs on different streams?
|
||||
virtual IVertexBuffer *GetDynamicVertexBuffer( int nStreamID, VertexFormat_t vertexFormat, bool bBuffered = true ) = 0;
|
||||
virtual IIndexBuffer *GetDynamicIndexBuffer( MaterialIndexFormat_t fmt, bool bBuffered = true ) = 0;
|
||||
|
||||
// A special path used to tick the front buffer while loading on the 360
|
||||
virtual void EnableNonInteractiveMode( MaterialNonInteractiveMode_t mode, ShaderNonInteractiveInfo_t *pInfo = NULL ) = 0;
|
||||
virtual void RefreshFrontBufferNonInteractive( ) = 0;
|
||||
virtual void HandleThreadEvent( uint32 threadEvent ) = 0;
|
||||
|
||||
#ifdef DX_TO_GL_ABSTRACTION
|
||||
virtual void DoStartupShaderPreloading( void ) = 0;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helper wrapper for IShaderBuffer for reading precompiled shader files
|
||||
// NOTE: This is meant to be instanced on the stack; so don't call Release!
|
||||
//-----------------------------------------------------------------------------
|
||||
class CUtlShaderBuffer : public IShaderBuffer
|
||||
{
|
||||
public:
|
||||
CUtlShaderBuffer( CUtlBuffer &buf ) : m_pBuf( &buf ) {}
|
||||
|
||||
virtual size_t GetSize() const
|
||||
{
|
||||
return m_pBuf->TellMaxPut();
|
||||
}
|
||||
|
||||
virtual const void* GetBits() const
|
||||
{
|
||||
return m_pBuf->Base();
|
||||
}
|
||||
|
||||
virtual void Release()
|
||||
{
|
||||
Assert( 0 );
|
||||
}
|
||||
|
||||
private:
|
||||
CUtlBuffer *m_pBuf;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Inline methods of IShaderDevice
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VertexShaderHandle_t IShaderDevice::CreateVertexShader( CUtlBuffer &buf, const char *pShaderVersion )
|
||||
{
|
||||
// NOTE: Text buffers are assumed to have source-code shader files
|
||||
// Binary buffers are assumed to have compiled shader files
|
||||
if ( buf.IsText() )
|
||||
{
|
||||
Assert( pShaderVersion );
|
||||
return CreateVertexShader( (const char *)buf.Base(), buf.TellMaxPut(), pShaderVersion );
|
||||
}
|
||||
|
||||
CUtlShaderBuffer shaderBuffer( buf );
|
||||
return CreateVertexShader( &shaderBuffer );
|
||||
}
|
||||
|
||||
inline VertexShaderHandle_t IShaderDevice::CreateVertexShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion )
|
||||
{
|
||||
VertexShaderHandle_t hVertexShader = VERTEX_SHADER_HANDLE_INVALID;
|
||||
IShaderBuffer* pShaderBuffer = CompileShader( pProgram, nBufLen, pShaderVersion );
|
||||
if ( pShaderBuffer )
|
||||
{
|
||||
hVertexShader = CreateVertexShader( pShaderBuffer );
|
||||
pShaderBuffer->Release();
|
||||
}
|
||||
return hVertexShader;
|
||||
}
|
||||
|
||||
inline GeometryShaderHandle_t IShaderDevice::CreateGeometryShader( CUtlBuffer &buf, const char *pShaderVersion )
|
||||
{
|
||||
// NOTE: Text buffers are assumed to have source-code shader files
|
||||
// Binary buffers are assumed to have compiled shader files
|
||||
if ( buf.IsText() )
|
||||
{
|
||||
Assert( pShaderVersion );
|
||||
return CreateGeometryShader( (const char *)buf.Base(), buf.TellMaxPut(), pShaderVersion );
|
||||
}
|
||||
|
||||
CUtlShaderBuffer shaderBuffer( buf );
|
||||
return CreateGeometryShader( &shaderBuffer );
|
||||
}
|
||||
|
||||
inline GeometryShaderHandle_t IShaderDevice::CreateGeometryShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion )
|
||||
{
|
||||
GeometryShaderHandle_t hGeometryShader = GEOMETRY_SHADER_HANDLE_INVALID;
|
||||
IShaderBuffer* pShaderBuffer = CompileShader( pProgram, nBufLen, pShaderVersion );
|
||||
if ( pShaderBuffer )
|
||||
{
|
||||
hGeometryShader = CreateGeometryShader( pShaderBuffer );
|
||||
pShaderBuffer->Release();
|
||||
}
|
||||
return hGeometryShader;
|
||||
}
|
||||
|
||||
inline PixelShaderHandle_t IShaderDevice::CreatePixelShader( CUtlBuffer &buf, const char *pShaderVersion )
|
||||
{
|
||||
// NOTE: Text buffers are assumed to have source-code shader files
|
||||
// Binary buffers are assumed to have compiled shader files
|
||||
if ( buf.IsText() )
|
||||
{
|
||||
Assert( pShaderVersion );
|
||||
return CreatePixelShader( (const char *)buf.Base(), buf.TellMaxPut(), pShaderVersion );
|
||||
}
|
||||
|
||||
CUtlShaderBuffer shaderBuffer( buf );
|
||||
return CreatePixelShader( &shaderBuffer );
|
||||
}
|
||||
|
||||
inline PixelShaderHandle_t IShaderDevice::CreatePixelShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion )
|
||||
{
|
||||
PixelShaderHandle_t hPixelShader = PIXEL_SHADER_HANDLE_INVALID;
|
||||
IShaderBuffer* pShaderBuffer = CompileShader( pProgram, nBufLen, pShaderVersion );
|
||||
if ( pShaderBuffer )
|
||||
{
|
||||
hPixelShader = CreatePixelShader( pShaderBuffer );
|
||||
pShaderBuffer->Release();
|
||||
}
|
||||
return hPixelShader;
|
||||
}
|
||||
|
||||
|
||||
#endif // ISHADERDEVICE_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ISHADERDEVICE_H
|
||||
#define ISHADERDEVICE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tier1/interface.h"
|
||||
#include "appframework/IAppSystem.h"
|
||||
#include "bitmap/imageformat.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "shaderapi/ishaderdynamic.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
struct MaterialAdapterInfo_t;
|
||||
class IMesh;
|
||||
class KeyValues;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Describes how to set the mode
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADER_DISPLAY_MODE_VERSION 1
|
||||
|
||||
struct ShaderDisplayMode_t
|
||||
{
|
||||
ShaderDisplayMode_t() { memset( this, 0, sizeof(ShaderDisplayMode_t) ); m_nVersion = SHADER_DISPLAY_MODE_VERSION; }
|
||||
|
||||
int m_nVersion;
|
||||
int m_nWidth; // 0 when running windowed means use desktop resolution
|
||||
int m_nHeight;
|
||||
ImageFormat m_Format; // use ImageFormats (ignored for windowed mode)
|
||||
int m_nRefreshRateNumerator; // Refresh rate. Use 0 in numerator + denominator for a default setting.
|
||||
int m_nRefreshRateDenominator; // Refresh rate = numerator / denominator.
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Describes how to set the device
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADER_DEVICE_INFO_VERSION 1
|
||||
|
||||
struct ShaderDeviceInfo_t
|
||||
{
|
||||
ShaderDeviceInfo_t() { memset( this, 0, sizeof(ShaderDeviceInfo_t) ); m_nVersion = SHADER_DEVICE_INFO_VERSION; m_DisplayMode.m_nVersion = SHADER_DISPLAY_MODE_VERSION; }
|
||||
|
||||
int m_nVersion;
|
||||
ShaderDisplayMode_t m_DisplayMode;
|
||||
int m_nBackBufferCount; // valid values are 1 or 2 [2 results in triple buffering]
|
||||
int m_nAASamples; // Number of AA samples to use
|
||||
int m_nAAQuality; // AA quality level
|
||||
int m_nDXLevel; // 0 means use recommended DX level for this adapter
|
||||
int m_nWindowedSizeLimitWidth; // Used if m_bLimitWindowedSize is set, defines max bounds for the back buffer
|
||||
int m_nWindowedSizeLimitHeight;
|
||||
|
||||
bool m_bWindowed : 1;
|
||||
bool m_bResizing : 1; // Only is meaningful when using windowed mode; means the window can be resized.
|
||||
bool m_bUseStencil : 1;
|
||||
bool m_bLimitWindowedSize : 1; // In windowed mode, should we prevent the back buffer from getting too large?
|
||||
bool m_bWaitForVSync : 1; // Would we not present until vsync?
|
||||
bool m_bScaleToOutputResolution : 1; // 360 ONLY: sets up hardware scaling
|
||||
bool m_bProgressive : 1; // 360 ONLY: interlaced or progressive
|
||||
bool m_bUsingMultipleWindows : 1; // Forces D3DPresent to use _COPY instead
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Info for non-interactive mode
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ShaderNonInteractiveInfo_t
|
||||
{
|
||||
ShaderAPITextureHandle_t m_hTempFullscreenTexture;
|
||||
int m_nPacifierCount;
|
||||
ShaderAPITextureHandle_t m_pPacifierTextures[64];
|
||||
float m_flNormalizedX;
|
||||
float m_flNormalizedY;
|
||||
float m_flNormalizedSize;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// For vertex/index buffers. What type is it?
|
||||
// (NOTE: mirror this with a similarly named enum at the material system level for backwards compatability.)
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShaderBufferType_t
|
||||
{
|
||||
SHADER_BUFFER_TYPE_STATIC = 0,
|
||||
SHADER_BUFFER_TYPE_DYNAMIC,
|
||||
SHADER_BUFFER_TYPE_STATIC_TEMP,
|
||||
SHADER_BUFFER_TYPE_DYNAMIC_TEMP,
|
||||
|
||||
SHADER_BUFFER_TYPE_COUNT,
|
||||
};
|
||||
|
||||
inline bool IsDynamicBufferType( ShaderBufferType_t type )
|
||||
{
|
||||
return ( ( type == SHADER_BUFFER_TYPE_DYNAMIC ) || ( type == SHADER_BUFFER_TYPE_DYNAMIC_TEMP ) );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Handle to a vertex, pixel, and geometry shader
|
||||
//-----------------------------------------------------------------------------
|
||||
DECLARE_POINTER_HANDLE( VertexShaderHandle_t );
|
||||
DECLARE_POINTER_HANDLE( GeometryShaderHandle_t );
|
||||
DECLARE_POINTER_HANDLE( PixelShaderHandle_t );
|
||||
|
||||
#define VERTEX_SHADER_HANDLE_INVALID ( (VertexShaderHandle_t)0 )
|
||||
#define GEOMETRY_SHADER_HANDLE_INVALID ( (GeometryShaderHandle_t)0 )
|
||||
#define PIXEL_SHADER_HANDLE_INVALID ( (PixelShaderHandle_t)0 )
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// A shader buffer returns a block of memory which must be released when done with it
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IShaderBuffer
|
||||
{
|
||||
public:
|
||||
virtual size_t GetSize() const = 0;
|
||||
virtual const void* GetBits() const = 0;
|
||||
virtual void Release() = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Mode chance callback
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef void (*ShaderModeChangeCallbackFunc_t)( void );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Methods related to discovering and selecting devices
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADER_DEVICE_MGR_INTERFACE_VERSION "ShaderDeviceMgr001"
|
||||
abstract_class IShaderDeviceMgr : public IAppSystem
|
||||
{
|
||||
public:
|
||||
// Gets the number of adapters...
|
||||
virtual int GetAdapterCount() const = 0;
|
||||
|
||||
// Returns info about each adapter
|
||||
virtual void GetAdapterInfo( int nAdapter, MaterialAdapterInfo_t& info ) const = 0;
|
||||
|
||||
// Gets recommended congifuration for a particular adapter at a particular dx level
|
||||
virtual bool GetRecommendedConfigurationInfo( int nAdapter, int nDXLevel, KeyValues *pConfiguration ) = 0;
|
||||
|
||||
// Returns the number of modes
|
||||
virtual int GetModeCount( int nAdapter ) const = 0;
|
||||
|
||||
// Returns mode information..
|
||||
virtual void GetModeInfo( ShaderDisplayMode_t* pInfo, int nAdapter, int nMode ) const = 0;
|
||||
|
||||
// Returns the current mode info for the requested adapter
|
||||
virtual void GetCurrentModeInfo( ShaderDisplayMode_t* pInfo, int nAdapter ) const = 0;
|
||||
|
||||
// Initialization, shutdown
|
||||
virtual bool SetAdapter( int nAdapter, int nFlags ) = 0;
|
||||
|
||||
// Sets the mode
|
||||
// Use the returned factory to get at an IShaderDevice and an IShaderRender
|
||||
// and any other interfaces we decide to create.
|
||||
// A returned factory of NULL indicates the mode was not set properly.
|
||||
virtual CreateInterfaceFn SetMode( void *hWnd, int nAdapter, const ShaderDeviceInfo_t& mode ) = 0;
|
||||
|
||||
// Installs a callback to get called
|
||||
virtual void AddModeChangeCallback( ShaderModeChangeCallbackFunc_t func ) = 0;
|
||||
virtual void RemoveModeChangeCallback( ShaderModeChangeCallbackFunc_t func ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Methods related to control of the device
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADER_DEVICE_INTERFACE_VERSION "ShaderDevice001"
|
||||
abstract_class IShaderDevice
|
||||
{
|
||||
public:
|
||||
// Releases/reloads resources when other apps want some memory
|
||||
virtual void ReleaseResources() = 0;
|
||||
virtual void ReacquireResources() = 0;
|
||||
|
||||
// returns the backbuffer format and dimensions
|
||||
virtual ImageFormat GetBackBufferFormat() const = 0;
|
||||
virtual void GetBackBufferDimensions( int& width, int& height ) const = 0;
|
||||
|
||||
// Returns the current adapter in use
|
||||
virtual int GetCurrentAdapter() const = 0;
|
||||
|
||||
// Are we using graphics?
|
||||
virtual bool IsUsingGraphics() const = 0;
|
||||
|
||||
// Use this to spew information about the 3D layer
|
||||
virtual void SpewDriverInfo() const = 0;
|
||||
|
||||
// What's the bit depth of the stencil buffer?
|
||||
virtual int StencilBufferBits() const = 0;
|
||||
|
||||
// Are we using a mode that uses MSAA
|
||||
virtual bool IsAAEnabled() const = 0;
|
||||
|
||||
// Does a page flip
|
||||
virtual void Present() = 0;
|
||||
|
||||
// Returns the window size
|
||||
virtual void GetWindowSize( int &nWidth, int &nHeight ) const = 0;
|
||||
|
||||
// Gamma ramp control
|
||||
virtual void SetHardwareGammaRamp( float fGamma, float fGammaTVRangeMin, float fGammaTVRangeMax, float fGammaTVExponent, bool bTVEnabled ) = 0;
|
||||
|
||||
// Creates/ destroys a child window
|
||||
virtual bool AddView( void* hWnd ) = 0;
|
||||
virtual void RemoveView( void* hWnd ) = 0;
|
||||
|
||||
// Activates a view
|
||||
virtual void SetView( void* hWnd ) = 0;
|
||||
|
||||
// Shader compilation
|
||||
virtual IShaderBuffer* CompileShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion ) = 0;
|
||||
|
||||
// Shader creation, destruction
|
||||
virtual VertexShaderHandle_t CreateVertexShader( IShaderBuffer* pShaderBuffer ) = 0;
|
||||
virtual void DestroyVertexShader( VertexShaderHandle_t hShader ) = 0;
|
||||
virtual GeometryShaderHandle_t CreateGeometryShader( IShaderBuffer* pShaderBuffer ) = 0;
|
||||
virtual void DestroyGeometryShader( GeometryShaderHandle_t hShader ) = 0;
|
||||
virtual PixelShaderHandle_t CreatePixelShader( IShaderBuffer* pShaderBuffer ) = 0;
|
||||
virtual void DestroyPixelShader( PixelShaderHandle_t hShader ) = 0;
|
||||
|
||||
// Utility methods to make shader creation simpler
|
||||
// NOTE: For the utlbuffer version, use a binary buffer for a compiled shader
|
||||
// and a text buffer for a source-code (.fxc) shader
|
||||
VertexShaderHandle_t CreateVertexShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion );
|
||||
VertexShaderHandle_t CreateVertexShader( CUtlBuffer &buf, const char *pShaderVersion = NULL );
|
||||
GeometryShaderHandle_t CreateGeometryShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion );
|
||||
GeometryShaderHandle_t CreateGeometryShader( CUtlBuffer &buf, const char *pShaderVersion = NULL );
|
||||
PixelShaderHandle_t CreatePixelShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion );
|
||||
PixelShaderHandle_t CreatePixelShader( CUtlBuffer &buf, const char *pShaderVersion = NULL );
|
||||
|
||||
// NOTE: Deprecated!! Use CreateVertexBuffer/CreateIndexBuffer instead
|
||||
// Creates/destroys Mesh
|
||||
virtual IMesh* CreateStaticMesh( VertexFormat_t vertexFormat, const char *pTextureBudgetGroup, IMaterial * pMaterial = NULL ) = 0;
|
||||
virtual void DestroyStaticMesh( IMesh* mesh ) = 0;
|
||||
|
||||
// Creates/destroys static vertex + index buffers
|
||||
virtual IVertexBuffer *CreateVertexBuffer( ShaderBufferType_t type, VertexFormat_t fmt, int nVertexCount, const char *pBudgetGroup ) = 0;
|
||||
virtual void DestroyVertexBuffer( IVertexBuffer *pVertexBuffer ) = 0;
|
||||
|
||||
virtual IIndexBuffer *CreateIndexBuffer( ShaderBufferType_t bufferType, MaterialIndexFormat_t fmt, int nIndexCount, const char *pBudgetGroup ) = 0;
|
||||
virtual void DestroyIndexBuffer( IIndexBuffer *pIndexBuffer ) = 0;
|
||||
|
||||
// Do we need to specify the stream here in the case of locking multiple dynamic VBs on different streams?
|
||||
virtual IVertexBuffer *GetDynamicVertexBuffer( int nStreamID, VertexFormat_t vertexFormat, bool bBuffered = true ) = 0;
|
||||
virtual IIndexBuffer *GetDynamicIndexBuffer( MaterialIndexFormat_t fmt, bool bBuffered = true ) = 0;
|
||||
|
||||
// A special path used to tick the front buffer while loading on the 360
|
||||
virtual void EnableNonInteractiveMode( MaterialNonInteractiveMode_t mode, ShaderNonInteractiveInfo_t *pInfo = NULL ) = 0;
|
||||
virtual void RefreshFrontBufferNonInteractive( ) = 0;
|
||||
virtual void HandleThreadEvent( uint32 threadEvent ) = 0;
|
||||
|
||||
#ifdef DX_TO_GL_ABSTRACTION
|
||||
virtual void DoStartupShaderPreloading( void ) = 0;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helper wrapper for IShaderBuffer for reading precompiled shader files
|
||||
// NOTE: This is meant to be instanced on the stack; so don't call Release!
|
||||
//-----------------------------------------------------------------------------
|
||||
class CUtlShaderBuffer : public IShaderBuffer
|
||||
{
|
||||
public:
|
||||
CUtlShaderBuffer( CUtlBuffer &buf ) : m_pBuf( &buf ) {}
|
||||
|
||||
virtual size_t GetSize() const
|
||||
{
|
||||
return m_pBuf->TellMaxPut();
|
||||
}
|
||||
|
||||
virtual const void* GetBits() const
|
||||
{
|
||||
return m_pBuf->Base();
|
||||
}
|
||||
|
||||
virtual void Release()
|
||||
{
|
||||
Assert( 0 );
|
||||
}
|
||||
|
||||
private:
|
||||
CUtlBuffer *m_pBuf;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Inline methods of IShaderDevice
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VertexShaderHandle_t IShaderDevice::CreateVertexShader( CUtlBuffer &buf, const char *pShaderVersion )
|
||||
{
|
||||
// NOTE: Text buffers are assumed to have source-code shader files
|
||||
// Binary buffers are assumed to have compiled shader files
|
||||
if ( buf.IsText() )
|
||||
{
|
||||
Assert( pShaderVersion );
|
||||
return CreateVertexShader( (const char *)buf.Base(), buf.TellMaxPut(), pShaderVersion );
|
||||
}
|
||||
|
||||
CUtlShaderBuffer shaderBuffer( buf );
|
||||
return CreateVertexShader( &shaderBuffer );
|
||||
}
|
||||
|
||||
inline VertexShaderHandle_t IShaderDevice::CreateVertexShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion )
|
||||
{
|
||||
VertexShaderHandle_t hVertexShader = VERTEX_SHADER_HANDLE_INVALID;
|
||||
IShaderBuffer* pShaderBuffer = CompileShader( pProgram, nBufLen, pShaderVersion );
|
||||
if ( pShaderBuffer )
|
||||
{
|
||||
hVertexShader = CreateVertexShader( pShaderBuffer );
|
||||
pShaderBuffer->Release();
|
||||
}
|
||||
return hVertexShader;
|
||||
}
|
||||
|
||||
inline GeometryShaderHandle_t IShaderDevice::CreateGeometryShader( CUtlBuffer &buf, const char *pShaderVersion )
|
||||
{
|
||||
// NOTE: Text buffers are assumed to have source-code shader files
|
||||
// Binary buffers are assumed to have compiled shader files
|
||||
if ( buf.IsText() )
|
||||
{
|
||||
Assert( pShaderVersion );
|
||||
return CreateGeometryShader( (const char *)buf.Base(), buf.TellMaxPut(), pShaderVersion );
|
||||
}
|
||||
|
||||
CUtlShaderBuffer shaderBuffer( buf );
|
||||
return CreateGeometryShader( &shaderBuffer );
|
||||
}
|
||||
|
||||
inline GeometryShaderHandle_t IShaderDevice::CreateGeometryShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion )
|
||||
{
|
||||
GeometryShaderHandle_t hGeometryShader = GEOMETRY_SHADER_HANDLE_INVALID;
|
||||
IShaderBuffer* pShaderBuffer = CompileShader( pProgram, nBufLen, pShaderVersion );
|
||||
if ( pShaderBuffer )
|
||||
{
|
||||
hGeometryShader = CreateGeometryShader( pShaderBuffer );
|
||||
pShaderBuffer->Release();
|
||||
}
|
||||
return hGeometryShader;
|
||||
}
|
||||
|
||||
inline PixelShaderHandle_t IShaderDevice::CreatePixelShader( CUtlBuffer &buf, const char *pShaderVersion )
|
||||
{
|
||||
// NOTE: Text buffers are assumed to have source-code shader files
|
||||
// Binary buffers are assumed to have compiled shader files
|
||||
if ( buf.IsText() )
|
||||
{
|
||||
Assert( pShaderVersion );
|
||||
return CreatePixelShader( (const char *)buf.Base(), buf.TellMaxPut(), pShaderVersion );
|
||||
}
|
||||
|
||||
CUtlShaderBuffer shaderBuffer( buf );
|
||||
return CreatePixelShader( &shaderBuffer );
|
||||
}
|
||||
|
||||
inline PixelShaderHandle_t IShaderDevice::CreatePixelShader( const char *pProgram, size_t nBufLen, const char *pShaderVersion )
|
||||
{
|
||||
PixelShaderHandle_t hPixelShader = PIXEL_SHADER_HANDLE_INVALID;
|
||||
IShaderBuffer* pShaderBuffer = CompileShader( pProgram, nBufLen, pShaderVersion );
|
||||
if ( pShaderBuffer )
|
||||
{
|
||||
hPixelShader = CreatePixelShader( pShaderBuffer );
|
||||
pShaderBuffer->Release();
|
||||
}
|
||||
return hPixelShader;
|
||||
}
|
||||
|
||||
|
||||
#endif // ISHADERDEVICE_H
|
||||
|
||||
@@ -1,108 +1,108 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
// This file defines a number of constants and structured which are used to build up a command
|
||||
// buffer to pass to ShaderAPI for state setting and other operations. Since the prupose of these
|
||||
// command buffers is to minimize and optimize calls into shaderapi, their structure is not
|
||||
// abstract - they are built out by the calling process.
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef COMMANDBUFFER_H
|
||||
#define COMMANDBUFFER_H
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// all commands defined with their struct
|
||||
enum CommandBufferCommand_t
|
||||
{
|
||||
// flow control commands.
|
||||
CBCMD_END = 0, // end of stream
|
||||
CBCMD_JUMP = 1, // int cmd, void *adr. jump to another
|
||||
// stream. Can be used to implement
|
||||
// non-sequentially allocated storage
|
||||
CBCMD_JSR = 2, // int cmd, void *adr. subroutine call to another stream.
|
||||
|
||||
// constant setting commands
|
||||
CBCMD_SET_PIXEL_SHADER_FLOAT_CONST = 256, // int cmd,int first_reg, int nregs, float values[nregs*4]
|
||||
|
||||
|
||||
CBCMD_SET_VERTEX_SHADER_FLOAT_CONST = 257, // int cmd,int first_reg, int nregs, float values[nregs*4]
|
||||
CBCMD_SET_VERTEX_SHADER_FLOAT_CONST_REF = 258, // int cmd,int first_reg, int nregs, &float values[nregs*4]
|
||||
CBCMD_SETPIXELSHADERFOGPARAMS = 259, // int cmd, int regdest
|
||||
CBCMD_STORE_EYE_POS_IN_PSCONST = 260, // int cmd, int regdest
|
||||
CBCMD_COMMITPIXELSHADERLIGHTING = 261, // int cmd, int regdest
|
||||
CBCMD_SETPIXELSHADERSTATEAMBIENTLIGHTCUBE = 262, // int cmd, int regdest
|
||||
CBCMD_SETAMBIENTCUBEDYNAMICSTATEVERTEXSHADER = 263, // int cmd
|
||||
CBCMD_SET_DEPTH_FEATHERING_CONST = 264, // int cmd, int constant register, float blend scale
|
||||
|
||||
// texture binding
|
||||
CBCMD_BIND_STANDARD_TEXTURE = 512, // cmd, sampler, texture id
|
||||
CBCMD_BIND_SHADERAPI_TEXTURE_HANDLE = 513, // cmd, sampler, texture handle
|
||||
|
||||
// shaders
|
||||
CBCMD_SET_PSHINDEX = 1024, // cmd, idx
|
||||
CBCMD_SET_VSHINDEX = 1025, // cmd, idx
|
||||
|
||||
// commands from mainline. In mainline commands no longer have
|
||||
// command id's specified like this. So I make up numbers...
|
||||
CBCMD_SET_VERTEX_SHADER_FLASHLIGHT_STATE = 2000, // cmd, int first_reg (for worldToTexture matrix)
|
||||
CBCMD_SET_PIXEL_SHADER_FLASHLIGHT_STATE = 2001, // cmd, int color reg, int atten reg, int origin reg, sampler (for flashlight texture)
|
||||
|
||||
CBCMD_SET_PIXEL_SHADER_UBERLIGHT_STATE = 2002, // cmd
|
||||
|
||||
CBCMD_SET_VERTEX_SHADER_NEARZFARZ_STATE = 2003, // cmd
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Commands used by the per-instance command buffer
|
||||
// NOTE: If you add commands, you probably want to change the size of
|
||||
// CInstanceStorageBuffer and/or the choice of making it a fixed-size allocation
|
||||
// see shaderlib/baseshader.*
|
||||
//
|
||||
// FIXME!! NOTE that this whole scheme here generates a dependency of the
|
||||
// shaders on internal guts of shaderapidx8, since it's responsible for
|
||||
// setting various pixel shader + vertex shader constants based on the
|
||||
// commands below. We need to remove this dependency as it's way too restrictive
|
||||
// and puts the smarts in the wrong place (see CBICMD_SETPIXELSHADERGLINTDAMPING
|
||||
// as an example). Not going to solve this for l4d though, as I don't anticipate
|
||||
// a large amount of new shader writing for that product.
|
||||
//-----------------------------------------------------------------------------
|
||||
enum CommandBufferInstanceCommand_t
|
||||
{
|
||||
CBICMD_END = 0, // end of stream
|
||||
CBICMD_JUMP, // int cmd, void *adr. jump to another
|
||||
// stream. Can be used to implement
|
||||
// non-sequentially allocated storage
|
||||
CBICMD_JSR, // int cmd, void *adr. subroutine call to another stream.
|
||||
|
||||
CBICMD_SETSKINNINGMATRICES, // int cmd
|
||||
|
||||
CBICMD_SETVERTEXSHADERLOCALLIGHTING, // int cmd
|
||||
CBICMD_SETPIXELSHADERLOCALLIGHTING, // int cmd, int regdest
|
||||
CBICMD_SETVERTEXSHADERAMBIENTLIGHTCUBE, // int cmd
|
||||
CBICMD_SETPIXELSHADERAMBIENTLIGHTCUBE, // int cmd, int regdest
|
||||
CBICMD_SETPIXELSHADERAMBIENTLIGHTCUBELUMINANCE, // int cmd, int regdest
|
||||
CBICMD_SETPIXELSHADERGLINTDAMPING, // int cmd, int regdest
|
||||
|
||||
CBICMD_BIND_ENV_CUBEMAP_TEXTURE, // cmd, sampler
|
||||
|
||||
CBICMD_SETMODULATIONPIXELSHADERDYNAMICSTATE,
|
||||
CBICMD_SETMODULATIONPIXELSHADERDYNAMICSTATE_LINEARCOLORSPACE_LINEARSCALE, // int cmd, int constant register, Vector color2
|
||||
CBICMD_SETMODULATIONPIXELSHADERDYNAMICSTATE_LINEARCOLORSPACE, // int cmd, int constant register, Vector color2
|
||||
CBICMD_SETMODULATIONPIXELSHADERDYNAMICSTATE_LINEARSCALE, // int cmd, int constant register, Vector color2, float scale
|
||||
CBICMD_SETMODULATIONVERTEXSHADERDYNAMICSTATE, // int cmd, int constant register, Vector color2
|
||||
CBICMD_SETMODULATIONPIXELSHADERDYNAMICSTATE_IDENTITY, // int cmd, int constant register
|
||||
CBICMD_SETMODULATIONVERTEXSHADERDYNAMICSTATE_LINEARSCALE, // int cmd, int constant register, Vector color2, float scale
|
||||
// This must be last
|
||||
CBICMD_COUNT,
|
||||
};
|
||||
|
||||
#endif // commandbuffer_h
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
// This file defines a number of constants and structured which are used to build up a command
|
||||
// buffer to pass to ShaderAPI for state setting and other operations. Since the prupose of these
|
||||
// command buffers is to minimize and optimize calls into shaderapi, their structure is not
|
||||
// abstract - they are built out by the calling process.
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef COMMANDBUFFER_H
|
||||
#define COMMANDBUFFER_H
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// all commands defined with their struct
|
||||
enum CommandBufferCommand_t
|
||||
{
|
||||
// flow control commands.
|
||||
CBCMD_END = 0, // end of stream
|
||||
CBCMD_JUMP = 1, // int cmd, void *adr. jump to another
|
||||
// stream. Can be used to implement
|
||||
// non-sequentially allocated storage
|
||||
CBCMD_JSR = 2, // int cmd, void *adr. subroutine call to another stream.
|
||||
|
||||
// constant setting commands
|
||||
CBCMD_SET_PIXEL_SHADER_FLOAT_CONST = 256, // int cmd,int first_reg, int nregs, float values[nregs*4]
|
||||
|
||||
|
||||
CBCMD_SET_VERTEX_SHADER_FLOAT_CONST = 257, // int cmd,int first_reg, int nregs, float values[nregs*4]
|
||||
CBCMD_SET_VERTEX_SHADER_FLOAT_CONST_REF = 258, // int cmd,int first_reg, int nregs, &float values[nregs*4]
|
||||
CBCMD_SETPIXELSHADERFOGPARAMS = 259, // int cmd, int regdest
|
||||
CBCMD_STORE_EYE_POS_IN_PSCONST = 260, // int cmd, int regdest
|
||||
CBCMD_COMMITPIXELSHADERLIGHTING = 261, // int cmd, int regdest
|
||||
CBCMD_SETPIXELSHADERSTATEAMBIENTLIGHTCUBE = 262, // int cmd, int regdest
|
||||
CBCMD_SETAMBIENTCUBEDYNAMICSTATEVERTEXSHADER = 263, // int cmd
|
||||
CBCMD_SET_DEPTH_FEATHERING_CONST = 264, // int cmd, int constant register, float blend scale
|
||||
|
||||
// texture binding
|
||||
CBCMD_BIND_STANDARD_TEXTURE = 512, // cmd, sampler, texture id
|
||||
CBCMD_BIND_SHADERAPI_TEXTURE_HANDLE = 513, // cmd, sampler, texture handle
|
||||
|
||||
// shaders
|
||||
CBCMD_SET_PSHINDEX = 1024, // cmd, idx
|
||||
CBCMD_SET_VSHINDEX = 1025, // cmd, idx
|
||||
|
||||
// commands from mainline. In mainline commands no longer have
|
||||
// command id's specified like this. So I make up numbers...
|
||||
CBCMD_SET_VERTEX_SHADER_FLASHLIGHT_STATE = 2000, // cmd, int first_reg (for worldToTexture matrix)
|
||||
CBCMD_SET_PIXEL_SHADER_FLASHLIGHT_STATE = 2001, // cmd, int color reg, int atten reg, int origin reg, sampler (for flashlight texture)
|
||||
|
||||
CBCMD_SET_PIXEL_SHADER_UBERLIGHT_STATE = 2002, // cmd
|
||||
|
||||
CBCMD_SET_VERTEX_SHADER_NEARZFARZ_STATE = 2003, // cmd
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Commands used by the per-instance command buffer
|
||||
// NOTE: If you add commands, you probably want to change the size of
|
||||
// CInstanceStorageBuffer and/or the choice of making it a fixed-size allocation
|
||||
// see shaderlib/baseshader.*
|
||||
//
|
||||
// FIXME!! NOTE that this whole scheme here generates a dependency of the
|
||||
// shaders on internal guts of shaderapidx8, since it's responsible for
|
||||
// setting various pixel shader + vertex shader constants based on the
|
||||
// commands below. We need to remove this dependency as it's way too restrictive
|
||||
// and puts the smarts in the wrong place (see CBICMD_SETPIXELSHADERGLINTDAMPING
|
||||
// as an example). Not going to solve this for l4d though, as I don't anticipate
|
||||
// a large amount of new shader writing for that product.
|
||||
//-----------------------------------------------------------------------------
|
||||
enum CommandBufferInstanceCommand_t
|
||||
{
|
||||
CBICMD_END = 0, // end of stream
|
||||
CBICMD_JUMP, // int cmd, void *adr. jump to another
|
||||
// stream. Can be used to implement
|
||||
// non-sequentially allocated storage
|
||||
CBICMD_JSR, // int cmd, void *adr. subroutine call to another stream.
|
||||
|
||||
CBICMD_SETSKINNINGMATRICES, // int cmd
|
||||
|
||||
CBICMD_SETVERTEXSHADERLOCALLIGHTING, // int cmd
|
||||
CBICMD_SETPIXELSHADERLOCALLIGHTING, // int cmd, int regdest
|
||||
CBICMD_SETVERTEXSHADERAMBIENTLIGHTCUBE, // int cmd
|
||||
CBICMD_SETPIXELSHADERAMBIENTLIGHTCUBE, // int cmd, int regdest
|
||||
CBICMD_SETPIXELSHADERAMBIENTLIGHTCUBELUMINANCE, // int cmd, int regdest
|
||||
CBICMD_SETPIXELSHADERGLINTDAMPING, // int cmd, int regdest
|
||||
|
||||
CBICMD_BIND_ENV_CUBEMAP_TEXTURE, // cmd, sampler
|
||||
|
||||
CBICMD_SETMODULATIONPIXELSHADERDYNAMICSTATE,
|
||||
CBICMD_SETMODULATIONPIXELSHADERDYNAMICSTATE_LINEARCOLORSPACE_LINEARSCALE, // int cmd, int constant register, Vector color2
|
||||
CBICMD_SETMODULATIONPIXELSHADERDYNAMICSTATE_LINEARCOLORSPACE, // int cmd, int constant register, Vector color2
|
||||
CBICMD_SETMODULATIONPIXELSHADERDYNAMICSTATE_LINEARSCALE, // int cmd, int constant register, Vector color2, float scale
|
||||
CBICMD_SETMODULATIONVERTEXSHADERDYNAMICSTATE, // int cmd, int constant register, Vector color2
|
||||
CBICMD_SETMODULATIONPIXELSHADERDYNAMICSTATE_IDENTITY, // int cmd, int constant register
|
||||
CBICMD_SETMODULATIONVERTEXSHADERDYNAMICSTATE_LINEARSCALE, // int cmd, int constant register, Vector color2, float scale
|
||||
// This must be last
|
||||
CBICMD_COUNT,
|
||||
};
|
||||
|
||||
#endif // commandbuffer_h
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,345 +1,345 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ISHADERDYNAMIC_H
|
||||
#define ISHADERDYNAMIC_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "shaderapi/shareddefs.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "tier0/basetypes.h"
|
||||
|
||||
|
||||
typedef int ShaderAPITextureHandle_t;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMeshBuilder;
|
||||
class IMaterialVar;
|
||||
struct LightDesc_t;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// State from ShaderAPI used to select proper vertex and pixel shader combos
|
||||
//-----------------------------------------------------------------------------
|
||||
struct LightState_t
|
||||
{
|
||||
int m_nNumLights;
|
||||
bool m_bAmbientLight;
|
||||
bool m_bStaticLight;
|
||||
inline int HasDynamicLight() { return (m_bAmbientLight || (m_nNumLights > 0)) ? 1 : 0; }
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Color correction info
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ShaderColorCorrectionInfo_t
|
||||
{
|
||||
bool m_bIsEnabled;
|
||||
int m_nLookupCount;
|
||||
float m_flDefaultWeight;
|
||||
float m_pLookupWeights[4];
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// the 3D shader API interface
|
||||
// This interface is all that shaders see.
|
||||
//-----------------------------------------------------------------------------
|
||||
enum StandardTextureId_t
|
||||
{
|
||||
// Lightmaps
|
||||
TEXTURE_LIGHTMAP = 0,
|
||||
TEXTURE_LIGHTMAP_FULLBRIGHT,
|
||||
TEXTURE_LIGHTMAP_BUMPED,
|
||||
TEXTURE_LIGHTMAP_BUMPED_FULLBRIGHT,
|
||||
|
||||
// Flat colors
|
||||
TEXTURE_WHITE,
|
||||
TEXTURE_BLACK,
|
||||
TEXTURE_GREY,
|
||||
TEXTURE_GREY_ALPHA_ZERO,
|
||||
|
||||
// Normalmaps
|
||||
TEXTURE_NORMALMAP_FLAT,
|
||||
|
||||
// Normalization
|
||||
TEXTURE_NORMALIZATION_CUBEMAP,
|
||||
TEXTURE_NORMALIZATION_CUBEMAP_SIGNED,
|
||||
|
||||
// Frame-buffer textures
|
||||
TEXTURE_FRAME_BUFFER_FULL_TEXTURE_0,
|
||||
TEXTURE_FRAME_BUFFER_FULL_TEXTURE_1,
|
||||
|
||||
// Color correction
|
||||
TEXTURE_COLOR_CORRECTION_VOLUME_0,
|
||||
TEXTURE_COLOR_CORRECTION_VOLUME_1,
|
||||
TEXTURE_COLOR_CORRECTION_VOLUME_2,
|
||||
TEXTURE_COLOR_CORRECTION_VOLUME_3,
|
||||
|
||||
// An alias to the Back Frame Buffer
|
||||
TEXTURE_FRAME_BUFFER_ALIAS,
|
||||
|
||||
// Noise for shadow mapping algorithm
|
||||
TEXTURE_SHADOW_NOISE_2D,
|
||||
|
||||
// A texture in which morph data gets accumulated (vs30, fast vertex textures required)
|
||||
TEXTURE_MORPH_ACCUMULATOR,
|
||||
|
||||
// A texture which contains morph weights
|
||||
TEXTURE_MORPH_WEIGHTS,
|
||||
|
||||
// A snapshot of the frame buffer's depth. Currently only valid on the 360
|
||||
TEXTURE_FRAME_BUFFER_FULL_DEPTH,
|
||||
|
||||
// A snapshot of the frame buffer's depth. Currently only valid on the 360
|
||||
TEXTURE_IDENTITY_LIGHTWARP,
|
||||
|
||||
TEXTURE_MAX_STD_TEXTURES = 32
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Viewport structure
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADER_VIEWPORT_VERSION 1
|
||||
struct ShaderViewport_t
|
||||
{
|
||||
int m_nVersion;
|
||||
int m_nTopLeftX;
|
||||
int m_nTopLeftY;
|
||||
int m_nWidth;
|
||||
int m_nHeight;
|
||||
float m_flMinZ;
|
||||
float m_flMaxZ;
|
||||
|
||||
ShaderViewport_t() : m_nVersion( SHADER_VIEWPORT_VERSION ) {}
|
||||
|
||||
void Init()
|
||||
{
|
||||
memset( this, 0, sizeof(ShaderViewport_t) );
|
||||
m_nVersion = SHADER_VIEWPORT_VERSION;
|
||||
}
|
||||
|
||||
void Init( int x, int y, int nWidth, int nHeight, float flMinZ = 0.0f, float flMaxZ = 1.0f )
|
||||
{
|
||||
m_nVersion = SHADER_VIEWPORT_VERSION;
|
||||
m_nTopLeftX = x; m_nTopLeftY = y; m_nWidth = nWidth; m_nHeight = nHeight;
|
||||
m_flMinZ = flMinZ;
|
||||
m_flMaxZ = flMaxZ;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The Shader interface versions
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADERDYNAMIC_INTERFACE_VERSION "ShaderDynamic001"
|
||||
abstract_class IShaderDynamicAPI
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void SetViewports( int nCount, const ShaderViewport_t* pViewports ) = 0;
|
||||
virtual int GetViewports( ShaderViewport_t* pViewports, int nMax ) const = 0;
|
||||
|
||||
// returns the current time in seconds....
|
||||
virtual double CurrentTime() const = 0;
|
||||
|
||||
// Gets the lightmap dimensions
|
||||
virtual void GetLightmapDimensions( int *w, int *h ) = 0;
|
||||
|
||||
// Scene fog state.
|
||||
// This is used by the shaders for picking the proper vertex shader for fogging based on dynamic state.
|
||||
virtual MaterialFogMode_t GetSceneFogMode( ) = 0;
|
||||
virtual void GetSceneFogColor( unsigned char *rgb ) = 0;
|
||||
|
||||
// stuff related to matrix stacks
|
||||
virtual void MatrixMode( MaterialMatrixMode_t matrixMode ) = 0;
|
||||
virtual void PushMatrix() = 0;
|
||||
virtual void PopMatrix() = 0;
|
||||
virtual void LoadMatrix( float *m ) = 0;
|
||||
virtual void MultMatrix( float *m ) = 0;
|
||||
virtual void MultMatrixLocal( float *m ) = 0;
|
||||
virtual void GetMatrix( MaterialMatrixMode_t matrixMode, float *dst ) = 0;
|
||||
virtual void LoadIdentity( void ) = 0;
|
||||
virtual void LoadCameraToWorld( void ) = 0;
|
||||
virtual void Ortho( double left, double right, double bottom, double top, double zNear, double zFar ) = 0;
|
||||
virtual void PerspectiveX( double fovx, double aspect, double zNear, double zFar ) = 0;
|
||||
virtual void PickMatrix( int x, int y, int width, int height ) = 0;
|
||||
virtual void Rotate( float angle, float x, float y, float z ) = 0;
|
||||
virtual void Translate( float x, float y, float z ) = 0;
|
||||
virtual void Scale( float x, float y, float z ) = 0;
|
||||
virtual void ScaleXY( float x, float y ) = 0;
|
||||
|
||||
// Sets the color to modulate by
|
||||
virtual void Color3f( float r, float g, float b ) = 0;
|
||||
virtual void Color3fv( float const* pColor ) = 0;
|
||||
virtual void Color4f( float r, float g, float b, float a ) = 0;
|
||||
virtual void Color4fv( float const* pColor ) = 0;
|
||||
|
||||
virtual void Color3ub( unsigned char r, unsigned char g, unsigned char b ) = 0;
|
||||
virtual void Color3ubv( unsigned char const* pColor ) = 0;
|
||||
virtual void Color4ub( unsigned char r, unsigned char g, unsigned char b, unsigned char a ) = 0;
|
||||
virtual void Color4ubv( unsigned char const* pColor ) = 0;
|
||||
|
||||
// Sets the constant register for vertex and pixel shaders
|
||||
virtual void SetVertexShaderConstant( int var, float const* pVec, int numConst = 1, bool bForce = false ) = 0;
|
||||
virtual void SetPixelShaderConstant( int var, float const* pVec, int numConst = 1, bool bForce = false ) = 0;
|
||||
|
||||
// Sets the default *dynamic* state
|
||||
virtual void SetDefaultState() = 0;
|
||||
|
||||
// Get the current camera position in world space.
|
||||
virtual void GetWorldSpaceCameraPosition( float* pPos ) const = 0;
|
||||
|
||||
virtual int GetCurrentNumBones( void ) const = 0;
|
||||
virtual int GetCurrentLightCombo( void ) const = 0;
|
||||
|
||||
virtual MaterialFogMode_t GetCurrentFogType( void ) const = 0;
|
||||
|
||||
// fixme: move this to shadow state
|
||||
virtual void SetTextureTransformDimension( TextureStage_t textureStage, int dimension, bool projected ) = 0;
|
||||
virtual void DisableTextureTransform( TextureStage_t textureStage ) = 0;
|
||||
virtual void SetBumpEnvMatrix( TextureStage_t textureStage, float m00, float m01, float m10, float m11 ) = 0;
|
||||
|
||||
// Sets the vertex and pixel shaders
|
||||
virtual void SetVertexShaderIndex( int vshIndex = -1 ) = 0;
|
||||
virtual void SetPixelShaderIndex( int pshIndex = 0 ) = 0;
|
||||
|
||||
// Get the dimensions of the back buffer.
|
||||
virtual void GetBackBufferDimensions( int& width, int& height ) const = 0;
|
||||
|
||||
// FIXME: The following 6 methods used to live in IShaderAPI
|
||||
// and were moved for stdshader_dx8. Let's try to move them back!
|
||||
|
||||
// Get the lights
|
||||
virtual int GetMaxLights( void ) const = 0;
|
||||
virtual const LightDesc_t& GetLight( int lightNum ) const = 0;
|
||||
|
||||
virtual void SetPixelShaderFogParams( int reg ) = 0;
|
||||
|
||||
// Render state for the ambient light cube
|
||||
virtual void SetVertexShaderStateAmbientLightCube() = 0;
|
||||
virtual void SetPixelShaderStateAmbientLightCube( int pshReg, bool bForceToBlack = false ) = 0;
|
||||
virtual void CommitPixelShaderLighting( int pshReg ) = 0;
|
||||
|
||||
// Use this to get the mesh builder that allows us to modify vertex data
|
||||
virtual CMeshBuilder* GetVertexModifyBuilder() = 0;
|
||||
virtual bool InFlashlightMode() const = 0;
|
||||
virtual const FlashlightState_t &GetFlashlightState( VMatrix &worldToTexture ) const = 0;
|
||||
virtual bool InEditorMode() const = 0;
|
||||
|
||||
// Gets the bound morph's vertex format; returns 0 if no morph is bound
|
||||
virtual MorphFormat_t GetBoundMorphFormat() = 0;
|
||||
|
||||
// Binds a standard texture
|
||||
virtual void BindStandardTexture( Sampler_t sampler, StandardTextureId_t id ) = 0;
|
||||
|
||||
virtual ITexture *GetRenderTargetEx( int nRenderTargetID ) = 0;
|
||||
|
||||
virtual void SetToneMappingScaleLinear( const Vector &scale ) = 0;
|
||||
virtual const Vector &GetToneMappingScaleLinear( void ) const = 0;
|
||||
virtual float GetLightMapScaleFactor( void ) const = 0;
|
||||
|
||||
virtual void LoadBoneMatrix( int boneIndex, const float *m ) = 0;
|
||||
|
||||
virtual void PerspectiveOffCenterX( double fovx, double aspect, double zNear, double zFar, double bottom, double top, double left, double right ) = 0;
|
||||
|
||||
virtual void SetFloatRenderingParameter(int parm_number, float value) = 0;
|
||||
|
||||
virtual void SetIntRenderingParameter(int parm_number, int value) = 0 ;
|
||||
virtual void SetVectorRenderingParameter(int parm_number, Vector const &value) = 0 ;
|
||||
|
||||
virtual float GetFloatRenderingParameter(int parm_number) const = 0 ;
|
||||
|
||||
virtual int GetIntRenderingParameter(int parm_number) const = 0 ;
|
||||
|
||||
virtual Vector GetVectorRenderingParameter(int parm_number) const = 0 ;
|
||||
|
||||
// stencil buffer operations.
|
||||
virtual void SetStencilEnable(bool onoff) = 0;
|
||||
virtual void SetStencilFailOperation(StencilOperation_t op) = 0;
|
||||
virtual void SetStencilZFailOperation(StencilOperation_t op) = 0;
|
||||
virtual void SetStencilPassOperation(StencilOperation_t op) = 0;
|
||||
virtual void SetStencilCompareFunction(StencilComparisonFunction_t cmpfn) = 0;
|
||||
virtual void SetStencilReferenceValue(int ref) = 0;
|
||||
virtual void SetStencilTestMask(uint32 msk) = 0;
|
||||
virtual void SetStencilWriteMask(uint32 msk) = 0;
|
||||
virtual void ClearStencilBufferRectangle( int xmin, int ymin, int xmax, int ymax,int value) = 0;
|
||||
|
||||
virtual void GetDXLevelDefaults(uint &max_dxlevel,uint &recommended_dxlevel) = 0;
|
||||
|
||||
virtual const FlashlightState_t &GetFlashlightStateEx( VMatrix &worldToTexture, ITexture **pFlashlightDepthTexture ) const = 0;
|
||||
|
||||
virtual float GetAmbientLightCubeLuminance() = 0;
|
||||
|
||||
virtual void GetDX9LightState( LightState_t *state ) const = 0;
|
||||
virtual int GetPixelFogCombo( ) = 0; //0 is either range fog, or no fog simulated with rigged range fog values. 1 is height fog
|
||||
|
||||
virtual void BindStandardVertexTexture( VertexTextureSampler_t sampler, StandardTextureId_t id ) = 0;
|
||||
|
||||
// Is hardware morphing enabled?
|
||||
virtual bool IsHWMorphingEnabled( ) const = 0;
|
||||
|
||||
virtual void GetStandardTextureDimensions( int *pWidth, int *pHeight, StandardTextureId_t id ) = 0;
|
||||
|
||||
virtual void SetBooleanVertexShaderConstant( int var, BOOL const* pVec, int numBools = 1, bool bForce = false ) = 0;
|
||||
virtual void SetIntegerVertexShaderConstant( int var, int const* pVec, int numIntVecs = 1, bool bForce = false ) = 0;
|
||||
virtual void SetBooleanPixelShaderConstant( int var, BOOL const* pVec, int numBools = 1, bool bForce = false ) = 0;
|
||||
virtual void SetIntegerPixelShaderConstant( int var, int const* pVec, int numIntVecs = 1, bool bForce = false ) = 0;
|
||||
|
||||
//Are we in a configuration that needs access to depth data through the alpha channel later?
|
||||
virtual bool ShouldWriteDepthToDestAlpha( void ) const = 0;
|
||||
|
||||
|
||||
// deformations
|
||||
virtual void PushDeformation( DeformationBase_t const *Deformation ) = 0;
|
||||
virtual void PopDeformation( ) = 0;
|
||||
virtual int GetNumActiveDeformations() const =0;
|
||||
|
||||
|
||||
// for shaders to set vertex shader constants. returns a packed state which can be used to set
|
||||
// the dynamic combo. returns # of active deformations
|
||||
virtual int GetPackedDeformationInformation( int nMaskOfUnderstoodDeformations,
|
||||
float *pConstantValuesOut,
|
||||
int nBufferSize,
|
||||
int nMaximumDeformations,
|
||||
int *pNumDefsOut ) const = 0;
|
||||
|
||||
// This lets the lower level system that certain vertex fields requested
|
||||
// in the shadow state aren't actually being read given particular state
|
||||
// known only at dynamic state time. It's here only to silence warnings.
|
||||
virtual void MarkUnusedVertexFields( unsigned int nFlags, int nTexCoordCount, bool *pUnusedTexCoords ) = 0;
|
||||
|
||||
|
||||
virtual void ExecuteCommandBuffer( uint8 *pCmdBuffer ) =0;
|
||||
|
||||
// interface for mat system to tell shaderapi about standard texture handles
|
||||
virtual void SetStandardTextureHandle( StandardTextureId_t nId, ShaderAPITextureHandle_t nHandle ) =0;
|
||||
|
||||
// Interface for mat system to tell shaderapi about color correction
|
||||
virtual void GetCurrentColorCorrection( ShaderColorCorrectionInfo_t* pInfo ) = 0;
|
||||
|
||||
virtual void SetPSNearAndFarZ( int pshReg ) = 0;
|
||||
|
||||
virtual void SetDepthFeatheringPixelShaderConstant( int iConstant, float fDepthBlendScale ) = 0;
|
||||
};
|
||||
// end class IShaderDynamicAPI
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Software vertex shaders
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef void (*SoftwareVertexShader_t)( CMeshBuilder& meshBuilder, IMaterialVar **params, IShaderDynamicAPI *pShaderAPI );
|
||||
|
||||
|
||||
#endif // ISHADERDYNAMIC_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ISHADERDYNAMIC_H
|
||||
#define ISHADERDYNAMIC_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "shaderapi/shareddefs.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "tier0/basetypes.h"
|
||||
|
||||
|
||||
typedef int ShaderAPITextureHandle_t;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMeshBuilder;
|
||||
class IMaterialVar;
|
||||
struct LightDesc_t;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// State from ShaderAPI used to select proper vertex and pixel shader combos
|
||||
//-----------------------------------------------------------------------------
|
||||
struct LightState_t
|
||||
{
|
||||
int m_nNumLights;
|
||||
bool m_bAmbientLight;
|
||||
bool m_bStaticLight;
|
||||
inline int HasDynamicLight() { return (m_bAmbientLight || (m_nNumLights > 0)) ? 1 : 0; }
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Color correction info
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ShaderColorCorrectionInfo_t
|
||||
{
|
||||
bool m_bIsEnabled;
|
||||
int m_nLookupCount;
|
||||
float m_flDefaultWeight;
|
||||
float m_pLookupWeights[4];
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// the 3D shader API interface
|
||||
// This interface is all that shaders see.
|
||||
//-----------------------------------------------------------------------------
|
||||
enum StandardTextureId_t
|
||||
{
|
||||
// Lightmaps
|
||||
TEXTURE_LIGHTMAP = 0,
|
||||
TEXTURE_LIGHTMAP_FULLBRIGHT,
|
||||
TEXTURE_LIGHTMAP_BUMPED,
|
||||
TEXTURE_LIGHTMAP_BUMPED_FULLBRIGHT,
|
||||
|
||||
// Flat colors
|
||||
TEXTURE_WHITE,
|
||||
TEXTURE_BLACK,
|
||||
TEXTURE_GREY,
|
||||
TEXTURE_GREY_ALPHA_ZERO,
|
||||
|
||||
// Normalmaps
|
||||
TEXTURE_NORMALMAP_FLAT,
|
||||
|
||||
// Normalization
|
||||
TEXTURE_NORMALIZATION_CUBEMAP,
|
||||
TEXTURE_NORMALIZATION_CUBEMAP_SIGNED,
|
||||
|
||||
// Frame-buffer textures
|
||||
TEXTURE_FRAME_BUFFER_FULL_TEXTURE_0,
|
||||
TEXTURE_FRAME_BUFFER_FULL_TEXTURE_1,
|
||||
|
||||
// Color correction
|
||||
TEXTURE_COLOR_CORRECTION_VOLUME_0,
|
||||
TEXTURE_COLOR_CORRECTION_VOLUME_1,
|
||||
TEXTURE_COLOR_CORRECTION_VOLUME_2,
|
||||
TEXTURE_COLOR_CORRECTION_VOLUME_3,
|
||||
|
||||
// An alias to the Back Frame Buffer
|
||||
TEXTURE_FRAME_BUFFER_ALIAS,
|
||||
|
||||
// Noise for shadow mapping algorithm
|
||||
TEXTURE_SHADOW_NOISE_2D,
|
||||
|
||||
// A texture in which morph data gets accumulated (vs30, fast vertex textures required)
|
||||
TEXTURE_MORPH_ACCUMULATOR,
|
||||
|
||||
// A texture which contains morph weights
|
||||
TEXTURE_MORPH_WEIGHTS,
|
||||
|
||||
// A snapshot of the frame buffer's depth. Currently only valid on the 360
|
||||
TEXTURE_FRAME_BUFFER_FULL_DEPTH,
|
||||
|
||||
// A snapshot of the frame buffer's depth. Currently only valid on the 360
|
||||
TEXTURE_IDENTITY_LIGHTWARP,
|
||||
|
||||
TEXTURE_MAX_STD_TEXTURES = 32
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Viewport structure
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADER_VIEWPORT_VERSION 1
|
||||
struct ShaderViewport_t
|
||||
{
|
||||
int m_nVersion;
|
||||
int m_nTopLeftX;
|
||||
int m_nTopLeftY;
|
||||
int m_nWidth;
|
||||
int m_nHeight;
|
||||
float m_flMinZ;
|
||||
float m_flMaxZ;
|
||||
|
||||
ShaderViewport_t() : m_nVersion( SHADER_VIEWPORT_VERSION ) {}
|
||||
|
||||
void Init()
|
||||
{
|
||||
memset( this, 0, sizeof(ShaderViewport_t) );
|
||||
m_nVersion = SHADER_VIEWPORT_VERSION;
|
||||
}
|
||||
|
||||
void Init( int x, int y, int nWidth, int nHeight, float flMinZ = 0.0f, float flMaxZ = 1.0f )
|
||||
{
|
||||
m_nVersion = SHADER_VIEWPORT_VERSION;
|
||||
m_nTopLeftX = x; m_nTopLeftY = y; m_nWidth = nWidth; m_nHeight = nHeight;
|
||||
m_flMinZ = flMinZ;
|
||||
m_flMaxZ = flMaxZ;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The Shader interface versions
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADERDYNAMIC_INTERFACE_VERSION "ShaderDynamic001"
|
||||
abstract_class IShaderDynamicAPI
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void SetViewports( int nCount, const ShaderViewport_t* pViewports ) = 0;
|
||||
virtual int GetViewports( ShaderViewport_t* pViewports, int nMax ) const = 0;
|
||||
|
||||
// returns the current time in seconds....
|
||||
virtual double CurrentTime() const = 0;
|
||||
|
||||
// Gets the lightmap dimensions
|
||||
virtual void GetLightmapDimensions( int *w, int *h ) = 0;
|
||||
|
||||
// Scene fog state.
|
||||
// This is used by the shaders for picking the proper vertex shader for fogging based on dynamic state.
|
||||
virtual MaterialFogMode_t GetSceneFogMode( ) = 0;
|
||||
virtual void GetSceneFogColor( unsigned char *rgb ) = 0;
|
||||
|
||||
// stuff related to matrix stacks
|
||||
virtual void MatrixMode( MaterialMatrixMode_t matrixMode ) = 0;
|
||||
virtual void PushMatrix() = 0;
|
||||
virtual void PopMatrix() = 0;
|
||||
virtual void LoadMatrix( float *m ) = 0;
|
||||
virtual void MultMatrix( float *m ) = 0;
|
||||
virtual void MultMatrixLocal( float *m ) = 0;
|
||||
virtual void GetMatrix( MaterialMatrixMode_t matrixMode, float *dst ) = 0;
|
||||
virtual void LoadIdentity( void ) = 0;
|
||||
virtual void LoadCameraToWorld( void ) = 0;
|
||||
virtual void Ortho( double left, double right, double bottom, double top, double zNear, double zFar ) = 0;
|
||||
virtual void PerspectiveX( double fovx, double aspect, double zNear, double zFar ) = 0;
|
||||
virtual void PickMatrix( int x, int y, int width, int height ) = 0;
|
||||
virtual void Rotate( float angle, float x, float y, float z ) = 0;
|
||||
virtual void Translate( float x, float y, float z ) = 0;
|
||||
virtual void Scale( float x, float y, float z ) = 0;
|
||||
virtual void ScaleXY( float x, float y ) = 0;
|
||||
|
||||
// Sets the color to modulate by
|
||||
virtual void Color3f( float r, float g, float b ) = 0;
|
||||
virtual void Color3fv( float const* pColor ) = 0;
|
||||
virtual void Color4f( float r, float g, float b, float a ) = 0;
|
||||
virtual void Color4fv( float const* pColor ) = 0;
|
||||
|
||||
virtual void Color3ub( unsigned char r, unsigned char g, unsigned char b ) = 0;
|
||||
virtual void Color3ubv( unsigned char const* pColor ) = 0;
|
||||
virtual void Color4ub( unsigned char r, unsigned char g, unsigned char b, unsigned char a ) = 0;
|
||||
virtual void Color4ubv( unsigned char const* pColor ) = 0;
|
||||
|
||||
// Sets the constant register for vertex and pixel shaders
|
||||
virtual void SetVertexShaderConstant( int var, float const* pVec, int numConst = 1, bool bForce = false ) = 0;
|
||||
virtual void SetPixelShaderConstant( int var, float const* pVec, int numConst = 1, bool bForce = false ) = 0;
|
||||
|
||||
// Sets the default *dynamic* state
|
||||
virtual void SetDefaultState() = 0;
|
||||
|
||||
// Get the current camera position in world space.
|
||||
virtual void GetWorldSpaceCameraPosition( float* pPos ) const = 0;
|
||||
|
||||
virtual int GetCurrentNumBones( void ) const = 0;
|
||||
virtual int GetCurrentLightCombo( void ) const = 0;
|
||||
|
||||
virtual MaterialFogMode_t GetCurrentFogType( void ) const = 0;
|
||||
|
||||
// fixme: move this to shadow state
|
||||
virtual void SetTextureTransformDimension( TextureStage_t textureStage, int dimension, bool projected ) = 0;
|
||||
virtual void DisableTextureTransform( TextureStage_t textureStage ) = 0;
|
||||
virtual void SetBumpEnvMatrix( TextureStage_t textureStage, float m00, float m01, float m10, float m11 ) = 0;
|
||||
|
||||
// Sets the vertex and pixel shaders
|
||||
virtual void SetVertexShaderIndex( int vshIndex = -1 ) = 0;
|
||||
virtual void SetPixelShaderIndex( int pshIndex = 0 ) = 0;
|
||||
|
||||
// Get the dimensions of the back buffer.
|
||||
virtual void GetBackBufferDimensions( int& width, int& height ) const = 0;
|
||||
|
||||
// FIXME: The following 6 methods used to live in IShaderAPI
|
||||
// and were moved for stdshader_dx8. Let's try to move them back!
|
||||
|
||||
// Get the lights
|
||||
virtual int GetMaxLights( void ) const = 0;
|
||||
virtual const LightDesc_t& GetLight( int lightNum ) const = 0;
|
||||
|
||||
virtual void SetPixelShaderFogParams( int reg ) = 0;
|
||||
|
||||
// Render state for the ambient light cube
|
||||
virtual void SetVertexShaderStateAmbientLightCube() = 0;
|
||||
virtual void SetPixelShaderStateAmbientLightCube( int pshReg, bool bForceToBlack = false ) = 0;
|
||||
virtual void CommitPixelShaderLighting( int pshReg ) = 0;
|
||||
|
||||
// Use this to get the mesh builder that allows us to modify vertex data
|
||||
virtual CMeshBuilder* GetVertexModifyBuilder() = 0;
|
||||
virtual bool InFlashlightMode() const = 0;
|
||||
virtual const FlashlightState_t &GetFlashlightState( VMatrix &worldToTexture ) const = 0;
|
||||
virtual bool InEditorMode() const = 0;
|
||||
|
||||
// Gets the bound morph's vertex format; returns 0 if no morph is bound
|
||||
virtual MorphFormat_t GetBoundMorphFormat() = 0;
|
||||
|
||||
// Binds a standard texture
|
||||
virtual void BindStandardTexture( Sampler_t sampler, StandardTextureId_t id ) = 0;
|
||||
|
||||
virtual ITexture *GetRenderTargetEx( int nRenderTargetID ) = 0;
|
||||
|
||||
virtual void SetToneMappingScaleLinear( const Vector &scale ) = 0;
|
||||
virtual const Vector &GetToneMappingScaleLinear( void ) const = 0;
|
||||
virtual float GetLightMapScaleFactor( void ) const = 0;
|
||||
|
||||
virtual void LoadBoneMatrix( int boneIndex, const float *m ) = 0;
|
||||
|
||||
virtual void PerspectiveOffCenterX( double fovx, double aspect, double zNear, double zFar, double bottom, double top, double left, double right ) = 0;
|
||||
|
||||
virtual void SetFloatRenderingParameter(int parm_number, float value) = 0;
|
||||
|
||||
virtual void SetIntRenderingParameter(int parm_number, int value) = 0 ;
|
||||
virtual void SetVectorRenderingParameter(int parm_number, Vector const &value) = 0 ;
|
||||
|
||||
virtual float GetFloatRenderingParameter(int parm_number) const = 0 ;
|
||||
|
||||
virtual int GetIntRenderingParameter(int parm_number) const = 0 ;
|
||||
|
||||
virtual Vector GetVectorRenderingParameter(int parm_number) const = 0 ;
|
||||
|
||||
// stencil buffer operations.
|
||||
virtual void SetStencilEnable(bool onoff) = 0;
|
||||
virtual void SetStencilFailOperation(StencilOperation_t op) = 0;
|
||||
virtual void SetStencilZFailOperation(StencilOperation_t op) = 0;
|
||||
virtual void SetStencilPassOperation(StencilOperation_t op) = 0;
|
||||
virtual void SetStencilCompareFunction(StencilComparisonFunction_t cmpfn) = 0;
|
||||
virtual void SetStencilReferenceValue(int ref) = 0;
|
||||
virtual void SetStencilTestMask(uint32 msk) = 0;
|
||||
virtual void SetStencilWriteMask(uint32 msk) = 0;
|
||||
virtual void ClearStencilBufferRectangle( int xmin, int ymin, int xmax, int ymax,int value) = 0;
|
||||
|
||||
virtual void GetDXLevelDefaults(uint &max_dxlevel,uint &recommended_dxlevel) = 0;
|
||||
|
||||
virtual const FlashlightState_t &GetFlashlightStateEx( VMatrix &worldToTexture, ITexture **pFlashlightDepthTexture ) const = 0;
|
||||
|
||||
virtual float GetAmbientLightCubeLuminance() = 0;
|
||||
|
||||
virtual void GetDX9LightState( LightState_t *state ) const = 0;
|
||||
virtual int GetPixelFogCombo( ) = 0; //0 is either range fog, or no fog simulated with rigged range fog values. 1 is height fog
|
||||
|
||||
virtual void BindStandardVertexTexture( VertexTextureSampler_t sampler, StandardTextureId_t id ) = 0;
|
||||
|
||||
// Is hardware morphing enabled?
|
||||
virtual bool IsHWMorphingEnabled( ) const = 0;
|
||||
|
||||
virtual void GetStandardTextureDimensions( int *pWidth, int *pHeight, StandardTextureId_t id ) = 0;
|
||||
|
||||
virtual void SetBooleanVertexShaderConstant( int var, BOOL const* pVec, int numBools = 1, bool bForce = false ) = 0;
|
||||
virtual void SetIntegerVertexShaderConstant( int var, int const* pVec, int numIntVecs = 1, bool bForce = false ) = 0;
|
||||
virtual void SetBooleanPixelShaderConstant( int var, BOOL const* pVec, int numBools = 1, bool bForce = false ) = 0;
|
||||
virtual void SetIntegerPixelShaderConstant( int var, int const* pVec, int numIntVecs = 1, bool bForce = false ) = 0;
|
||||
|
||||
//Are we in a configuration that needs access to depth data through the alpha channel later?
|
||||
virtual bool ShouldWriteDepthToDestAlpha( void ) const = 0;
|
||||
|
||||
|
||||
// deformations
|
||||
virtual void PushDeformation( DeformationBase_t const *Deformation ) = 0;
|
||||
virtual void PopDeformation( ) = 0;
|
||||
virtual int GetNumActiveDeformations() const =0;
|
||||
|
||||
|
||||
// for shaders to set vertex shader constants. returns a packed state which can be used to set
|
||||
// the dynamic combo. returns # of active deformations
|
||||
virtual int GetPackedDeformationInformation( int nMaskOfUnderstoodDeformations,
|
||||
float *pConstantValuesOut,
|
||||
int nBufferSize,
|
||||
int nMaximumDeformations,
|
||||
int *pNumDefsOut ) const = 0;
|
||||
|
||||
// This lets the lower level system that certain vertex fields requested
|
||||
// in the shadow state aren't actually being read given particular state
|
||||
// known only at dynamic state time. It's here only to silence warnings.
|
||||
virtual void MarkUnusedVertexFields( unsigned int nFlags, int nTexCoordCount, bool *pUnusedTexCoords ) = 0;
|
||||
|
||||
|
||||
virtual void ExecuteCommandBuffer( uint8 *pCmdBuffer ) =0;
|
||||
|
||||
// interface for mat system to tell shaderapi about standard texture handles
|
||||
virtual void SetStandardTextureHandle( StandardTextureId_t nId, ShaderAPITextureHandle_t nHandle ) =0;
|
||||
|
||||
// Interface for mat system to tell shaderapi about color correction
|
||||
virtual void GetCurrentColorCorrection( ShaderColorCorrectionInfo_t* pInfo ) = 0;
|
||||
|
||||
virtual void SetPSNearAndFarZ( int pshReg ) = 0;
|
||||
|
||||
virtual void SetDepthFeatheringPixelShaderConstant( int iConstant, float fDepthBlendScale ) = 0;
|
||||
};
|
||||
// end class IShaderDynamicAPI
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Software vertex shaders
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef void (*SoftwareVertexShader_t)( CMeshBuilder& meshBuilder, IMaterialVar **params, IShaderDynamicAPI *pShaderAPI );
|
||||
|
||||
|
||||
#endif // ISHADERDYNAMIC_H
|
||||
|
||||
@@ -1,368 +1,368 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ISHADERSHADOW_H
|
||||
#define ISHADERSHADOW_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "shaderapi/shareddefs.h"
|
||||
#include <materialsystem/imaterial.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMeshBuilder;
|
||||
class IMaterialVar;
|
||||
struct LightDesc_t;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// important enumerations
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShaderDepthFunc_t
|
||||
{
|
||||
SHADER_DEPTHFUNC_NEVER,
|
||||
SHADER_DEPTHFUNC_NEARER,
|
||||
SHADER_DEPTHFUNC_EQUAL,
|
||||
SHADER_DEPTHFUNC_NEAREROREQUAL,
|
||||
SHADER_DEPTHFUNC_FARTHER,
|
||||
SHADER_DEPTHFUNC_NOTEQUAL,
|
||||
SHADER_DEPTHFUNC_FARTHEROREQUAL,
|
||||
SHADER_DEPTHFUNC_ALWAYS
|
||||
};
|
||||
|
||||
enum ShaderBlendFactor_t
|
||||
{
|
||||
SHADER_BLEND_ZERO,
|
||||
SHADER_BLEND_ONE,
|
||||
SHADER_BLEND_DST_COLOR,
|
||||
SHADER_BLEND_ONE_MINUS_DST_COLOR,
|
||||
SHADER_BLEND_SRC_ALPHA,
|
||||
SHADER_BLEND_ONE_MINUS_SRC_ALPHA,
|
||||
SHADER_BLEND_DST_ALPHA,
|
||||
SHADER_BLEND_ONE_MINUS_DST_ALPHA,
|
||||
SHADER_BLEND_SRC_ALPHA_SATURATE,
|
||||
SHADER_BLEND_SRC_COLOR,
|
||||
SHADER_BLEND_ONE_MINUS_SRC_COLOR
|
||||
};
|
||||
|
||||
enum ShaderBlendOp_t
|
||||
{
|
||||
SHADER_BLEND_OP_ADD,
|
||||
SHADER_BLEND_OP_SUBTRACT,
|
||||
SHADER_BLEND_OP_REVSUBTRACT,
|
||||
SHADER_BLEND_OP_MIN,
|
||||
SHADER_BLEND_OP_MAX
|
||||
};
|
||||
|
||||
enum ShaderAlphaFunc_t
|
||||
{
|
||||
SHADER_ALPHAFUNC_NEVER,
|
||||
SHADER_ALPHAFUNC_LESS,
|
||||
SHADER_ALPHAFUNC_EQUAL,
|
||||
SHADER_ALPHAFUNC_LEQUAL,
|
||||
SHADER_ALPHAFUNC_GREATER,
|
||||
SHADER_ALPHAFUNC_NOTEQUAL,
|
||||
SHADER_ALPHAFUNC_GEQUAL,
|
||||
SHADER_ALPHAFUNC_ALWAYS
|
||||
};
|
||||
|
||||
enum ShaderStencilFunc_t
|
||||
{
|
||||
SHADER_STENCILFUNC_NEVER = 0,
|
||||
SHADER_STENCILFUNC_LESS,
|
||||
SHADER_STENCILFUNC_EQUAL,
|
||||
SHADER_STENCILFUNC_LEQUAL,
|
||||
SHADER_STENCILFUNC_GREATER,
|
||||
SHADER_STENCILFUNC_NOTEQUAL,
|
||||
SHADER_STENCILFUNC_GEQUAL,
|
||||
SHADER_STENCILFUNC_ALWAYS
|
||||
};
|
||||
|
||||
enum ShaderStencilOp_t
|
||||
{
|
||||
SHADER_STENCILOP_KEEP = 0,
|
||||
SHADER_STENCILOP_ZERO,
|
||||
SHADER_STENCILOP_SET_TO_REFERENCE,
|
||||
SHADER_STENCILOP_INCREMENT_CLAMP,
|
||||
SHADER_STENCILOP_DECREMENT_CLAMP,
|
||||
SHADER_STENCILOP_INVERT,
|
||||
SHADER_STENCILOP_INCREMENT_WRAP,
|
||||
SHADER_STENCILOP_DECREMENT_WRAP,
|
||||
};
|
||||
|
||||
enum ShaderTexChannel_t
|
||||
{
|
||||
SHADER_TEXCHANNEL_COLOR = 0,
|
||||
SHADER_TEXCHANNEL_ALPHA
|
||||
};
|
||||
|
||||
enum ShaderPolyModeFace_t
|
||||
{
|
||||
SHADER_POLYMODEFACE_FRONT,
|
||||
SHADER_POLYMODEFACE_BACK,
|
||||
SHADER_POLYMODEFACE_FRONT_AND_BACK,
|
||||
};
|
||||
|
||||
enum ShaderPolyMode_t
|
||||
{
|
||||
SHADER_POLYMODE_POINT,
|
||||
SHADER_POLYMODE_LINE,
|
||||
SHADER_POLYMODE_FILL
|
||||
};
|
||||
|
||||
enum ShaderTexArg_t
|
||||
{
|
||||
SHADER_TEXARG_TEXTURE = 0,
|
||||
SHADER_TEXARG_VERTEXCOLOR,
|
||||
SHADER_TEXARG_SPECULARCOLOR,
|
||||
SHADER_TEXARG_CONSTANTCOLOR,
|
||||
SHADER_TEXARG_PREVIOUSSTAGE,
|
||||
SHADER_TEXARG_NONE,
|
||||
SHADER_TEXARG_ZERO,
|
||||
SHADER_TEXARG_TEXTUREALPHA,
|
||||
SHADER_TEXARG_INVTEXTUREALPHA,
|
||||
SHADER_TEXARG_ONE,
|
||||
};
|
||||
|
||||
enum ShaderTexOp_t
|
||||
{
|
||||
// DX5 shaders support these
|
||||
SHADER_TEXOP_MODULATE = 0,
|
||||
SHADER_TEXOP_MODULATE2X,
|
||||
SHADER_TEXOP_MODULATE4X,
|
||||
SHADER_TEXOP_SELECTARG1,
|
||||
SHADER_TEXOP_SELECTARG2,
|
||||
SHADER_TEXOP_DISABLE,
|
||||
|
||||
// DX6 shaders support these
|
||||
SHADER_TEXOP_ADD,
|
||||
SHADER_TEXOP_SUBTRACT,
|
||||
SHADER_TEXOP_ADDSIGNED2X,
|
||||
SHADER_TEXOP_BLEND_CONSTANTALPHA,
|
||||
SHADER_TEXOP_BLEND_TEXTUREALPHA,
|
||||
SHADER_TEXOP_BLEND_PREVIOUSSTAGEALPHA,
|
||||
SHADER_TEXOP_MODULATECOLOR_ADDALPHA,
|
||||
SHADER_TEXOP_MODULATEINVCOLOR_ADDALPHA,
|
||||
|
||||
// DX7
|
||||
SHADER_TEXOP_DOTPRODUCT3
|
||||
};
|
||||
|
||||
enum ShaderTexGenParam_t
|
||||
{
|
||||
SHADER_TEXGENPARAM_OBJECT_LINEAR,
|
||||
SHADER_TEXGENPARAM_EYE_LINEAR,
|
||||
SHADER_TEXGENPARAM_SPHERE_MAP,
|
||||
SHADER_TEXGENPARAM_CAMERASPACEREFLECTIONVECTOR,
|
||||
SHADER_TEXGENPARAM_CAMERASPACENORMAL
|
||||
};
|
||||
|
||||
enum ShaderDrawBitField_t
|
||||
{
|
||||
SHADER_DRAW_POSITION = 0x0001,
|
||||
SHADER_DRAW_NORMAL = 0x0002,
|
||||
SHADER_DRAW_COLOR = 0x0004,
|
||||
SHADER_DRAW_SPECULAR = 0x0008,
|
||||
|
||||
SHADER_DRAW_TEXCOORD0 = 0x0010,
|
||||
SHADER_DRAW_TEXCOORD1 = 0x0020,
|
||||
SHADER_DRAW_TEXCOORD2 = 0x0040,
|
||||
SHADER_DRAW_TEXCOORD3 = 0x0080,
|
||||
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD0 = 0x0100,
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD1 = 0x0200,
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD2 = 0x0400,
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD3 = 0x0800,
|
||||
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD0 = 0x1000,
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD1 = 0x2000,
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD2 = 0x4000,
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD3 = 0x8000,
|
||||
|
||||
SHADER_TEXCOORD_MASK = SHADER_DRAW_TEXCOORD0 | SHADER_DRAW_TEXCOORD1 |
|
||||
SHADER_DRAW_TEXCOORD2 | SHADER_DRAW_TEXCOORD3,
|
||||
|
||||
SHADER_LIGHTMAP_TEXCOORD_MASK = SHADER_DRAW_LIGHTMAP_TEXCOORD0 |
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD1 |
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD2 |
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD3,
|
||||
|
||||
SHADER_SECONDARY_TEXCOORD_MASK = SHADER_DRAW_SECONDARY_TEXCOORD0 |
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD1 |
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD2 |
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD3,
|
||||
};
|
||||
|
||||
|
||||
enum ShaderFogMode_t
|
||||
{
|
||||
SHADER_FOGMODE_DISABLED = 0,
|
||||
SHADER_FOGMODE_OO_OVERBRIGHT,
|
||||
SHADER_FOGMODE_BLACK,
|
||||
SHADER_FOGMODE_GREY,
|
||||
SHADER_FOGMODE_FOGCOLOR,
|
||||
SHADER_FOGMODE_WHITE,
|
||||
SHADER_FOGMODE_NUMFOGMODES
|
||||
};
|
||||
|
||||
enum ShaderMaterialSource_t
|
||||
{
|
||||
SHADER_MATERIALSOURCE_MATERIAL = 0,
|
||||
SHADER_MATERIALSOURCE_COLOR1,
|
||||
SHADER_MATERIALSOURCE_COLOR2,
|
||||
};
|
||||
|
||||
|
||||
// m_ZBias has only two bits in ShadowState_t, so be careful extending this enum
|
||||
enum PolygonOffsetMode_t
|
||||
{
|
||||
SHADER_POLYOFFSET_DISABLE = 0x0,
|
||||
SHADER_POLYOFFSET_DECAL = 0x1,
|
||||
SHADER_POLYOFFSET_SHADOW_BIAS = 0x2,
|
||||
SHADER_POLYOFFSET_RESERVED = 0x3 // Reserved for future use
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The Shader interface versions
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADERSHADOW_INTERFACE_VERSION "ShaderShadow010"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// the shader API interface (methods called from shaders)
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IShaderShadow
|
||||
{
|
||||
public:
|
||||
// Sets the default *shadow* state
|
||||
virtual void SetDefaultState() = 0;
|
||||
|
||||
// Methods related to depth buffering
|
||||
virtual void DepthFunc( ShaderDepthFunc_t depthFunc ) = 0;
|
||||
virtual void EnableDepthWrites( bool bEnable ) = 0;
|
||||
virtual void EnableDepthTest( bool bEnable ) = 0;
|
||||
virtual void EnablePolyOffset( PolygonOffsetMode_t nOffsetMode ) = 0;
|
||||
|
||||
// These methods for controlling stencil are obsolete and stubbed to do nothing. Stencil
|
||||
// control is via the shaderapi/material system now, not part of the shadow state.
|
||||
// Methods related to stencil
|
||||
virtual void EnableStencil( bool bEnable ) = 0;
|
||||
virtual void StencilFunc( ShaderStencilFunc_t stencilFunc ) = 0;
|
||||
virtual void StencilPassOp( ShaderStencilOp_t stencilOp ) = 0;
|
||||
virtual void StencilFailOp( ShaderStencilOp_t stencilOp ) = 0;
|
||||
virtual void StencilDepthFailOp( ShaderStencilOp_t stencilOp ) = 0;
|
||||
virtual void StencilReference( int nReference ) = 0;
|
||||
virtual void StencilMask( int nMask ) = 0;
|
||||
virtual void StencilWriteMask( int nMask ) = 0;
|
||||
|
||||
// Suppresses/activates color writing
|
||||
virtual void EnableColorWrites( bool bEnable ) = 0;
|
||||
virtual void EnableAlphaWrites( bool bEnable ) = 0;
|
||||
|
||||
// Methods related to alpha blending
|
||||
virtual void EnableBlending( bool bEnable ) = 0;
|
||||
virtual void BlendFunc( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor ) = 0;
|
||||
// More below...
|
||||
|
||||
// Alpha testing
|
||||
virtual void EnableAlphaTest( bool bEnable ) = 0;
|
||||
virtual void AlphaFunc( ShaderAlphaFunc_t alphaFunc, float alphaRef /* [0-1] */ ) = 0;
|
||||
|
||||
// Wireframe/filled polygons
|
||||
virtual void PolyMode( ShaderPolyModeFace_t face, ShaderPolyMode_t polyMode ) = 0;
|
||||
|
||||
// Back face culling
|
||||
virtual void EnableCulling( bool bEnable ) = 0;
|
||||
|
||||
// constant color + transparency
|
||||
virtual void EnableConstantColor( bool bEnable ) = 0;
|
||||
|
||||
// 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
|
||||
virtual void VertexShaderVertexFormat( unsigned int nFlags,
|
||||
int nTexCoordCount, int* pTexCoordDimensions, int nUserDataSize ) = 0;
|
||||
|
||||
// Pixel and vertex shader methods
|
||||
virtual void SetVertexShader( const char* pFileName, int nStaticVshIndex ) = 0;
|
||||
virtual void SetPixelShader( const char* pFileName, int nStaticPshIndex = 0 ) = 0;
|
||||
|
||||
// Indicates we're going to light the model
|
||||
virtual void EnableLighting( bool bEnable ) = 0;
|
||||
|
||||
// Enables specular lighting (lighting has also got to be enabled)
|
||||
virtual void EnableSpecular( bool bEnable ) = 0;
|
||||
|
||||
// Convert from linear to gamma color space on writes to frame buffer.
|
||||
virtual void EnableSRGBWrite( bool bEnable ) = 0;
|
||||
|
||||
// Convert from gamma to linear on texture fetch.
|
||||
virtual void EnableSRGBRead( Sampler_t sampler, bool bEnable ) = 0;
|
||||
|
||||
// Activate/deactivate skinning. Indexed blending is automatically
|
||||
// enabled if it's available for this hardware. When blending is enabled,
|
||||
// we allocate enough room for 3 weights (max allowed)
|
||||
virtual void EnableVertexBlend( bool bEnable ) = 0;
|
||||
|
||||
// per texture unit stuff
|
||||
virtual void OverbrightValue( TextureStage_t stage, float value ) = 0;
|
||||
virtual void EnableTexture( Sampler_t sampler, bool bEnable ) = 0;
|
||||
virtual void EnableTexGen( TextureStage_t stage, bool bEnable ) = 0;
|
||||
virtual void TexGen( TextureStage_t stage, ShaderTexGenParam_t param ) = 0;
|
||||
|
||||
// alternate method of specifying per-texture unit stuff, more flexible and more complicated
|
||||
// Can be used to specify different operation per channel (alpha/color)...
|
||||
virtual void EnableCustomPixelPipe( bool bEnable ) = 0;
|
||||
virtual void CustomTextureStages( int stageCount ) = 0;
|
||||
virtual void CustomTextureOperation( TextureStage_t stage, ShaderTexChannel_t channel,
|
||||
ShaderTexOp_t op, ShaderTexArg_t arg1, ShaderTexArg_t arg2 ) = 0;
|
||||
|
||||
// indicates what per-vertex data we're providing
|
||||
virtual void DrawFlags( unsigned int drawFlags ) = 0;
|
||||
|
||||
// A simpler method of dealing with alpha modulation
|
||||
virtual void EnableAlphaPipe( bool bEnable ) = 0;
|
||||
virtual void EnableConstantAlpha( bool bEnable ) = 0;
|
||||
virtual void EnableVertexAlpha( bool bEnable ) = 0;
|
||||
virtual void EnableTextureAlpha( TextureStage_t stage, bool bEnable ) = 0;
|
||||
|
||||
// GR - Separate alpha blending
|
||||
virtual void EnableBlendingSeparateAlpha( bool bEnable ) = 0;
|
||||
virtual void BlendFuncSeparateAlpha( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor ) = 0;
|
||||
virtual void FogMode( ShaderFogMode_t fogMode ) = 0;
|
||||
|
||||
virtual void SetDiffuseMaterialSource( ShaderMaterialSource_t materialSource ) = 0;
|
||||
|
||||
// Indicates the morph format for use with a vertex shader
|
||||
// The flags to pass in here come from the MorphFormatFlags_t enum
|
||||
virtual void SetMorphFormat( MorphFormat_t flags ) = 0;
|
||||
|
||||
virtual void DisableFogGammaCorrection( bool bDisable ) = 0; //some blending modes won't work properly with corrected fog
|
||||
|
||||
// Alpha to coverage
|
||||
virtual void EnableAlphaToCoverage( bool bEnable ) = 0;
|
||||
|
||||
// Shadow map filtering
|
||||
virtual void SetShadowDepthFiltering( Sampler_t stage ) = 0;
|
||||
|
||||
// More alpha blending state
|
||||
virtual void BlendOp( ShaderBlendOp_t blendOp ) = 0;
|
||||
virtual void BlendOpSeparateAlpha( ShaderBlendOp_t blendOp ) = 0;
|
||||
};
|
||||
// end class IShaderShadow
|
||||
|
||||
|
||||
|
||||
#endif // ISHADERSHADOW_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ISHADERSHADOW_H
|
||||
#define ISHADERSHADOW_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "shaderapi/shareddefs.h"
|
||||
#include <materialsystem/imaterial.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMeshBuilder;
|
||||
class IMaterialVar;
|
||||
struct LightDesc_t;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// important enumerations
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShaderDepthFunc_t
|
||||
{
|
||||
SHADER_DEPTHFUNC_NEVER,
|
||||
SHADER_DEPTHFUNC_NEARER,
|
||||
SHADER_DEPTHFUNC_EQUAL,
|
||||
SHADER_DEPTHFUNC_NEAREROREQUAL,
|
||||
SHADER_DEPTHFUNC_FARTHER,
|
||||
SHADER_DEPTHFUNC_NOTEQUAL,
|
||||
SHADER_DEPTHFUNC_FARTHEROREQUAL,
|
||||
SHADER_DEPTHFUNC_ALWAYS
|
||||
};
|
||||
|
||||
enum ShaderBlendFactor_t
|
||||
{
|
||||
SHADER_BLEND_ZERO,
|
||||
SHADER_BLEND_ONE,
|
||||
SHADER_BLEND_DST_COLOR,
|
||||
SHADER_BLEND_ONE_MINUS_DST_COLOR,
|
||||
SHADER_BLEND_SRC_ALPHA,
|
||||
SHADER_BLEND_ONE_MINUS_SRC_ALPHA,
|
||||
SHADER_BLEND_DST_ALPHA,
|
||||
SHADER_BLEND_ONE_MINUS_DST_ALPHA,
|
||||
SHADER_BLEND_SRC_ALPHA_SATURATE,
|
||||
SHADER_BLEND_SRC_COLOR,
|
||||
SHADER_BLEND_ONE_MINUS_SRC_COLOR
|
||||
};
|
||||
|
||||
enum ShaderBlendOp_t
|
||||
{
|
||||
SHADER_BLEND_OP_ADD,
|
||||
SHADER_BLEND_OP_SUBTRACT,
|
||||
SHADER_BLEND_OP_REVSUBTRACT,
|
||||
SHADER_BLEND_OP_MIN,
|
||||
SHADER_BLEND_OP_MAX
|
||||
};
|
||||
|
||||
enum ShaderAlphaFunc_t
|
||||
{
|
||||
SHADER_ALPHAFUNC_NEVER,
|
||||
SHADER_ALPHAFUNC_LESS,
|
||||
SHADER_ALPHAFUNC_EQUAL,
|
||||
SHADER_ALPHAFUNC_LEQUAL,
|
||||
SHADER_ALPHAFUNC_GREATER,
|
||||
SHADER_ALPHAFUNC_NOTEQUAL,
|
||||
SHADER_ALPHAFUNC_GEQUAL,
|
||||
SHADER_ALPHAFUNC_ALWAYS
|
||||
};
|
||||
|
||||
enum ShaderStencilFunc_t
|
||||
{
|
||||
SHADER_STENCILFUNC_NEVER = 0,
|
||||
SHADER_STENCILFUNC_LESS,
|
||||
SHADER_STENCILFUNC_EQUAL,
|
||||
SHADER_STENCILFUNC_LEQUAL,
|
||||
SHADER_STENCILFUNC_GREATER,
|
||||
SHADER_STENCILFUNC_NOTEQUAL,
|
||||
SHADER_STENCILFUNC_GEQUAL,
|
||||
SHADER_STENCILFUNC_ALWAYS
|
||||
};
|
||||
|
||||
enum ShaderStencilOp_t
|
||||
{
|
||||
SHADER_STENCILOP_KEEP = 0,
|
||||
SHADER_STENCILOP_ZERO,
|
||||
SHADER_STENCILOP_SET_TO_REFERENCE,
|
||||
SHADER_STENCILOP_INCREMENT_CLAMP,
|
||||
SHADER_STENCILOP_DECREMENT_CLAMP,
|
||||
SHADER_STENCILOP_INVERT,
|
||||
SHADER_STENCILOP_INCREMENT_WRAP,
|
||||
SHADER_STENCILOP_DECREMENT_WRAP,
|
||||
};
|
||||
|
||||
enum ShaderTexChannel_t
|
||||
{
|
||||
SHADER_TEXCHANNEL_COLOR = 0,
|
||||
SHADER_TEXCHANNEL_ALPHA
|
||||
};
|
||||
|
||||
enum ShaderPolyModeFace_t
|
||||
{
|
||||
SHADER_POLYMODEFACE_FRONT,
|
||||
SHADER_POLYMODEFACE_BACK,
|
||||
SHADER_POLYMODEFACE_FRONT_AND_BACK,
|
||||
};
|
||||
|
||||
enum ShaderPolyMode_t
|
||||
{
|
||||
SHADER_POLYMODE_POINT,
|
||||
SHADER_POLYMODE_LINE,
|
||||
SHADER_POLYMODE_FILL
|
||||
};
|
||||
|
||||
enum ShaderTexArg_t
|
||||
{
|
||||
SHADER_TEXARG_TEXTURE = 0,
|
||||
SHADER_TEXARG_VERTEXCOLOR,
|
||||
SHADER_TEXARG_SPECULARCOLOR,
|
||||
SHADER_TEXARG_CONSTANTCOLOR,
|
||||
SHADER_TEXARG_PREVIOUSSTAGE,
|
||||
SHADER_TEXARG_NONE,
|
||||
SHADER_TEXARG_ZERO,
|
||||
SHADER_TEXARG_TEXTUREALPHA,
|
||||
SHADER_TEXARG_INVTEXTUREALPHA,
|
||||
SHADER_TEXARG_ONE,
|
||||
};
|
||||
|
||||
enum ShaderTexOp_t
|
||||
{
|
||||
// DX5 shaders support these
|
||||
SHADER_TEXOP_MODULATE = 0,
|
||||
SHADER_TEXOP_MODULATE2X,
|
||||
SHADER_TEXOP_MODULATE4X,
|
||||
SHADER_TEXOP_SELECTARG1,
|
||||
SHADER_TEXOP_SELECTARG2,
|
||||
SHADER_TEXOP_DISABLE,
|
||||
|
||||
// DX6 shaders support these
|
||||
SHADER_TEXOP_ADD,
|
||||
SHADER_TEXOP_SUBTRACT,
|
||||
SHADER_TEXOP_ADDSIGNED2X,
|
||||
SHADER_TEXOP_BLEND_CONSTANTALPHA,
|
||||
SHADER_TEXOP_BLEND_TEXTUREALPHA,
|
||||
SHADER_TEXOP_BLEND_PREVIOUSSTAGEALPHA,
|
||||
SHADER_TEXOP_MODULATECOLOR_ADDALPHA,
|
||||
SHADER_TEXOP_MODULATEINVCOLOR_ADDALPHA,
|
||||
|
||||
// DX7
|
||||
SHADER_TEXOP_DOTPRODUCT3
|
||||
};
|
||||
|
||||
enum ShaderTexGenParam_t
|
||||
{
|
||||
SHADER_TEXGENPARAM_OBJECT_LINEAR,
|
||||
SHADER_TEXGENPARAM_EYE_LINEAR,
|
||||
SHADER_TEXGENPARAM_SPHERE_MAP,
|
||||
SHADER_TEXGENPARAM_CAMERASPACEREFLECTIONVECTOR,
|
||||
SHADER_TEXGENPARAM_CAMERASPACENORMAL
|
||||
};
|
||||
|
||||
enum ShaderDrawBitField_t
|
||||
{
|
||||
SHADER_DRAW_POSITION = 0x0001,
|
||||
SHADER_DRAW_NORMAL = 0x0002,
|
||||
SHADER_DRAW_COLOR = 0x0004,
|
||||
SHADER_DRAW_SPECULAR = 0x0008,
|
||||
|
||||
SHADER_DRAW_TEXCOORD0 = 0x0010,
|
||||
SHADER_DRAW_TEXCOORD1 = 0x0020,
|
||||
SHADER_DRAW_TEXCOORD2 = 0x0040,
|
||||
SHADER_DRAW_TEXCOORD3 = 0x0080,
|
||||
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD0 = 0x0100,
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD1 = 0x0200,
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD2 = 0x0400,
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD3 = 0x0800,
|
||||
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD0 = 0x1000,
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD1 = 0x2000,
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD2 = 0x4000,
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD3 = 0x8000,
|
||||
|
||||
SHADER_TEXCOORD_MASK = SHADER_DRAW_TEXCOORD0 | SHADER_DRAW_TEXCOORD1 |
|
||||
SHADER_DRAW_TEXCOORD2 | SHADER_DRAW_TEXCOORD3,
|
||||
|
||||
SHADER_LIGHTMAP_TEXCOORD_MASK = SHADER_DRAW_LIGHTMAP_TEXCOORD0 |
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD1 |
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD2 |
|
||||
SHADER_DRAW_LIGHTMAP_TEXCOORD3,
|
||||
|
||||
SHADER_SECONDARY_TEXCOORD_MASK = SHADER_DRAW_SECONDARY_TEXCOORD0 |
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD1 |
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD2 |
|
||||
SHADER_DRAW_SECONDARY_TEXCOORD3,
|
||||
};
|
||||
|
||||
|
||||
enum ShaderFogMode_t
|
||||
{
|
||||
SHADER_FOGMODE_DISABLED = 0,
|
||||
SHADER_FOGMODE_OO_OVERBRIGHT,
|
||||
SHADER_FOGMODE_BLACK,
|
||||
SHADER_FOGMODE_GREY,
|
||||
SHADER_FOGMODE_FOGCOLOR,
|
||||
SHADER_FOGMODE_WHITE,
|
||||
SHADER_FOGMODE_NUMFOGMODES
|
||||
};
|
||||
|
||||
enum ShaderMaterialSource_t
|
||||
{
|
||||
SHADER_MATERIALSOURCE_MATERIAL = 0,
|
||||
SHADER_MATERIALSOURCE_COLOR1,
|
||||
SHADER_MATERIALSOURCE_COLOR2,
|
||||
};
|
||||
|
||||
|
||||
// m_ZBias has only two bits in ShadowState_t, so be careful extending this enum
|
||||
enum PolygonOffsetMode_t
|
||||
{
|
||||
SHADER_POLYOFFSET_DISABLE = 0x0,
|
||||
SHADER_POLYOFFSET_DECAL = 0x1,
|
||||
SHADER_POLYOFFSET_SHADOW_BIAS = 0x2,
|
||||
SHADER_POLYOFFSET_RESERVED = 0x3 // Reserved for future use
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The Shader interface versions
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SHADERSHADOW_INTERFACE_VERSION "ShaderShadow010"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// the shader API interface (methods called from shaders)
|
||||
//-----------------------------------------------------------------------------
|
||||
abstract_class IShaderShadow
|
||||
{
|
||||
public:
|
||||
// Sets the default *shadow* state
|
||||
virtual void SetDefaultState() = 0;
|
||||
|
||||
// Methods related to depth buffering
|
||||
virtual void DepthFunc( ShaderDepthFunc_t depthFunc ) = 0;
|
||||
virtual void EnableDepthWrites( bool bEnable ) = 0;
|
||||
virtual void EnableDepthTest( bool bEnable ) = 0;
|
||||
virtual void EnablePolyOffset( PolygonOffsetMode_t nOffsetMode ) = 0;
|
||||
|
||||
// These methods for controlling stencil are obsolete and stubbed to do nothing. Stencil
|
||||
// control is via the shaderapi/material system now, not part of the shadow state.
|
||||
// Methods related to stencil
|
||||
virtual void EnableStencil( bool bEnable ) = 0;
|
||||
virtual void StencilFunc( ShaderStencilFunc_t stencilFunc ) = 0;
|
||||
virtual void StencilPassOp( ShaderStencilOp_t stencilOp ) = 0;
|
||||
virtual void StencilFailOp( ShaderStencilOp_t stencilOp ) = 0;
|
||||
virtual void StencilDepthFailOp( ShaderStencilOp_t stencilOp ) = 0;
|
||||
virtual void StencilReference( int nReference ) = 0;
|
||||
virtual void StencilMask( int nMask ) = 0;
|
||||
virtual void StencilWriteMask( int nMask ) = 0;
|
||||
|
||||
// Suppresses/activates color writing
|
||||
virtual void EnableColorWrites( bool bEnable ) = 0;
|
||||
virtual void EnableAlphaWrites( bool bEnable ) = 0;
|
||||
|
||||
// Methods related to alpha blending
|
||||
virtual void EnableBlending( bool bEnable ) = 0;
|
||||
virtual void BlendFunc( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor ) = 0;
|
||||
// More below...
|
||||
|
||||
// Alpha testing
|
||||
virtual void EnableAlphaTest( bool bEnable ) = 0;
|
||||
virtual void AlphaFunc( ShaderAlphaFunc_t alphaFunc, float alphaRef /* [0-1] */ ) = 0;
|
||||
|
||||
// Wireframe/filled polygons
|
||||
virtual void PolyMode( ShaderPolyModeFace_t face, ShaderPolyMode_t polyMode ) = 0;
|
||||
|
||||
// Back face culling
|
||||
virtual void EnableCulling( bool bEnable ) = 0;
|
||||
|
||||
// constant color + transparency
|
||||
virtual void EnableConstantColor( bool bEnable ) = 0;
|
||||
|
||||
// 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
|
||||
virtual void VertexShaderVertexFormat( unsigned int nFlags,
|
||||
int nTexCoordCount, int* pTexCoordDimensions, int nUserDataSize ) = 0;
|
||||
|
||||
// Pixel and vertex shader methods
|
||||
virtual void SetVertexShader( const char* pFileName, int nStaticVshIndex ) = 0;
|
||||
virtual void SetPixelShader( const char* pFileName, int nStaticPshIndex = 0 ) = 0;
|
||||
|
||||
// Indicates we're going to light the model
|
||||
virtual void EnableLighting( bool bEnable ) = 0;
|
||||
|
||||
// Enables specular lighting (lighting has also got to be enabled)
|
||||
virtual void EnableSpecular( bool bEnable ) = 0;
|
||||
|
||||
// Convert from linear to gamma color space on writes to frame buffer.
|
||||
virtual void EnableSRGBWrite( bool bEnable ) = 0;
|
||||
|
||||
// Convert from gamma to linear on texture fetch.
|
||||
virtual void EnableSRGBRead( Sampler_t sampler, bool bEnable ) = 0;
|
||||
|
||||
// Activate/deactivate skinning. Indexed blending is automatically
|
||||
// enabled if it's available for this hardware. When blending is enabled,
|
||||
// we allocate enough room for 3 weights (max allowed)
|
||||
virtual void EnableVertexBlend( bool bEnable ) = 0;
|
||||
|
||||
// per texture unit stuff
|
||||
virtual void OverbrightValue( TextureStage_t stage, float value ) = 0;
|
||||
virtual void EnableTexture( Sampler_t sampler, bool bEnable ) = 0;
|
||||
virtual void EnableTexGen( TextureStage_t stage, bool bEnable ) = 0;
|
||||
virtual void TexGen( TextureStage_t stage, ShaderTexGenParam_t param ) = 0;
|
||||
|
||||
// alternate method of specifying per-texture unit stuff, more flexible and more complicated
|
||||
// Can be used to specify different operation per channel (alpha/color)...
|
||||
virtual void EnableCustomPixelPipe( bool bEnable ) = 0;
|
||||
virtual void CustomTextureStages( int stageCount ) = 0;
|
||||
virtual void CustomTextureOperation( TextureStage_t stage, ShaderTexChannel_t channel,
|
||||
ShaderTexOp_t op, ShaderTexArg_t arg1, ShaderTexArg_t arg2 ) = 0;
|
||||
|
||||
// indicates what per-vertex data we're providing
|
||||
virtual void DrawFlags( unsigned int drawFlags ) = 0;
|
||||
|
||||
// A simpler method of dealing with alpha modulation
|
||||
virtual void EnableAlphaPipe( bool bEnable ) = 0;
|
||||
virtual void EnableConstantAlpha( bool bEnable ) = 0;
|
||||
virtual void EnableVertexAlpha( bool bEnable ) = 0;
|
||||
virtual void EnableTextureAlpha( TextureStage_t stage, bool bEnable ) = 0;
|
||||
|
||||
// GR - Separate alpha blending
|
||||
virtual void EnableBlendingSeparateAlpha( bool bEnable ) = 0;
|
||||
virtual void BlendFuncSeparateAlpha( ShaderBlendFactor_t srcFactor, ShaderBlendFactor_t dstFactor ) = 0;
|
||||
virtual void FogMode( ShaderFogMode_t fogMode ) = 0;
|
||||
|
||||
virtual void SetDiffuseMaterialSource( ShaderMaterialSource_t materialSource ) = 0;
|
||||
|
||||
// Indicates the morph format for use with a vertex shader
|
||||
// The flags to pass in here come from the MorphFormatFlags_t enum
|
||||
virtual void SetMorphFormat( MorphFormat_t flags ) = 0;
|
||||
|
||||
virtual void DisableFogGammaCorrection( bool bDisable ) = 0; //some blending modes won't work properly with corrected fog
|
||||
|
||||
// Alpha to coverage
|
||||
virtual void EnableAlphaToCoverage( bool bEnable ) = 0;
|
||||
|
||||
// Shadow map filtering
|
||||
virtual void SetShadowDepthFiltering( Sampler_t stage ) = 0;
|
||||
|
||||
// More alpha blending state
|
||||
virtual void BlendOp( ShaderBlendOp_t blendOp ) = 0;
|
||||
virtual void BlendOpSeparateAlpha( ShaderBlendOp_t blendOp ) = 0;
|
||||
};
|
||||
// end class IShaderShadow
|
||||
|
||||
|
||||
|
||||
#endif // ISHADERSHADOW_H
|
||||
|
||||
@@ -1,131 +1,131 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ISHADERUTIL_H
|
||||
#define ISHADERUTIL_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "appframework/IAppSystem.h"
|
||||
#include "shaderapi/ishaderapi.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class ITexture;
|
||||
struct MaterialSystem_Config_t;
|
||||
struct ImageFormatInfo_t;
|
||||
enum Sampler_t;
|
||||
enum VertexTextureSampler_t;
|
||||
enum StandardTextureId_t;
|
||||
class CPrimList;
|
||||
struct ShaderColorCorrectionInfo_t;
|
||||
|
||||
#define SHADER_UTIL_INTERFACE_VERSION "VShaderUtil001"
|
||||
|
||||
enum shaderthreadevent_t
|
||||
{
|
||||
SHADER_THREAD_RELEASE_RESOURCES = 1,
|
||||
SHADER_THREAD_ACQUIRE_RESOURCES = 2,
|
||||
SHADER_THREAD_DEVICE_LOST = 3,
|
||||
SHADER_THREAD_EVICT_RESOURCES = 4,
|
||||
SHADER_THREAD_OTHER_APP_START = 5,
|
||||
SHADER_THREAD_OTHER_APP_END = 6,
|
||||
SHADER_THREAD_RESET_RENDER_STATE = 7,
|
||||
};
|
||||
|
||||
abstract_class IShaderUtil : public IAppSystem
|
||||
{
|
||||
public:
|
||||
// Method to allow clients access to the MaterialSystem_Config
|
||||
virtual MaterialSystem_Config_t& GetConfig() = 0;
|
||||
|
||||
// Allows us to convert image formats
|
||||
virtual bool ConvertImageFormat( unsigned char *src, enum ImageFormat srcImageFormat,
|
||||
unsigned char *dst, enum ImageFormat dstImageFormat,
|
||||
int width, int height, int srcStride = 0, int dstStride = 0 ) = 0;
|
||||
|
||||
// Figures out the amount of memory needed by a bitmap
|
||||
virtual int GetMemRequired( int width, int height, int depth, ImageFormat format, bool mipmap ) = 0;
|
||||
|
||||
// Gets image format info
|
||||
virtual const ImageFormatInfo_t& ImageFormatInfo( ImageFormat fmt ) const = 0;
|
||||
|
||||
// Bind standard textures
|
||||
virtual void BindStandardTexture( Sampler_t sampler, StandardTextureId_t id ) = 0;
|
||||
|
||||
// What are the lightmap dimensions?
|
||||
virtual void GetLightmapDimensions( int *w, int *h ) = 0;
|
||||
|
||||
// These methods are called when the shader must eject + restore HW memory
|
||||
virtual void ReleaseShaderObjects() = 0;
|
||||
virtual void RestoreShaderObjects( CreateInterfaceFn shaderFactory, int nChangeFlags = 0 ) = 0;
|
||||
|
||||
// Used to prevent meshes from drawing.
|
||||
virtual bool IsInStubMode() = 0;
|
||||
virtual bool InFlashlightMode() const = 0;
|
||||
|
||||
// For the shader API to shove the current version of aniso level into the
|
||||
// "definitive" place (g_config) when the shader API decides to change it.
|
||||
// Eventually, we should have a better system of who owns the definitive
|
||||
// versions of config vars.
|
||||
virtual void NoteAnisotropicLevel( int currentLevel ) = 0;
|
||||
|
||||
// NOTE: Stuff after this is added after shipping HL2.
|
||||
|
||||
// Are we rendering through the editor?
|
||||
virtual bool InEditorMode() const = 0;
|
||||
|
||||
// Gets the bound morph's vertex format; returns 0 if no morph is bound
|
||||
virtual MorphFormat_t GetBoundMorphFormat() = 0;
|
||||
|
||||
virtual ITexture *GetRenderTargetEx( int nRenderTargetID ) = 0;
|
||||
|
||||
// Tells the material system to draw a buffer clearing quad
|
||||
virtual void DrawClearBufferQuad( unsigned char r, unsigned char g, unsigned char b, unsigned char a, bool bClearColor, bool bClearAlpha, bool bClearDepth ) = 0;
|
||||
|
||||
#if defined( _X360 )
|
||||
virtual void ReadBackBuffer( Rect_t *pSrcRect, Rect_t *pDstRect, unsigned char *pData, ImageFormat dstFormat, int nDstStride ) = 0;
|
||||
#endif
|
||||
|
||||
// Calls from meshes to material system to handle queing/threading
|
||||
virtual bool OnDrawMesh( IMesh *pMesh, int firstIndex, int numIndices ) = 0;
|
||||
virtual bool OnDrawMesh( IMesh *pMesh, CPrimList *pLists, int nLists ) = 0;
|
||||
virtual bool OnSetFlexMesh( IMesh *pStaticMesh, IMesh *pMesh, int nVertexOffsetInBytes ) = 0;
|
||||
virtual bool OnSetColorMesh( IMesh *pStaticMesh, IMesh *pMesh, int nVertexOffsetInBytes ) = 0;
|
||||
virtual bool OnSetPrimitiveType( IMesh *pMesh, MaterialPrimitiveType_t type ) = 0;
|
||||
virtual bool OnFlushBufferedPrimitives() = 0;
|
||||
|
||||
|
||||
virtual void SyncMatrices() = 0;
|
||||
virtual void SyncMatrix( MaterialMatrixMode_t ) = 0;
|
||||
|
||||
virtual void BindStandardVertexTexture( VertexTextureSampler_t sampler, StandardTextureId_t id ) = 0;
|
||||
virtual void GetStandardTextureDimensions( int *pWidth, int *pHeight, StandardTextureId_t id ) = 0;
|
||||
|
||||
virtual int MaxHWMorphBatchCount() const = 0;
|
||||
|
||||
// Interface for mat system to tell shaderapi about color correction
|
||||
virtual void GetCurrentColorCorrection( ShaderColorCorrectionInfo_t* pInfo ) = 0;
|
||||
// received an event while not in owning thread, handle this outside
|
||||
virtual void OnThreadEvent( uint32 threadEvent ) = 0;
|
||||
|
||||
virtual MaterialThreadMode_t GetThreadMode( ) = 0;
|
||||
virtual bool IsRenderThreadSafe( ) = 0;
|
||||
|
||||
// Remove any materials from memory that aren't in use as determined
|
||||
// by the IMaterial's reference count.
|
||||
virtual void UncacheUnusedMaterials( bool bRecomputeStateSnapshots = false ) = 0;
|
||||
};
|
||||
|
||||
#endif // ISHADERUTIL_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef ISHADERUTIL_H
|
||||
#define ISHADERUTIL_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "appframework/IAppSystem.h"
|
||||
#include "shaderapi/ishaderapi.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// forward declarations
|
||||
//-----------------------------------------------------------------------------
|
||||
class ITexture;
|
||||
struct MaterialSystem_Config_t;
|
||||
struct ImageFormatInfo_t;
|
||||
enum Sampler_t;
|
||||
enum VertexTextureSampler_t;
|
||||
enum StandardTextureId_t;
|
||||
class CPrimList;
|
||||
struct ShaderColorCorrectionInfo_t;
|
||||
|
||||
#define SHADER_UTIL_INTERFACE_VERSION "VShaderUtil001"
|
||||
|
||||
enum shaderthreadevent_t
|
||||
{
|
||||
SHADER_THREAD_RELEASE_RESOURCES = 1,
|
||||
SHADER_THREAD_ACQUIRE_RESOURCES = 2,
|
||||
SHADER_THREAD_DEVICE_LOST = 3,
|
||||
SHADER_THREAD_EVICT_RESOURCES = 4,
|
||||
SHADER_THREAD_OTHER_APP_START = 5,
|
||||
SHADER_THREAD_OTHER_APP_END = 6,
|
||||
SHADER_THREAD_RESET_RENDER_STATE = 7,
|
||||
};
|
||||
|
||||
abstract_class IShaderUtil : public IAppSystem
|
||||
{
|
||||
public:
|
||||
// Method to allow clients access to the MaterialSystem_Config
|
||||
virtual MaterialSystem_Config_t& GetConfig() = 0;
|
||||
|
||||
// Allows us to convert image formats
|
||||
virtual bool ConvertImageFormat( unsigned char *src, enum ImageFormat srcImageFormat,
|
||||
unsigned char *dst, enum ImageFormat dstImageFormat,
|
||||
int width, int height, int srcStride = 0, int dstStride = 0 ) = 0;
|
||||
|
||||
// Figures out the amount of memory needed by a bitmap
|
||||
virtual int GetMemRequired( int width, int height, int depth, ImageFormat format, bool mipmap ) = 0;
|
||||
|
||||
// Gets image format info
|
||||
virtual const ImageFormatInfo_t& ImageFormatInfo( ImageFormat fmt ) const = 0;
|
||||
|
||||
// Bind standard textures
|
||||
virtual void BindStandardTexture( Sampler_t sampler, StandardTextureId_t id ) = 0;
|
||||
|
||||
// What are the lightmap dimensions?
|
||||
virtual void GetLightmapDimensions( int *w, int *h ) = 0;
|
||||
|
||||
// These methods are called when the shader must eject + restore HW memory
|
||||
virtual void ReleaseShaderObjects() = 0;
|
||||
virtual void RestoreShaderObjects( CreateInterfaceFn shaderFactory, int nChangeFlags = 0 ) = 0;
|
||||
|
||||
// Used to prevent meshes from drawing.
|
||||
virtual bool IsInStubMode() = 0;
|
||||
virtual bool InFlashlightMode() const = 0;
|
||||
|
||||
// For the shader API to shove the current version of aniso level into the
|
||||
// "definitive" place (g_config) when the shader API decides to change it.
|
||||
// Eventually, we should have a better system of who owns the definitive
|
||||
// versions of config vars.
|
||||
virtual void NoteAnisotropicLevel( int currentLevel ) = 0;
|
||||
|
||||
// NOTE: Stuff after this is added after shipping HL2.
|
||||
|
||||
// Are we rendering through the editor?
|
||||
virtual bool InEditorMode() const = 0;
|
||||
|
||||
// Gets the bound morph's vertex format; returns 0 if no morph is bound
|
||||
virtual MorphFormat_t GetBoundMorphFormat() = 0;
|
||||
|
||||
virtual ITexture *GetRenderTargetEx( int nRenderTargetID ) = 0;
|
||||
|
||||
// Tells the material system to draw a buffer clearing quad
|
||||
virtual void DrawClearBufferQuad( unsigned char r, unsigned char g, unsigned char b, unsigned char a, bool bClearColor, bool bClearAlpha, bool bClearDepth ) = 0;
|
||||
|
||||
#if defined( _X360 )
|
||||
virtual void ReadBackBuffer( Rect_t *pSrcRect, Rect_t *pDstRect, unsigned char *pData, ImageFormat dstFormat, int nDstStride ) = 0;
|
||||
#endif
|
||||
|
||||
// Calls from meshes to material system to handle queing/threading
|
||||
virtual bool OnDrawMesh( IMesh *pMesh, int firstIndex, int numIndices ) = 0;
|
||||
virtual bool OnDrawMesh( IMesh *pMesh, CPrimList *pLists, int nLists ) = 0;
|
||||
virtual bool OnSetFlexMesh( IMesh *pStaticMesh, IMesh *pMesh, int nVertexOffsetInBytes ) = 0;
|
||||
virtual bool OnSetColorMesh( IMesh *pStaticMesh, IMesh *pMesh, int nVertexOffsetInBytes ) = 0;
|
||||
virtual bool OnSetPrimitiveType( IMesh *pMesh, MaterialPrimitiveType_t type ) = 0;
|
||||
virtual bool OnFlushBufferedPrimitives() = 0;
|
||||
|
||||
|
||||
virtual void SyncMatrices() = 0;
|
||||
virtual void SyncMatrix( MaterialMatrixMode_t ) = 0;
|
||||
|
||||
virtual void BindStandardVertexTexture( VertexTextureSampler_t sampler, StandardTextureId_t id ) = 0;
|
||||
virtual void GetStandardTextureDimensions( int *pWidth, int *pHeight, StandardTextureId_t id ) = 0;
|
||||
|
||||
virtual int MaxHWMorphBatchCount() const = 0;
|
||||
|
||||
// Interface for mat system to tell shaderapi about color correction
|
||||
virtual void GetCurrentColorCorrection( ShaderColorCorrectionInfo_t* pInfo ) = 0;
|
||||
// received an event while not in owning thread, handle this outside
|
||||
virtual void OnThreadEvent( uint32 threadEvent ) = 0;
|
||||
|
||||
virtual MaterialThreadMode_t GetThreadMode( ) = 0;
|
||||
virtual bool IsRenderThreadSafe( ) = 0;
|
||||
|
||||
// Remove any materials from memory that aren't in use as determined
|
||||
// by the IMaterial's reference count.
|
||||
virtual void UncacheUnusedMaterials( bool bRecomputeStateSnapshots = false ) = 0;
|
||||
};
|
||||
|
||||
#endif // ISHADERUTIL_H
|
||||
|
||||
@@ -1,111 +1,111 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: NOTE: This file is for backward compat!
|
||||
// We'll get rid of it soon. Most of the contents of this file were moved
|
||||
// into shaderpi/ishadershadow.h, shaderapi/ishaderdynamic.h, or
|
||||
// shaderapi/shareddefs.h
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef SHADERAPI_SHAREDDEFS_H
|
||||
#define SHADERAPI_SHAREDDEFS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Important enumerations
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShaderShadeMode_t
|
||||
{
|
||||
SHADER_FLAT = 0,
|
||||
SHADER_SMOOTH
|
||||
};
|
||||
|
||||
enum ShaderTexCoordComponent_t
|
||||
{
|
||||
SHADER_TEXCOORD_S = 0,
|
||||
SHADER_TEXCOORD_T,
|
||||
SHADER_TEXCOORD_U
|
||||
};
|
||||
|
||||
enum ShaderTexFilterMode_t
|
||||
{
|
||||
SHADER_TEXFILTERMODE_NEAREST,
|
||||
SHADER_TEXFILTERMODE_LINEAR,
|
||||
SHADER_TEXFILTERMODE_NEAREST_MIPMAP_NEAREST,
|
||||
SHADER_TEXFILTERMODE_LINEAR_MIPMAP_NEAREST,
|
||||
SHADER_TEXFILTERMODE_NEAREST_MIPMAP_LINEAR,
|
||||
SHADER_TEXFILTERMODE_LINEAR_MIPMAP_LINEAR,
|
||||
SHADER_TEXFILTERMODE_ANISOTROPIC
|
||||
};
|
||||
|
||||
enum ShaderTexWrapMode_t
|
||||
{
|
||||
SHADER_TEXWRAPMODE_CLAMP,
|
||||
SHADER_TEXWRAPMODE_REPEAT,
|
||||
SHADER_TEXWRAPMODE_BORDER
|
||||
// MIRROR? - probably don't need it.
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sampler + texture stage identifiers
|
||||
// NOTE: Texture stages are used only by fixed function shading algorithms
|
||||
// Samplers are used to enable and bind textures + by programmable shading algorithms
|
||||
//-----------------------------------------------------------------------------
|
||||
enum TextureStage_t
|
||||
{
|
||||
SHADER_TEXTURE_STAGE0 = 0,
|
||||
SHADER_TEXTURE_STAGE1,
|
||||
};
|
||||
|
||||
enum Sampler_t
|
||||
{
|
||||
SHADER_SAMPLER0 = 0,
|
||||
SHADER_SAMPLER1,
|
||||
SHADER_SAMPLER2,
|
||||
SHADER_SAMPLER3,
|
||||
SHADER_SAMPLER4,
|
||||
SHADER_SAMPLER5,
|
||||
SHADER_SAMPLER6,
|
||||
SHADER_SAMPLER7,
|
||||
SHADER_SAMPLER8,
|
||||
SHADER_SAMPLER9,
|
||||
SHADER_SAMPLER10,
|
||||
SHADER_SAMPLER11,
|
||||
SHADER_SAMPLER12,
|
||||
SHADER_SAMPLER13,
|
||||
SHADER_SAMPLER14,
|
||||
SHADER_SAMPLER15,
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Vertex texture sampler identifiers
|
||||
//-----------------------------------------------------------------------------
|
||||
enum VertexTextureSampler_t
|
||||
{
|
||||
SHADER_VERTEXTEXTURE_SAMPLER0 = 0,
|
||||
SHADER_VERTEXTEXTURE_SAMPLER1,
|
||||
SHADER_VERTEXTEXTURE_SAMPLER2,
|
||||
SHADER_VERTEXTEXTURE_SAMPLER3,
|
||||
};
|
||||
|
||||
|
||||
#if defined( _X360 )
|
||||
#define REVERSE_DEPTH_ON_X360 //uncomment to use D3DFMT_D24FS8 with an inverted depth viewport for better performance. Keep this in sync with the same named #define in materialsystem/stdshaders/common_fxc.h
|
||||
#endif
|
||||
|
||||
#if defined( REVERSE_DEPTH_ON_X360 )
|
||||
#define ReverseDepthOnX360() true
|
||||
#else
|
||||
#define ReverseDepthOnX360() false
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // SHADERAPI_SHAREDDEFS_H
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: NOTE: This file is for backward compat!
|
||||
// We'll get rid of it soon. Most of the contents of this file were moved
|
||||
// into shaderpi/ishadershadow.h, shaderapi/ishaderdynamic.h, or
|
||||
// shaderapi/shareddefs.h
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef SHADERAPI_SHAREDDEFS_H
|
||||
#define SHADERAPI_SHAREDDEFS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Important enumerations
|
||||
//-----------------------------------------------------------------------------
|
||||
enum ShaderShadeMode_t
|
||||
{
|
||||
SHADER_FLAT = 0,
|
||||
SHADER_SMOOTH
|
||||
};
|
||||
|
||||
enum ShaderTexCoordComponent_t
|
||||
{
|
||||
SHADER_TEXCOORD_S = 0,
|
||||
SHADER_TEXCOORD_T,
|
||||
SHADER_TEXCOORD_U
|
||||
};
|
||||
|
||||
enum ShaderTexFilterMode_t
|
||||
{
|
||||
SHADER_TEXFILTERMODE_NEAREST,
|
||||
SHADER_TEXFILTERMODE_LINEAR,
|
||||
SHADER_TEXFILTERMODE_NEAREST_MIPMAP_NEAREST,
|
||||
SHADER_TEXFILTERMODE_LINEAR_MIPMAP_NEAREST,
|
||||
SHADER_TEXFILTERMODE_NEAREST_MIPMAP_LINEAR,
|
||||
SHADER_TEXFILTERMODE_LINEAR_MIPMAP_LINEAR,
|
||||
SHADER_TEXFILTERMODE_ANISOTROPIC
|
||||
};
|
||||
|
||||
enum ShaderTexWrapMode_t
|
||||
{
|
||||
SHADER_TEXWRAPMODE_CLAMP,
|
||||
SHADER_TEXWRAPMODE_REPEAT,
|
||||
SHADER_TEXWRAPMODE_BORDER
|
||||
// MIRROR? - probably don't need it.
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sampler + texture stage identifiers
|
||||
// NOTE: Texture stages are used only by fixed function shading algorithms
|
||||
// Samplers are used to enable and bind textures + by programmable shading algorithms
|
||||
//-----------------------------------------------------------------------------
|
||||
enum TextureStage_t
|
||||
{
|
||||
SHADER_TEXTURE_STAGE0 = 0,
|
||||
SHADER_TEXTURE_STAGE1,
|
||||
};
|
||||
|
||||
enum Sampler_t
|
||||
{
|
||||
SHADER_SAMPLER0 = 0,
|
||||
SHADER_SAMPLER1,
|
||||
SHADER_SAMPLER2,
|
||||
SHADER_SAMPLER3,
|
||||
SHADER_SAMPLER4,
|
||||
SHADER_SAMPLER5,
|
||||
SHADER_SAMPLER6,
|
||||
SHADER_SAMPLER7,
|
||||
SHADER_SAMPLER8,
|
||||
SHADER_SAMPLER9,
|
||||
SHADER_SAMPLER10,
|
||||
SHADER_SAMPLER11,
|
||||
SHADER_SAMPLER12,
|
||||
SHADER_SAMPLER13,
|
||||
SHADER_SAMPLER14,
|
||||
SHADER_SAMPLER15,
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Vertex texture sampler identifiers
|
||||
//-----------------------------------------------------------------------------
|
||||
enum VertexTextureSampler_t
|
||||
{
|
||||
SHADER_VERTEXTEXTURE_SAMPLER0 = 0,
|
||||
SHADER_VERTEXTEXTURE_SAMPLER1,
|
||||
SHADER_VERTEXTEXTURE_SAMPLER2,
|
||||
SHADER_VERTEXTEXTURE_SAMPLER3,
|
||||
};
|
||||
|
||||
|
||||
#if defined( _X360 )
|
||||
#define REVERSE_DEPTH_ON_X360 //uncomment to use D3DFMT_D24FS8 with an inverted depth viewport for better performance. Keep this in sync with the same named #define in materialsystem/stdshaders/common_fxc.h
|
||||
#endif
|
||||
|
||||
#if defined( REVERSE_DEPTH_ON_X360 )
|
||||
#define ReverseDepthOnX360() true
|
||||
#else
|
||||
#define ReverseDepthOnX360() false
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // SHADERAPI_SHAREDDEFS_H
|
||||
|
||||
Reference in New Issue
Block a user