Declaring constants instead of literals in vertex shader. Standard practice, or needless rigor?

前端 未结 2 583
谎友^
谎友^ 2021-01-13 06:45

In a vertex shader, there is of course a limited amount of uniform storage allowed, and it is my understanding that different systems may i

2条回答
  •  感情败类
    2021-01-13 07:16

    Regarding Kimi's mention about not finding anything in the spec, Appendix A-7 of The OpenGL® ES Shading Language spec does include the following:

    When calculating the number of uniform variables used, any literal constants present in the shader source after preprocessing are included when calculating the storage requirements. Multiple instances of identical constants should count multiple times.

    This is probably the source of the recommendation in OpenGL® ES 2.0 Programming Guide that Kimi quotes.

    However, the spec does not mandate this restriction, and presumably any implementation is free to improve on it, but I cannot find anything either way regarding the iOS GL drivers.

    I'm curious, did anyone actually follow up on the ideas of overloading a sample shader with literals, in an attempt to reach any potential maximum uniform limit?

    (Sorry...I had intended to post this answer as a comment to Kimi's answer, but don't have the required 50 Rep points yet).

提交回复
热议问题