Removed ARB fragment shader stuff.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent f768704cbf
commit a9a9768872

@ -249,7 +249,6 @@ CDriverGL3::CDriverGL3()
_ForceDXTCCompression= false; _ForceDXTCCompression= false;
_ForceTextureResizePower= 0; _ForceTextureResizePower= 0;
_ForceNativeFragmentPrograms = true;
_SumTextureMemoryUsed = false; _SumTextureMemoryUsed = false;
@ -279,12 +278,6 @@ CDriverGL3::CDriverGL3()
_LightMapLastStageEnv.Env.SrcArg0Alpha= CMaterial::Texture; _LightMapLastStageEnv.Env.SrcArg0Alpha= CMaterial::Texture;
_LightMapLastStageEnv.Env.OpArg0Alpha= CMaterial::SrcAlpha; _LightMapLastStageEnv.Env.OpArg0Alpha= CMaterial::SrcAlpha;
ATIWaterShaderHandleNoDiffuseMap = 0;
ATIWaterShaderHandle = 0;
ATICloudShaderHandle = 0;
std::fill(ARBWaterShader, ARBWaterShader + 4, 0);
/// buildCausticCubeMapTex(); /// buildCausticCubeMapTex();
_SpecularBatchOn= false; _SpecularBatchOn= false;
@ -452,10 +445,6 @@ bool CDriverGL3::setupDisplay()
//=========================================================== //===========================================================
initEMBM(); initEMBM();
// Init fragment shaders if present
//===========================================================
initFragmentShaders();
// Activate the default texture environnments for all stages. // Activate the default texture environnments for all stages.
//=========================================================== //===========================================================
for(uint stage=0;stage<inlGetNumTextStages(); stage++) for(uint stage=0;stage<inlGetNumTextStages(); stage++)
@ -733,8 +722,6 @@ bool CDriverGL3::release()
deleteOcclusionQuery(_OcclusionQueryList.front()); deleteOcclusionQuery(_OcclusionQueryList.front());
} }
deleteFragmentShaders();
// release caustic cube map // release caustic cube map
// _CauticCubeMap = NULL; // _CauticCubeMap = NULL;
@ -1295,260 +1282,9 @@ void CDriverGL3::initEMBM()
} }
// ***************************************************************************
/** Water fragment program with extension ARB_fragment_program
*/
static const char *WaterCodeNoDiffuseForARBFragmentProgram =
"!!ARBfp1.0 \n\
OPTION ARB_precision_hint_nicest; \n\
PARAM bump0ScaleBias = program.env[0]; \n\
PARAM bump1ScaleBias = program.env[1]; \n\
ATTRIB bump0TexCoord = fragment.texcoord[0]; \n\
ATTRIB bump1TexCoord = fragment.texcoord[1]; \n\
ATTRIB envMapTexCoord = fragment.texcoord[2]; \n\
OUTPUT oCol = result.color; \n\
TEMP bmValue; \n\
#read bump map 0 \n\
TEX bmValue, bump0TexCoord, texture[0], 2D; \n\
#bias result (include scaling) \n\
MAD bmValue, bmValue, bump0ScaleBias.xxxx, bump0ScaleBias.yyzz; \n\
ADD bmValue, bmValue, bump1TexCoord; \n\
#read bump map 1 \n\
TEX bmValue, bmValue, texture[1], 2D; \n\
#bias result (include scaling) \n\
MAD bmValue, bmValue, bump1ScaleBias.xxxx, bump1ScaleBias.yyzz; \n\
#add envmap coord \n\
ADD bmValue, bmValue, envMapTexCoord; \n\
#read envmap \n\
TEX oCol, bmValue, texture[2], 2D; \n\
END ";
static const char *WaterCodeNoDiffuseWithFogForARBFragmentProgram =
"!!ARBfp1.0 \n\
OPTION ARB_precision_hint_nicest; \n\
PARAM bump0ScaleBias = program.env[0]; \n\
PARAM bump1ScaleBias = program.env[1]; \n\
PARAM fogColor = state.fog.color; \n\
PARAM fogFactor = program.env[2]; \n\
ATTRIB bump0TexCoord = fragment.texcoord[0]; \n\
ATTRIB bump1TexCoord = fragment.texcoord[1]; \n\
ATTRIB envMapTexCoord = fragment.texcoord[2]; \n\
ATTRIB fogValue = fragment.fogcoord; \n\
OUTPUT oCol = result.color; \n\
TEMP bmValue; \n\
TEMP envMap; \n\
TEMP tmpFog; \n\
#read bump map 0 \n\
TEX bmValue, bump0TexCoord, texture[0], 2D; \n\
#bias result (include scaling) \n\
MAD bmValue, bmValue, bump0ScaleBias.xxxx, bump0ScaleBias.yyzz; \n\
ADD bmValue, bmValue, bump1TexCoord; \n\
#read bump map 1 \n\
TEX bmValue, bmValue, texture[1], 2D; \n\
#bias result (include scaling) \n\
MAD bmValue, bmValue, bump1ScaleBias.xxxx, bump1ScaleBias.yyzz; \n\
#add envmap coord \n\
ADD bmValue, bmValue, envMapTexCoord; \n\
#read envmap \n\
TEX envMap, bmValue, texture[2], 2D; \n\
#compute fog \n\
MAD_SAT tmpFog, fogValue.x, fogFactor.x, fogFactor.y; \n\
LRP oCol, tmpFog.x, envMap, fogColor; \n\
END ";
// **************************************************************************************
/** Water fragment program with extension ARB_fragment_program and a diffuse map applied
*/
static const char *WaterCodeForARBFragmentProgram =
"!!ARBfp1.0 \n\
OPTION ARB_precision_hint_nicest; \n\
PARAM bump0ScaleBias = program.env[0]; \n\
PARAM bump1ScaleBias = program.env[1]; \n\
ATTRIB bump0TexCoord = fragment.texcoord[0]; \n\
ATTRIB bump1TexCoord = fragment.texcoord[1]; \n\
ATTRIB envMapTexCoord = fragment.texcoord[2]; \n\
ATTRIB diffuseTexCoord = fragment.texcoord[3]; \n\
OUTPUT oCol = result.color; \n\
TEMP bmValue; \n\
TEMP diffuse; \n\
TEMP envMap; \n\
#read bump map 0 \n\
TEX bmValue, bump0TexCoord, texture[0], 2D; \n\
#bias result (include scaling) \n\
MAD bmValue, bmValue, bump0ScaleBias.xxxx, bump0ScaleBias.yyzz; \n\
ADD bmValue, bmValue, bump1TexCoord; \n\
#read bump map 1 \n\
TEX bmValue, bmValue, texture[1], 2D; \n\
#bias result (include scaling) \n\
MAD bmValue, bmValue, bump1ScaleBias.xxxx, bump1ScaleBias.yyzz; \n\
#add envmap coord \n\
ADD bmValue, bmValue, envMapTexCoord; \n\
#read envmap \n\
TEX envMap, bmValue, texture[2], 2D; \n\
#read diffuse \n\
TEX diffuse, diffuseTexCoord, texture[3], 2D; \n\
#modulate diffuse and envmap to get result \n\
MUL oCol, diffuse, envMap; \n\
END ";
static const char *WaterCodeWithFogForARBFragmentProgram =
"!!ARBfp1.0 \n\
OPTION ARB_precision_hint_nicest; \n\
PARAM bump0ScaleBias = program.env[0]; \n\
PARAM bump1ScaleBias = program.env[1]; \n\
PARAM fogColor = state.fog.color; \n\
PARAM fogFactor = program.env[2]; \n\
ATTRIB bump0TexCoord = fragment.texcoord[0]; \n\
ATTRIB bump1TexCoord = fragment.texcoord[1]; \n\
ATTRIB envMapTexCoord = fragment.texcoord[2]; \n\
ATTRIB diffuseTexCoord = fragment.texcoord[3]; \n\
ATTRIB fogValue = fragment.fogcoord; \n\
OUTPUT oCol = result.color; \n\
TEMP bmValue; \n\
TEMP diffuse; \n\
TEMP envMap; \n\
TEMP tmpFog; \n\
#read bump map 0 \n\
TEX bmValue, bump0TexCoord, texture[0], 2D; \n\
#bias result (include scaling) \n\
MAD bmValue, bmValue, bump0ScaleBias.xxxx, bump0ScaleBias.yyzz; \n\
ADD bmValue, bmValue, bump1TexCoord; \n\
#read bump map 1 \n\
TEX bmValue, bmValue, texture[1], 2D; \n\
#bias result (include scaling) \n\
MAD bmValue, bmValue, bump1ScaleBias.xxxx, bump1ScaleBias.yyzz; \n\
#add envmap coord \n\
ADD bmValue, bmValue, envMapTexCoord; \n\
TEX envMap, bmValue, texture[2], 2D; \n\
TEX diffuse, diffuseTexCoord, texture[3], 2D; \n\
MAD_SAT tmpFog, fogValue.x, fogFactor.x, fogFactor.y; \n\
#modulate diffuse and envmap to get result \n\
MUL diffuse, diffuse, envMap; \n\
LRP oCol, tmpFog.x, diffuse, fogColor; \n\
END ";
// ***************************************************************************
/** Load a ARB_fragment_program_code, and ensure it is loaded natively
*/
uint loadARBFragmentProgramStringNative(const char *prog, bool forceNativePrograms)
{
H_AUTO_OGL(loadARBFragmentProgramStringNative);
if (!prog)
{
nlwarning("The param 'prog' is null, cannot load");
return 0;
}
GLuint progID;
nglGenProgramsARB(1, &progID);
if (!progID)
{
nlwarning("glGenProgramsARB returns a progID NULL");
return 0;
}
nglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, progID);
GLint errorPos, isNative;
nglProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(prog), prog);
nglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
nglGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &isNative);
if (errorPos == -1)
{
if (!isNative && forceNativePrograms)
{
nlwarning("Fragment program isn't supported natively; purging program");
nglDeleteProgramsARB(1, &progID);
return 0;
}
return progID;
}
else
{
nlwarning("init fragment program failed: errorPos: %d isNative: %d: %s", errorPos, isNative, (const char*)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
}
return 0;
}
// *************************************************************************** // ***************************************************************************
void CDriverGL3::forceNativeFragmentPrograms(bool nativeOnly) void CDriverGL3::forceNativeFragmentPrograms(bool nativeOnly)
{ {
_ForceNativeFragmentPrograms = nativeOnly;
}
// ***************************************************************************
void CDriverGL3::initFragmentShaders()
{
H_AUTO_OGL(CDriverGL3_initFragmentShaders);
///////////////////
// WATER SHADERS //
///////////////////
// the ARB_fragment_program is prioritary over other extensions when present
{
nlinfo("WATER: Try ARB_fragment_program");
ARBWaterShader[0] = loadARBFragmentProgramStringNative(WaterCodeNoDiffuseForARBFragmentProgram, _ForceNativeFragmentPrograms);
ARBWaterShader[1] = loadARBFragmentProgramStringNative(WaterCodeNoDiffuseWithFogForARBFragmentProgram, _ForceNativeFragmentPrograms);
ARBWaterShader[2] = loadARBFragmentProgramStringNative(WaterCodeForARBFragmentProgram, _ForceNativeFragmentPrograms);
ARBWaterShader[3] = loadARBFragmentProgramStringNative(WaterCodeWithFogForARBFragmentProgram, _ForceNativeFragmentPrograms);
bool ok = true;
for(uint k = 0; k < 4; ++k)
{
if (!ARBWaterShader[k])
{
ok = false;
deleteARBFragmentPrograms();
nlwarning("WATER: fragment %d is not loaded, not using ARB_fragment_program at all", k);
break;
}
}
if (ok)
{
nlinfo("WATER: ARB_fragment_program OK, Use it");
return;
}
}
}
// ***************************************************************************
void CDriverGL3::deleteARBFragmentPrograms()
{
H_AUTO_OGL(CDriverGL3_deleteARBFragmentPrograms);
for(uint k = 0; k < 4; ++k)
{
if (ARBWaterShader[k])
{
GLuint progId = (GLuint) ARBWaterShader[k];
nglDeleteProgramsARB(1, &progId);
ARBWaterShader[k] = 0;
}
}
}
// ***************************************************************************
void CDriverGL3::deleteFragmentShaders()
{
H_AUTO_OGL(CDriverGL3_deleteFragmentShaders)
deleteARBFragmentPrograms();
if (ATIWaterShaderHandleNoDiffuseMap)
{
nglDeleteFragmentShaderATI((GLuint) ATIWaterShaderHandleNoDiffuseMap);
ATIWaterShaderHandleNoDiffuseMap = 0;
}
if (ATIWaterShaderHandle)
{
nglDeleteFragmentShaderATI((GLuint) ATIWaterShaderHandle);
ATIWaterShaderHandle = 0;
}
if (ATICloudShaderHandle)
{
nglDeleteFragmentShaderATI((GLuint) ATICloudShaderHandle);
ATICloudShaderHandle = 0;
}
} }
// *************************************************************************** // ***************************************************************************

