2013-09-07 16:33:18 +00:00
/**
* \ file gpu_program . cpp
2013-09-07 18:41:07 +00:00
* \ brief IGPUProgram
2013-09-07 16:33:18 +00:00
* \ date 2013 - 09 - 07 15 : 00 GMT
* \ author Jan Boon ( Kaetemi )
2013-09-07 18:41:07 +00:00
* IGPUProgram
2013-09-07 16:33:18 +00:00
*/
/*
* Copyright ( C ) 2013 by authors
*
* This file is part of NL3D .
* NL3D is free software : you can redistribute it and / or modify it
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation , either version 3 of the
* License , or ( at your option ) any later version .
*
* NL3D is distributed in the hope that it will be useful , but WITHOUT
* ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE . See the GNU Affero General
* Public License for more details .
*
* You should have received a copy of the GNU Affero General Public
* License along with NL3D . If not , see
* < http : //www.gnu.org/licenses/>.
*/
# include <nel/misc/types_nl.h>
# include <nel/3d/gpu_program.h>
// STL includes
// NeL includes
// #include <nel/misc/debug.h>
# include <nel/misc/string_mapper.h>
// Project includes
2013-09-07 18:41:07 +00:00
# include <nel/3d/driver.h>
2013-09-07 16:33:18 +00:00
using namespace std ;
// using namespace NLMISC;
namespace NL3D {
2013-09-07 18:41:07 +00:00
// ***************************************************************************
IGPUProgramDrvInfos : : IGPUProgramDrvInfos ( IDriver * drv , ItGPUPrgDrvInfoPtrList it )
2013-09-07 16:33:18 +00:00
{
2013-09-07 18:41:07 +00:00
_Driver = drv ;
_DriverIterator = it ;
2013-09-07 16:33:18 +00:00
}
2013-09-07 18:41:07 +00:00
// ***************************************************************************
IGPUProgramDrvInfos : : ~ IGPUProgramDrvInfos ( )
2013-09-07 16:33:18 +00:00
{
2013-09-07 18:41:07 +00:00
_Driver - > removeGPUPrgDrvInfoPtr ( _DriverIterator ) ;
2013-09-07 16:33:18 +00:00
}
2013-09-07 18:41:07 +00:00
// ***************************************************************************
IGPUProgram : : IGPUProgram ( )
2013-09-07 16:33:18 +00:00
{
2013-09-07 18:41:07 +00:00
2013-09-07 16:33:18 +00:00
}
2013-09-07 18:41:07 +00:00
// ***************************************************************************
2013-09-09 16:33:38 +00:00
IGPUProgram : : ~ IGPUProgram ( )
2013-09-07 16:33:18 +00:00
{
2013-09-09 16:33:38 +00:00
// Must kill the drv mirror of this program.
m_DrvInfo . kill ( ) ;
2013-09-07 16:33:18 +00:00
}
2013-09-09 16:33:38 +00:00
void IGPUProgram : : buildInfo ( CSource * source )
2013-09-07 16:33:18 +00:00
{
2013-09-09 16:33:38 +00:00
nlassert ( ! m_Source ) ;
m_Source = source ;
// Fill index cache
CGPUProgramFeatures & features = m_Source - > Features ;
TProfile profile = m_Source - > Profile ; // for special cases
if ( features . DriverFlags & CGPUProgramFeatures : : ModelView )
{
2013-09-09 22:31:26 +00:00
m_Indices . ModelView = getUniformIndex ( " modelView " ) ;
2013-09-09 16:33:38 +00:00
if ( m_Indices . ModelView = = ~ 0 )
{
2013-09-09 22:31:26 +00:00
nlwarning ( " Missing 'modelView' in gpu program '%s', ModelView disabled " , source - > DisplayName . c_str ( ) ) ;
2013-09-09 16:33:38 +00:00
features . DriverFlags & = ~ CGPUProgramFeatures : : ModelView ;
}
}
if ( features . DriverFlags & CGPUProgramFeatures : : ModelViewInverse )
{
2013-09-09 22:31:26 +00:00
m_Indices . ModelViewInverse = getUniformIndex ( " modelViewInverse " ) ;
2013-09-09 16:33:38 +00:00
if ( m_Indices . ModelViewInverse = = ~ 0 )
{
2013-09-09 22:31:26 +00:00
nlwarning ( " Missing 'modelViewInverse' in gpu program '%s', ModelViewInverse disabled " , source - > DisplayName . c_str ( ) ) ;
2013-09-09 16:33:38 +00:00
features . DriverFlags & = ~ CGPUProgramFeatures : : ModelViewInverse ;
}
}
if ( features . DriverFlags & CGPUProgramFeatures : : ModelViewTranspose )
{
2013-09-09 22:31:26 +00:00
m_Indices . ModelViewTranspose = getUniformIndex ( " modelViewTranspose " ) ;
2013-09-09 16:33:38 +00:00
if ( m_Indices . ModelViewTranspose = = ~ 0 )
{
2013-09-09 22:31:26 +00:00
nlwarning ( " Missing 'modelViewTranspose' in gpu program '%s', ModelViewTranspose disabled " , source - > DisplayName . c_str ( ) ) ;
2013-09-09 16:33:38 +00:00
features . DriverFlags & = ~ CGPUProgramFeatures : : ModelViewTranspose ;
}
}
if ( features . DriverFlags & CGPUProgramFeatures : : ModelViewInverseTranspose )
{
2013-09-09 22:31:26 +00:00
m_Indices . ModelViewInverseTranspose = getUniformIndex ( " modelViewInverseTranspose " ) ;
2013-09-09 16:33:38 +00:00
if ( m_Indices . ModelViewInverseTranspose = = ~ 0 )
{
2013-09-09 22:31:26 +00:00
nlwarning ( " Missing 'modelViewInverseTranspose' in gpu program '%s', ModelViewInverseTranspose disabled " , source - > DisplayName . c_str ( ) ) ;
2013-09-09 16:33:38 +00:00
features . DriverFlags & = ~ CGPUProgramFeatures : : ModelViewInverseTranspose ;
}
}
if ( features . DriverFlags & CGPUProgramFeatures : : Projection )
{
2013-09-09 22:31:26 +00:00
m_Indices . Projection = getUniformIndex ( " projection " ) ;
2013-09-09 16:33:38 +00:00
if ( m_Indices . Projection = = ~ 0 )
{
2013-09-09 22:31:26 +00:00
nlwarning ( " Missing 'projection' in gpu program '%s', Projection disabled " , source - > DisplayName . c_str ( ) ) ;
2013-09-09 16:33:38 +00:00
features . DriverFlags & = ~ CGPUProgramFeatures : : Projection ;
}
}
if ( features . DriverFlags & CGPUProgramFeatures : : ProjectionInverse )
{
2013-09-09 22:31:26 +00:00
m_Indices . ProjectionInverse = getUniformIndex ( " projectionInverse " ) ;
2013-09-09 16:33:38 +00:00
if ( m_Indices . ProjectionInverse = = ~ 0 )
{
2013-09-09 22:31:26 +00:00
nlwarning ( " Missing 'projectionInverse' in gpu program '%s', ProjectionInverse disabled " , source - > DisplayName . c_str ( ) ) ;
2013-09-09 16:33:38 +00:00
features . DriverFlags & = ~ CGPUProgramFeatures : : ProjectionInverse ;
}
}
if ( features . DriverFlags & CGPUProgramFeatures : : ProjectionTranspose )
{
2013-09-09 22:31:26 +00:00
m_Indices . ProjectionTranspose = getUniformIndex ( " projectionTranspose " ) ;
2013-09-09 16:33:38 +00:00
if ( m_Indices . ProjectionTranspose = = ~ 0 )
{
2013-09-09 22:31:26 +00:00
nlwarning ( " Missing 'projectionTranspose' in gpu program '%s', ProjectionTranspose disabled " , source - > DisplayName . c_str ( ) ) ;
2013-09-09 16:33:38 +00:00
features . DriverFlags & = ~ CGPUProgramFeatures : : ProjectionTranspose ;
}
}
if ( features . DriverFlags & CGPUProgramFeatures : : ProjectionInverseTranspose )
{
2013-09-09 22:31:26 +00:00
m_Indices . ProjectionInverseTranspose = getUniformIndex ( " projectionInverseTranspose " ) ;
2013-09-09 16:33:38 +00:00
if ( m_Indices . ProjectionInverseTranspose = = ~ 0 )
{
2013-09-09 22:31:26 +00:00
nlwarning ( " Missing 'projectionInverseTranspose' in gpu program '%s', ProjectionInverseTranspose disabled " , source - > DisplayName . c_str ( ) ) ;
2013-09-09 16:33:38 +00:00
features . DriverFlags & = ~ CGPUProgramFeatures : : ProjectionInverseTranspose ;
}
}
if ( features . DriverFlags & CGPUProgramFeatures : : ModelViewProjection )
{
2013-09-09 22:31:26 +00:00
m_Indices . ModelViewProjection = getUniformIndex ( " modelViewProjection " ) ;
2013-09-09 16:33:38 +00:00
if ( m_Indices . ModelViewProjection = = ~ 0 )
{
2013-09-09 22:31:26 +00:00
nlwarning ( " Missing 'modelViewProjection' in gpu program '%s', ModelViewProjection disabled " , source - > DisplayName . c_str ( ) ) ;
2013-09-09 16:33:38 +00:00
features . DriverFlags & = ~ CGPUProgramFeatures : : ModelViewProjection ;
}
}
if ( features . DriverFlags & CGPUProgramFeatures : : ModelViewProjectionInverse )
{
2013-09-09 22:31:26 +00:00
m_Indices . ModelViewProjectionInverse = getUniformIndex ( " modelViewProjectionInverse " ) ;
2013-09-09 16:33:38 +00:00
if ( m_Indices . ModelViewProjectionInverse = = ~ 0 )
{
2013-09-09 22:31:26 +00:00
nlwarning ( " Missing 'modelViewProjectionInverse' in gpu program '%s', ModelViewProjectionInverse disabled " , source - > DisplayName . c_str ( ) ) ;
2013-09-09 16:33:38 +00:00
features . DriverFlags & = ~ CGPUProgramFeatures : : ModelViewProjectionInverse ;
}
}
if ( features . DriverFlags & CGPUProgramFeatures : : ModelViewProjectionTranspose )
{
2013-09-09 22:31:26 +00:00
m_Indices . ModelViewProjectionTranspose = getUniformIndex ( " modelViewProjectionTranspose " ) ;
2013-09-09 16:33:38 +00:00
if ( m_Indices . ModelViewProjectionTranspose = = ~ 0 )
{
2013-09-09 22:31:26 +00:00
nlwarning ( " Missing 'modelViewProjectionTranspose' in gpu program '%s', ModelViewProjectionTranspose disabled " , source - > DisplayName . c_str ( ) ) ;
2013-09-09 16:33:38 +00:00
features . DriverFlags & = ~ CGPUProgramFeatures : : ModelViewProjectionTranspose ;
}
}
if ( features . DriverFlags & CGPUProgramFeatures : : ModelViewProjectionInverseTranspose )
{
2013-09-09 22:31:26 +00:00
m_Indices . ModelViewProjectionInverseTranspose = getUniformIndex ( " modelViewProjectionInverseTranspose " ) ;
2013-09-09 16:33:38 +00:00
if ( m_Indices . ModelViewProjectionInverseTranspose = = ~ 0 )
{
2013-09-09 22:31:26 +00:00
nlwarning ( " Missing 'modelViewProjectionInverseTranspose' in gpu program '%s', ModelViewProjectionInverseTranspose disabled " , source - > DisplayName . c_str ( ) ) ;
2013-09-09 16:33:38 +00:00
features . DriverFlags & = ~ CGPUProgramFeatures : : ModelViewProjectionInverseTranspose ;
}
}
2013-09-09 22:31:26 +00:00
if ( features . DriverFlags & CGPUProgramFeatures : : Fog )
{
m_Indices . Fog = getUniformIndex ( " fog " ) ;
if ( m_Indices . Fog = = ~ 0 )
{
nlwarning ( " Missing 'fog' in gpu program '%s', Fog disabled " , source - > DisplayName . c_str ( ) ) ;
features . DriverFlags & = ~ CGPUProgramFeatures : : Fog ;
}
}
2013-09-09 16:33:38 +00:00
//
// Rough example, modify as necessary.
//
/*if (features.DriverFlags & CGPUProgramFeatures::DriverAmbient || features.MaterialFlags & CGPUProgramFeatures::MaterialAmbient)
{
m_Indices . Ambient = getUniformIndex ( " nlAmbient " ) ;
if ( m_Indices . Ambient = = ~ 0 )
{
nlwarning ( " Missing 'nlAmbient' in gpu program '%s', Ambient disabled " , source - > DisplayName . c_str ( ) ) ;
features . DriverFlags & = ~ CGPUProgramFeatures : : DriverAmbient ;
features . MaterialFlags & = ~ CGPUProgramFeatures : : MaterialAmbient ;
}
} */
2013-09-09 18:49:59 +00:00
buildInfo ( ) ;
}
void IGPUProgram : : buildInfo ( )
{
2013-09-07 16:33:18 +00:00
}
} /* namespace NL3D */
/* end of file */