From a2cc2b39cad9808a08265001e23b170729a1b05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 18 Dec 2018 10:42:29 +0100 Subject: [PATCH] Additional raw string shaders --- GPU/Directx9/FramebufferDX9.cpp | 53 ++++++++++++++------------- GPU/GLES/FramebufferManagerGLES.cpp | 56 +++++++++++++++-------------- 2 files changed, 55 insertions(+), 54 deletions(-) diff --git a/GPU/Directx9/FramebufferDX9.cpp b/GPU/Directx9/FramebufferDX9.cpp index 9bcbec3427..8631e7b5db 100644 --- a/GPU/Directx9/FramebufferDX9.cpp +++ b/GPU/Directx9/FramebufferDX9.cpp @@ -47,34 +47,33 @@ namespace DX9 { -static const char * vscode = - "struct VS_IN {\n" - " float4 ObjPos : POSITION;\n" - " float2 Uv : TEXCOORD0;\n" - "};" - "struct VS_OUT {\n" - " float4 ProjPos : POSITION;\n" - " float2 Uv : TEXCOORD0;\n" - "};\n" - "VS_OUT main( VS_IN In ) {\n" - " VS_OUT Out;\n" - " Out.ProjPos = In.ObjPos;\n" - " Out.Uv = In.Uv;\n" - " return Out;\n" - "}\n"; +static const char *vscode = R"( +struct VS_IN { + float4 ObjPos : POSITION; + float2 Uv : TEXCOORD0; +};" +struct VS_OUT { + float4 ProjPos : POSITION; + float2 Uv : TEXCOORD0; +}; +VS_OUT main( VS_IN In ) { + VS_OUT Out; + Out.ProjPos = In.ObjPos; + Out.Uv = In.Uv; + return Out; +}; +)"; -//-------------------------------------------------------------------------------------- -// Pixel shader -//-------------------------------------------------------------------------------------- -static const char * pscode = - "sampler s: register(s0);\n" - "struct PS_IN {\n" - " float2 Uv : TEXCOORD0;\n" - "};\n" - "float4 main( PS_IN In ) : COLOR {\n" - " float4 c = tex2D(s, In.Uv);\n" - " return c;\n" - "}\n"; +static const char *pscode = R"( +sampler s: register(s0); +struct PS_IN { + float2 Uv : TEXCOORD0; +}; +float4 main( PS_IN In ) : COLOR { + float4 c = tex2D(s, In.Uv); + return c; +}; +)"; static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = { { 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, diff --git a/GPU/GLES/FramebufferManagerGLES.cpp b/GPU/GLES/FramebufferManagerGLES.cpp index 780735da13..46f69b6050 100644 --- a/GPU/GLES/FramebufferManagerGLES.cpp +++ b/GPU/GLES/FramebufferManagerGLES.cpp @@ -48,34 +48,36 @@ #include "GPU/GLES/DrawEngineGLES.h" #include "GPU/GLES/ShaderManagerGLES.h" -static const char tex_fs[] = - "#if __VERSION__ >= 130\n" - "#define varying in\n" - "#define texture2D texture\n" - "#define gl_FragColor fragColor0\n" - "out vec4 fragColor0;\n" - "#endif\n" - "#ifdef GL_ES\n" - "precision mediump float;\n" - "#endif\n" - "uniform sampler2D sampler0;\n" - "varying vec2 v_texcoord0;\n" - "void main() {\n" - " gl_FragColor = texture2D(sampler0, v_texcoord0);\n" - "}\n"; +static const char tex_fs[] = R"( +#if __VERSION__ >= 130 +#define varying in +#define texture2D texture +#define gl_FragColor fragColor0 +out vec4 fragColor0; +#endif +#ifdef GL_ES +precision mediump float; +#endif +uniform sampler2D sampler0; +varying vec2 v_texcoord0; +void main() { + gl_FragColor = texture2D(sampler0, v_texcoord0); +} +)"; -static const char basic_vs[] = - "#if __VERSION__ >= 130\n" - "#define attribute in\n" - "#define varying out\n" - "#endif\n" - "attribute vec4 a_position;\n" - "attribute vec2 a_texcoord0;\n" - "varying vec2 v_texcoord0;\n" - "void main() {\n" - " v_texcoord0 = a_texcoord0;\n" - " gl_Position = a_position;\n" - "}\n"; +static const char basic_vs[] = R"( +#if __VERSION__ >= 130 +#define attribute in +#define varying out +#endif +attribute vec4 a_position; +attribute vec2 a_texcoord0; +varying vec2 v_texcoord0; +void main() { + v_texcoord0 = a_texcoord0; + gl_Position = a_position; +} +)"; void FramebufferManagerGLES::CompileDraw2DProgram() { if (!draw2dprogram_) {