Error: Fragment shader failed to compile in rev 528 in macOS

Having technical difficulties with Supermodel? Last-minute wardrobe malfunction? Get help here.
Forum rules
Keep it classy!

  • No ROM requests or links.
  • Do not ask to be a play tester.
  • Do not ask about release dates.
  • No drama!

Error: Fragment shader failed to compile in rev 528 in macOS

Postby christian776 » Sun Mar 26, 2017 4:15 pm

Hi !

I'm a long time follower and this is my first post!. Since I'm running macOS I'm compiling from source and I've found an issue that breaks the shaders under macOS (Sierra). In particular this is is the issue that only happens in the new renderer at the SVN r528 since the introduction of textureSize in R3DShader.cpp

Code: Select all
christian@Christians-MacBook-Pro:~/Games/EMUS/Model3/model3emu-code/bin$ ./Supermodel /Users/christian/Games/EMUS/roms/model3/lamachin.zip -new3d
Supermodel: A Sega Model 3 Arcade Emulator (Version 0.3a-WIP)
Copyright 2011-2016 by Bart Trzynadlowski and Nik Henson

    Title:          L.A. Machineguns
    ROM Set:        lamachin
    Developer:      Sega
    Year:           1998
    Step:           2.1
    Extra Hardware: Security Board

Error: Fragment shader failed to compile. Your OpenGL driver said:
ERROR: 0:31: Invalid call of undeclared identifier 'textureSize'
ERROR: 0:32: Use of undeclared identifier 'scale'
ERROR: 0:33: Use of undeclared identifier 'tex2Data'

Error: Failed to link shader objects. Your OpenGL driver said:
ERROR: One or more attached shaders not successfully compiled


As a result the 3d scene looks bleached.
http://imgur.com/a/N9ZLS
christian776
 
Posts: 13
Joined: Sun Mar 26, 2017 2:04 pm

Re: Error: Fragment shader failed to compile in rev 528 in m

Postby Bart » Sun Mar 26, 2017 9:38 pm

I think I see what the problem is. The textureSize() function is implemented in GLSL 1.3 and higher (Ian even made a note of it).

Can you run "supermodel -print-gl-info" and paste the results here?
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Error: Fragment shader failed to compile in rev 528 in m

Postby Bart » Sun Mar 26, 2017 9:44 pm

Ian: there is a workaround mentioned here that would require checking the GLEW version. Problem is that I include the header file with Supermodel for convenience and I'm not sure how people would normally fetch it. The header file we have defines GLEW_VERSION_3_0.

According to that link the textureSize function is part of GLSL 1.3 / OpenGL 3.0 and Mac only supports GLSL 1.2 / GL 2.1 for now. I'm working on getting all platforms to GLSL 1.5 / GL 3.2 core profile but we're not there yet. See developer.blender.org/T49012

For now a hack like this might work. GLSL:

#if VERSION < 130
uniform vec2 textureSz;
vec2 textureSize(in unusedSampler) {
return textureSz;
}
#endif

Application code:
Make the node responsible for setting textureSz values if (not GLEW_VERSION_3_0).

Is textureSize called for only one texture or more than one? This hack assumes only one.
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Error: Fragment shader failed to compile in rev 528 in m

Postby Ian » Mon Mar 27, 2017 3:02 am

I was hoping this wouldn't be an issue ..
but it's simple enough to just pass the base texture size as a uniform
Ian
 
Posts: 1216
Joined: Tue Feb 23, 2016 9:23 am

Re: Error: Fragment shader failed to compile in rev 528 in m

Postby christian776 » Mon Mar 27, 2017 5:06 am

Hi !
I've came across the same posts googling around but I dont know much about the OpenGL pipeline as to fix it myself. Having said that this the output

Code: Select all
christian@Christians-MacBook-Pro:~/Games/EMUS/Model3/model3emu-code/bin$ ./Supermodel -print-gl-info
Supermodel: A Sega Model 3 Arcade Emulator (Version 0.3a-WIP)
Copyright 2011-2016 by Bart Trzynadlowski and Nik Henson

OpenGL information:

  Vendor                   : NVIDIA Corporation
  Renderer                 : NVIDIA GeForce GT 750M OpenGL Engine
  Version                  : 2.1 NVIDIA-10.14.20 355.10.05.15f03
  Shading Language Version : 1.20
  Maximum Vertex Array Size: 1048575 vertices
  Maximum Texture Size     : 16384 texels
  Maximum Vertex Attributes: 16
  Maximum Vertex Uniforms  : 4096
  Maximum Texture Img Units: 16
