After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 662184 - Pipeline shaders often fail to link on GLES2 because of different n_tex_coord_attribs
Pipeline shaders often fail to link on GLES2 because of different n_tex_coord...
Status: RESOLVED FIXED
Product: cogl
Classification: Platform
Component: CoglPipeline
unspecified
Other All
: Normal normal
: ---
Assigned To: Cogl maintainer(s)
Cogl maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2011-10-19 12:36 UTC by Neil Roberts
Modified: 2011-11-02 13:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test-just-vertex-shader: Sample a texture in the fragment pipeline (4.64 KB, patch)
2011-10-19 12:36 UTC, Neil Roberts
none Details | Review
Use the same number for n_tex_coord_attribs in all linked shaders (14.39 KB, patch)
2011-10-19 12:36 UTC, Neil Roberts
none Details | Review

Description Neil Roberts 2011-10-19 12:36:15 UTC
Cogl generates the boiler plate for shaders on GLES2 and it needs to
pick a size for the texture coord arrays. However it can end up
picking different numbers for the shaders and then it will fail when
it tries to link them together. Attached is a patch for
test-just-vertex-shader which demonstrates the problem. It also
affects test-pick and test-shader-effect in the Clutter test suite.
Comment 1 Neil Roberts 2011-10-19 12:36:17 UTC
Created attachment 199427 [details] [review]
test-just-vertex-shader: Sample a texture in the fragment pipeline

Previously the layer combine on the test pipeline was set up to
replace the incoming color with the layer constant. This patch changes
it to sample the replacement color from a 1x1 texture instead. This
exposes a bug on the GLES2 backend where the vertex shader will be
generated with a size for cogl_tex_coord_out of 4 but the
corresponding declaration in the fragment shader will have n_layers,
which is 1. This makes the program fail to link and the test fails.
Comment 2 Neil Roberts 2011-10-19 12:36:19 UTC
Created attachment 199428 [details] [review]
Use the same number for n_tex_coord_attribs in all linked shaders

On GLES2, we need to specify an array size for the texture coord
varying array. Previously this size would be decided in one of the
following ways:

- For generated vertex shaders it is always the number of layers in
  the pipeline.

- For generated fragment shaders it is the highest sampled texture
  unit in the pipeline or the number of attributes supplied by the
  primitive, whichever is higher.

- For user shaders it is usually the number of attributes supplied by
  the primitive. However, if the application tries to compile the
  shader and query the result before using it, it will always be at
  least 4.

These shaders can quite easily end up with different values for the
declaration which makes it fail to link. This patch changes it so that
all of the shaders are generated with the maximum of the number of
texture attributes supplied by the primitive and the number of layers
in the pipeline. If this value changes then the shaders are
regenerated, including user shaders. That way all of the shaders will
always have the same value.
Comment 3 Neil Roberts 2011-11-02 13:54:45 UTC
I've pushed the two patches to master as 757916f..00f0a66 and the main patch to the cogl-1.8 branch as 521b39c