MaT
MaT

Reputation: 1606

Shader - Performance and functions

I am creating vertex and fragment shaders and I would like to know if using functions inside my shader, for better readability, could have an impact on performance and optimisation.

Upvotes: 2

Views: 981

Answers (1)

Emilian Cioca
Emilian Cioca

Reputation: 91

When considering the job of a compiler to optimize code, shaders provide some of the most ideal circumstances. They don't link to other files or libraries, the data-in/data-out is strictly defined and the language itself is limited. This allows your graphics drivers to very aggressively optimize your shader code.

Functions written in a shader will be compiled as though they were inline. So you don't have to worry about those either. It's definitely worth your time to keep the code readable and user friendly. The compiler will take care of the rest.

Upvotes: 5

Related Questions