@ -1319,9 +1319,6 @@ private:
bool _ForceDXTCCompression; bool _ForceDXTCCompression;
/// Divisor for textureResize (power). /// Divisor for textureResize (power).
uint _ForceTextureResizePower; uint _ForceTextureResizePower;
// enforcement of native fragment program check
bool _ForceNativeFragmentPrograms;
// user texture matrix // user texture matrix
NLMISC::CMatrix _UserTexMat[IDRV_MAT_MAXTEXTURES]; NLMISC::CMatrix _UserTexMat[IDRV_MAT_MAXTEXTURES];
@ -1366,26 +1363,6 @@ private:
bool _NeedToRestaureGammaRamp; bool _NeedToRestaureGammaRamp;
uint16 _GammaRampBackuped[3*256]; uint16 _GammaRampBackuped[3*256];
/// \fragment shaders
// @{
GLuint ATIWaterShaderHandleNoDiffuseMap; // water support on R200
GLuint ATIWaterShaderHandle; // water support on R200
GLuint ATICloudShaderHandle; // cloud support for R200 and more
GLuint ARBWaterShader[4]; // water support on R300, NV30 & the like
void initFragmentShaders();
void deleteFragmentShaders();
void deleteARBFragmentPrograms();
void setupWaterPassR200(const CMaterial &mat);
void setupWaterPassARB(const CMaterial &mat);
// @}
bool _PolygonSmooth; bool _PolygonSmooth;
/// \Render to texture /// \Render to texture

