Lazy shader update. attribute -> ATTRIBUTE, varying -> VARYING. Moved some shader preprocessor stuff from llviewershadermgr.cpp to llshadermgr.cpp to match LL (although it looks more messy)
This commit is contained in:
@@ -543,22 +543,52 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
|
||||
//we can't have any lines longer than 1024 characters
|
||||
//or any shaders longer than 1024 lines... deal - DaveP
|
||||
GLcharARB buff[1024] = {0};
|
||||
GLcharARB* text[1024] = {0};
|
||||
GLcharARB buff[1024];
|
||||
GLcharARB* text[4096];
|
||||
GLuint count = 0;
|
||||
|
||||
if (gGLManager.mGLVersion < 2.1f)
|
||||
F32 version = gGLManager.mGLVersion;
|
||||
if (version < 2.1f)
|
||||
{
|
||||
text[count++] = strdup("#version 110\n");
|
||||
text[count++] = strdup("#define ATTRIBUTE attribute\n");
|
||||
text[count++] = strdup("#define VARYING varying\n");
|
||||
}
|
||||
else if (gGLManager.mGLVersion < 3.f)
|
||||
else if (version < 3.f)
|
||||
{
|
||||
//set version to 1.20
|
||||
text[count++] = strdup("#version 120\n");
|
||||
text[count++] = strdup("#define ATTRIBUTE attribute\n");
|
||||
text[count++] = strdup("#define VARYING varying\n");
|
||||
}
|
||||
else
|
||||
{ //set version to 1.30
|
||||
text[count++] = strdup("#version 130\n");
|
||||
text[count++] = strdup("#define ATTRIBUTE in\n");
|
||||
|
||||
if (type == GL_VERTEX_SHADER_ARB)
|
||||
{ //"varying" state is "out" in a vertex program, "in" in a fragment program
|
||||
// ("varying" is deprecated after version 1.20)
|
||||
text[count++] = strdup("#define VARYING out\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
text[count++] = strdup("#define VARYING in\n");
|
||||
}
|
||||
|
||||
//backwards compatibility with legacy texture lookup syntax
|
||||
text[count++] = strdup("#define textureCube texture\n");
|
||||
text[count++] = strdup("#define texture2DLod textureLod\n");
|
||||
text[count++] = strdup("#define shadow2D(a,b) vec2(texture(a,b))\n"); //Shadow lookups only return a single float.
|
||||
|
||||
//Also deprecated:
|
||||
text[count++] = strdup("#define texture2D texture\n");
|
||||
text[count++] = strdup("#define texture2DRect texture\n");
|
||||
text[count++] = strdup("#define shadow2DRect(a,b) vec2(texture(a,b))\n");
|
||||
|
||||
//Will go away soon:
|
||||
text[count++] = strdup("#define ftransform() gl_ModelViewProjectionMatrix * gl_Vertex\n");
|
||||
|
||||
}
|
||||
|
||||
//copy preprocessor definitions into buffer
|
||||
@@ -608,8 +638,11 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
text[count++] = strdup(decl.c_str());
|
||||
}
|
||||
|
||||
if(texture_index_channels != 1)
|
||||
text[count++] = strdup("varying float vary_texture_index;\n");
|
||||
if (texture_index_channels > 1)
|
||||
{
|
||||
text[count++] = strdup("VARYING float vary_texture_index;\n");
|
||||
}
|
||||
|
||||
text[count++] = strdup("vec4 diffuseLookup(vec2 texcoord)\n");
|
||||
text[count++] = strdup("{\n");
|
||||
|
||||
@@ -659,8 +692,9 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
text[count++] = strdup("}\n");
|
||||
}
|
||||
}
|
||||
|
||||
//copy file into memory
|
||||
while( fgets((char *)buff, 1024, file) != NULL && count < LL_ARRAY_SIZE(buff) )
|
||||
while( fgets((char *)buff, 1024, file) != NULL && count < LL_ARRAY_SIZE(text) )
|
||||
{
|
||||
text[count++] = (GLcharARB *)strdup((char *)buff);
|
||||
}
|
||||
@@ -735,6 +769,14 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
for (GLuint i = 0; i < count; i++)
|
||||
{
|
||||
ostr << i << ": " << text[i];
|
||||
|
||||
if (i % 128 == 0)
|
||||
{ //dump every 128 lines
|
||||
|
||||
LL_WARNS("ShaderLoading") << "\n" << ostr.str() << llendl;
|
||||
ostr = std::stringstream();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LL_WARNS("ShaderLoading") << "\n" << ostr.str() << llendl;
|
||||
|
||||
Reference in New Issue
Block a user