Add support for per-vertex point sizes
This adds a new function to enable per-vertex point size on a pipeline. This can be set with cogl_pipeline_set_per_vertex_point_size(). Once enabled the point size can be set either by drawing with an attribute named 'cogl_point_size_in' or by writing to the 'cogl_point_size_out' builtin from a snippet. There is a feature flag which must be checked for before using per-vertex point sizes. This will only be set on GL >= 2.0 or on GLES 2.0. GL will only let you set a per-vertex point size from GLSL by writing to gl_PointSize. This is only available in GL2 and not in the older GLSL extensions. The per-vertex point size has its own pipeline state flag so that it can be part of the state that affects vertex shader generation. Having to enable the per vertex point size with a separate function is a bit awkward. Ideally it would work like the color attribute where you can just set it for every vertex in your primitive with cogl_pipeline_set_color or set it per-vertex by just using the attribute. This is harder to get working with the point size because we need to generate a different vertex shader depending on what attributes are bound. I think if we wanted to make this work transparently we would still want to internally have a pipeline property describing whether the shader was generated with per-vertex support so that it would work with the shader cache correctly. Potentially we could make the per-vertex property internal and automatically make a weak pipeline whenever the attribute is bound. However we would then also need to automatically detect when an application is writing to cogl_point_size_out from a snippet. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit 8495d9c1c15ce389885a9356d965eabd97758115) Conflicts: cogl/cogl-context.c cogl/cogl-pipeline-private.h cogl/cogl-pipeline.c cogl/cogl-private.h cogl/driver/gl/cogl-pipeline-progend-fixed.c cogl/driver/gl/gl/cogl-pipeline-progend-fixed-arbfp.c
This commit is contained in:
@ -203,6 +203,16 @@ COGL_BEGIN_DECLS
|
||||
* </glossentry>
|
||||
* <glossentry>
|
||||
* <glossterm>float
|
||||
* <emphasis>cogl_point_size_in</emphasis></glossterm>
|
||||
* <glossdef><para>
|
||||
* The incoming point size from the cogl_point_size_in attribute.
|
||||
* This is only available if
|
||||
* cogl_pipeline_set_per_vertex_point_size() is set on the
|
||||
* pipeline.
|
||||
* </para></glossdef>
|
||||
* </glossentry>
|
||||
* <glossentry>
|
||||
* <glossterm>float
|
||||
* <emphasis>cogl_point_size_out</emphasis></glossterm>
|
||||
* <glossdef><para>
|
||||
* The calculated size of a point. This is equivalent to #gl_PointSize.
|
||||
@ -321,6 +331,10 @@ typedef struct _CoglSnippet CoglSnippet;
|
||||
* @COGL_SNIPPET_HOOK_VERTEX: A hook for the entire vertex processing
|
||||
* stage of the pipeline.
|
||||
* @COGL_SNIPPET_HOOK_VERTEX_TRANSFORM: A hook for the vertex transformation.
|
||||
* @COGL_SNIPPET_HOOK_POINT_SIZE: A hook for manipulating the point
|
||||
* size of a vertex. This is only used if
|
||||
* cogl_pipeline_set_per_vertex_point_size() is enabled on the
|
||||
* pipeline.
|
||||
* @COGL_SNIPPET_HOOK_FRAGMENT: A hook for the entire fragment
|
||||
* processing stage of the pipeline.
|
||||
* @COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM: A hook for applying the
|
||||
@ -422,6 +436,39 @@ typedef struct _CoglSnippet CoglSnippet;
|
||||
* </glossdef>
|
||||
* </glossentry>
|
||||
* <glossentry>
|
||||
* <glossterm>%COGL_SNIPPET_HOOK_POINT_SIZE</glossterm>
|
||||
* <glossdef>
|
||||
* <para>
|
||||
* Adds a shader snippet that will hook on to the point size
|
||||
* calculation step within the vertex shader stage. The snippet should
|
||||
* write to the builtin cogl_point_size_out with the new point size.
|
||||
* The snippet can either read cogl_point_size_in directly and write a
|
||||
* new value or first read an existing value in cogl_point_size_out
|
||||
* that would be set by a previous snippet. Note that this hook is
|
||||
* only used if cogl_pipeline_set_per_vertex_point_size() is enabled
|
||||
* on the pipeline.
|
||||
* </para>
|
||||
* <para>
|
||||
* The ‘declarations’ string in @snippet will be inserted in the
|
||||
* global scope of the shader. Use this to declare any uniforms,
|
||||
* attributes or functions that the snippet requires.
|
||||
* </para>
|
||||
* <para>
|
||||
* The ‘pre’ string in @snippet will be inserted just before
|
||||
* calculating the point size.
|
||||
* </para>
|
||||
* <para>
|
||||
* The ‘replace’ string in @snippet will be used instead of the
|
||||
* generated point size calculation if it is present.
|
||||
* </para>
|
||||
* <para>
|
||||
* The ‘post’ string in @snippet will be inserted after the
|
||||
* standard point size calculation is done. This can be used to modify
|
||||
* cogl_point_size_out in addition to the default processing.
|
||||
* </para>
|
||||
* </glossdef>
|
||||
* </glossentry>
|
||||
* <glossentry>
|
||||
* <glossterm>%COGL_SNIPPET_HOOK_FRAGMENT</glossterm>
|
||||
* <glossdef>
|
||||
* <para>
|
||||
@ -583,6 +630,7 @@ typedef enum {
|
||||
COGL_SNIPPET_HOOK_VERTEX = 0,
|
||||
COGL_SNIPPET_HOOK_VERTEX_TRANSFORM,
|
||||
COGL_SNIPPET_HOOK_VERTEX_GLOBALS,
|
||||
COGL_SNIPPET_HOOK_POINT_SIZE,
|
||||
|
||||
/* Per pipeline fragment hooks */
|
||||
COGL_SNIPPET_HOOK_FRAGMENT = 2048,
|
||||
|
Reference in New Issue
Block a user