PDA

View Full Version : ERROR: Not all shaders have valid object code.



evovch
04-09-2012, 09:37 AM
Hello, everybody.

Searched in the net, many posts by no answer.
Trying to make the easiest programm get this error:
"Linker failure: Vertex shader(s) failed to link, no fragment shader(s) defined." or
"Linker failure: Vertex shader(s) failed to link, fragment shader(s) failed to link." depending on the configuration (frag shader off/on.
"ERROR: Not all shaders have valid object code.ERROR: Not all shaders have valid object code."

Both shaders do compile succesfully. Debugging shows that glLinkProgram fails.

Using MSVC++ 2010 under Win7.
Does anything depend on the harware? My graph card supports only version 3.2. Changing 1st line in shaders to
#version 320
does not help.

Vertex shader:
-----------------------------------------------------
#version 420

layout (location = 0) in vec4 in_Position;
layout (location = 1) in vec4 in_Color;

smooth out vec4 ex_Color;

void main()
{
gl_Position = in_Position;
ex_Color = in_Color;
}
-----------------------------------------------------

Fragment shader:
-----------------------------------------------------
#version 420

smooth in vec4 ex_Color;

out vec4 out_Color;

void main()
{
out_Color = ex_Color;
}
-----------------------------------------------------


Some parts from the source:

...
GLuint theProg;
...
std::vector<GLuint> shaderList;
shaderList.push_back(OvchCreateShader(GL_VERTEX_SH ADER, VertShaderFilename));
shaderList.push_back(OvchCreateShader(GL_FRAGMENT_ SHADER, FragShaderFilename));
theProg = OvchCreateProg(shaderList);
std::for_each(shaderList.begin(), shaderList.end(), glDeleteShader);
...
GLuint program = glCreateProgram();
for (size_t iLoop = 0; iLoop < shaderList.size(); iLoop++)
{ glAttachShader(program, shaderList[iLoop]); }
glLinkProgram(program);
...


Thank you! Any ideas?


Solved:
Stupid mistake - I did not send the shader's source to the glShaderSource inside my OvchCreateShader.

But now I get another problem.

ERROR: 0:1: '' : Version number not supported by GL2
ERROR: 0:3: 'layout' : syntax error parse error
ERROR: compilation errors. No code generated.

ERROR: 0:1: '' : Version number not supported by GL2
ERROR: 0:3: 'layout' : syntax error parse error
ERROR: compilation errors. No code generated.

ERROR: 0:1: '' : Version number not supported by GL2
ERROR: compilation errors. No code generated.

ERROR: 0:1: '' : Version number not supported by GL2
ERROR: compilation errors. No code generated.

kRogue
04-09-2012, 01:12 PM
Does anything depend on the harware? My graph card supports only version 3.2. Changing 1st line in shaders to
#version 320
does not help.


if your card only support GL 3.2 (which is odd, such a card would also likely support GL3.3, what is the card and driver pair?) then doing #version 420 is a .... recipe.. for bad things to happen.


Without seeing the contents of OvchCreateShader, it is hard to tell.... my suspicion is a "silent read file error" on the fragment shader and/or vertex shader. An empty string is a valid shader which would compile fine...

the call: glGetShaderSource will have GL return to you what it thinks the shader source code is...

evovch
04-10-2012, 02:18 AM
I have ATI Mobility Radeon HD 4300 Series and corresponding driver. It is a laptop.


Below is the OvchCreateShader implementation.
I modified it a little bit since the last post, but still...
At the end you'll fins the messages during run.


GLuint OvchRenderer::OvchCreateShader(GLenum eShaderType, const string&amp; strShaderFile)
{
GLuint shader = glCreateShader(eShaderType);

// Read shader from the file with name `strShaderFile` into string `strShaderData`
string strShaderData;
string line;
std::ifstream fileShader (strShaderFile);
if (fileShader.is_open())
{
while (fileShader.good())
{
getline(fileShader, line);
strShaderData += line + "\n";
}
fileShader.close();
}
else
*debugFile << "Error opening shader file:" << strShaderFile << endl;

// Convert string `strShaderData` into C-type string `cstrShaderData`
char* cstrShaderData;
cstrShaderData = new char [strShaderData.size()+1];
strcpy_s (cstrShaderData, strShaderData.size()+1, strShaderData.c_str());

// Debug output
*debugFile << "-----------------------" << endl;
*debugFile << cstrShaderData;
*debugFile << "-----------------------" << endl;

glShaderSource(shader, 1, (const GLchar**)&amp;cstrShaderData, NULL);

glCompileShader(shader);

// Get diagnostics info and print it in case of error
GLint status;
glGetShaderiv(shader, GL_COMPILE_STATUS, &amp;status);
if (status == GL_FALSE)
{
GLint infoLogLength;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &amp;infoLogLength);

GLchar *strInfoLog = new GLchar[infoLogLength + 1];
glGetShaderInfoLog(shader, infoLogLength, NULL, strInfoLog);

const char *strShaderType = NULL;
switch(eShaderType)
{
case GL_VERTEX_SHADER: strShaderType = "vertex"; break;
case GL_GEOMETRY_SHADER: strShaderType = "geometry"; break;
case GL_FRAGMENT_SHADER: strShaderType = "fragment"; break;
}

*debugFile << "Compile failure in " << strShaderType << " shader:" << endl << strInfoLog << endl;
delete[] strInfoLog;
}

return shader;
}


Debug output


-----------------------
#version 320

layout (location = 0) in vec4 in_Position;
layout (location = 1) in vec4 in_Color;

smooth out vec4 ex_Color;

void main()
{
gl_Position = in_Position;
ex_Color = in_Color;
}
-----------------------
Compile failure in vertex shader:
Vertex shader failed to compile with the following errors:
ERROR: 0:1: '' : Version number not supported by GL2
ERROR: 0:3: 'layout' : syntax error parse error
ERROR: compilation errors. No code generated.

-----------------------
#version 320

smooth in vec4 ex_Color;

out vec4 out_Color;

void main()
{
out_Color = ex_Color;
}
-----------------------
Compile failure in fragment shader:
Fragment shader failed to compile with the following errors:
ERROR: 0:1: '' : Version number not supported by GL2
ERROR: compilation errors. No code generated.

Linker failure: Vertex and Fragment shader(s) were not successfully compiled before glLinkProgram() was called. Link failed.

kyle_
04-10-2012, 06:19 AM
Please note that there is no 320 version for GLSL. GLSL version that was introduced in GL 3.2 is 150.

Edit: Also, layout declarations for attribute/frag out bindings are available from GLSL 330 on, so you will need to rewrite if you want to target GLSL 150.

evovch
04-13-2012, 02:56 AM
So, please, let me formulate the quiestion another way.

I would like to write my program using OpenGL 4.2 core profile.
Suppose I have a mashine with the corresponding graph card, but I do not have permanent access to it.
Can I work somehow on my laptop with that "ATI Mobility Radeon HD 4300 Series"?

Thank you.

evovch
04-16-2012, 02:47 AM
Here is some info concearning the problem

http://developer.nvidia.com/opengl-driver

Soon I'll try to do something with NVidia Quadro 600

V-man
04-16-2012, 05:05 AM
So, please, let me formulate the quiestion another way.

I would like to write my program using OpenGL 4.2 core profile.
Suppose I have a mashine with the corresponding graph card, but I do not have permanent access to it.
Can I work somehow on my laptop with that "ATI Mobility Radeon HD 4300 Series"?

Thank you.

I suppose you can write a program that converts your GLSL shader between systems and you should be fine as long as you don't really use GL 4.2 features in your shader and your source code.