0 Replies Latest reply on Oct 10, 2012 1:52 PM by guubao

    [Bug Report] GLSL macro causes glsl-compiler freeze

    guubao

      OS: Win7 64bit

       

      Renderer info:

      GL_VENDOR:Intel

      GL_RENDERER:Intel(R) HD Graphics 3000

      GL_VERSION:3.1.0 - Build 8.15.10.2761

       

      Description:

      Thread never returns from call to glCompileShader.

       

      Code:

       

      //Compiler freezes

      std::string macros =

      "#version 130\r\n"

      "#define TEST_MACRO(X) uniform sampler2D agent_##X\r\n";

       

      std::string source =

      "TEST_MACRO(text0);\r\n";

       

      gl::GLint shader = gl::glCreateShader(gl::GL_VERTEX_SHADER);

       

      const char* sources[] = {macros.c_str(), source.c_str()};

      gl::GLint lens[] = {macros.size(),source.size()};

       

      gl::glShaderSource(shader,2,sources,lens);

      gl::glCompileShader(shader);

       

       

      Other similar problem:

      Description:

       

      Very similar code results compiling error, even thou I think that glsl-shader code is valid.

      According to http://www.opengl.org/wiki/GLSL_Object#Shader_compiling glShaderSource should work like string given to it are combined.

      GLSL code will compile if both source strings are combined before giving them to compiler.

       

      Code:

       

      //Compile fail

      std::string macros =

      "#version 130\r\n"

      "#define TEST_MACRO(X) uniform sampler2D agent_##X; uniform vec4 agent_##X##_atlas_rect\r\n";

       

      std::string source =

      "TEST_MACRO(text0);\r\n";

       

      gl::GLint shader = gl::glCreateShader(gl::GL_VERTEX_SHADER);

       

      const char* sources[] = {macros.c_str(), source.c_str()};

      gl::GLint lens[] = {macros.size(),source.size()};

       

      gl::glShaderSource(shader,2,sources,lens);

      gl::glCompileShader(shader);

       

      //Log:

      //ERROR: 1:2: 'uniform' : no qualifiers allowed for function return

      //ERROR: 1:2: 'text0' : syntax error syntax error