diff options
Diffstat (limited to 'Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp')
| -rw-r--r-- | Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp index f27f56d701..a8360fa9c3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp @@ -518,16 +518,18 @@ void ProgramShaderCache::CreateHeader ( void ) { GLSL_VERSION v = g_ogl_config.eSupportedGLSLVersion; snprintf(s_glsl_header, sizeof(s_glsl_header), - "#version %s\n" - "%s\n" // default precision + "%s\n" "%s\n" // ubo "%s\n" // early-z + // Precision defines for GLSLES2/3 + "%s\n" + "\n"// A few required defines and ones that will make our lives a lot easier - "#define ATTRIN in\n" - "#define ATTROUT out\n" - "#define VARYIN %s in\n" - "#define VARYOUT %s out\n" + "#define ATTRIN %s\n" + "#define ATTROUT %s\n" + "#define VARYIN %s\n" + "#define VARYOUT %s\n" // Silly differences "#define float2 vec2\n" @@ -542,18 +544,41 @@ void ProgramShaderCache::CreateHeader ( void ) "%s\n" "%s\n" "%s\n" + + // GLSLES2 hacks + "%s\n" + "%s\n" + "%s\n" + "%s\n" + "%s\n" + "%s\n" + "%s\n" + "#define COLOROUT(name) %s\n" + - , v==GLSLES3 ? "300 es" : v==GLSL_130 ? "130" : v==GLSL_140 ? "140" : "150" - , v==GLSLES3 ? "precision highp float;" : "" + , v==GLSLES2 ? "" : v==GLSLES3 ? "#version 300 es" : v==GLSL_130 ? "#version 130" : v==GLSL_140 ? "#version 140" : "#version 150" , g_ActiveConfig.backend_info.bSupportsGLSLUBO && v<GLSL_140 ? "#extension GL_ARB_uniform_buffer_object : enable" : "" , g_ActiveConfig.backend_info.bSupportsEarlyZ ? "#extension GL_ARB_shader_image_load_store : enable" : "" - , DriverDetails::HasBug(DriverDetails::BUG_BROKENCENTROID) ? "" : "centroid" - , DriverDetails::HasBug(DriverDetails::BUG_BROKENCENTROID) ? "" : "centroid" + , (v==GLSLES3 || v==GLSLES2) ? "precision highp float;" : "" + + , v==GLSLES2 ? "attribute" : "in" + , v==GLSLES2 ? "attribute" : "out" + , v==GLSLES2 ? "varying" : DriverDetails::HasBug(DriverDetails::BUG_BROKENCENTROID) ? "in" : "centroid in" + , v==GLSLES2 ? "varying" : DriverDetails::HasBug(DriverDetails::BUG_BROKENCENTROID) ? "out" : "centroid out" - , v==GLSLES3 ? "" : v<=GLSL_130 ? "#extension GL_ARB_texture_rectangle : enable" : "#define texture2DRect texture" + , v==GLSLES2 ? "#define texture2DRect texture2D" : v==GLSLES3 ? "" : v<=GLSL_130 ? "#extension GL_ARB_texture_rectangle : enable" : "#define texture2DRect texture" , v==GLSLES3 ? "#define texture2DRect(samp, uv) texelFetch(samp, ivec2(floor(uv)), 0)" : "" - , v==GLSLES3 ? "#define sampler2DRect sampler2D" : "" + , (v==GLSLES3 || v==GLSLES2) ? "#define sampler2DRect sampler2D" : "" + + , v==GLSLES2 ? "#define texture texture2D" : "" + , v==GLSLES2 ? "#define round(x) floor((x)+0.5)" : "" + , v==GLSLES2 ? "#define out " : "" + , v==GLSLES2 ? "#define ocol0 gl_FragColor" : "" + , v==GLSLES2 ? "#define ocol1 gl_FragColor" : "" + , v==GLSLES2 ? "#extension GL_NV_uniform_buffer_object : enable" : "" + , v==GLSLES2 ? "#extension GL_NV_fragdepth : enable" : "" + , v==GLSLES2 ? "" : "out vec4 name;" ); } |