@ -702,35 +702,6 @@ static bool setupEXTBlendColor(const char *glext)
return true; return true;
} }
// *********************************
static bool setupARBFragmentProgram(const char *glext)
{
H_AUTO_OGL(setupARBFragmentProgram);
CHECK_EXT("GL_ARB_fragment_program");
CHECK_ADDRESS(NEL_PFNGLPROGRAMSTRINGARBPROC, glProgramStringARB);
CHECK_ADDRESS(NEL_PFNGLBINDPROGRAMARBPROC, glBindProgramARB);
CHECK_ADDRESS(NEL_PFNGLDELETEPROGRAMSARBPROC, glDeleteProgramsARB);
CHECK_ADDRESS(NEL_PFNGLGENPROGRAMSARBPROC, glGenProgramsARB);
CHECK_ADDRESS(NEL_PFNGLPROGRAMENVPARAMETER4DARBPROC, glProgramEnvParameter4dARB);
CHECK_ADDRESS(NEL_PFNGLPROGRAMENVPARAMETER4DVARBPROC, glProgramEnvParameter4dvARB);
CHECK_ADDRESS(NEL_PFNGLPROGRAMENVPARAMETER4FARBPROC, glProgramEnvParameter4fARB);
CHECK_ADDRESS(NEL_PFNGLPROGRAMENVPARAMETER4FVARBPROC, glProgramEnvParameter4fvARB);
CHECK_ADDRESS(NEL_PFNGLPROGRAMLOCALPARAMETER4DARBPROC, glProgramLocalParameter4dARB);
CHECK_ADDRESS(NEL_PFNGLPROGRAMLOCALPARAMETER4DVARBPROC, glProgramLocalParameter4dvARB);
CHECK_ADDRESS(NEL_PFNGLPROGRAMLOCALPARAMETER4FARBPROC, glProgramLocalParameter4fARB);
CHECK_ADDRESS(NEL_PFNGLPROGRAMLOCALPARAMETER4FVARBPROC, glProgramLocalParameter4fvARB);
CHECK_ADDRESS(NEL_PFNGLGETPROGRAMENVPARAMETERDVARBPROC, glGetProgramEnvParameterdvARB);
CHECK_ADDRESS(NEL_PFNGLGETPROGRAMENVPARAMETERFVARBPROC, glGetProgramEnvParameterfvARB);
CHECK_ADDRESS(NEL_PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC, glGetProgramLocalParameterdvARB);
CHECK_ADDRESS(NEL_PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC, glGetProgramLocalParameterfvARB);
CHECK_ADDRESS(NEL_PFNGLGETPROGRAMIVARBPROC, glGetProgramivARB);
CHECK_ADDRESS(NEL_PFNGLGETPROGRAMSTRINGARBPROC, glGetProgramStringARB);
CHECK_ADDRESS(NEL_PFNGLISPROGRAMARBPROC, glIsProgramARB);
return true;
}
// *************************************************************************** // ***************************************************************************
static bool setupARBVertexBufferObject(const char *glext) static bool setupARBVertexBufferObject(const char *glext)
{ {
@ -753,78 +724,6 @@ static bool setupARBVertexBufferObject(const char *glext)
return true; return true;
} }
// ***************************************************************************
static bool setupARBVertexProgram(const char *glext)
{
H_AUTO_OGL(setupARBVertexProgram);
CHECK_EXT("GL_ARB_vertex_program");
CHECK_ADDRESS(PFNGLVERTEXATTRIB1SARBPROC, glVertexAttrib1sARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB1FARBPROC, glVertexAttrib1fARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB1DARBPROC, glVertexAttrib1dARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB2SARBPROC, glVertexAttrib2sARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB2FARBPROC, glVertexAttrib2fARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB2DARBPROC, glVertexAttrib2dARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB3SARBPROC, glVertexAttrib3sARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB3FARBPROC, glVertexAttrib3fARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB3DARBPROC, glVertexAttrib3dARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4SARBPROC, glVertexAttrib4sARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4FARBPROC, glVertexAttrib4fARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4DARBPROC, glVertexAttrib4dARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4NUBARBPROC, glVertexAttrib4NubARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB1SVARBPROC, glVertexAttrib1svARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB1FVARBPROC, glVertexAttrib1fvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB1DVARBPROC, glVertexAttrib1dvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB2SVARBPROC, glVertexAttrib2svARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB2FVARBPROC, glVertexAttrib2fvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB2DVARBPROC, glVertexAttrib2dvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB3SVARBPROC, glVertexAttrib3svARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB3FVARBPROC, glVertexAttrib3fvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB3DVARBPROC, glVertexAttrib3dvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4BVARBPROC, glVertexAttrib4bvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4SVARBPROC, glVertexAttrib4svARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4IVARBPROC, glVertexAttrib4ivARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4UBVARBPROC, glVertexAttrib4ubvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4USVARBPROC, glVertexAttrib4usvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4UIVARBPROC, glVertexAttrib4uivARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4FVARBPROC, glVertexAttrib4fvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4DVARBPROC, glVertexAttrib4dvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4NBVARBPROC, glVertexAttrib4NbvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4NSVARBPROC, glVertexAttrib4NsvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4NIVARBPROC, glVertexAttrib4NivARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4NUBVARBPROC, glVertexAttrib4NubvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4NUSVARBPROC, glVertexAttrib4NusvARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIB4NUIVARBPROC, glVertexAttrib4NuivARB);
CHECK_ADDRESS(PFNGLVERTEXATTRIBPOINTERARBPROC, glVertexAttribPointerARB);
CHECK_ADDRESS(PFNGLENABLEVERTEXATTRIBARRAYARBPROC, glEnableVertexAttribArrayARB);
CHECK_ADDRESS(PFNGLDISABLEVERTEXATTRIBARRAYARBPROC, glDisableVertexAttribArrayARB);
CHECK_ADDRESS(PFNGLPROGRAMSTRINGARBPROC, glProgramStringARB);
CHECK_ADDRESS(PFNGLBINDPROGRAMARBPROC, glBindProgramARB);
CHECK_ADDRESS(PFNGLDELETEPROGRAMSARBPROC, glDeleteProgramsARB);
CHECK_ADDRESS(PFNGLGENPROGRAMSARBPROC, glGenProgramsARB);
CHECK_ADDRESS(PFNGLPROGRAMENVPARAMETER4FARBPROC, glProgramEnvParameter4fARB);
CHECK_ADDRESS(PFNGLPROGRAMENVPARAMETER4DARBPROC, glProgramEnvParameter4dARB);
CHECK_ADDRESS(PFNGLPROGRAMENVPARAMETER4FVARBPROC, glProgramEnvParameter4fvARB);
CHECK_ADDRESS(PFNGLPROGRAMENVPARAMETER4DVARBPROC, glProgramEnvParameter4dvARB);
CHECK_ADDRESS(PFNGLPROGRAMLOCALPARAMETER4FARBPROC, glProgramLocalParameter4fARB);
CHECK_ADDRESS(PFNGLPROGRAMLOCALPARAMETER4DARBPROC, glProgramLocalParameter4dARB);
CHECK_ADDRESS(PFNGLPROGRAMLOCALPARAMETER4FVARBPROC, glProgramLocalParameter4fvARB);
CHECK_ADDRESS(PFNGLPROGRAMLOCALPARAMETER4DVARBPROC, glProgramLocalParameter4dvARB);
CHECK_ADDRESS(PFNGLGETPROGRAMENVPARAMETERFVARBPROC, glGetProgramEnvParameterfvARB);
CHECK_ADDRESS(PFNGLGETPROGRAMENVPARAMETERDVARBPROC, glGetProgramEnvParameterdvARB);
CHECK_ADDRESS(PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC, glGetProgramLocalParameterfvARB);
CHECK_ADDRESS(PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC, glGetProgramLocalParameterdvARB);
CHECK_ADDRESS(PFNGLGETPROGRAMIVARBPROC, glGetProgramivARB);
CHECK_ADDRESS(PFNGLGETPROGRAMSTRINGARBPROC, glGetProgramStringARB);
CHECK_ADDRESS(PFNGLGETVERTEXATTRIBDVARBPROC, glGetVertexAttribdvARB);
CHECK_ADDRESS(PFNGLGETVERTEXATTRIBFVARBPROC, glGetVertexAttribfvARB);
CHECK_ADDRESS(PFNGLGETVERTEXATTRIBIVARBPROC, glGetVertexAttribivARB);
CHECK_ADDRESS(PFNGLGETVERTEXATTRIBPOINTERVARBPROC, glGetVertexAttribPointervARB);
CHECK_ADDRESS(PFNGLISPROGRAMARBPROC, glIsProgramARB);
return true;
}
// *************************************************************************** // ***************************************************************************
static bool setupNVOcclusionQuery(const char *glext) static bool setupNVOcclusionQuery(const char *glext)
{ {
@ -1129,10 +1028,6 @@ void registerGlExtensions(CGlExtensions &ext)
// Check for cube mapping // Check for cube mapping
ext.ARBTextureCubeMap = setupARBTextureCubeMap(glext); ext.ARBTextureCubeMap = setupARBTextureCubeMap(glext);
setupARBVertexProgram(glext);
setupARBFragmentProgram(glext);
// Check EXTSecondaryColor // Check EXTSecondaryColor
ext.EXTSecondaryColor= setupEXTSecondaryColor(glext); ext.EXTSecondaryColor= setupEXTSecondaryColor(glext);

@ -1604,54 +1604,6 @@ void CDriverGL3::setupCloudPass (uint /* pass */)
activateTexture(0, mat.getTexture(0)); activateTexture(0, mat.getTexture(0));
activateTexture(1, mat.getTexture(0)); activateTexture(1, mat.getTexture(0));
if (_CurrentTexEnvSpecial[0] != TexEnvSpecialCloudStage0)
{
{
// TODO : for now the state is not cached in _CurrentTexEnvSpecial
nglBindFragmentShaderATI(ATICloudShaderHandle);
glEnable(GL_FRAGMENT_SHADER_ATI);
float cst[4] = { 0.f, 0.f, 0.f, mat.getColor().A / 255.f };
nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst);
/*
_DriverGLStates.activeTextureARB(0);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
// Operator.
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_INTERPOLATE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_INTERPOLATE_EXT);
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_ZERO );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE0_ARB );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA);
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_ZERO );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_TEXTURE1_ARB );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA);
// Arg2.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_ZERO );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_PRIMARY_COLOR_EXT );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);
_DriverGLStates.activeTextureARB(1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
// Operator.
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE);
// Arg0.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_ZERO );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA);
// Arg1.
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_ZERO );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_CONSTANT_EXT );
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA);
*/
}
}
} }
// *************************************************************************** // ***************************************************************************
@ -1659,8 +1611,6 @@ void CDriverGL3::endCloudMultiPass()
{ {
H_AUTO_OGL(CDriverGL3_endCloudMultiPass) H_AUTO_OGL(CDriverGL3_endCloudMultiPass)
nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud); nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud);
if (ATICloudShaderHandle)
glDisable(GL_FRAGMENT_SHADER_ATI);
} }
// *************************************************************************** // ***************************************************************************
@ -1671,93 +1621,34 @@ sint CDriverGL3::beginWaterMultiPass()
return 1; return 1;
} }
// *************************************************************************** // ***************************************************************************
/** water setup for ATI /** Presetupped texture shader for water shader on NV20
*/ */
void CDriverGL3::setupWaterPassR200(const CMaterial &mat) static const uint8 WaterNoDiffuseTexAddrMode[IDRV_MAT_MAXTEXTURES] =
{ {
H_AUTO_OGL(CDriverGL3_setupWaterPassR200); CMaterial::FetchTexture,
CMaterial::OffsetTexture,
CMaterial::OffsetTexture,
CMaterial::TextureOff
};
uint k; static const uint8 WaterTexAddrMode[IDRV_MAT_MAXTEXTURES] =
ITexture *tex = mat.getTexture(0); {
if (tex) CMaterial::FetchTexture,
{ CMaterial::OffsetTexture,
// if (tex->isBumpMap()) CMaterial::OffsetTexture,
// { CMaterial::FetchTexture
// CTextureBump *tb = static_cast<CTextureBump *>(tex); };
// }
setupTexture(*tex);
activateTexture(0, tex);
}
tex = mat.getTexture(1);
if (tex)
{
// if (tex->isBumpMap())
// {
// CTextureBump *tb = static_cast<CTextureBump *>(tex);
// }
setupTexture(*tex);
activateTexture(1, tex);
}
tex = mat.getTexture(2);
if (tex)
{
setupTexture(*tex);
activateTexture(2, tex);
}
tex = mat.getTexture(3);
if (tex)
{
setupTexture(*tex);
activateTexture(3, tex);
}
for (k = 4; k < inlGetNumTextStages(); ++k)
{
activateTexture(k, NULL);
}
if (mat.getTexture(3) != NULL) // is there a diffuse map ?
{
nglBindFragmentShaderATI(ATIWaterShaderHandle);
}
else
{
nglBindFragmentShaderATI(ATIWaterShaderHandleNoDiffuseMap);
}
glEnable(GL_FRAGMENT_SHADER_ATI);
// set constants static const float IdentityTexMat[4] = { 1.f, 0.f, 0.f, 1.f };
if (mat.getTexture(0) && mat.getTexture(0)->isBumpMap())
{
float factor = NLMISC::safe_cast<CTextureBump *>(mat.getTexture(0))->getNormalizationFactor();
float cst[4] = { factor, factor, factor, 0.f };
nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst);
}
else
{
float cst[4] = { 1.f, 1.f, 1.f, 0.f };
nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst);
}
//
if (mat.getTexture(1) && mat.getTexture(1)->isBumpMap())
{
float factor = NLMISC::safe_cast<CTextureBump *>(mat.getTexture(1))->getNormalizationFactor();
float cst[4] = { factor, factor, factor, 0.f };
nglSetFragmentShaderConstantATI(GL_CON_1_ATI, cst);
}
else
{
float cst[4] = { 1.f, 1.f, 1.f, 0.f };
nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst);
}
}
// *************************************************************************** // ***************************************************************************
/** water setup for ARB_fragment_program void CDriverGL3::setupWaterPass(uint /* pass */)
*/
void CDriverGL3::setupWaterPassARB(const CMaterial &mat)
{ {
H_AUTO_OGL(CDriverGL3_setupWaterPassARB); H_AUTO_OGL(CDriverGL3_setupWaterPass)
nlassert (_CurrentMaterial);
CMaterial &mat = *_CurrentMaterial;
nlassert(_CurrentMaterial->getShader() == CMaterial::Water);
uint k; uint k;
ITexture *tex = mat.getTexture(0); ITexture *tex = mat.getTexture(0);
@ -1790,85 +1681,7 @@ void CDriverGL3::setupWaterPassARB(const CMaterial &mat)
{ {
activateTexture(k, NULL); activateTexture(k, NULL);
} }
nglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ARBWaterShader[(_FogEnabled ? 1 : 0) | (mat.getTexture(3) != NULL ? 2 : 0)]);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
// setup the constant
if (mat.getTexture(0) && mat.getTexture(0)->isBumpMap())
{
float factor = 0.25f * NLMISC::safe_cast<CTextureBump *>(mat.getTexture(0))->getNormalizationFactor();
nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, 2.f * factor, -1.f * factor, 0.f, 0.f); // scale_bias from [0, 1] to [-1, 1] and factor applied
}
else
{
nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, 2.f, -1.f, 0.f, 0.f); // scale_bias from [0, 1] to [-1, 1] and factor applied
}
// setup the constant
if (mat.getTexture(1) && mat.getTexture(1)->isBumpMap())
{
float factor = NLMISC::safe_cast<CTextureBump *>(mat.getTexture(1))->getNormalizationFactor();
nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 2.f * factor, -1.f * factor, 0.f, 0.f); // scale_bias from [0, 1] to [-1, 1] and factor applied
}
else
{
nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 2.f, -1.f, 0.f, 0.f); // scale_bias from [0, 1] to [-1, 1] and factor applied
}
if (_FogEnabled)
{
if (_FogStart == _FogEnd)
{
nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2, 0.f, 0.f, 0.f, 0.f);
}
else
{
/** Unfortunately, the EXT_vertex_shader extension has to output the fog values in the [0, 1] range to work with the standard pipeline.
* So we must add a special path for this case, where the fog coordinate is 'unscaled' again.
* NB : this is fixed in later drivers (from 6.14.10.6343), so check this
*/
nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2, - 1.f/ (_FogEnd - _FogStart), _FogEnd / (_FogEnd - _FogStart), 0.f, 0.f);
}
}
}
// ***************************************************************************
/** Presetupped texture shader for water shader on NV20
*/
static const uint8 WaterNoDiffuseTexAddrMode[IDRV_MAT_MAXTEXTURES] =
{
CMaterial::FetchTexture,
CMaterial::OffsetTexture,
CMaterial::OffsetTexture,
CMaterial::TextureOff
};
static const uint8 WaterTexAddrMode[IDRV_MAT_MAXTEXTURES] =
{
CMaterial::FetchTexture,
CMaterial::OffsetTexture,
CMaterial::OffsetTexture,
CMaterial::FetchTexture
};
static const float IdentityTexMat[4] = { 1.f, 0.f, 0.f, 1.f };
// ***************************************************************************
void CDriverGL3::setupWaterPass(uint /* pass */)
{
H_AUTO_OGL(CDriverGL3_setupWaterPass)
nlassert (_CurrentMaterial);
CMaterial &mat = *_CurrentMaterial;
nlassert(_CurrentMaterial->getShader() == CMaterial::Water);
if (ARBWaterShader[0])
{
setupWaterPassARB(mat);
}
else if (ATIWaterShaderHandleNoDiffuseMap)
{
setupWaterPassR200(mat);
}
} }
// *************************************************************************** // ***************************************************************************
@ -1878,14 +1691,7 @@ void CDriverGL3::endWaterMultiPass()
nlassert(_CurrentMaterial->getShader() == CMaterial::Water); nlassert(_CurrentMaterial->getShader() == CMaterial::Water);
// NB : as fragment shaders / programs bypass the texture envs, no special env enum is added (c.f CTexEnvSpecial) // NB : as fragment shaders / programs bypass the texture envs, no special env enum is added (c.f CTexEnvSpecial)
if (ARBWaterShader[0])
{
glDisable(GL_FRAGMENT_PROGRAM_ARB);
}
else if (ATIWaterShaderHandleNoDiffuseMap)
{
glDisable(GL_FRAGMENT_SHADER_ATI);
}
} }
#ifdef NL_STATIC #ifdef NL_STATIC

Loading…
Cancel
Save