pezcode / Cluster

Clustered shading implementation with bgfx
MIT License
427 stars 28 forks source link

Cannot build on Ubuntu due to linking errors #10

Closed alexpanter closed 2 years ago

alexpanter commented 2 years ago

Hi, Are there any known compatibility issues with compiling through cmake on ubuntu 21? I'm getting a lot of linking errors:

[ 69%] Linking CXX executable shaderc
/usr/bin/ld: libspirv-tools.a(pass.cpp.o): in function `spvtools::opt::IRContext::AddCapability(SpvCapability_)':
pass.cpp:(.text._ZN8spvtools3opt9IRContext13AddCapabilityE14SpvCapability_[_ZN8spvtools3opt9IRContext13AddCapabilityE14SpvCapability_]+0x306): undefined reference to `spvtools::opt::FeatureManager::AddCapability(SpvCapability_)'
/usr/bin/ld: pass.cpp:(.text._ZN8spvtools3opt9IRContext13AddCapabilityE14SpvCapability_[_ZN8spvtools3opt9IRContext13AddCapabilityE14SpvCapability_]+0x4ac): undefined reference to `spvtools::opt::FeatureManager::Analyze(spvtools::opt::Module*)'
/usr/bin/ld: libspirv-tools.a(private_to_local_pass.cpp.o): in function `spvtools::opt::PrivateToLocalPass::Process()':
private_to_local_pass.cpp:(.text+0x3914): undefined reference to `spvtools::opt::FeatureManager::Analyze(spvtools::opt::Module*)'
/usr/bin/ld: libspirv-tools.a(relax_float_ops_pass.cpp.o): in function `spvtools::opt::IRContext::AnalyzeFeatures()':
relax_float_ops_pass.cpp:(.text._ZN8spvtools3opt9IRContext15AnalyzeFeaturesEv[_ZN8spvtools3opt9IRContext15AnalyzeFeaturesEv]+0xd9): undefined reference to `spvtools::opt::FeatureManager::Analyze(spvtools::opt::Module*)'

[...]

I have spirv-tools installed, and have also used the machine for compiling both OpenGL and Vulkan applications. So I should have all the essentials. Any tips on what might be going wrong? :)

clibequilibrium commented 2 years ago

@alexpanter you might try to bump bgfx.cmake version to the latest. You will have to change couple lines of code as _BGFX_DISCARD_TEXTURESAMPLERS changed to _BGFX_DISCARDBINDINGS

pezcode commented 2 years ago

That's odd since bgfx uses a bundled spirv-tools that it compiles itself. I don't have access to a Linux machine for the next two weeks, so I'm afraid I can't help you debug this for the time being.

Upgrading bgfx.cmake as @clibequilibrium suggested may help, but it's likely that the shaders also need changes. At some point I should upgrade those dependencies :eyes:

alexpanter commented 2 years ago

I tried this on another linux machine, also with ubuntu 21, and it worked fine. So something's likely wrong with the machine. Looks good.

But my desktop GPU (NVIDIA Geforce GTX 680, 2GB RAM) isn't too happy about it - 11ms render time for 1000 lights doesn't sound too good, maybe the computer is just too old? (bought in 2011). At least from what I can tell by looking at Jeremiah van Oosten's presentation that shouldn't be too much.

pezcode commented 2 years ago

Glad you got it working 🙌

As for performance... this isn't quite as optimized as it could be 🤠 It's a hobby project that largely emphasizes readability over performance, and van Oosten's implementation has some significant changes. Most importantly, he culls lights against the camera frustum with a BVH before sorting them into clusters, avoiding a bunch of work.

I could add this kind of stuff, but it's not all that interesting to me, and I'm finding it hard to find the free time these days.

Since the original issue seems to be gone, I'll close this issue. Feel free to re-open if any Ubuntu issues are left.