问题
I am trying to figure out what is the maximum number of varying vectors and uniforms I can use on a device that is OpenGL ES 2.0 compatible. I am trying to understand how MAX_VARYING_VECTORS works. So if MAX_VARYING_VECTORS is 8, does that mean I can store 8 * 4 bytes of data for varyings or does it mean that I can only define 8 varyings irrespective of the data type?
回答1:
MAX_VARYING_VECTORS is measured in units of 4-member float vectors (vec4). So with the minimum guaranteed value of 8, you can have 8 varyings of type vec4.
The rules on how exactly other types fit into this available space are fairly complex. For the example where MAX_VARYING_VECTORS is 8, the whole thing is treated as a 2D array of 8 rows and 4 columns. Space in this array is allocated to varyings in a certain order (which mostly goes from largest to smallest), and rules that depend on the size of the variable and the size/location of empty space still available in the array.
The exact rules fill about 2.5 pages in the GLSL ES 1.00 spec document. They are on pages 111-113. Copying the whole thing would not make a lot of sense, and I'm afraid that I can't turn it into something much simpler while still remaining accurate.
来源:https://stackoverflow.com/questions/29551458/max-varying-vectors-and-floats-for-gles-2-0