Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Getting invisible menus on Linux / Radeon RX480 / Mesa 18.1.3 because of shader compilation error:

Error compiling fragment shader: src/shaders/text_frag.glsl
0:15(33): error: sampler arrays indexed with non-constant expressions are forbidden in GLSL 1.30 and later

(1 edit)

Well this one of the more bizarre errors I've seen. I thought it might be a driver issue but the version of GLSL I'm using is archaic even by open-source standards. I have an idea on how to get around it but for now try just changing the first line in src/shaders/text_frag.glsl and src/shaders/text_vert.glsl to #version 400 and see if it clears up, let me know if it does as that will be a lot neater than what I have in mind on my end.

Yes, this seems to fix it. The rest of the game also seems to work fine without issues, though I'm seeing some minor glitches in the menu button borders.


Also, I tried testing the game on some other (older) systems, but the game refuses to launch, producing the error: Illegal hardware instruction (core dumped).

(2 edits)

I've seen this happening on another computer, I'm pretty sure it's actually a related problem. Apparently the way I've been doing quick 2D rendering isn't actually possible on newer hardware without artifacting so I'm going to have to refactor my system for that slightly. For now I'm uploading some different shaders that should work better (albeit at 1/8th the speed), should be done in about half an hour.

As for illegal hardware instruction errors, that would be from the instruction set I've compiled with, CPUs made before 2011 are pretty much guaranteed to not work. Frankly this is something I'm open to spending time on as I would like older hardware to be able to run the game, it's just hard to find a good set of compiler flags to build with.

EDIT: Also the game is 64-bit only, I could build for 32 bit as well but I haven't tried up to this point. I might make a point of that for next Demo Day.

(1 edit) (+1)

I ran into this exact GLSL issue a few months back. Excuse the plug, but I wrote up my solution here, if you want something that's backwards compatible: https://coaldev.tumblr.com/post/170129777035/preprocessing-glsl-shaders

Since you're using C++, you may have an easier time implementing this.

I haven't done the replacement trick for now, though I was doing something similar in the LibGDX build and will eventually here again to consolidate constants between shaders and game code. Your write-up did help me get to a solution with macros for hardcoding array-access and branching to stick to a single sampler call each pass. I'm happy with that for now, I just need to check that it resolves the corruption issue in korpiroot's screenshot. It doesn't happen on any of my machines but I did see it on my roommate's computer so I can check on that.