Speed of cos() and sin() function in GLSL shaders?

前端 未结 6 1936
别那么骄傲
别那么骄傲 2021-01-17 10:51

I\'m interested in information about the speed of sin() and cos() in Open GL Shader Language.

The GLSL Specification Document indi

6条回答
  •  误落风尘
    2021-01-17 11:33

    You'd have to test this out yourself, but I'm pretty sure that branching in a shader is far more expensive than a sin or cos calculation. GLSL compilers are pretty good about optimizing shaders, worrying about this is premature optimization. If you later find that, through your entire program, your shaders are the bottleneck, then you can worry about optimizing this.

    If you want to take a look at the assembly code of your shader for a specific platform, I would recommend AMD GPU ShaderAnalyzer.

提交回复
热议问题