Author Topic: Shader versioning test  (Read 21241 times)

0 Members and 1 Guest are viewing this topic.

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Random observations from testing this:

-Apparently GL_ARB_texture_buffer_object isn't supported by the driver (I'm pretty sure that it actually is present, but not at the #version used; this is on a Radeon R9 285 using Catalyst 15.8)
-The lightshaft fragment shader uses the name "sample" for one of its temp variables, this is a keyword in glsl4 and will cause compilation issues.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Echelon9

  • Moderator
  • 210
Thanks for looking at this The E.
-Apparently GL_ARB_texture_buffer_object isn't supported by the driver (I'm pretty sure that it actually is present, but not at the #version used; this is on a Radeon R9 285 using Catalyst 15.8)

GL_ARB_texture_buffer_object is supported at OpenGL 3.1 / GLSL 1.40. Do you mind please sharing your fs2open.log for that particular hardware?

Quote
-The lightshaft fragment shader uses the name "sample" for one of its temp variables, this is a keyword in glsl4 and will cause compilation issues.

PR #419 has been created on Github to fix this. [Fix merged into master.] Thanks for the report!
« Last Edit: November 07, 2015, 06:50:37 am by Echelon9 »

 

Offline Echelon9

  • Moderator
  • 210
An idea I had floating in my mind was to have something called gr_is_capable() which would be some sort of function other parts of the code outside of the gr_screen specific code that would refer to when trying to figure out if a particular piece of code needed to be run or not.

gr_is_capable would accept a bunch of identifier constants like "CAPABILITY_DEFERED_LIGHTING", "CAPABILITY_ENV_MAPPING", "CAPABILITY_SOFT_PARTICLES", etc and would do all the work in determining if an end system is capable of a certain graphics feature.

Internally inside the gr_opengl code (and hypothetically the gr_vulkan code), we would have a table in the backend that lists all the pre-requisite extensions and shader versions needed for a particular graphics feature. So that way, the only code that needs to really know about extensions or a shader versions would be in the code that actually deals with OpenGL.

I agree with and like the sound of this approach. Flexibility when we get the opportunity to include a Vulkan renderer would be useful. I'll think some more about the table concept and how it could be implemented efficiently.

Quote
Echelon9's stuff seems to be a good step in the right direction.

Thanks! I'll run it through a few more local tests, and then setup a Github PR for wider code review.

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Did some further testing. Turns out that, at least for this particular hardware/driver combo, it is not necessary to enable GL_ARB_texture_buffer_object at all. Removing that line from the main vertex shader makes it compile cleanly.

The gl_init debug stuff:
Code: [Select]
Initializing OpenGL graphics device at 1280x800 with 32-bit color...
  Initializing WGL...
  Requested WGL Video values = R: 8, G: 8, B: 8, depth: 24, stencil: 8, double-buffer: 1
  Actual WGL Video values    = R: 8, G: 8, B: 8, depth: 24, stencil: 8, double-buffer: 1
  OpenGL Vendor    : ATI Technologies Inc.
  OpenGL Renderer  : AMD Radeon R9 200 Series
  OpenGL Version   : 4.5.13399 Compatibility Profile Context 15.201.1151.1007

  Using extension "GL_EXT_fog_coord".
  Using extension "GL_ARB_multitexture".
  Using extension "GL_ARB_texture_env_add".
  Using extension "GL_ARB_texture_compression".
  Using extension "GL_EXT_texture_compression_s3tc".
  Using extension "GL_EXT_texture_filter_anisotropic".
  Using extension "GL_ARB_texture_env_combine".
  Using extension "GL_EXT_compiled_vertex_array".
  Using extension "GL_EXT_draw_range_elements".
  Using extension "GL_ARB_texture_mirrored_repeat".
  Using extension "GL_ARB_texture_non_power_of_two".
  Using extension "GL_ARB_vertex_buffer_object".
  Using extension "GL_ARB_pixel_buffer_object".
  Using extension "GL_SGIS_generate_mipmap".
  Using extension "GL_EXT_framebuffer_object".
  Using extension "GL_ARB_texture_rectangle".
  Using extension "GL_EXT_bgra".
  Using extension "GL_ARB_texture_cube_map".
  Using extension "GL_EXT_texture_lod_bias".
  Using extension "GL_ARB_point_sprite".
  Using extension "GL_ARB_shading_language_100".
  Using extension "GL_ARB_shader_objects".
  Using extension "GL_ARB_vertex_shader".
  Using extension "GL_ARB_fragment_shader".
  Using extension "GL_ARB_shader_texture_lod".
  Using extension "GL_ARB_texture_float".
  Using extension "GL_ARB_draw_elements_base_vertex".
  Using extension "GL_EXT_framebuffer_blit".
  Using extension "GL_EXT_geometry_shader4".
  Using extension "GL_EXT_texture_array".
  Using extension "GL_ARB_uniform_buffer_object".
  Using extension "GL_EXT_transform_feedback".
  Using extension "GL_ARB_draw_instanced".
  Using extension "GL_ARB_texture_buffer_object".
  Found special extension function "wglSwapIntervalEXT".

Compiling new shader:
Particle Effects
   Loading built-in default shader for: effect-v.sdr
   Loading built-in default shader for: effect-particle-f.sdr
Shader Variant Features:
Compiling new shader:
Particle Effects
   Loading built-in default shader for: effect-v.sdr
   Loading built-in default shader for: effect-particle-f.sdr
   Loading built-in default shader for: effect-screen-g.sdr
Shader Variant Features:
Geometry shader point-based particles
Compiling new shader:
Distortion Effects
   Loading built-in default shader for: effect-distort-v.sdr
   Loading built-in default shader for: effect-distort-f.sdr
Shader Variant Features:
Compiling new shader:
Deferred Lighting
   Loading built-in default shader for: deferred-v.sdr
   Loading built-in default shader for: deferred-f.sdr
Shader Variant Features:
Compiling new shader:
Clear Deferred Lighting Buffer
   Loading built-in default shader for: deferred-clear-v.sdr
   Loading built-in default shader for: deferred-clear-f.sdr
Shader Variant Features:

Compiling new shader:
Post Processing
   Loading built-in default shader for: post-v.sdr
   Loading built-in default shader for: post-f.sdr
WARNING: Unable to get shader uniform location for "depth_tex"!
WARNING: Unable to get shader uniform location for "timer"!
Shader Variant Features:
Compiling new shader:
Bloom Brightpass
   Loading built-in default shader for: post-v.sdr
   Loading built-in default shader for: brightpass-f.sdr
Shader Variant Features:
Compiling new shader:
Gaussian Blur
   Loading built-in default shader for: post-v.sdr
   Loading built-in default shader for: blur-f.sdr
Shader Variant Features:
Horizontal blur pass
Compiling new shader:
Gaussian Blur
   Loading built-in default shader for: post-v.sdr
   Loading built-in default shader for: blur-f.sdr
Shader Variant Features:
Vertical blur pass
Compiling new shader:
FXAA
   Loading built-in default shader for: fxaa-v.sdr
   Loading built-in default shader for: fxaa-f.sdr
Shader Variant Features:
Compiling new shader:
FXAA Prepass
   Loading built-in default shader for: post-v.sdr
   Loading built-in default shader for: fxaapre-f.sdr
Shader Variant Features:
  Max texture units: 8 (32)
  Max client texture states: 8 (16)
  Max elements vertices: 2147483647
  Max elements indices: 16777215
  Max texture size: 16384x16384
  Max render buffer size: 16384x16384
  Can use compressed textures: YES
  Texture compression available: YES
  Post-processing enabled: YES
  Using trilinear texture filter.
  OpenGL Shader Version: 4.40
... OpenGL init is complete!

If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Talon 1024

  • 29
  • How do you turn this on?
    • Mods, Games, and Stuff
I've just tried compiling a build from the repo linked from this post, and I don't think shader compilation is working with my setup. Some ship models, as well as the starfield.pof, will not move from the mission origin point; some ship models don't appear at all; The only parts of the ship that moves from the origin point are glowpoints; black or white boxes appear around thruster FX; and debris pieces will randomly appear or disappear, depending on how close the camera is to said debris piece.

Stuff on Google Drive. Contains my fs2_open.log, glxinfo output, and some screenshots taken from the release build. I am unable to start playing if I use the debug build.
« Last Edit: November 08, 2015, 03:09:26 am by Talon 1024 »
To understand religion, you need to understand morality first. | WCSaga website | WCSaga Forum | 158th website | 158th forum | Project Leader: WC: Hostile Frontier | WCHF Thread at CIC | Wing Blender | Twist of Fate | Multipart turrets on angled surfaces, tutorial included. | My Google Drive stuff | To convert speeds from WC to WCS, multiply both the cruise speed and the Afterburner speed by 0.15625 (5/32)

FS2 Mods I'm waiting on: Inferno 10th Anniversary
Current Project: Contestant Android app, Learn4Life iOS app, Blender Commander (importer).
The FreeSpace Font Foundry is back in action!

 

Offline Echelon9

  • Moderator
  • 210
Did some further testing. Turns out that, at least for this particular hardware/driver combo, it is not necessary to enable GL_ARB_texture_buffer_object at all. Removing that line from the main vertex shader makes it compile cleanly.

The gl_init debug stuff:
Code: [Select]
<snip>

On review of the shader in globalincs/def_files.cpp it is a bit odd that we request GL_ARB_texture_buffer_object as an extension unconditionally, when there is core support as of OpenGL 3.1 - GLSL 1.40.

Perhaps we should wrap "#extension GL_ARB_texture_buffer_object : enable" in a #if __VERSION__ < 140?

 

Offline Echelon9

  • Moderator
  • 210
Stuff on Google Drive. Contains my fs2_open.log, glxinfo output, and some screenshots taken from the release build. I am unable to start playing if I use the debug build.

Thanks talon 1024, yes the shader compilation on NVIDIA's proprietary blob drivers is failing where we supply pre-GLSL 140 features and you have a modern GLSL 140+ card i.e.
Code: [Select]
  OpenGL Vendor    : NVIDIA Corporation
  OpenGL Renderer  : GeForce GTX 970/PCIe/SSE2
  OpenGL Version   : 4.5.0 NVIDIA 352.41
...
Compiling new shader:
Particle Effects
   Loading built-in default shader for: effect-v.sdr
   Loading built-in default shader for: effect-particle-f.sdr
Vertex shader failed to compile:
0(3) : warning C7555: 'attribute' is deprecated, use 'in/out' instead
0(9) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(10) : warning C7555: 'varying' is deprecated, use 'in/out' instead
0(24) : error C7616: global function ftransform is removed after version 140
0(25) : error C7616: global variable gl_ModelViewMatrix is removed after version 140
0(25) : error C7616: global variable gl_Vertex is removed after version 140
0(30) : error C7616: global variable gl_TexCoord is removed after version 140
0(30) : error C7616: global variable gl_MultiTexCoord0 is removed after version 140
0(31) : warning C7533: global variable gl_FrontColor is deprecated after version 120
0(31) : error C7616: global variable gl_Color is removed after version 140
0(32) : warning C7533: global variable gl_FrontSecondaryColor is deprecated after version 120
0(35) : error C7616: global variable gl_ClipVertex is removed after version 140

Given you presumably can play with a master release build, this refactor has identified some limitations with how scalable our shaders are at present.

 

Offline m!m

  • 211
Those issues are similar to what I encountered when trying to implement the driver blacklist. As we don't support any OpenGL version beyond 2.1 the biggest #version directive we can use is #version 120. The rest of the shader code then needs to be adjusted to only use features available in that language version. The features from OpenGL 3 could be available via extensions but I am not sure how that would work.

 

Offline Echelon9

  • Moderator
  • 210
Would talon and others on this thread re-test my PR branch here: https://github.com/scp-fs2open/fs2open.github.com/pull/425

I've removed the most problematic change, so hopeful this will aid merging the remaining valuable refactors.

 

Offline Talon 1024

  • 29
  • How do you turn this on?
    • Mods, Games, and Stuff
I don't appear to be having any problems with these builds. Here are some debug logs:

This one is from "A Game of TAG", and this one is from "A Lion at the Door"
To understand religion, you need to understand morality first. | WCSaga website | WCSaga Forum | 158th website | 158th forum | Project Leader: WC: Hostile Frontier | WCHF Thread at CIC | Wing Blender | Twist of Fate | Multipart turrets on angled surfaces, tutorial included. | My Google Drive stuff | To convert speeds from WC to WCS, multiply both the cruise speed and the Afterburner speed by 0.15625 (5/32)

FS2 Mods I'm waiting on: Inferno 10th Anniversary
Current Project: Contestant Android app, Learn4Life iOS app, Blender Commander (importer).
The FreeSpace Font Foundry is back in action!

 

Offline Echelon9

  • Moderator
  • 210
Thanks. A favourable report is great to hear (and expected given the reduced set of refactors now present in the PR).

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Actually, you do have problems. The FXAA shader failed to compile.

Code: [Select]
Compiling new shader:
FXAA
   Loading built-in default shader for: fxaa-v.sdr
   Loading built-in default shader for: fxaa-f.sdr
Fragment shader failed to compile:
0(201) : warning C7506: OpenGL does not define the global type float4
0(203) : warning C7506: OpenGL does not define the global type float2
0(204) : error C0000: syntax error, unexpected ',', expecting "::" at token ","
0(249) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(286) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(296) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(297) : warning C7506: OpenGL does not define the global function saturate
0(299) : error C0000: syntax error, unexpected '.', expecting "::" at token "."
0(302) : error C0000: syntax error, unexpected '.', expecting "::" at token "."
0(307) : error C0000: syntax error, unexpected '.', expecting "::" at token "."
0(310) : error C0000: syntax error, unexpected '.', expecting "::" at token "."
0(316) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(321) : error C0000: syntax error, unexpected "-=", expecting "::" at token "-="
0(325) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(328) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(495) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(509) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(520) : error C1121: main: function type parameters not allowed

ERROR! Unable to create fragment shader!
Error while compiling FXAA shaders. FXAA will be unavailable.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Echelon9

  • Moderator
  • 210
Actually, you do have problems. The FXAA shader failed to compile.

Code: [Select]
Compiling new shader:
FXAA
   Loading built-in default shader for: fxaa-v.sdr
   Loading built-in default shader for: fxaa-f.sdr
Fragment shader failed to compile:
0(201) : warning C7506: OpenGL does not define the global type float4
0(203) : warning C7506: OpenGL does not define the global type float2
0(204) : error C0000: syntax error, unexpected ',', expecting "::" at token ","
0(249) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(286) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(296) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(297) : warning C7506: OpenGL does not define the global function saturate
0(299) : error C0000: syntax error, unexpected '.', expecting "::" at token "."
0(302) : error C0000: syntax error, unexpected '.', expecting "::" at token "."
0(307) : error C0000: syntax error, unexpected '.', expecting "::" at token "."
0(310) : error C0000: syntax error, unexpected '.', expecting "::" at token "."
0(316) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(321) : error C0000: syntax error, unexpected "-=", expecting "::" at token "-="
0(325) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(328) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(495) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(509) : error C0000: syntax error, unexpected reserved word "if" at token "if"
0(520) : error C1121: main: function type parameters not allowed

ERROR! Unable to create fragment shader!
Error while compiling FXAA shaders. FXAA will be unavailable.

Thanks for testing. Can you please provide the section of the fs2open.log that includes the OpenGL renderer string (i.e. need to know what OS, graphics card, and driver).

 

Offline Talon 1024

  • 29
  • How do you turn this on?
    • Mods, Games, and Stuff
OS: Ubuntu Linux 15.10
Code: [Select]
OpenGL Vendor    : NVIDIA Corporation
OpenGL Renderer  : GeForce GTX 970/PCIe/SSE2
OpenGL Version   : 4.5.0 NVIDIA 352.63

