"L. Spiro Engine"

F:/My Projects/LSEngine/Modules/LSGraphicsLib/Src/DirectXShaders/LSGDirectX9CompiledShader.h

00001 
00018 #ifndef __LSG_DIRECTX9COMPILEDSHADER_H__
00019 #define __LSG_DIRECTX9COMPILEDSHADER_H__
00020 
00021 #include "../LSGGraphicsLib.h"
00022 #include "../DirectX/LSGDirectX9LosableResource.h"
00023 #include "../ShaderLanguage/LSGCompiledShaderBase.h"
00024 #include "../ShaderLanguage/LSGShaderBase.h"
00025 
00026 #ifdef LSG_DX9
00027 
00028 namespace lsg {
00029 
00039         class CDirectX9CompiledShader : public CCompiledShaderBase, public CDirectX9LosableResource {
00040         public :
00041                 // == Various constructors.
00042                 LSE_CALLCTOR                                                                            CDirectX9CompiledShader();
00043                 LSE_CALLCTOR                                                                            ~CDirectX9CompiledShader();
00044 
00045 
00046                 // == Functions.
00050                 virtual LSVOID LSE_CALL                                                         Reset();
00051 
00058                 LSBOOL LSE_CALL                                                                         SetUniforms( const CShaderTranslationProcessorBase::LSG_UNIFORM_LIST &_ulUniforms );
00059 
00066                 CShaderBase::LSG_HANDLE LSE_CALL                                        GetConstantByName( const LSCHAR * _pcName );
00067 
00075                 LSBOOL LSE_CALL                                                                         SetFloat( CShaderBase::LSG_HANDLE _hHandle, LSFLOAT _fValue );
00076 
00085                 LSBOOL LSE_CALL                                                                         SetFloatArray( CShaderBase::LSG_HANDLE _hHandle, const LSFLOAT * _pfValues, LSUINT32 _ui32Total );
00086 
00094                 LSBOOL LSE_CALL                                                                         SetInt( CShaderBase::LSG_HANDLE _hHandle, LSINT32 _iValue );
00095 
00104                 LSBOOL LSE_CALL                                                                         SetIntArray( CShaderBase::LSG_HANDLE _hHandle, const LSINT32 * _piValues, LSUINT32 _ui32Total );
00105 
00113                 LSBOOL LSE_CALL                                                                         SetBool( CShaderBase::LSG_HANDLE _hHandle, LSBOOL _bValue );
00114 
00123                 LSBOOL LSE_CALL                                                                         SetBoolArray( CShaderBase::LSG_HANDLE _hHandle, const LSBOOL * _pbValues, LSUINT32 _ui32Total );
00124 
00132                 LSBOOL LSE_CALL                                                                         SetVector2( CShaderBase::LSG_HANDLE _hHandle, const CVector2 &_vValue );
00133 
00142                 LSBOOL LSE_CALL                                                                         SetVector2Array( CShaderBase::LSG_HANDLE _hHandle, const CVector2 * _pvValues, LSUINT32 _ui32Total );
00143 
00151                 LSBOOL LSE_CALL                                                                         SetVector3( CShaderBase::LSG_HANDLE _hHandle, const CVector3 &_vValue );
00152 
00161                 LSBOOL LSE_CALL                                                                         SetVector3Array( CShaderBase::LSG_HANDLE _hHandle, const CVector3 * _pvValues, LSUINT32 _ui32Total );
00162 
00170                 LSBOOL LSE_CALL                                                                         SetVector4( CShaderBase::LSG_HANDLE _hHandle, const CVector4 &_vValue );
00171 
00180                 LSBOOL LSE_CALL                                                                         SetVector4Array( CShaderBase::LSG_HANDLE _hHandle, const CVector4 * _pvValues, LSUINT32 _ui32Total );
00181 
00189                 LSBOOL LSE_CALL                                                                         SetMatrix2x2( CShaderBase::LSG_HANDLE _hHandle, const CMatrix2x2 &_mValue );
00190 
00198                 LSBOOL LSE_CALL                                                                         SetMatrix3x3( CShaderBase::LSG_HANDLE _hHandle, const CMatrix3x3 &_mValue );
00199 
00207                 LSBOOL LSE_CALL                                                                         SetMatrix4x4( CShaderBase::LSG_HANDLE _hHandle, const CMatrix4x4 &_mValue );
00208 
00217                 LSBOOL LSE_CALL                                                                         SetMatrix4x4Array( CShaderBase::LSG_HANDLE _hHandle, const CMatrix4x4 * _pmValues, LSUINT32 _ui32Total );
00218 
00219 
00220         protected :
00221                 // == Types.
00225                 typedef struct LSG_CONSTANT_MAP {
00229                         D3DXHANDLE                                                                              hDirectXHandle;
00230 
00234                         LSUINT32                                                                                ui32Name;
00235 
00239                         LSUINT32                                                                                ui32DataPtr;
00240 
00245                         LSBOOL                                                                                  bDirty;
00246                 } * LPLSG_CONSTANT_MAP, * const LPCLSG_CONSTANT_MAP;
00247 
00248 
00249                 // == Members.
00253                 ID3DXBuffer *                                                                           m_pbShader;
00254 
00258                 ID3DXConstantTable *                                                            m_pctConstantTable;
00259 
00263                 CShaderTranslationProcessorBase::LSG_UNIFORM_LIST       m_ulUniforms;
00264 
00268                 LSUINT32                                                                                        m_ui32NextUniformStart;
00269 
00273                 CVectorPoD<LSUINT8, LSUINT32>                                           m_vUniformBuffer;
00274 
00278                 CVectorPoD<LSG_CONSTANT_MAP>                                            m_vConstantMap;
00279 
00283                 CVectorPoD<LSUINT8, LSUINT32>                                           m_vTempBuffer;
00284 
00285 
00286                 // == Functions.
00292                 template <typename tnType>
00293                 static LSVOID LSE_CALL                                                          SafeRelease( tnType &_tObj );
00294 
00295 
00296         private :
00297                 typedef CCompiledShaderBase                                                     Parent;
00298         };
00299 
00300 
00301         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00302         // DEFINITIONS
00303         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00304         // == Functions.
00310         template <typename tnType>
00311         LSE_INLINE LSVOID LSE_CALL CDirectX9CompiledShader::SafeRelease( tnType &_tObj ) {
00312                 if ( _tObj ) {
00313                         _tObj->Release();
00314                         _tObj = NULL;
00315                 }
00316         }
00317 
00318 }       // namespace lsg
00319 
00320 #endif  // #ifdef LSG_DX9
00321 
00322 #endif  // __LSG_DIRECTX9COMPILEDSHADER_H__
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator