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

Shader subroutine support #201

Open
djeis97 opened this issue May 27, 2018 · 1 comment
Open

Shader subroutine support #201

djeis97 opened this issue May 27, 2018 · 1 comment

Comments

@djeis97
Copy link
Contributor

djeis97 commented May 27, 2018

Rather new glsl feature, but one that would be immensely useful.

https://www.khronos.org/opengl/wiki/Shader_Subroutine
http://www.lighthouse3d.com/tutorials/glsl-tutorial/subroutines/

Basic idea is that you can declare "subroutines" instead of functions and declare "subroutine uniforms" which can be called like functions in the shader. Then, when prepping to draw with the shader, you can assign subroutines to the subroutine uniforms in order to set the behavior of the shader.

Here's my instinct for the simplest way to make these usable:

  • provide a way to generate a glsl subroutine string from an external function, so existing external function infrastructure could mostly just be reused
  • add uniforms with function types which generate subroutine uniforms (along with some introspection API for detecting these)
  • add an argument to make-stage for the list of subroutines, since there's no way for varjo to detect which subroutines to include automatically.

That would let wrappers like CEPL or Shadow provide their own system for managing/integrating subroutines.

There's also this concept of "subroutine types", which are basically just abbreviations for a function signatures that both a subroutine and the corresponding subroutine uniform need to reference, but I'm thinking varjo could probably generate these automatically? Maybe make them from the uniforms and then include them on each subroutine which has a compatible type?

@djeis97
Copy link
Contributor Author

djeis97 commented May 27, 2018

Alternately, maybe the uniforms and subroutines should state the subroutine type explicitly, because I think having varjo be overeager assigning subroutine types will lead to glsl complaining about the potential for recursion if a subroutine tries to call another subroutine. Ofc, that means some consistency check would need to be made to ensure that the subroutine type is used properly...

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

No branches or pull requests

1 participant