gl-renderer: Use compile-time annotation in vertex shader

Reuse fragment shader's compile-time annotation logic in vertex
shader for consistency.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit is contained in:
Loïc Molinari 2024-04-29 18:17:35 +02:00 committed by Daniel Stone
parent f7a14ba0e7
commit 22d9b9815f
1 changed files with 9 additions and 5 deletions

View File

@ -25,6 +25,9 @@
* SOFTWARE.
*/
/* For annotating shader compile-time constant arguments */
#define compile_const const
/* enum gl_shader_texcoord_input */
#define SHADER_TEXCOORD_INPUT_ATTRIB 0
#define SHADER_TEXCOORD_INPUT_SURFACE 1
@ -47,13 +50,14 @@ attribute vec2 texcoord;
/* Match the varying precision to the fragment shader */
varying FRAG_PRECISION vec2 v_texcoord;
compile_const int c_texcoord_input = DEF_TEXCOORD_INPUT;
void main()
{
gl_Position = proj * vec4(position, 0.0, 1.0);
#if DEF_TEXCOORD_INPUT == SHADER_TEXCOORD_INPUT_ATTRIB
v_texcoord = texcoord;
#elif DEF_TEXCOORD_INPUT == SHADER_TEXCOORD_INPUT_SURFACE
v_texcoord = vec2(surface_to_buffer * vec4(position, 0.0, 1.0));
#endif
if (c_texcoord_input == SHADER_TEXCOORD_INPUT_ATTRIB)
v_texcoord = texcoord;
else if (c_texcoord_input == SHADER_TEXCOORD_INPUT_SURFACE)
v_texcoord = vec2(surface_to_buffer * vec4(position, 0.0, 1.0));
}