BTW, the post above from The E was about the log that I had posted. FXAA is barely noticeable, so that's why I said I didn't appear to have any problems, despite the fact the FXAA shader failed to compile.
« Last Edit: November 26, 2015, 09:21:24 pm by Talon 1024 »
To understand religion, you need to understand morality first. | WCSaga website | WCSaga Forum | 158th website | 158th forum | Project Leader: WC: Hostile Frontier | WCHF Thread at CIC | Wing Blender | Twist of Fate | Multipart turrets on angled surfaces, tutorial included. | My Google Drive stuff | To convert speeds from WC to WCS, multiply both the cruise speed and the Afterburner speed by 0.15625 (5/32)

FS2 Mods I'm waiting on: Inferno 10th Anniversary
Current Project: Contestant Android app, Learn4Life iOS app, Blender Commander (importer).
The FreeSpace Font Foundry is back in action!

 
Results on Ubuntu 15.10, GPU 6650M, driver Catalyst and Mesa.
Looks ok on Catalyst (FXAA shader fails), on Mesa it crash if I try to go to Tech Room or F3 Lab.

[attachment DELETED!! by Strong Bad]

 

Offline Echelon9

  • Moderator
  • 210
Thanks for all the testing, and logs reported. Overall it is progressing well.

  • FXAA shader compile error with float4 - I think this is a separate bug, which is only reported now that we are tickling a different code path in the GLSL shader. Our FXAA shaders were translated from a joint OpenGL GLSL / DirectX HLSL shader. We are going down a code path that hits 'float4' which is not present in OpenGL GLSL (but is in DirectX HLSL)
  • Mesa shader compiler errors with mat3 - Reported as "cannot construct `mat3' from a matrix in GLSL 1.10 (GLSL 1.20 or GLSL ES 1.00 required)". This is a known issue with our (lack) of using the GLSL #version command. It is being tracked in GitHub Issue #235.

[UPDATE]  To resolve the FXAA shader compile error, I've pushed a further commit to my testing branch. Lift up FXAA shader GLSL version check to opengl_post_load_shader(), out of the GLSL shader compiler preprocessor stage. Could those who saw this issue please retest?
« Last Edit: November 28, 2015, 12:31:30 am by Echelon9 »

 
Yep, FXAA works.

[attachment DELETED!! by Strong Bad]

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
The lightshaft post process fragment shader uses "sample" as a variable name, this needs to be fixed too.

Code: [Select]
Compiling new shader:
Lightshafts
   Loading built-in default shader for: post-v.sdr
   Loading built-in default shader for: ls-f.sdr
Fragment shader failed to compile:
Fragment shader failed to compile with the following errors:
ERROR: 0:26: error(#132) Syntax error: "sample" parse error
ERROR: error(#273) 1 compilation errors.  No code generated


ERROR! Unable to create fragment shader!
ASSERTION: "handle >= 0" at gropenglshader.cpp:214
Freeing all existing models...
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Echelon9

  • Moderator
  • 210
Thanks for the lightshaft GLSL shader 'sample' error report.

The incorrect use of reserved keyword 'sample' was fixed in this commit, so perhaps you need to refresh your local checkout of my PR?

Overall, this refactor is looking promising given positive feedback from a broad range of testers (and it's an added bonus where it is uncovering some other long latent bugs in our shaders).
« Last Edit: December 02, 2015, 12:01:07 am by Echelon9 »

 

Offline Talon 1024

  • 29
  • How do you turn this on?
    • Mods, Games, and Stuff
I just compiled and tested a brand new build from the latest revision of the GitHub repo, and I am getting no shader compilation errors on my 64-bit Ubuntu 15.10 setup with an NVidia GeForce GTX 970.
To understand religion, you need to understand morality first. | WCSaga website | WCSaga Forum | 158th website | 158th forum | Project Leader: WC: Hostile Frontier | WCHF Thread at CIC | Wing Blender | Twist of Fate | Multipart turrets on angled surfaces, tutorial included. | My Google Drive stuff | To convert speeds from WC to WCS, multiply both the cruise speed and the Afterburner speed by 0.15625 (5/32)

FS2 Mods I'm waiting on: Inferno 10th Anniversary
Current Project: Contestant Android app, Learn4Life iOS app, Blender Commander (importer).
The FreeSpace Font Foundry is back in action!