Add fragment and vertex snippet hooks for global declarations
This adds hook points to add global function and variable declarations to either the fragment or vertex shader. The declarations can then be used by subsequent snippets. Only the ‘declarations’ string of the snippet is used and the code is directly put in the global scope near the top of the shader. The reason this is necessary rather than just adding a normal snippet with the declarations is that for the other hooks Cogl assumes that the snippets are independent of each other. That means if a snippet has a replace string then it will assume that it doesn't even need to generate the code for earlier hooks which means the global declarations would be lost. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit ebb82d5b0bc30487b7101dc66b769160b40f92ca)
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2011 Intel Corporation.
|
||||
* Copyright (C) 2011, 2013 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -312,6 +312,12 @@ typedef struct _CoglSnippet CoglSnippet;
|
||||
to within a pipeline. */
|
||||
/**
|
||||
* CoglSnippetHook:
|
||||
* @COGL_SNIPPET_HOOK_VERTEX_GLOBALS: A hook for declaring global data
|
||||
* that can be shared with all other snippets that are on a vertex
|
||||
* hook.
|
||||
* @COGL_SNIPPET_HOOK_FRAGMENT_GLOBALS: A hook for declaring global
|
||||
* data wthat can be shared with all other snippets that are on a
|
||||
* fragment hook.
|
||||
* @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.
|
||||
@ -330,6 +336,30 @@ typedef struct _CoglSnippet CoglSnippet;
|
||||
*
|
||||
* <glosslist>
|
||||
* <glossentry>
|
||||
* <glossterm>%COGL_SNIPPET_HOOK_VERTEX_GLOBALS</glossterm>
|
||||
* <glossdef>
|
||||
* <para>
|
||||
* Adds a shader snippet at the beginning of the global section of the
|
||||
* shader for the vertex processing. Any declarations here can be
|
||||
* shared with all other snippets that are attached to a vertex hook.
|
||||
* Only the ‘declarations’ string is used and the other strings are
|
||||
* ignored.
|
||||
* </para>
|
||||
* </glossdef>
|
||||
* </glossentry>
|
||||
* <glossentry>
|
||||
* <glossterm>%COGL_SNIPPET_HOOK_FRAGMENT_GLOBALS</glossterm>
|
||||
* <glossdef>
|
||||
* <para>
|
||||
* Adds a shader snippet at the beginning of the global section of the
|
||||
* shader for the fragment processing. Any declarations here can be
|
||||
* shared with all other snippets that are attached to a fragment
|
||||
* hook. Only the ‘declarations’ string is used and the other strings
|
||||
* are ignored.
|
||||
* </para>
|
||||
* </glossdef>
|
||||
* </glossentry>
|
||||
* <glossentry>
|
||||
* <glossterm>%COGL_SNIPPET_HOOK_VERTEX</glossterm>
|
||||
* <glossdef>
|
||||
* <para>
|
||||
@ -552,9 +582,11 @@ typedef enum {
|
||||
/* Per pipeline vertex hooks */
|
||||
COGL_SNIPPET_HOOK_VERTEX = 0,
|
||||
COGL_SNIPPET_HOOK_VERTEX_TRANSFORM,
|
||||
COGL_SNIPPET_HOOK_VERTEX_GLOBALS,
|
||||
|
||||
/* Per pipeline fragment hooks */
|
||||
COGL_SNIPPET_HOOK_FRAGMENT = 2048,
|
||||
COGL_SNIPPET_HOOK_FRAGMENT_GLOBALS,
|
||||
|
||||
/* Per layer vertex hooks */
|
||||
COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM = 4096,
|
||||
|
Reference in New Issue
Block a user