gl-renderer: move vertex shader into new file

This patch adds the tooling for incorporating files as C data, so that
files can be built into the binaries. The tool is in Python to avoid
adding extra dependencies like xxd.

xxd.py is copied from Mesa as-is, from commit
b729cd58d76f97f3fc04a67569535ee5ef2f5278 (master branch on 2021-01-26),
a.k.a 21.0-branchpoint-635-gb729cd58d76.

Moving the GLSL vertex shader into a separate file is not that
interesting, the purpose of this commit is to provide a simple
demonstration of the tooling. The real benefits come in a following
patch where the fragment shaders are re-written and externalized.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen
2020-11-25 13:22:26 +02:00
parent 3ec25d7812
commit d913363394
5 changed files with 151 additions and 10 deletions
+2 -10
View File
@@ -32,16 +32,8 @@
#include "gl-renderer.h"
#include "gl-renderer-internal.h"
static const char vertex_shader[] =
"uniform mat4 proj;\n"
"attribute vec2 position;\n"
"attribute vec2 texcoord;\n"
"varying vec2 v_texcoord;\n"
"void main()\n"
"{\n"
" gl_Position = proj * vec4(position, 0.0, 1.0);\n"
" v_texcoord = texcoord;\n"
"}\n";
/* static const char vertex_shader[]; vertex.glsl */
#include "vertex-shader.h"
/* Declare common fragment shader uniforms */
#define FRAGMENT_CONVERT_YUV \
+8
View File
@@ -4,12 +4,20 @@ endif
config_h.set('ENABLE_EGL', '1')
vertex_glsl = custom_target(
'vertex-shader.h',
command: cmd_xxd + [ '-n', 'vertex_shader' ],
input: 'vertex.glsl',
output: 'vertex-shader.h',
)
srcs_renderer_gl = [
'egl-glue.c',
'gl-renderer.c',
'gl-shaders.c',
linux_dmabuf_unstable_v1_protocol_c,
linux_dmabuf_unstable_v1_server_protocol_h,
vertex_glsl,
]
deps_renderer_gl = [
+37
View File
@@ -0,0 +1,37 @@
/*
* Copyright 2012 Intel Corporation
* Copyright 2015,2019 Collabora, Ltd.
* Copyright 2016 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
uniform mat4 proj;
attribute vec2 position;
attribute vec2 texcoord;
varying vec2 v_texcoord;
void main()
{
gl_Position = proj * vec4(position, 0.0, 1.0);
v_texcoord = texcoord;
}