Removed unneeded parser related code from the opengl pixel program implementation

This commit is contained in:
kaetemi 2013-06-19 02:33:19 +02:00
parent daccf30f15
commit e905a85436
4 changed files with 78 additions and 128 deletions

View file

@ -65,8 +65,16 @@ public:
/// Destructor /// Destructor
virtual ~CPixelProgram (); virtual ~CPixelProgram ();
/// Get the program
inline const std::string& getProgram() const { return _Program; };
/// The driver informations. For the driver implementation only. /// The driver informations. For the driver implementation only.
NLMISC::CRefPtr<IPixelProgramDrvInfos> _DrvInfo; NLMISC::CRefPtr<IPixelProgramDrvInfos> _DrvInfo;
protected:
/// The progam
std::string _Program;
}; };

View file

@ -1344,7 +1344,7 @@ private:
/// \name Pixel program implementation /// \name Pixel program implementation
// @{ // @{
bool activeARBPixelProgram (CPixelProgram *program); bool activeARBPixelProgram (CPixelProgram *program);
// TODO_REMOVE_PARSER bool setupARBPixelProgram (const CPixelProgramParser::CPProgram &parsedProgram, GLuint id/*, bool &specularWritten*/); bool setupARBPixelProgram (const CPixelProgram *program, GLuint id/*, bool &specularWritten*/);
//@} //@}

View file

