[client] egl: remove the rest of the shaders into seperate files

This commit is contained in:
Geoffrey McRae 2019-03-28 15:53:15 +11:00
parent 10f7efecb2
commit b524c077a4
19 changed files with 240 additions and 247 deletions

View File

@ -1 +1 @@
a12-116-gf09ee0bdb3+1
a12-117-g10f7efecb2+1

View File

@ -14,6 +14,19 @@ make_object(
shader/desktop.vert
shader/desktop_rgb.frag
shader/desktop_yuv.frag
shader/cursor.vert
shader/cursor_rgb.frag
shader/cursor_mono.frag
shader/fps.vert
shader/fps.frag
shader/fps_bg.frag
shader/alert.vert
shader/alert.frag
shader/alert_bg.frag
shader/splash_bg.vert
shader/splash_bg.frag
shader/splash_logo.vert
shader/splash_logo.frag
)
add_library(renderer_egl STATIC

View File

@ -28,6 +28,11 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <stdlib.h>
#include <string.h>
// these headers are auto generated by cmake
#include "alert.vert.h"
#include "alert.frag.h"
#include "alert_bg.frag.h"
struct EGL_Alert
{
const LG_Font * font;
@ -51,57 +56,6 @@ struct EGL_Alert
GLint uScreenBG, uSizeBG, uColorBG;
};
static const char vertex_shader[] = "\
#version 300 es\n\
\
layout(location = 0) in vec3 vertexPosition_modelspace;\
layout(location = 1) in vec2 vertexUV;\
\
uniform vec2 screen;\
uniform vec2 size;\
uniform vec4 color;\
\
out highp vec2 uv;\
out highp vec4 c;\
\
void main()\
{\
gl_Position.xyz = vertexPosition_modelspace; \
gl_Position.w = 1.0; \
gl_Position.xy *= screen.xy * size.xy; \
\
uv = vertexUV;\
c = color;\
}\
";
static const char frag_shader[] = "\
#version 300 es\n\
\
in highp vec2 uv;\
out highp vec4 color;\
\
uniform sampler2D sampler1;\
\
void main()\
{\
color = texture(sampler1, uv);\
}\
";
static const char frag_shaderBG[] = "\
#version 300 es\n\
\
in highp vec4 c;\
out highp vec4 color;\
\
void main()\
{\
color = c;\
}\
";
bool egl_alert_init(EGL_Alert ** alert, const LG_Font * font, LG_FontObj fontObj)
{
*alert = (EGL_Alert *)malloc(sizeof(EGL_Alert));
@ -137,16 +91,16 @@ bool egl_alert_init(EGL_Alert ** alert, const LG_Font * font, LG_FontObj fontObj
if (!egl_shader_compile((*alert)->shader,
vertex_shader, sizeof(vertex_shader),
frag_shader , sizeof(frag_shader )))
b_shader_alert_vert, b_shader_alert_vert_size,
b_shader_alert_frag, b_shader_alert_frag_size))
{
DEBUG_ERROR("Failed to compile the alert shader");
return false;
}
if (!egl_shader_compile((*alert)->shaderBG,
vertex_shader, sizeof(vertex_shader),
frag_shaderBG, sizeof(frag_shaderBG)))
b_shader_alert_vert , b_shader_alert_vert_size,
b_shader_alert_bg_frag, b_shader_alert_bg_frag_size))
{
DEBUG_ERROR("Failed to compile the alert shader");
return false;

View File

@ -28,6 +28,11 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <stdlib.h>
#include <string.h>
// these headers are auto generated by cmake
#include "cursor.vert.h"
#include "cursor_rgb.frag.h"
#include "cursor_mono.frag.h"
struct EGL_Cursor
{
LG_Lock lock;
@ -59,65 +64,6 @@ struct EGL_Cursor
struct EGL_Model * model;
};
static const char vertex_shader[] = "\
#version 300 es\n\
\
layout(location = 0) in vec3 vertexPosition_modelspace;\
layout(location = 1) in vec2 vertexUV;\
\
uniform vec4 mouse;\
\
out highp vec2 uv;\
\
void main()\
{\
gl_Position.xyz = vertexPosition_modelspace;\
gl_Position.w = 1.0;\
\
gl_Position.x += 1.0f;\
gl_Position.y -= 1.0f;\
\
gl_Position.x *= mouse.z;\
gl_Position.y *= mouse.w;\
\
gl_Position.x += mouse.x;\
gl_Position.y -= mouse.y;\
\
uv = vertexUV;\
}\
";
static const char frag_mouse_mono[] = "\
#version 300 es\n\
\
in highp vec2 uv;\
out highp vec4 color;\
\
uniform sampler2D sampler1;\
\
void main()\
{\
highp vec4 tmp = texture(sampler1, uv);\
if (tmp.rgb == vec3(0.0, 0.0, 0.0))\
discard;\
color = tmp;\
}\
";
static const char frag_rgba[] = "\
#version 300 es\n\
\
in highp vec2 uv;\
out highp vec4 color;\
\
uniform sampler2D sampler1;\
\
void main()\
{\
color = texture(sampler1, uv);\
}\
";
bool egl_cursor_init(EGL_Cursor ** cursor)
{
*cursor = (EGL_Cursor *)malloc(sizeof(EGL_Cursor));
@ -156,8 +102,8 @@ bool egl_cursor_init(EGL_Cursor ** cursor)
if (!egl_shader_compile(
(*cursor)->shader,
vertex_shader, sizeof(vertex_shader),
frag_rgba , sizeof(frag_rgba )))
b_shader_cursor_vert , b_shader_cursor_vert_size,
b_shader_cursor_rgb_frag, b_shader_cursor_rgb_frag_size))
{
DEBUG_ERROR("Failed to compile the cursor shader");
return false;
@ -165,8 +111,8 @@ bool egl_cursor_init(EGL_Cursor ** cursor)
if (!egl_shader_compile(
(*cursor)->shaderMono,
vertex_shader , sizeof(vertex_shader ),
frag_mouse_mono, sizeof(frag_mouse_mono)))
b_shader_cursor_vert , b_shader_cursor_vert_size,
b_shader_cursor_mono_frag, b_shader_cursor_mono_frag_size))
{
DEBUG_ERROR("Failed to compile the cursor mono shader");
return false;

View File

@ -28,6 +28,11 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <stdlib.h>
#include <string.h>
// these headers are auto generated by cmake
#include "fps.vert.h"
#include "fps.frag.h"
#include "fps_bg.frag.h"
struct EGL_FPS
{
const LG_Font * font;
@ -46,57 +51,6 @@ struct EGL_FPS
GLint uScreenBG, uSizeBG;
};
static const char vertex_shader[] = "\
#version 300 es\n\
\
layout(location = 0) in vec3 vertexPosition_modelspace;\
layout(location = 1) in vec2 vertexUV;\
\
uniform vec2 screen;\
uniform vec2 size;\
\
out highp vec2 uv;\
\
void main()\
{\
gl_Position.xyz = vertexPosition_modelspace; \
gl_Position.w = 1.0; \
gl_Position.xy *= screen.xy * size.xy; \
gl_Position.x -= 1.0 - (screen.x * size.x);\
gl_Position.y += 1.0 - (screen.y * size.y);\
gl_Position.x += screen.x * 10.0; \
gl_Position.y -= screen.y * 10.0; \
\
uv = vertexUV;\
}\
";
static const char frag_shader[] = "\
#version 300 es\n\
\
in highp vec2 uv;\
out highp vec4 color;\
\
uniform sampler2D sampler1;\
\
void main()\
{\
color = texture(sampler1, uv);\
}\
";
static const char frag_shaderBG[] = "\
#version 300 es\n\
\
out highp vec4 color;\
\
void main()\
{\
color = vec4(0.0, 0.0, 1.0, 0.5);\
}\
";
bool egl_fps_init(EGL_FPS ** fps, const LG_Font * font, LG_FontObj fontObj)
{
*fps = (EGL_FPS *)malloc(sizeof(EGL_FPS));
@ -131,16 +85,16 @@ bool egl_fps_init(EGL_FPS ** fps, const LG_Font * font, LG_FontObj fontObj)
if (!egl_shader_compile((*fps)->shader,
vertex_shader, sizeof(vertex_shader),
frag_shader , sizeof(frag_shader )))
b_shader_fps_vert, b_shader_fps_vert_size,
b_shader_fps_frag, b_shader_fps_frag_size))
{
DEBUG_ERROR("Failed to compile the fps shader");
return false;
}
if (!egl_shader_compile((*fps)->shaderBG,
vertex_shader, sizeof(vertex_shader),
frag_shaderBG, sizeof(frag_shaderBG)))
b_shader_fps_vert , b_shader_fps_vert_size,
b_shader_fps_bg_frag, b_shader_fps_bg_frag_size))
{
DEBUG_ERROR("Failed to compile the fps shader");
return false;

View File

@ -0,0 +1,11 @@
#version 300 es
in highp vec2 uv;
out highp vec4 color;
uniform sampler2D sampler1;
void main()
{
color = texture(sampler1, uv);
}

View File

@ -0,0 +1,21 @@
#version 300 es
layout(location = 0) in vec3 vertexPosition_modelspace;
layout(location = 1) in vec2 vertexUV;
uniform vec2 screen;
uniform vec2 size;
uniform vec4 color;
out highp vec2 uv;
out highp vec4 c;
void main()
{
gl_Position.xyz = vertexPosition_modelspace;
gl_Position.w = 1.0;
gl_Position.xy *= screen.xy * size.xy;
uv = vertexUV;
c = color;
}

View File

@ -0,0 +1,9 @@
#version 300 es
in highp vec4 c;
out highp vec4 color;
void main()
{
color = c;
}

View File

@ -0,0 +1,25 @@
#version 300 es
layout(location = 0) in vec3 vertexPosition_modelspace;
layout(location = 1) in vec2 vertexUV;
uniform vec4 mouse;
out highp vec2 uv;
void main()
{
gl_Position.xyz = vertexPosition_modelspace;
gl_Position.w = 1.0;
gl_Position.x += 1.0f;
gl_Position.y -= 1.0f;
gl_Position.x *= mouse.z;
gl_Position.y *= mouse.w;
gl_Position.x += mouse.x;
gl_Position.y -= mouse.y;
uv = vertexUV;
}

View File

@ -0,0 +1,14 @@
#version 300 es
in highp vec2 uv;
out highp vec4 color;
uniform sampler2D sampler1;
void main()
{
highp vec4 tmp = texture(sampler1, uv);
if (tmp.rgb == vec3(0.0, 0.0, 0.0))
discard;
color = tmp;
}

View File

@ -0,0 +1,11 @@
#version 300 es
in highp vec2 uv;
out highp vec4 color;
uniform sampler2D sampler1;
void main()
{
color = texture(sampler1, uv);
}

View File

@ -0,0 +1,11 @@
#version 300 es
in highp vec2 uv;
out highp vec4 color;
uniform sampler2D sampler1;
void main()
{
color = texture(sampler1, uv);
}

View File

@ -0,0 +1,22 @@
#version 300 es
layout(location = 0) in vec3 vertexPosition_modelspace;
layout(location = 1) in vec2 vertexUV;
uniform vec2 screen;
uniform vec2 size;
out highp vec2 uv;
void main()
{
gl_Position.xyz = vertexPosition_modelspace;
gl_Position.w = 1.0;
gl_Position.xy *= screen.xy * size.xy;
gl_Position.x -= 1.0 - (screen.x * size.x);
gl_Position.y += 1.0 - (screen.y * size.y);
gl_Position.x += screen.x * 10.0;
gl_Position.y -= screen.y * 10.0;
uv = vertexUV;
}

View File

@ -0,0 +1,8 @@
#version 300 es
out highp vec4 color;
void main()
{
color = vec4(0.0, 0.0, 1.0, 0.5);
}

View File

@ -0,0 +1,13 @@
#version 300 es
in highp vec3 pos;
in highp float a;
out highp vec4 color;
uniform sampler2D sampler1;
void main()
{
highp float d = 1.0 - sqrt(pos.x * pos.x + pos.y * pos.y) / 2.0;
color = vec4(0.234375 * d, 0.015625f * d, 0.425781f * d, a);
}

View File

@ -0,0 +1,17 @@
#version 300 es
layout(location = 0) in vec3 vertexPosition_modelspace;
uniform float alpha;
out highp vec3 pos;
out highp float a;
void main()
{
gl_Position.xyz = vertexPosition_modelspace;
gl_Position.w = 1.0;
pos = vertexPosition_modelspace;
a = alpha;
}

View File

@ -0,0 +1,11 @@
#version 300 es
out highp vec4 color;
in highp float a;
uniform sampler2D sampler1;
void main()
{
color = vec4(1.0, 1.0, 1.0, a);
}

View File

@ -0,0 +1,16 @@
#version 300 es
layout(location = 0) in vec3 vertexPosition_modelspace;
uniform vec2 scale;
out highp float a;
void main()
{
gl_Position.xyz = vertexPosition_modelspace;
gl_Position.y *= scale.y;
gl_Position.w = 1.0;
a = scale.x;
}

View File

@ -31,6 +31,12 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <string.h>
#include <math.h>
// these headers are auto generated by cmake
#include "splash_bg.vert.h"
#include "splash_bg.frag.h"
#include "splash_logo.vert.h"
#include "splash_logo.frag.h"
struct EGL_Splash
{
EGL_Shader * bgShader;
@ -44,75 +50,6 @@ struct EGL_Splash
GLint uScale;
};
static const char vertex_bgShader[] = "\
#version 300 es\n\
\
layout(location = 0) in vec3 vertexPosition_modelspace;\
\
uniform float alpha;\
\
out highp vec3 pos; \
out highp float a; \
\
void main()\
{\
gl_Position.xyz = vertexPosition_modelspace; \
gl_Position.w = 1.0; \
\
pos = vertexPosition_modelspace; \
a = alpha; \
}\
";
static const char frag_bgShader[] = "\
#version 300 es\n\
\
in highp vec3 pos;\
in highp float a;\
out highp vec4 color;\
\
uniform sampler2D sampler1;\
\
void main()\
{\
highp float d = 1.0 - sqrt(pos.x * pos.x + pos.y * pos.y) / 2.0; \
color = vec4(0.234375 * d, 0.015625f * d, 0.425781f * d, a); \
}\
";
static const char vertex_logoShader[] = "\
#version 300 es\n\
\
layout(location = 0) in vec3 vertexPosition_modelspace;\
\
uniform vec2 scale;\
\
out highp float a; \
\
void main()\
{\
gl_Position.xyz = vertexPosition_modelspace; \
gl_Position.y *= scale.y; \
gl_Position.w = 1.0; \
\
a = scale.x; \
}\
";
static const char frag_logoShader[] = "\
#version 300 es\n\
\
out highp vec4 color;\
in highp float a;\
\
uniform sampler2D sampler1;\
\
void main()\
{\
color = vec4(1.0, 1.0, 1.0, a);\
}\
";
bool egl_splash_init(EGL_Splash ** splash)
{
*splash = (EGL_Splash *)malloc(sizeof(EGL_Splash));
@ -131,8 +68,8 @@ bool egl_splash_init(EGL_Splash ** splash)
}
if (!egl_shader_compile((*splash)->bgShader,
vertex_bgShader, sizeof(vertex_bgShader),
frag_bgShader , sizeof(frag_bgShader )))
b_shader_splash_bg_vert, b_shader_splash_bg_vert_size,
b_shader_splash_bg_frag, b_shader_splash_bg_frag_size))
{
DEBUG_ERROR("Failed to compile the splash bgShader");
return false;
@ -155,8 +92,8 @@ bool egl_splash_init(EGL_Splash ** splash)
}
if (!egl_shader_compile((*splash)->logoShader,
vertex_logoShader, sizeof(vertex_logoShader),
frag_logoShader , sizeof(frag_logoShader )))
b_shader_splash_logo_vert, b_shader_splash_logo_vert_size,
b_shader_splash_logo_frag, b_shader_splash_logo_frag_size))
{
DEBUG_ERROR("Failed to compile the splash logoShader");
return false;