Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1035] glslang support #1037

Closed
wants to merge 3 commits into from
Closed

Conversation

psi29a
Copy link
Contributor

@psi29a psi29a commented Nov 28, 2023

Pull Request Template

Description

Adds support for selecting use of system glslang (by default) or using cmake's FetchContent
glslang compilation support is now by default available

Fixes #1035

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Validated to work with system installed lib: Ubuntu and macOS (brew)
  • Validated with compiled from source via FetchContent

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@timoore
Copy link
Contributor

timoore commented Nov 28, 2023

Why does your commit remove VSG_SUPPORTS_ShaderCompiler? That's an important requirement for some use cases.

@psi29a
Copy link
Contributor Author

psi29a commented Nov 28, 2023

Why does your commit remove VSG_SUPPORTS_ShaderCompiler? That's an important requirement for some use cases.

Yeah, changing ABI out of the blue is bad, but look at this way, it's always on now, so no need test for its support.

@robertosfield what should the policy for deprecation be?

@timoore
Copy link
Contributor

timoore commented Nov 28, 2023

Why does your commit remove VSG_SUPPORTS_ShaderCompiler? That's an important requirement for some use cases.

Yeah, changing ABI out of the blue is bad, but look at this way, it's always on now, so no need test for its support.

My point is this: why do you think it should be deprecated, especially as part of a PR that does something else? Running VSG in an environment where there are only precompiled SPIRV files available should be supported.

@robertosfield
Copy link
Collaborator

A case of one step forward, ten steps back. This is an easy reject.

Forcing an update to a much later CMake version is something I really want to avoid unless we really have to. This change could break the build where the VSG compiles fine yet now. It's changes like this that could create a lot of work for us downstream.

The change for VSG_SUPPORTS_ShaderCompiler is really bad too. We still want to be able to compile the VSG without glslang. It's perfectly possible to use the VSG without glslang, it's just some usage cases that rely upon shader compilation.

I understand the desire to make things more flexible but this is huge step back in flexibility.

@@ -4,7 +4,7 @@ on:
pull_request:
env:
BuildDocEnabled: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
CMakeVersion: 3.10.x
CMakeVersion: 3.24.x
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do this, shouldn't you change the minimum version in CMakeLists.txt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can, yes.

@timoore
Copy link
Contributor

timoore commented Nov 28, 2023

Just a sidebar: I don't think a recent version of CMake is an onerous requirement. I just tried installing CMake on Ubuntu 22.04.2 using snap and it happily installed cmake v3.27. 8. The FetchContent support is better in 3.24 and directly supports using find_package as an alternative to downloading and building the content.

I also don't think that there's anything inherently wrong with building against a custom version of glslang, but I would prefer using FetchContent to pull it from your repo.

@robertosfield
Copy link
Collaborator

Any extra hurdle that folks need to jump has to be judged by the benefit it provides. Slightly better FetchContent support is not enough reason. find_package with glslang has been problematic in the past as well so it's a potentially reintroducing more problems than is solves. We have to be very careful about any of these changes. As I've said too often now, this is the far from the first time around trying to get glslang to work cleanly, trying stuff I've already tried and failed with is really not helpful at moving us forward.

@psi29a
Copy link
Contributor Author

psi29a commented Nov 28, 2023

Why reject? Just say what needs to change? :)

I would say that explicit is better than implicit, and that using a system lib should be preferred over pulling it in from source. So VSG_USE_SYSTEM_GLSLANG defaults to ON.

FetchContent works, it requires 3.17 however 3.24 has additional creature comforts that require less hacky cmake.

I believe the main concern was: VSG_SUPPORTS_ShaderCompiler

Sure, we can still keep this. This would imply that we allow compiling without glslang support which is fine as well.

Would adding the above back allow this PR to be reopened? :)

Right now, I'm on my private repo making sure all of CI compiles, there is some last bits on the android side that need fixing.

@robertosfield
Copy link
Collaborator

I tried FetchContent before I tried just pulling stuff in directly. I resorted to the solution we have because FetchContent and the other solutions I tried didn't work well enough in all the different situations that users use the VSG. How many times do I need to say the same thing? I've spent many days trying many different combinations of ways to get glslang to work well within the VSG.

I don't like having glslang built as part of the VSG, it's cludge to get around the fact that gslang was breaking build/runtime on too many different user systems.

The only thing that might change things is if the glslang project itself changes things - allow us to specify the version requirements easily and robustly without breaking when an older, problematic in various ways, version is available but not usable. If glslang starts behaving itself sufficiently as a standalone project then we can ditch the internal glslang completely and just use find_package().

@psi29a
Copy link
Contributor Author

psi29a commented Nov 29, 2023

If you'd prefer find_package, that's fine too as it works fine on macos and ubuntu. The odd one out would be windows I think.

What bothers me is that there is an implicit attempt to grab glslang and if it can't do that, it's ignored. It's a best effort attempt.

Can this go away?

Or do you still wish to do a best-effort attempt to fetch it if it's not found?

I'm asking because I'd prefer it to be an optional param that is off by default, as you said, some projects don't want it. Rather be explicit than implicit.

@robertosfield
Copy link
Collaborator

If the attempt to pill in glslang fails it very much isn't ignored.

The VSG sets #define about support for glslang in the automatically generated headers so it can be checked at compile time, as well as a function that enables a check at runtime. As Tim pointed out your PR actually broke this...

If the glslang project has fixed the problems that prevent using it via find_package then we may be able to ditch our internal build and just link to it as we do Vulkan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inability to compile vsg with gslang support in build environments without network access
3 participants