@ -90,45 +90,21 @@ bool CDriverGL::activeARBPixelProgram(CPixelProgram *program)
// Program setuped ? // Program setuped ?
if (program->_DrvInfo==NULL) if (program->_DrvInfo==NULL)
{ {
/* TODO_REMOVE_PARSER
// Insert into driver list. (so it is deleted when driver is deleted). // Insert into driver list. (so it is deleted when driver is deleted).
ItPixelPrgDrvInfoPtrList it= _PixelPrgDrvInfos.insert(_PixelPrgDrvInfos.end()); ItPixelPrgDrvInfoPtrList it= _PixelPrgDrvInfos.insert(_PixelPrgDrvInfos.end(), (NL3D::IPixelProgramDrvInfos*)NULL);
// Create a driver info // Create a driver info
*it = drvInfo = new CPixelProgamDrvInfosGL (this, it); *it = drvInfo = new CPixelProgamDrvInfosGL (this, it);
// Set the pointer // Set the pointer
program->_DrvInfo=drvInfo; program->_DrvInfo=drvInfo;
std::string asmProgram; if(!setupARBPixelProgram(program, drvInfo->ID))
CPixelProgramParser::CPProgram parsedProgram;
if(program->isEffectProgram())
{
asmProgram = program->getProgram();
CPPParserD3D parser;
// try to parse the program
std::string errorOutput;
bool result = parser.parse(asmProgram.c_str(), parsedProgram, errorOutput);
if (!result)
{
nlwarning("Unable to parse a pixel program.");
#ifdef NL_DEBUG
nlerror(errorOutput.c_str());
#endif
return false;
}
}
if(!setupARBPixelProgram(parsedProgram, drvInfo->ID))
{ {
delete drvInfo; delete drvInfo;
program->_DrvInfo = NULL; program->_DrvInfo = NULL;
_PixelPrgDrvInfos.erase(it); _PixelPrgDrvInfos.erase(it);
return false; return false;
} }
*/
} }
else else
{ {
@ -152,19 +128,14 @@ bool CDriverGL::activeARBPixelProgram(CPixelProgram *program)
return true; return true;
} }
// TODO_REMOVE_PARSER
#if 0
// *************************************************************************** // ***************************************************************************
bool CDriverGL::setupARBPixelProgram (const CPixelProgramParser::CPProgram &inParsedProgram, GLuint id/*, bool &specularWritten*/) bool CDriverGL::setupARBPixelProgram (const CPixelProgram *program, GLuint id/*, bool &specularWritten*/)
{ {
H_AUTO_OGL(CDriverGL_setupARBPixelProgram) H_AUTO_OGL(CDriverGL_setupARBPixelProgram)
// convert from proprietary format to ARB_pixel_program code const std::string &code = program->getProgram();
CPixelProgramConversionARB vpConvertARB;
std::string code;
if(!vpConvertARB.convert(inParsedProgram, code)) return false;
//
nglBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, id); nglBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, id);
glGetError(); glGetError();
nglProgramStringARB( GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, code.size(), code.c_str() ); nglProgramStringARB( GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, code.size(), code.c_str() );
@ -175,10 +146,10 @@ bool CDriverGL::setupARBPixelProgram (const CPixelProgramParser::CPProgram &inPa
{ {
GLint position; GLint position;
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &position); glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &position);
nlassert(position != -1) // there was an error.. nlassert(position != -1); // there was an error..
nlassert(position < (GLint) code.size()); nlassert(position < (GLint) code.size());
uint line = 0; uint line = 0;
const char *lineStart = code.c_str(); const char *lineStart = program->getProgram().c_str();
for(uint k = 0; k < (uint) position; ++k) for(uint k = 0; k < (uint) position; ++k)
{ {
if (code[k] == '\n') if (code[k] == '\n')
@ -209,7 +180,6 @@ bool CDriverGL::setupARBPixelProgram (const CPixelProgramParser::CPProgram &inPa
} }
return true; return true;
} }
#endif
// *************************************************************************** // ***************************************************************************
@ -217,12 +187,8 @@ void CDriverGL::setPixelProgramConstant (uint index, float f0, float f1, float f
{ {
H_AUTO_OGL(CDriverGL_setPixelProgramConstant) H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
//if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, index, f0, f1, f2, f3); nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, index, f0, f1, f2, f3);
}
} }
@ -232,12 +198,8 @@ void CDriverGL::setPixelProgramConstant (uint index, double d0, double d1, doubl
{ {
H_AUTO_OGL(CDriverGL_setPixelProgramConstant) H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
// if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
nglProgramEnvParameter4dARB(GL_FRAGMENT_PROGRAM_ARB, index, d0, d1, d2, d3); nglProgramEnvParameter4dARB(GL_FRAGMENT_PROGRAM_ARB, index, d0, d1, d2, d3);
}
} }
@ -247,12 +209,8 @@ void CDriverGL::setPixelProgramConstant (uint index, const NLMISC::CVector& valu
{ {
H_AUTO_OGL(CDriverGL_setPixelProgramConstant) H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
// if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, index, value.x, value.y, value.z, 0); nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, index, value.x, value.y, value.z, 0);
}
} }
@ -262,12 +220,8 @@ void CDriverGL::setPixelProgramConstant (uint index, const NLMISC::CVectorD& val
{ {
H_AUTO_OGL(CDriverGL_setPixelProgramConstant) H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
// if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
nglProgramEnvParameter4dARB(GL_FRAGMENT_PROGRAM_ARB, index, value.x, value.y, value.z, 0); nglProgramEnvParameter4dARB(GL_FRAGMENT_PROGRAM_ARB, index, value.x, value.y, value.z, 0);
}
} }
@ -276,9 +230,6 @@ void CDriverGL::setPixelProgramConstant (uint index, uint num, const float *src)
{ {
H_AUTO_OGL(CDriverGL_setPixelProgramConstant) H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
// if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
{ {
for(uint k = 0; k < num; ++k) for(uint k = 0; k < num; ++k)
@ -286,7 +237,6 @@ void CDriverGL::setPixelProgramConstant (uint index, uint num, const float *src)
nglProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, index + k, src + 4 * k); nglProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, index + k, src + 4 * k);
} }
} }
}
} }
// *************************************************************************** // ***************************************************************************
@ -294,9 +244,6 @@ void CDriverGL::setPixelProgramConstant (uint index, uint num, const double *src
{ {
H_AUTO_OGL(CDriverGL_setPixelProgramConstant) H_AUTO_OGL(CDriverGL_setPixelProgramConstant)
// if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
{ {
for(uint k = 0; k < num; ++k) for(uint k = 0; k < num; ++k)
@ -304,7 +251,6 @@ void CDriverGL::setPixelProgramConstant (uint index, uint num, const double *src
nglProgramEnvParameter4dvARB(GL_FRAGMENT_PROGRAM_ARB, index + k, src + 4 * k); nglProgramEnvParameter4dvARB(GL_FRAGMENT_PROGRAM_ARB, index + k, src + 4 * k);
} }
} }
}
} }
// *************************************************************************** // ***************************************************************************
@ -313,9 +259,6 @@ void CDriverGL::setPixelProgramConstantMatrix (uint index, IDriver::TMatrix matr
{ {
H_AUTO_OGL(CDriverGL_setPixelProgramConstantMatrix) H_AUTO_OGL(CDriverGL_setPixelProgramConstantMatrix)
// if(_LastSetuppedVP && _LastSetuppedVP->isEffectProgram())
if (_LastSetuppedPP) // TODO_REMOVE_EFFECTS
{
if (_Extensions.ARBFragmentProgram) if (_Extensions.ARBFragmentProgram)
{ {
@ -366,7 +309,6 @@ void CDriverGL::setPixelProgramConstantMatrix (uint index, IDriver::TMatrix matr
nglProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, index + 2, matDatas + 8); nglProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, index + 2, matDatas + 8);
nglProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, index + 3, matDatas + 12); nglProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, index + 3, matDatas + 12);
} }
}
} }
// TODO_REMOVE_PARSER // TODO_REMOVE_PARSER

View file

@ -48,7 +48,7 @@ IPixelProgramDrvInfos::~IPixelProgramDrvInfos ()
// *************************************************************************** // ***************************************************************************
CPixelProgram::CPixelProgram(const char* program) CPixelProgram::CPixelProgram(const char* program) : _Program(program)
{ {
} }