Is there anything similar to UberShader in CUDA? or is there any good solution in CUDA?

is there anything similar to UberShader in CUDA? or is there any good solution in CUDA?
https://www.gamedev.net/forums/topic/659145-what-is-a-uber-shader/

From that link:

Frequently when people refer to an ubershader they’re referring to one large shader that’s compiled many times with different defines for different features.

Yes, you can write CUDA code that way. Whether you would want to is perhaps a matter of debate.

A C++ method to do this would be template metaprogramming .

1 Like

Shader Cache - CRYENGINE Programming - Documentation

how about shader cahce?
https://forums.developer.nvidia.com/t/is-there-anything-similar-to-shadercache-in-cuda/267876

That kind of caching only applies to JIT compilation. When you use JIT compilation with CUDA it does deposit the generated machine code in a cache. Have you had a chance to read this developer blog post:

You have asked a number of questions now that inquire about CUDA equivalents to concepts from the graphics world. In my experience, approaching programming language X using concepts from programming language Y leads to suboptimal results, and the resulting code is often hard to maintain, as it is not idiomatic X code, and thus difficult for X programmers to understand.

If guidance is needed, it is best to consult examples by competent programmers in language X to see idiomatic ways of addressing particular use cases.

In general, I would recommend to use machine code generated with the CUDA off-line compiler, and stuff that into fat binaries that cover all relevant GPU target architectures. Use JIT compilation only where it is truly necessary, e.g. where code needs to be generated on-the-fly based on interactive user input.

1 Like