snes9xgit / snes9x

Snes9x - Portable Super Nintendo Entertainment System (TM) emulator
http://www.snes9x.com
Other
2.66k stars 460 forks source link

Can't build slang shaders despite development libraries being installed #568

Closed jstolarek closed 5 years ago

jstolarek commented 5 years ago

I can't build glslang shaders on Debian Buster despite having glslang-dev library on my system. Here's a build log:

$ meson build --buildtype=release --strip
The Meson build system
Version: 0.49.2
Source dir: /dane/projekty/snes9x/gtk
Build dir: /dane/projekty/snes9x/gtk/build
Build type: native build
Project name: snes9x-gtk
Project version: 1.60
Native C compiler: cc (gcc 8.3.0 "cc (Debian 8.3.0-6) 8.3.0")
Native C++ compiler: c++ (gcc 8.3.0 "c++ (Debian 8.3.0-6) 8.3.0")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (0.29)
Dependency glib-2.0 found: YES 2.58.3
Dependency gthread-2.0 found: YES 2.58.3
Dependency gobject-2.0 found: YES 2.58.3
Dependency sdl2 found: YES 2.0.9
Message: Building with GTK+-2.0
Dependency gtk+-2.0 found: YES 2.24.32
Library X11 found: YES
Library Xext found: YES
Library dl found: YES
Dependency xrandr found: YES 1.5.1
Dependency epoxy found: YES 1.5.3
Library glslang found: YES
Library SPIRV found: YES
Library OSDependent found: YES
Library OGLCompiler found: YES
Library SPVRemapper found: YES
Library glslang-default-resource-limits found: NO
Dependency xv found: YES 1.0.11
Dependency alsa found: YES 1.1.8
Dependency libpulse found: YES 12.2
Dependency libpng found: YES 1.6.36
Dependency minizip found: YES 1.2.8
Dependency zlib found: YES 1.2.11
Checking for function "mkstemp" : YES
Has header "strings.h" : YES
Has header "stdint.h" : YES
Message: Snes9x GTK+ Build Configuration
[Locations] prefix:            /usr/local
            datadir:           share
            appdatadir:        /usr/local/share/snes9x
            localedir:         /usr/local/share/locale
[Options]   Build type:        release
            GTK+ version:      2
            Wayland:           false
            OpenGL:            true
             slang shaders:    false
            XVideo:            true
            ALSA:              true
            Open Sound System: false
            PulseAudio:        true
            PortAudio:         false
            HQ2X filter:       true
            xBRZ filter:       true
            Screenshot saving: true
            zlib compression:  true
            System minizip:    true
glslang libraries not found. Slang shaders will be disabled.
Build targets in project: 7
Found ninja-1.8.2 at /usr/bin/ninja

As you can see there's a line that says Library glslang-default-resource-limits found: NO. Perhaps I am barking at the wrong tree here, but there seems to be no Debian package that provides glslang-default-resource-limits library. glslang in Debian is currently at version 7.10 - is this missing library something that was added in a newer version? If so, then I suggest updating build instructions to list the minimal required version of glslang required to build the shaders.

bearoso commented 5 years ago

No, that library should be included in version 7.10, too. I just tested it by compiling the tag from glslang's git and doing a dummy install. Debian must not be installing that library for some reason.

I can't include just the structure manually because it changes from version to version and the library is linked to it and there would be a mismatch. I'd rather not include the whole glslang package statically.

bearoso commented 5 years ago

OK, should be fixed now. Debian isn't providing shared libraries and glslang includes the resource limits objects in the glslang.a archive when building statically.

jstolarek commented 5 years ago

Nope, I just pulled (I'm at 673896f) and I'm still seeing the same problem.

bearoso commented 5 years ago

Should be fixed now.

jstolarek commented 5 years ago

meson now says:

....
Library glslang-default-resource-limits found: NO
...
            OpenGL:            true
             slang shaders:    true
...
glslang-default-resource-limits not found. Assuming it is linked statically into glslang.

Compilation ends with an error:

(.text+0x86a9): undefined reference to `glslang::TBuiltInParseablesHlsl::TBuiltInParseablesHlsl()'
/usr/bin/ld: snes9x-gtk@exe/.._shaders_slang.cpp.o: in function `GLSLShader::slang_compile(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
slang.cpp:(.text+0x3e6e): undefined reference to `glslang::DefaultTBuiltInResource'
/usr/bin/ld: slang.cpp:(.text+0x3ea3): undefined reference to `glslang::DefaultTBuiltInResource'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
bearoso commented 5 years ago

That's not going to work, then. It'll have to use the shared libraries.

jstolarek commented 5 years ago

Does that mean this classifies as "wont fix" under Debian?

bearoso commented 5 years ago

For now, yes. I recommend just building the shared glslang libraries manually and installing them. cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=true with the glslang build system will do it.

bearoso commented 5 years ago

I went ahead and added back the built-in default resources. This broke version compatibility before, so I don't know if there's still any problems.

jstolarek commented 5 years ago

I did a build on 491f57ca and 2971fbb. Both work, i.e. meson detects the shaders and ninja builds without errors. The only difference is that on 491f57ca there's this extra meson check for glslang-default-resource-limits. Thanks!

Is there a guide for dummies on how to use shaders? Somehow I expected that if shaders build successfully they will be available out of the box, but that does not seem to be the case - or at least I don't see any new menu options available or any new files being installed in the system.

bearoso commented 5 years ago

They're available here: https://github.com/libretro/slang-shaders You select a .slangp profile and configure it through the View->Shader Parameters dialog.

jstolarek commented 5 years ago

Ok, now everything works - thanks!