Update supportVertexProgram calls
This commit is contained in:
parent
7967709e0e
commit
4adbfd4e4e
11 changed files with 72 additions and 27 deletions
|
@ -1103,7 +1103,7 @@ public:
|
||||||
|
|
||||||
/** Return true if the driver supports the specified vertex program profile.
|
/** Return true if the driver supports the specified vertex program profile.
|
||||||
*/
|
*/
|
||||||
virtual bool supportVertexProgram(CVertexProgram::TProfile profile = CVertexProgram::nelvp) const = 0;
|
virtual bool supportVertexProgram(CVertexProgram::TProfile profile) const = 0;
|
||||||
|
|
||||||
/** Compile the given vertex program, return if successful.
|
/** Compile the given vertex program, return if successful.
|
||||||
* If a vertex program was set active before compilation,
|
* If a vertex program was set active before compilation,
|
||||||
|
|
|
@ -106,6 +106,7 @@ public:
|
||||||
// @}
|
// @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static void initVertexPrograms();
|
||||||
void setupLighting(CScene *scene, CMeshBaseInstance *mbi, const NLMISC::CMatrix &invertedModelMat);
|
void setupLighting(CScene *scene, CMeshBaseInstance *mbi, const NLMISC::CMatrix &invertedModelMat);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -3003,7 +3003,7 @@ bool CDriverD3D::stretchRect(ITexture * srcText, NLMISC::CRect &srcRect, ITextur
|
||||||
|
|
||||||
bool CDriverD3D::supportBloomEffect() const
|
bool CDriverD3D::supportBloomEffect() const
|
||||||
{
|
{
|
||||||
return supportVertexProgram();
|
return supportVertexProgram(CVertexProgram::nelvp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
|
@ -1112,7 +1112,7 @@ public:
|
||||||
|
|
||||||
/** Return true if the driver supports the specified vertex program profile.
|
/** Return true if the driver supports the specified vertex program profile.
|
||||||
*/
|
*/
|
||||||
virtual bool supportVertexProgram(CVertexProgram::TProfile profile = CVertexProgram::nelvp) const;
|
virtual bool supportVertexProgram(CVertexProgram::TProfile profile) const;
|
||||||
|
|
||||||
/** Compile the given vertex program, return if successful.
|
/** Compile the given vertex program, return if successful.
|
||||||
* If a vertex program was set active before compilation,
|
* If a vertex program was set active before compilation,
|
||||||
|
|
|
@ -689,7 +689,7 @@ bool CDriverGL::stretchRect(ITexture * /* srcText */, NLMISC::CRect &/* srcRect
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
bool CDriverGL::supportBloomEffect() const
|
bool CDriverGL::supportBloomEffect() const
|
||||||
{
|
{
|
||||||
return (supportVertexProgram() && supportFrameBufferObject() && supportPackedDepthStencil() && supportTextureRectangle());
|
return (supportVertexProgram(CVertexProgram::nelvp) && supportFrameBufferObject() && supportPackedDepthStencil() && supportTextureRectangle());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
|
@ -1318,7 +1318,7 @@ private:
|
||||||
|
|
||||||
/** Return true if the driver supports the specified vertex program profile.
|
/** Return true if the driver supports the specified vertex program profile.
|
||||||
*/
|
*/
|
||||||
virtual bool supportVertexProgram(CVertexProgram::TProfile profile = CVertexProgram::nelvp) const;
|
virtual bool supportVertexProgram(CVertexProgram::TProfile profile) const;
|
||||||
|
|
||||||
/** Compile the given vertex program, return if successful.
|
/** Compile the given vertex program, return if successful.
|
||||||
* If a vertex program was set active before compilation,
|
* If a vertex program was set active before compilation,
|
||||||
|
|
|
@ -568,18 +568,21 @@ void CLandscape::clear()
|
||||||
void CLandscape::setDriver(IDriver *drv)
|
void CLandscape::setDriver(IDriver *drv)
|
||||||
{
|
{
|
||||||
nlassert(drv);
|
nlassert(drv);
|
||||||
if(_Driver != drv)
|
if (_Driver != drv)
|
||||||
{
|
{
|
||||||
_Driver= drv;
|
_Driver= drv;
|
||||||
|
|
||||||
// Does the driver support VertexShader???
|
// Does the driver support VertexShader???
|
||||||
// only if VP supported by GPU.
|
// only if VP supported by GPU.
|
||||||
_VertexShaderOk= (_Driver->supportVertexProgram() && !_Driver->isVertexProgramEmulated());
|
_VertexShaderOk = (!_Driver->isVertexProgramEmulated() && (
|
||||||
|
_Driver->supportVertexProgram(CVertexProgram::nelvp)
|
||||||
|
// || _Driver->supportVertexProgram(CVertexProgram::glsl330v) // TODO_VP_GLSL
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
// Does the driver has sufficient requirements for Vegetable???
|
// Does the driver has sufficient requirements for Vegetable???
|
||||||
// only if VP supported by GPU, and Only if max vertices allowed.
|
// only if VP supported by GPU, and Only if max vertices allowed.
|
||||||
_DriverOkForVegetable= _VertexShaderOk && (_Driver->getMaxVerticesByVertexBufferHard()>=(uint)NL3D_LANDSCAPE_VEGETABLE_MAX_AGP_VERTEX_MAX);
|
_DriverOkForVegetable = _VertexShaderOk && (_Driver->getMaxVerticesByVertexBufferHard()>=(uint)NL3D_LANDSCAPE_VEGETABLE_MAX_AGP_VERTEX_MAX);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,10 @@ void CLandscapeVBAllocator::updateDriver(IDriver *driver)
|
||||||
deleteVertexProgram();
|
deleteVertexProgram();
|
||||||
// Then rebuild VB format, and VertexProgram, if needed.
|
// Then rebuild VB format, and VertexProgram, if needed.
|
||||||
// Do it only if VP supported by GPU.
|
// Do it only if VP supported by GPU.
|
||||||
setupVBFormatAndVertexProgram(_Driver->supportVertexProgram() && !_Driver->isVertexProgramEmulated());
|
setupVBFormatAndVertexProgram(!_Driver->isVertexProgramEmulated() && (
|
||||||
|
_Driver->supportVertexProgram(CVertexProgram::nelvp)
|
||||||
|
// || _Driver->supportVertexProgram(CVertexProgram::glsl330v) // TODO_VP_GLSL
|
||||||
|
));
|
||||||
|
|
||||||
// must reallocate the VertexBuffer.
|
// must reallocate the VertexBuffer.
|
||||||
if( _NumVerticesAllocated>0 )
|
if( _NumVerticesAllocated>0 )
|
||||||
|
@ -568,7 +571,8 @@ void CLandscapeVBAllocator::setupVBFormatAndVertexProgram(bool withVertexProgr
|
||||||
_VB.initEx();
|
_VB.initEx();
|
||||||
|
|
||||||
// Init the Vertex Program.
|
// Init the Vertex Program.
|
||||||
_VertexProgram[0]= new CVertexProgramLandscape(Far0);
|
_VertexProgram[0] = new CVertexProgramLandscape(Far0);
|
||||||
|
nlverify(_Driver->compileVertexProgram(_VertexProgram[0]));
|
||||||
}
|
}
|
||||||
else if(_Type==Far1)
|
else if(_Type==Far1)
|
||||||
{
|
{
|
||||||
|
@ -584,6 +588,7 @@ void CLandscapeVBAllocator::setupVBFormatAndVertexProgram(bool withVertexProgr
|
||||||
|
|
||||||
// Init the Vertex Program.
|
// Init the Vertex Program.
|
||||||
_VertexProgram[0] = new CVertexProgramLandscape(Far1);
|
_VertexProgram[0] = new CVertexProgramLandscape(Far1);
|
||||||
|
nlverify(_Driver->compileVertexProgram(_VertexProgram[0]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -599,9 +604,11 @@ void CLandscapeVBAllocator::setupVBFormatAndVertexProgram(bool withVertexProgr
|
||||||
|
|
||||||
// Init the Vertex Program.
|
// Init the Vertex Program.
|
||||||
_VertexProgram[0] = new CVertexProgramLandscape(Tile, false);
|
_VertexProgram[0] = new CVertexProgramLandscape(Tile, false);
|
||||||
|
nlverify(_Driver->compileVertexProgram(_VertexProgram[0]));
|
||||||
|
|
||||||
// Init the Vertex Program for lightmap pass
|
// Init the Vertex Program for lightmap pass
|
||||||
_VertexProgram[1] = new CVertexProgramLandscape(Tile, true);
|
_VertexProgram[1] = new CVertexProgramLandscape(Tile, true);
|
||||||
|
nlverify(_Driver->compileVertexProgram(_VertexProgram[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -499,19 +499,19 @@ bool CMeshVPPerPixelLight::begin(IDriver *drv,
|
||||||
const NLMISC::CVector &viewerPos)
|
const NLMISC::CVector &viewerPos)
|
||||||
{
|
{
|
||||||
// test if supported by driver
|
// test if supported by driver
|
||||||
if (!
|
if (drv->isVertexProgramEmulated()
|
||||||
(drv->supportVertexProgram()
|
|| !drv->supportPerPixelLighting(SpecularLighting))
|
||||||
&& !drv->isVertexProgramEmulated()
|
|
||||||
&& drv->supportPerPixelLighting(SpecularLighting)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
enable(true, drv); // must enable the vertex program before the vb is activated
|
enable(true, drv); // must enable the vertex program before the vb is activated
|
||||||
CVertexProgramPerPixelLight *program = _ActiveVertexProgram;
|
CVertexProgramPerPixelLight *program = _ActiveVertexProgram;
|
||||||
nlassert(program);
|
if (!program)
|
||||||
|
{
|
||||||
|
// failed to compile vertex program
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
CRenderTrav *renderTrav= &scene->getRenderTrav();
|
CRenderTrav *renderTrav= &scene->getRenderTrav();
|
||||||
/// Setup for gouraud lighting
|
/// Setup for gouraud lighting
|
||||||
|
@ -593,8 +593,14 @@ void CMeshVPPerPixelLight::enable(bool enabled, IDriver *drv)
|
||||||
| (SpecularLighting ? 2 : 0)
|
| (SpecularLighting ? 2 : 0)
|
||||||
| (_IsPointLight ? 1 : 0);
|
| (_IsPointLight ? 1 : 0);
|
||||||
//
|
//
|
||||||
drv->activeVertexProgram((CVertexProgramPerPixelLight *)_VertexProgram[idVP]);
|
if (drv->activeVertexProgram((CVertexProgramPerPixelLight *)_VertexProgram[idVP]))
|
||||||
_ActiveVertexProgram = _VertexProgram[idVP];
|
{
|
||||||
|
_ActiveVertexProgram = _VertexProgram[idVP];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ActiveVertexProgram = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -207,12 +207,11 @@ void CMeshVPWindTree::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
|
||||||
f.serial(SpecularLighting);
|
f.serial(SpecularLighting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMeshVPWindTree::initVertexPrograms()
|
||||||
// ***************************************************************************
|
|
||||||
void CMeshVPWindTree::initInstance(CMeshBaseInstance *mbi)
|
|
||||||
{
|
{
|
||||||
// init the vertexProgram code.
|
// init the vertexProgram code.
|
||||||
static bool vpCreated= false;
|
static bool vpCreated= false;
|
||||||
|
|
||||||
if(!vpCreated)
|
if(!vpCreated)
|
||||||
{
|
{
|
||||||
vpCreated= true;
|
vpCreated= true;
|
||||||
|
@ -231,6 +230,12 @@ void CMeshVPWindTree::initInstance(CMeshBaseInstance *mbi)
|
||||||
_VertexProgram[i] = new CVertexProgramWindTree(numPls, normalize, specular);
|
_VertexProgram[i] = new CVertexProgramWindTree(numPls, normalize, specular);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ***************************************************************************
|
||||||
|
void CMeshVPWindTree::initInstance(CMeshBaseInstance *mbi)
|
||||||
|
{
|
||||||
|
initVertexPrograms();
|
||||||
|
|
||||||
// init a random phase.
|
// init a random phase.
|
||||||
mbi->_VPWindTreePhase= frand(1);
|
mbi->_VPWindTreePhase= frand(1);
|
||||||
|
@ -374,7 +379,7 @@ inline void CMeshVPWindTree::setupPerInstanceConstants(IDriver *driver, CScene
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
bool CMeshVPWindTree::begin(IDriver *driver, CScene *scene, CMeshBaseInstance *mbi, const NLMISC::CMatrix &invertedModelMat, const NLMISC::CVector & /*viewerPos*/)
|
bool CMeshVPWindTree::begin(IDriver *driver, CScene *scene, CMeshBaseInstance *mbi, const NLMISC::CMatrix &invertedModelMat, const NLMISC::CVector & /*viewerPos*/)
|
||||||
{
|
{
|
||||||
if (!(driver->supportVertexProgram() && !driver->isVertexProgramEmulated())) return false;
|
if (driver->isVertexProgramEmulated()) return false;
|
||||||
|
|
||||||
|
|
||||||
// Activate the good VertexProgram
|
// Activate the good VertexProgram
|
||||||
|
@ -393,8 +398,16 @@ bool CMeshVPWindTree::begin(IDriver *driver, CScene *scene, CMeshBaseInstance *m
|
||||||
// correct VP id for correct unmber of pls.
|
// correct VP id for correct unmber of pls.
|
||||||
idVP= numPls*4 + idVP;
|
idVP= numPls*4 + idVP;
|
||||||
// activate VP.
|
// activate VP.
|
||||||
driver->activeVertexProgram(_VertexProgram[idVP]);
|
if (driver->activeVertexProgram(_VertexProgram[idVP]))
|
||||||
_ActiveVertexProgram = _VertexProgram[idVP];
|
{
|
||||||
|
_ActiveVertexProgram = _VertexProgram[idVP];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// vertex program not supported
|
||||||
|
_ActiveVertexProgram = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// precompute mesh
|
// precompute mesh
|
||||||
|
@ -461,7 +474,20 @@ bool CMeshVPWindTree::supportMeshBlockRendering() const
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
bool CMeshVPWindTree::isMBRVpOk(IDriver *driver) const
|
bool CMeshVPWindTree::isMBRVpOk(IDriver *driver) const
|
||||||
{
|
{
|
||||||
return driver->supportVertexProgram() && !driver->isVertexProgramEmulated();
|
initVertexPrograms();
|
||||||
|
|
||||||
|
if (driver->isVertexProgramEmulated())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (uint i = 0; i < NumVp; ++i)
|
||||||
|
{
|
||||||
|
if (!driver->compileVertexProgram(_VertexProgram[i]))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
|
@ -98,7 +98,9 @@ void CVegetableVBAllocator::updateDriver(IDriver *driver)
|
||||||
_VBHardOk= false;
|
_VBHardOk= false;
|
||||||
|
|
||||||
// Driver must support VP.
|
// Driver must support VP.
|
||||||
nlassert(_Driver->supportVertexProgram());
|
nlassert(_Driver->supportVertexProgram(CVertexProgram::nelvp)
|
||||||
|
// || _Driver->supportVertexProgram(CVertexProgram::glsl330v) // TODO_VP_GLSL
|
||||||
|
);
|
||||||
|
|
||||||
// must reallocate the VertexBuffer.
|
// must reallocate the VertexBuffer.
|
||||||
if( _NumVerticesAllocated>0 )
|
if( _NumVerticesAllocated>0 )
|
||||||
|
|
Loading…
Reference in a new issue