From f0f60901ffb65059a451382e5b117aebd753578b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 17 Apr 2016 00:08:45 +0200 Subject: [PATCH] Move all shader files to header files (gfx/drivers/gl_shaders) --- .../gl_shaders/core_alpha_blend.glsl.frag.h | 8 ++ .../gl_shaders/core_alpha_blend.glsl.vert.h | 12 ++ .../gl_shaders/core_opaque.glsl.frag.h | 7 + .../gl_shaders/core_opaque.glsl.vert.h | 10 ++ .../gl_shaders/legacy_opaque.glsl.frag.h | 6 + .../gl_shaders/legacy_opaque.glsl.vert.h | 7 + ....frag.h => modern_alpha_blend.glsl.frag.h} | 0 ....vert.h => modern_alpha_blend.glsl.vert.h} | 0 .../gl_shaders/modern_opaque.glsl.frag.h | 9 ++ .../gl_shaders/modern_opaque.glsl.vert.h | 12 ++ .../pipeline_xmb_ribbon.glsl.frag.h | 7 + .../pipeline_xmb_ribbon.glsl.vert.h | 28 ++++ gfx/drivers_shader/shader_glsl.c | 129 ++---------------- 13 files changed, 118 insertions(+), 117 deletions(-) create mode 100644 gfx/drivers/gl_shaders/core_alpha_blend.glsl.frag.h create mode 100644 gfx/drivers/gl_shaders/core_alpha_blend.glsl.vert.h create mode 100644 gfx/drivers/gl_shaders/core_opaque.glsl.frag.h create mode 100644 gfx/drivers/gl_shaders/core_opaque.glsl.vert.h create mode 100644 gfx/drivers/gl_shaders/legacy_opaque.glsl.frag.h create mode 100644 gfx/drivers/gl_shaders/legacy_opaque.glsl.vert.h rename gfx/drivers/gl_shaders/{modern_alpha_blend_glsl.frag.h => modern_alpha_blend.glsl.frag.h} (100%) rename gfx/drivers/gl_shaders/{modern_alpha_blend_glsl.vert.h => modern_alpha_blend.glsl.vert.h} (100%) create mode 100644 gfx/drivers/gl_shaders/modern_opaque.glsl.frag.h create mode 100644 gfx/drivers/gl_shaders/modern_opaque.glsl.vert.h create mode 100644 gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h create mode 100644 gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/core_alpha_blend.glsl.frag.h b/gfx/drivers/gl_shaders/core_alpha_blend.glsl.frag.h new file mode 100644 index 0000000000..d324e14336 --- /dev/null +++ b/gfx/drivers/gl_shaders/core_alpha_blend.glsl.frag.h @@ -0,0 +1,8 @@ +static const char *stock_fragment_core_blend = + "uniform sampler2D Texture;\n" + "in vec2 tex_coord;\n" + "in vec4 color;\n" + "out vec4 FragColor;\n" + "void main() {\n" + " FragColor = color * texture(Texture, tex_coord);\n" + "}"; diff --git a/gfx/drivers/gl_shaders/core_alpha_blend.glsl.vert.h b/gfx/drivers/gl_shaders/core_alpha_blend.glsl.vert.h new file mode 100644 index 0000000000..8e7bad2e83 --- /dev/null +++ b/gfx/drivers/gl_shaders/core_alpha_blend.glsl.vert.h @@ -0,0 +1,12 @@ +static const char *stock_vertex_core_blend = + "in vec2 TexCoord;\n" + "in vec2 VertexCoord;\n" + "in vec4 Color;\n" + "uniform mat4 MVPMatrix;\n" + "out vec2 tex_coord;\n" + "out vec4 color;\n" + "void main() {\n" + " gl_Position = MVPMatrix * vec4(VertexCoord, 0.0, 1.0);\n" + " tex_coord = TexCoord;\n" + " color = Color;\n" + "}"; diff --git a/gfx/drivers/gl_shaders/core_opaque.glsl.frag.h b/gfx/drivers/gl_shaders/core_opaque.glsl.frag.h new file mode 100644 index 0000000000..7074aac0b3 --- /dev/null +++ b/gfx/drivers/gl_shaders/core_opaque.glsl.frag.h @@ -0,0 +1,7 @@ +static const char *stock_fragment_core = + "uniform sampler2D Texture;\n" + "in vec2 tex_coord;\n" + "out vec4 FragColor;\n" + "void main() {\n" + " FragColor = vec4(texture(Texture, tex_coord).rgb, 1.0);\n" + "}"; diff --git a/gfx/drivers/gl_shaders/core_opaque.glsl.vert.h b/gfx/drivers/gl_shaders/core_opaque.glsl.vert.h new file mode 100644 index 0000000000..eac8a11414 --- /dev/null +++ b/gfx/drivers/gl_shaders/core_opaque.glsl.vert.h @@ -0,0 +1,10 @@ +static const char *stock_vertex_core = + "in vec2 TexCoord;\n" + "in vec2 VertexCoord;\n" + "in vec4 Color;\n" + "uniform mat4 MVPMatrix;\n" + "out vec2 tex_coord;\n" + "void main() {\n" + " gl_Position = MVPMatrix * vec4(VertexCoord, 0.0, 1.0);\n" + " tex_coord = TexCoord;\n" + "}"; diff --git a/gfx/drivers/gl_shaders/legacy_opaque.glsl.frag.h b/gfx/drivers/gl_shaders/legacy_opaque.glsl.frag.h new file mode 100644 index 0000000000..4c8850853a --- /dev/null +++ b/gfx/drivers/gl_shaders/legacy_opaque.glsl.frag.h @@ -0,0 +1,6 @@ +static const char *stock_fragment_legacy = + "uniform sampler2D Texture;\n" + "varying vec4 color;\n" + "void main() {\n" + " gl_FragColor = color * texture2D(Texture, gl_TexCoord[0].xy);\n" + "}"; diff --git a/gfx/drivers/gl_shaders/legacy_opaque.glsl.vert.h b/gfx/drivers/gl_shaders/legacy_opaque.glsl.vert.h new file mode 100644 index 0000000000..93f3042b7e --- /dev/null +++ b/gfx/drivers/gl_shaders/legacy_opaque.glsl.vert.h @@ -0,0 +1,7 @@ +static const char *stock_vertex_legacy = + "varying vec4 color;\n" + "void main() {\n" + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + " gl_TexCoord[0] = gl_MultiTexCoord0;\n" + " color = gl_Color;\n" + "}"; diff --git a/gfx/drivers/gl_shaders/modern_alpha_blend_glsl.frag.h b/gfx/drivers/gl_shaders/modern_alpha_blend.glsl.frag.h similarity index 100% rename from gfx/drivers/gl_shaders/modern_alpha_blend_glsl.frag.h rename to gfx/drivers/gl_shaders/modern_alpha_blend.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/modern_alpha_blend_glsl.vert.h b/gfx/drivers/gl_shaders/modern_alpha_blend.glsl.vert.h similarity index 100% rename from gfx/drivers/gl_shaders/modern_alpha_blend_glsl.vert.h rename to gfx/drivers/gl_shaders/modern_alpha_blend.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/modern_opaque.glsl.frag.h b/gfx/drivers/gl_shaders/modern_opaque.glsl.frag.h new file mode 100644 index 0000000000..186546902e --- /dev/null +++ b/gfx/drivers/gl_shaders/modern_opaque.glsl.frag.h @@ -0,0 +1,9 @@ +static const char *stock_fragment_modern = + "#ifdef GL_ES\n" + "precision mediump float;\n" + "#endif\n" + "uniform sampler2D Texture;\n" + "varying vec2 tex_coord;\n" + "void main() {\n" + " gl_FragColor = vec4(texture2D(Texture, tex_coord).rgb, 1.0);\n" + "}"; diff --git a/gfx/drivers/gl_shaders/modern_opaque.glsl.vert.h b/gfx/drivers/gl_shaders/modern_opaque.glsl.vert.h new file mode 100644 index 0000000000..fd5d93aafe --- /dev/null +++ b/gfx/drivers/gl_shaders/modern_opaque.glsl.vert.h @@ -0,0 +1,12 @@ +/* Need to duplicate these to work around broken stuff on Android. + * Must enforce alpha = 1.0 or 32-bit games can potentially go black. */ +static const char *stock_vertex_modern = + "attribute vec2 TexCoord;\n" + "attribute vec2 VertexCoord;\n" + "attribute vec4 Color;\n" + "uniform mat4 MVPMatrix;\n" + "varying vec2 tex_coord;\n" + "void main() {\n" + " gl_Position = MVPMatrix * vec4(VertexCoord, 0.0, 1.0);\n" + " tex_coord = TexCoord;\n" + "}"; diff --git a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h new file mode 100644 index 0000000000..43509b1135 --- /dev/null +++ b/gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h @@ -0,0 +1,7 @@ +static const char *stock_fragment_xmb = + "uniform float time;\n" + "varying vec3 v;\n" + "void main()\n" + "{\n" + " gl_FragColor = vec4(1.0, 1.0, 1.0, 0.05);\n" + "}\n"; diff --git a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.vert.h b/gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.vert.h new file mode 100644 index 0000000000..142e6e1169 --- /dev/null +++ b/gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.vert.h @@ -0,0 +1,28 @@ +static const char *stock_vertex_xmb = + "attribute vec3 vPosition;\n" + "uniform float time;\n" + "varying vec3 v;\n" + "float iqhash( float n )\n" + "{\n" + " return fract(sin(n)*43758.5453);\n" + "}\n" + "float noise( vec3 x )\n" + "{\n" + " vec3 p = floor(x);\n" + " vec3 f = fract(x);\n" + " f = f*f*(3.0-2.0*f);\n" + " float n = p.x + p.y*57.0 + 113.0*p.z;\n" + " return mix(mix(mix( iqhash(n+0.0 ), iqhash(n+1.0 ),f.x),\n" + " mix( iqhash(n+57.0 ), iqhash(n+58.0 ),f.x),f.y),\n" + " mix(mix( iqhash(n+113.0), iqhash(n+114.0),f.x),\n" + " mix( iqhash(n+170.0), iqhash(n+171.0),f.x),f.y),f.z);\n" + "}\n" + "void main()\n" + "{\n" + " v = vPosition;\n" + " vec3 v2 = v;\n" + " v2.x = v2.x + time/2.0;\n" + " v2.z = v.z * 3.0;\n" + " v.y = -cos((v.x+v.z/3.0+time)*2.0)/10.0 - noise(v2.xyz)/4.0;\n" + " gl_Position = vec4(v, 1.0);\n" + "}\n"; diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 8264786b30..2f777269ca 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -113,124 +113,19 @@ static const char *glsl_prefixes[] = { "ruby", }; -/* Need to duplicate these to work around broken stuff on Android. - * Must enforce alpha = 1.0 or 32-bit games can potentially go black. */ -static const char *stock_vertex_modern = - "attribute vec2 TexCoord;\n" - "attribute vec2 VertexCoord;\n" - "attribute vec4 Color;\n" - "uniform mat4 MVPMatrix;\n" - "varying vec2 tex_coord;\n" - "void main() {\n" - " gl_Position = MVPMatrix * vec4(VertexCoord, 0.0, 1.0);\n" - " tex_coord = TexCoord;\n" - "}"; +#include "../drivers/gl_shaders/modern_opaque.glsl.vert.h" +#include "../drivers/gl_shaders/modern_opaque.glsl.frag.h" +#include "../drivers/gl_shaders/core_opaque.glsl.vert.h" +#include "../drivers/gl_shaders/core_opaque.glsl.frag.h" +#include "../drivers/gl_shaders/legacy_opaque.glsl.vert.h" +#include "../drivers/gl_shaders/legacy_opaque.glsl.frag.h" +#include "../drivers/gl_shaders/modern_alpha_blend.glsl.vert.h" +#include "../drivers/gl_shaders/modern_alpha_blend.glsl.frag.h" +#include "../drivers/gl_shaders/core_alpha_blend.glsl.vert.h" +#include "../drivers/gl_shaders/core_alpha_blend.glsl.frag.h" -static const char *stock_fragment_modern = - "#ifdef GL_ES\n" - "precision mediump float;\n" - "#endif\n" - "uniform sampler2D Texture;\n" - "varying vec2 tex_coord;\n" - "void main() {\n" - " gl_FragColor = vec4(texture2D(Texture, tex_coord).rgb, 1.0);\n" - "}"; - -static const char *stock_vertex_core = - "in vec2 TexCoord;\n" - "in vec2 VertexCoord;\n" - "in vec4 Color;\n" - "uniform mat4 MVPMatrix;\n" - "out vec2 tex_coord;\n" - "void main() {\n" - " gl_Position = MVPMatrix * vec4(VertexCoord, 0.0, 1.0);\n" - " tex_coord = TexCoord;\n" - "}"; - -static const char *stock_fragment_core = - "uniform sampler2D Texture;\n" - "in vec2 tex_coord;\n" - "out vec4 FragColor;\n" - "void main() {\n" - " FragColor = vec4(texture(Texture, tex_coord).rgb, 1.0);\n" - "}"; - -static const char *stock_vertex_legacy = - "varying vec4 color;\n" - "void main() {\n" - " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" - " gl_TexCoord[0] = gl_MultiTexCoord0;\n" - " color = gl_Color;\n" - "}"; - -static const char *stock_fragment_legacy = - "uniform sampler2D Texture;\n" - "varying vec4 color;\n" - "void main() {\n" - " gl_FragColor = color * texture2D(Texture, gl_TexCoord[0].xy);\n" - "}"; - -#include "../drivers/gl_shaders/modern_alpha_blend_glsl.vert.h" -#include "../drivers/gl_shaders/modern_alpha_blend_glsl.frag.h" - -static const char *stock_vertex_core_blend = - "in vec2 TexCoord;\n" - "in vec2 VertexCoord;\n" - "in vec4 Color;\n" - "uniform mat4 MVPMatrix;\n" - "out vec2 tex_coord;\n" - "out vec4 color;\n" - "void main() {\n" - " gl_Position = MVPMatrix * vec4(VertexCoord, 0.0, 1.0);\n" - " tex_coord = TexCoord;\n" - " color = Color;\n" - "}"; - -static const char *stock_fragment_core_blend = - "uniform sampler2D Texture;\n" - "in vec2 tex_coord;\n" - "in vec4 color;\n" - "out vec4 FragColor;\n" - "void main() {\n" - " FragColor = color * texture(Texture, tex_coord);\n" - "}"; - -static const char *stock_vertex_xmb = - "attribute vec3 vPosition;\n" - "uniform float time;\n" - "varying vec3 v;\n" - "float iqhash( float n )\n" - "{\n" - " return fract(sin(n)*43758.5453);\n" - "}\n" - "float noise( vec3 x )\n" - "{\n" - " vec3 p = floor(x);\n" - " vec3 f = fract(x);\n" - " f = f*f*(3.0-2.0*f);\n" - " float n = p.x + p.y*57.0 + 113.0*p.z;\n" - " return mix(mix(mix( iqhash(n+0.0 ), iqhash(n+1.0 ),f.x),\n" - " mix( iqhash(n+57.0 ), iqhash(n+58.0 ),f.x),f.y),\n" - " mix(mix( iqhash(n+113.0), iqhash(n+114.0),f.x),\n" - " mix( iqhash(n+170.0), iqhash(n+171.0),f.x),f.y),f.z);\n" - "}\n" - "void main()\n" - "{\n" - " v = vPosition;\n" - " vec3 v2 = v;\n" - " v2.x = v2.x + time/2.0;\n" - " v2.z = v.z * 3.0;\n" - " v.y = -cos((v.x+v.z/3.0+time)*2.0)/10.0 - noise(v2.xyz)/4.0;\n" - " gl_Position = vec4(v, 1.0);\n" - "}\n"; - -static const char *stock_fragment_xmb = - "uniform float time;\n" - "varying vec3 v;\n" - "void main()\n" - "{\n" - " gl_FragColor = vec4(1.0, 1.0, 1.0, 0.05);\n" - "}\n"; +#include "../drivers/gl_shaders/pipeline_xmb_ribbon.glsl.vert.h" +#include "../drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h" typedef struct glsl_shader_data {