christian776
 
Posts: 13
Joined: Sun Mar 26, 2017 2:04 pm

Re: Error: Fragment shader failed to compile in rev 528 in m

Postby christian776 » Mon Mar 27, 2017 5:11 am

In case my previous post didn't work, here's again the output. Apparently it's something related to the OpenGL context being created in Core Profile, and SDL2 seems to be using the Compatibility Profile.

Code: Select all
christian@Christians-MacBook-Pro:~/Games/EMUS/Model3/model3emu-code/bin$ ./Supermodel -print-gl-info
Supermodel: A Sega Model 3 Arcade Emulator (Version 0.3a-WIP)
Copyright 2011-2016 by Bart Trzynadlowski and Nik Henson

OpenGL information:

  Vendor                   : NVIDIA Corporation
  Renderer                 : NVIDIA GeForce GT 750M OpenGL Engine
  Version                  : 2.1 NVIDIA-10.14.20 355.10.05.15f03
  Shading Language Version : 1.20
  Maximum Vertex Array Size: 1048575 vertices
  Maximum Texture Size     : 16384 texels
  Maximum Vertex Attributes: 16
  Maximum Vertex Uniforms  : 4096
  Maximum Texture Img Units: 16
christian776
 
Posts: 13
Joined: Sun Mar 26, 2017 2:04 pm

Re: Error: Fragment shader failed to compile in rev 528 in m

Postby Bart » Mon Mar 27, 2017 8:36 am

We don't use SDL2 yet. I should probably upgrade to that. I found this interesting discussion.

Christian, try the following: in Src/OSD/SDL/Main.cpp, in the CreateGLScreen() function (line 186), insert the following code right after the SDL_InitSubSystem() call:

Code: Select all
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);


You can experiment with the minor version as well and see if any of this helps. I'm curious to hear the results. If it does not appear to work, you may also try to insert it before the SDL_InitSubSystem() call, although I don't think that will be necessary.
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Error: Fragment shader failed to compile in rev 528 in m

Postby Ian » Mon Mar 27, 2017 8:58 am

I dont think OS X supports compatibility profiles .. although I could be wrong.
I am guessing he really is stuck at opengl 2.1
Ian
 
Posts: 1216
Joined: Tue Feb 23, 2016 9:23 am

Re: Error: Fragment shader failed to compile in rev 528 in m

Postby christian776 » Mon Mar 27, 2017 7:45 pm

Hey guys,

I understand the idea behind adding those two lines, that is forcing to use OpenGL 3.2 right ? So, I'm getting compilation errors if add those two

Code: Select all
Src/OSD/SDL/Main.cpp:179:24: error: use of undeclared identifier 'SDL_GL_CONTEXT_PROFILE_MASK'
  SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
                       ^
Src/OSD/SDL/Main.cpp:179:53: error: use of undeclared identifier 'SDL_GL_CONTEXT_PROFILE_CORE'
  SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
                                                    ^
Src/OSD/SDL/Main.cpp:180:23: error: use of undeclared identifier 'SDL_GL_CONTEXT_MAJOR_VERSION'
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
                      ^
Src/OSD/SDL/Main.cpp:181:23: error: use of undeclared identifier 'SDL_GL_CONTEXT_MINOR_VERSION'
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);


It kind of makes sense since according to the SDL Wiki these only work on SDL2 .. or am I wrong?

thanks for the feedback and good ideas :)
christian776
 
Posts: 13
Joined: Sun Mar 26, 2017 2:04 pm

Re: Error: Fragment shader failed to compile in rev 528 in m

Postby Bart » Mon Mar 27, 2017 9:06 pm

Yeah I guess we need to move to SDL2. I'll have to add that to the to-do list. It may take a while. The API changes should be negligible but I'm worried about the input system, which is quite complex! If there are any changes at all, it will delay the migration.

But even so, as Ian points out, SDL2 might not fix the issue. He may have to insert a workaround for systems stuck at GLSL 1.2.
User avatar
Bart
Site Admin
 
Posts: 2058
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Next

Return to The Fitting Room

Who is online

Users browsing this forum: No registered users and 2 guests