diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 272de6119f..e76c8d4737 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -163,14 +163,14 @@ if(PACKAGE_MODE) endif(PACKAGE_MODE) #------------------------------------------------------------------------------- -# Select nvidia cg shader api by default +# Select nvidia cg shader api by default (zzogl only) #------------------------------------------------------------------------------- if(NOT DEFINED GLSL_API) set(GLSL_API FALSE) endif(NOT DEFINED GLSL_API) #------------------------------------------------------------------------------- -# Select GLX API by default +# Select GLX API by default (zzogl only) #------------------------------------------------------------------------------- if(NOT DEFINED EGL_API) set(EGL_API FALSE) @@ -178,6 +178,13 @@ else() message(STATUS "EGL is experimental and not expected to work yet!!!") endif() +#------------------------------------------------------------------------------- +# Select opengl api by default (gsdx) +#------------------------------------------------------------------------------- +if(NOT DEFINED GLES_API) + set(GLES_API FALSE) +endif() + #------------------------------------------------------------------------------- # Use the precompiled shader file by default #------------------------------------------------------------------------------- diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index ce88ae5f35..667c9694f1 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -44,6 +44,10 @@ if(XDG_STD) add_definitions(-DXDG_STD) endif(XDG_STD) +if(GLES_API) + add_definitions(-DENABLE_GLES) +endif() + set(GSdxSources GLLoader.cpp GPU.cpp @@ -189,7 +193,14 @@ endif() add_library(${Output} SHARED ${GSdxSources} ${GSdxHeaders}) target_link_libraries(${Output} ${X11_LIBRARIES}) -target_link_libraries(${Output} ${OPENGL_LIBRARIES}) +message(INFO "DEBUG ${OPENGL_LIBRARIES}") + +if (GLES) + target_link_libraries(${Output} /usr/lib/i386-linux-gnu/libGLU.so;/usr/lib/i386-linux-gnu/libGLESv2.so;/usr/lib/i386-linux-gnu/libSM.so;/usr/lib/i386-linux-gnu/libICE.so;/usr/lib/i386-linux-gnu/libX11.so;/usr/lib/i386-linux-gnu/libXext.so) +else() + target_link_libraries(${Output} ${OPENGL_LIBRARIES}) +endif() + target_link_libraries(${Output} ${EGL_LIBRARIES}) if(Linux) diff --git a/plugins/GSdx/GLLoader.cpp b/plugins/GSdx/GLLoader.cpp index 7a4ee5add1..60d817791e 100644 --- a/plugins/GSdx/GLLoader.cpp +++ b/plugins/GSdx/GLLoader.cpp @@ -134,6 +134,7 @@ namespace GLLoader { GLuint major_gl = s[dot-1]-'0'; GLuint minor_gl = s[dot+1]-'0'; +#ifndef ENABLE_GLES if ( (major_gl < 3) || ( major_gl == 3 && minor_gl < 2 ) ) { fprintf(stderr, "Geometry shaders are not supported. Required openGL3.2\n"); found_geometry_shader = false; @@ -152,13 +153,14 @@ namespace GLLoader { // Opensource driver spotted found_only_gl30 = true; } - +#else + found_geometry_shader = false; +#endif if ( (major_gl < major) || ( major_gl == major && minor_gl < minor ) ) { fprintf(stderr, "OPENGL %d.%d is not supported\n", major, minor); return false; } - return true; } @@ -166,8 +168,6 @@ namespace GLLoader { int max_ext = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext); - fprintf(stderr, "DEBUG: check_gl_supported_extension\n"); - if (gl_GetStringi && max_ext) { for (GLint i = 0; i < max_ext; i++) { string ext((const char*)gl_GetStringi(GL_EXTENSIONS, i)); @@ -181,9 +181,13 @@ namespace GLLoader { // Replace previous extensions (when driver will be updated) if (ext.compare("GL_ARB_copy_image") == 0) found_GL_ARB_copy_image = true; if (ext.compare("GL_ARB_gpu_shader5") == 0) found_GL_ARB_gpu_shader5 = true; +#ifdef ENABLE_GLES + fprintf(stderr, "DEBUG ext: %s\n", ext.c_str()); +#endif } } +#ifndef ENABLE_GLES if (!found_GL_ARB_separate_shader_objects) { fprintf(stderr, "INFO: GL_ARB_separate_shader_objects is not supported\n"); } @@ -214,6 +218,7 @@ namespace GLLoader { fprintf(stderr, "Override GL_ARB_copy_image detection\n"); fprintf(stderr, "Override GL_NV_copy_image detection\n"); } +#endif return true; } diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 84863138ef..c8898a62f1 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -247,21 +247,25 @@ bool GSDeviceOGL::Create(GSWnd* wnd) int ShadeBoost_Contrast = theApp.GetConfig("ShadeBoost_Contrast", 50); int ShadeBoost_Brightness = theApp.GetConfig("ShadeBoost_Brightness", 50); int ShadeBoost_Saturation = theApp.GetConfig("ShadeBoost_Saturation", 50); - std::string shade_macro = format("#define SB_SATURATION %d\n", ShadeBoost_Saturation) - + format("#define SB_BRIGHTNESS %d\n", ShadeBoost_Brightness) - + format("#define SB_CONTRAST %d\n", ShadeBoost_Contrast); + std::string shade_macro = format("#define SB_SATURATION %d.0\n", ShadeBoost_Saturation) + + format("#define SB_BRIGHTNESS %d.0\n", ShadeBoost_Brightness) + + format("#define SB_CONTRAST %d.0\n", ShadeBoost_Contrast); m_shadeboost.ps = m_shader->Compile("shadeboost.glsl", "ps_main", GL_FRAGMENT_SHADER, shadeboost_glsl, shade_macro); // **************************************************************** // rasterization configuration // **************************************************************** +#ifndef ENABLE_GLES glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); +#endif glDisable(GL_CULL_FACE); glEnable(GL_SCISSOR_TEST); // FIXME enable it when multisample code will be here // DX: rd.MultisampleEnable = true; +#ifndef ENABLE_GLES glDisable(GL_MULTISAMPLE); +#endif #ifdef ONLY_LINES glLineWidth(5.0); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); @@ -1048,9 +1052,11 @@ void GSDeviceOGL::OMSetFBO(GLuint fbo, GLenum buffer) //if (fbo) fprintf(stderr, "FB status %x\n", gl_CheckFramebufferStatus(GL_FRAMEBUFFER)); } - if (m_state.draw != buffer) { + // Note if m_fbo is 0, standard GL_BACK will be used instead + if (m_fbo && m_state.draw != buffer) { m_state.draw = buffer; - glDrawBuffer(buffer); + GLenum target[1] = {buffer}; + gl_DrawBuffers(1, target); } } @@ -1080,14 +1086,8 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto { if (rt == NULL || !static_cast(rt)->IsBackbuffer()) { if (rt) { - // FIXME DEBUG special case for GL_R16UI - if (rt->GetFormat() == GL_R16UI) { - OMSetFBO(m_fbo, GL_COLOR_ATTACHMENT1); - static_cast(rt)->Attach(GL_COLOR_ATTACHMENT1); - } else { - OMSetFBO(m_fbo, GL_COLOR_ATTACHMENT0); - static_cast(rt)->Attach(GL_COLOR_ATTACHMENT0); - } + OMSetFBO(m_fbo); + static_cast(rt)->Attach(GL_COLOR_ATTACHMENT0); } else { // Note: NULL rt is only used in DATE so far. Color writing is disabled // on the blend setup @@ -1123,6 +1123,7 @@ void GSDeviceOGL::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVecto void GSDeviceOGL::CheckDebugLog() { +#ifndef ENABLE_GLES unsigned int count = 16; // max. num. of messages that will be read from the log int bufsize = 2048; unsigned int sources[16] = {}; @@ -1146,6 +1147,7 @@ void GSDeviceOGL::CheckDebugLog() } delete[] messageLog; +#endif } void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message) diff --git a/plugins/GSdx/GSShaderOGL.cpp b/plugins/GSdx/GSShaderOGL.cpp index d71e6bc58a..df3e244d2b 100644 --- a/plugins/GSdx/GSShaderOGL.cpp +++ b/plugins/GSdx/GSShaderOGL.cpp @@ -223,18 +223,19 @@ void GSShaderOGL::UseProgram() if (it == m_single_prog.end()) { m_prog = LinkNewProgram(); m_single_prog[sel] = m_prog; + + ValidateProgram(m_prog); + + gl_UseProgram(m_prog); + // warning it must be done after the "setup" of the program SetupUniform(); } else { m_prog = it->second; + gl_UseProgram(m_prog); } - gl_UseProgram(m_prog); - - // TODO: might be possible to do it only when prog is linked - // Seem to be OK! - //SetupUniform(); } else { - ValidateProgram(m_pipeline); + ValidatePipeline(m_pipeline); SetupUniform(); } @@ -243,6 +244,8 @@ void GSShaderOGL::UseProgram() std::string GSShaderOGL::GenGlslHeader(const std::string& entry, GLenum type, const std::string& macro) { std::string header; +#ifndef ENABLE_GLES + if (GLLoader::found_only_gl30) { header = "#version 130\n"; } else { @@ -268,6 +271,12 @@ std::string GSShaderOGL::GenGlslHeader(const std::string& entry, GLenum type, co header += "#define ENABLE_OGL_STENCIL_DEBUG 1\n"; #endif +#else + header = "#version 300 es\n"; + header += "#define DISABLE_SSO\n"; + header += "#define DISABLE_GL42\n"; +#endif + // Allow to puts several shader in 1 files switch (type) { case GL_VERTEX_SHADER: diff --git a/plugins/GSdx/GSVertexArrayOGL.h b/plugins/GSdx/GSVertexArrayOGL.h index 827a049cbf..6356b30f47 100644 --- a/plugins/GSdx/GSVertexArrayOGL.h +++ b/plugins/GSdx/GSVertexArrayOGL.h @@ -98,8 +98,21 @@ class GSBufferOGL { } } +#ifdef ENABLE_GLES + void upload(const void* src, uint32 count, uint32 basevertex = 0) +#else void upload(const void* src, uint32 count) +#endif { +#ifdef ENABLE_GLES + // Emulate gl_DrawElementsBaseVertex... Maybe GLES 4 you know! + if (basevertex) { + uint32* data = (uint32*) src; + for (uint32 i = 0; i < count; i++) { + data[i] += basevertex; + } + } +#endif if (m_sub_data_config) { subdata_upload(src, count); } else { @@ -152,12 +165,20 @@ class GSBufferOGL { void Draw(GLenum mode, GLint basevertex) { +#ifdef ENABLE_GLES + glDrawElements(mode, m_count, GL_UNSIGNED_INT, (void*)(m_start * m_stride)); +#else gl_DrawElementsBaseVertex(mode, m_count, GL_UNSIGNED_INT, (void*)(m_start * m_stride), basevertex); +#endif } void Draw(GLenum mode, GLint basevertex, int offset, int count) { +#ifdef ENABLE_GLES + glDrawElements(mode, count, GL_UNSIGNED_INT, (void*)((m_start + offset) * m_stride)); +#else gl_DrawElementsBaseVertex(mode, count, GL_UNSIGNED_INT, (void*)((m_start + offset) * m_stride), basevertex); +#endif } size_t GetStart() { return m_start; } @@ -233,7 +254,13 @@ public: void UploadVB(const void* vertices, size_t count) { m_vb->upload(vertices, count); } - void UploadIB(const void* index, size_t count) { m_ib->upload(index, count); } + void UploadIB(const void* index, size_t count) { +#ifdef ENABLE_GLES + m_ib->upload(index, count, m_vb->GetStart()); +#else + m_ib->upload(index, count); +#endif + } bool MapVB(void **pointer, size_t count) { return m_vb->Map(pointer, count); } diff --git a/plugins/GSdx/GSWndEGL.cpp b/plugins/GSdx/GSWndEGL.cpp index d2797e8625..ae2258b24a 100644 --- a/plugins/GSdx/GSWndEGL.cpp +++ b/plugins/GSdx/GSWndEGL.cpp @@ -34,6 +34,12 @@ void GSWndEGL::CreateContext(int major, int minor) EGLConfig eglConfig; EGLint numConfigs; EGLint contextAttribs[] = +#ifdef ENABLE_GLES + { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; +#else { EGL_CONTEXT_MAJOR_VERSION_KHR, major, EGL_CONTEXT_MINOR_VERSION_KHR, minor, @@ -43,6 +49,7 @@ void GSWndEGL::CreateContext(int major, int minor) EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, EGL_NONE }; +#endif EGLint NullContextAttribs[] = { EGL_NONE }; EGLint attrList[] = { EGL_RED_SIZE, 8, @@ -53,7 +60,9 @@ void GSWndEGL::CreateContext(int major, int minor) EGL_NONE }; +#ifndef ENABLE_GLES eglBindAPI(EGL_OPENGL_API); +#endif if ( !eglChooseConfig(m_eglDisplay, attrList, &eglConfig, 1, &numConfigs) ) { @@ -94,7 +103,9 @@ void GSWndEGL::AttachContext() if (!IsContextAttached()) { // The setting of the API is local to a thread. This function // can be called from 2 threads. +#ifndef ENABLE_GLES eglBindAPI(EGL_OPENGL_API); +#endif //fprintf(stderr, "Attach the context\n"); eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext); diff --git a/plugins/GSdx/res/convert.glsl b/plugins/GSdx/res/convert.glsl index 2d9a015330..233463b3d5 100644 --- a/plugins/GSdx/res/convert.glsl +++ b/plugins/GSdx/res/convert.glsl @@ -9,7 +9,7 @@ struct vertex_basic #ifdef VERTEX_SHADER -#if __VERSION__ > 140 +#if !GL_ES && __VERSION__ > 140 out gl_PerVertex { vec4 gl_Position; float gl_PointSize; @@ -28,7 +28,7 @@ layout(location = 1) in vec2 TEXCOORD0; // smooth, the default, means to do perspective-correct interpolation. // // The centroid qualifier only matters when multisampling. If this qualifier is not present, then the value is interpolated to the pixel's center, anywhere in the pixel, or to one of the pixel's samples. This sample may lie outside of the actual primitive being rendered, since a primitive can cover only part of a pixel's area. The centroid qualifier is used to prevent this; the interpolation point must fall within both the pixel's area and the primitive's area. -#if __VERSION__ > 140 +#if !GL_ES && __VERSION__ > 140 out SHADER { @@ -64,7 +64,7 @@ void vs_main() #ifdef FRAGMENT_SHADER -#if __VERSION__ > 140 +#if !GL_ES && __VERSION__ > 140 in SHADER { @@ -89,8 +89,12 @@ layout(location = 1) in vec2 SHADERt; #endif +// Give a different name so I remember there is a special case! +#ifdef ps_main1 +layout(location = 0) out uint SV_Target1; +#else layout(location = 0) out vec4 SV_Target0; -layout(location = 1) out uint SV_Target1; +#endif #ifdef DISABLE_GL42 uniform sampler2D TextureSampler; @@ -124,11 +128,14 @@ vec4 ps_crt(uint i) return sample_c() * clamp((mask[i] + 0.5f), 0.0f, 1.0f); } +#ifdef ps_main0 void ps_main0() { SV_Target0 = sample_c(); } +#endif +#ifdef ps_main1 void ps_main1() { vec4 c = sample_c(); @@ -139,7 +146,9 @@ void ps_main1() SV_Target1 = (i.x & uint(0x001f)) | (i.y & uint(0x03e0)) | (i.z & uint(0x7c00)) | (i.w & uint(0x8000)); } +#endif +#ifdef ps_main7 void ps_main7() { vec4 c = sample_c(); @@ -148,7 +157,9 @@ void ps_main7() SV_Target0 = c; } +#endif +#ifdef ps_main5 void ps_main5() // triangular { highp uvec4 p = uvec4(PSin_p); @@ -157,7 +168,9 @@ void ps_main5() // triangular SV_Target0 = c; } +#endif +#ifdef ps_main6 void ps_main6() // diagonal { uvec4 p = uvec4(PSin_p); @@ -166,36 +179,43 @@ void ps_main6() // diagonal SV_Target0 = c; } +#endif // Used for DATE (stencil) +#ifdef ps_main2 void ps_main2() { - if((sample_c().a - 127.5f / 255) < 0) // >= 0x80 pass + if((sample_c().a - 127.5f / 255.0f) < 0.0f) // >= 0x80 pass discard; #ifdef ENABLE_OGL_STENCIL_DEBUG SV_Target0 = vec4(1.0f, 0.0f, 0.0f, 1.0f); #endif } +#endif // Used for DATE (stencil) +#ifdef ps_main3 void ps_main3() { - if((127.5f / 255 - sample_c().a) < 0) // < 0x80 pass (== 0x80 should not pass) + if((127.5f / 255.0f - sample_c().a) < 0.0f) // < 0x80 pass (== 0x80 should not pass) discard; #ifdef ENABLE_OGL_STENCIL_DEBUG SV_Target0 = vec4(1.0f, 0.0f, 0.0f, 1.0f); #endif } +#endif +#ifdef ps_main4 void ps_main4() { // FIXME mod and fmod are different when value are negative // output.c = fmod(sample_c(input.t) * 255 + 0.5f, 256) / 255; - vec4 c = mod(sample_c() * 255 + 0.5f, 256) / 255; + vec4 c = mod(sample_c() * 255.0f + 0.5f, 256.0f) / 255.0f; SV_Target0 = c; } +#endif #endif diff --git a/plugins/GSdx/res/fxaa.fx b/plugins/GSdx/res/fxaa.fx index afe2c52d9d..e65beda2d0 100644 --- a/plugins/GSdx/res/fxaa.fx +++ b/plugins/GSdx/res/fxaa.fx @@ -87,7 +87,7 @@ uniform sampler2D TextureSampler; layout(binding = 0) uniform sampler2D TextureSampler; #endif -#if __VERSION__ > 140 +#if !GL_ES && __VERSION__ > 140 in SHADER { diff --git a/plugins/GSdx/res/glsl_source.h b/plugins/GSdx/res/glsl_source.h index 797d7bfbbe..83b07a29be 100644 --- a/plugins/GSdx/res/glsl_source.h +++ b/plugins/GSdx/res/glsl_source.h @@ -34,7 +34,7 @@ static const char* convert_glsl = "\n" "#ifdef VERTEX_SHADER\n" "\n" - "#if __VERSION__ > 140\n" + "#if !GL_ES && __VERSION__ > 140\n" "out gl_PerVertex {\n" " vec4 gl_Position;\n" " float gl_PointSize;\n" @@ -53,7 +53,7 @@ static const char* convert_glsl = "// smooth, the default, means to do perspective-correct interpolation.\n" "//\n" "// The centroid qualifier only matters when multisampling. If this qualifier is not present, then the value is interpolated to the pixel's center, anywhere in the pixel, or to one of the pixel's samples. This sample may lie outside of the actual primitive being rendered, since a primitive can cover only part of a pixel's area. The centroid qualifier is used to prevent this; the interpolation point must fall within both the pixel's area and the primitive's area.\n" - "#if __VERSION__ > 140\n" + "#if !GL_ES && __VERSION__ > 140\n" "\n" "out SHADER\n" "{\n" @@ -89,7 +89,7 @@ static const char* convert_glsl = "\n" "#ifdef FRAGMENT_SHADER\n" "\n" - "#if __VERSION__ > 140\n" + "#if !GL_ES && __VERSION__ > 140\n" "\n" "in SHADER\n" "{\n" @@ -114,8 +114,12 @@ static const char* convert_glsl = "\n" "#endif\n" "\n" + "// Give a different name so I remember there is a special case!\n" + "#ifdef ps_main1\n" + "layout(location = 0) out uint SV_Target1;\n" + "#else\n" "layout(location = 0) out vec4 SV_Target0;\n" - "layout(location = 1) out uint SV_Target1;\n" + "#endif\n" "\n" "#ifdef DISABLE_GL42\n" "uniform sampler2D TextureSampler;\n" @@ -149,11 +153,14 @@ static const char* convert_glsl = " return sample_c() * clamp((mask[i] + 0.5f), 0.0f, 1.0f);\n" "}\n" "\n" + "#ifdef ps_main0\n" "void ps_main0()\n" "{\n" " SV_Target0 = sample_c();\n" "}\n" + "#endif\n" "\n" + "#ifdef ps_main1\n" "void ps_main1()\n" "{\n" " vec4 c = sample_c();\n" @@ -164,7 +171,9 @@ static const char* convert_glsl = "\n" " SV_Target1 = (i.x & uint(0x001f)) | (i.y & uint(0x03e0)) | (i.z & uint(0x7c00)) | (i.w & uint(0x8000));\n" "}\n" + "#endif\n" "\n" + "#ifdef ps_main7\n" "void ps_main7()\n" "{\n" " vec4 c = sample_c();\n" @@ -173,7 +182,9 @@ static const char* convert_glsl = "\n" " SV_Target0 = c;\n" "}\n" + "#endif\n" "\n" + "#ifdef ps_main5\n" "void ps_main5() // triangular\n" "{\n" " highp uvec4 p = uvec4(PSin_p);\n" @@ -182,7 +193,9 @@ static const char* convert_glsl = "\n" " SV_Target0 = c;\n" "}\n" + "#endif\n" "\n" + "#ifdef ps_main6\n" "void ps_main6() // diagonal\n" "{\n" " uvec4 p = uvec4(PSin_p);\n" @@ -191,37 +204,44 @@ static const char* convert_glsl = "\n" " SV_Target0 = c;\n" "}\n" + "#endif\n" "\n" "// Used for DATE (stencil)\n" + "#ifdef ps_main2\n" "void ps_main2()\n" "{\n" - " if((sample_c().a - 127.5f / 255) < 0) // >= 0x80 pass\n" + " if((sample_c().a - 127.5f / 255.0f) < 0.0f) // >= 0x80 pass\n" " discard;\n" "\n" "#ifdef ENABLE_OGL_STENCIL_DEBUG\n" " SV_Target0 = vec4(1.0f, 0.0f, 0.0f, 1.0f);\n" "#endif\n" "}\n" + "#endif\n" "\n" "// Used for DATE (stencil)\n" + "#ifdef ps_main3\n" "void ps_main3()\n" "{\n" - " if((127.5f / 255 - sample_c().a) < 0) // < 0x80 pass (== 0x80 should not pass)\n" + " if((127.5f / 255.0f - sample_c().a) < 0.0f) // < 0x80 pass (== 0x80 should not pass)\n" " discard;\n" "\n" "#ifdef ENABLE_OGL_STENCIL_DEBUG\n" " SV_Target0 = vec4(1.0f, 0.0f, 0.0f, 1.0f);\n" "#endif\n" "}\n" + "#endif\n" "\n" + "#ifdef ps_main4\n" "void ps_main4()\n" "{\n" " // FIXME mod and fmod are different when value are negative\n" " // output.c = fmod(sample_c(input.t) * 255 + 0.5f, 256) / 255;\n" - " vec4 c = mod(sample_c() * 255 + 0.5f, 256) / 255;\n" + " vec4 c = mod(sample_c() * 255.0f + 0.5f, 256.0f) / 255.0f;\n" "\n" " SV_Target0 = c;\n" "}\n" + "#endif\n" "\n" "#endif\n" ; @@ -235,7 +255,7 @@ static const char* interlace_glsl = " vec2 t;\n" "};\n" "\n" - "#if __VERSION__ > 140\n" + "#if !GL_ES && __VERSION__ > 140\n" "\n" "in SHADER\n" "{\n" @@ -309,7 +329,7 @@ static const char* interlace_glsl = " vec4 c1 = texture(TextureSampler, PSin_t);\n" " vec4 c2 = texture(TextureSampler, PSin_t + ZrH);\n" "\n" - " SV_Target0 = (c0 + c1 * 2 + c2) / 4;\n" + " SV_Target0 = (c0 + c1 * 2.0f + c2) / 4.0f;\n" "}\n" "\n" "void ps_main3()\n" @@ -329,7 +349,7 @@ static const char* merge_glsl = " vec2 t;\n" "};\n" "\n" - "#if __VERSION__ > 140\n" + "#if !GL_ES && __VERSION__ > 140\n" "\n" "in SHADER\n" "{\n" @@ -376,7 +396,7 @@ static const char* merge_glsl = "void ps_main0()\n" "{\n" " vec4 c = texture(TextureSampler, PSin_t);\n" - " c.a = min(c.a * 2, 1.0);\n" + " c.a = min(c.a * 2.0, 1.0);\n" " SV_Target0 = c;\n" "}\n" "\n" @@ -407,7 +427,7 @@ static const char* shadeboost_glsl = "\n" "#ifdef FRAGMENT_SHADER\n" "\n" - "#if __VERSION__ > 140\n" + "#if !GL_ES && __VERSION__ > 140\n" "\n" "in SHADER\n" "{\n" @@ -548,7 +568,7 @@ static const char* tfx_glsl = "layout(location = 5) in uvec2 i_uv;\n" "layout(location = 6) in vec4 i_f;\n" "\n" - "#if __VERSION__ > 140\n" + "#if !GL_ES && __VERSION__ > 140\n" "\n" "out SHADER\n" "{\n" @@ -578,7 +598,7 @@ static const char* tfx_glsl = "\n" "#endif\n" "\n" - "#if __VERSION__ > 140\n" + "#if !GL_ES && __VERSION__ > 140\n" "out gl_PerVertex {\n" " invariant vec4 gl_Position;\n" " float gl_PointSize;\n" @@ -628,7 +648,7 @@ static const char* tfx_glsl = " {\n" " if(VS_FST != 0)\n" " {\n" - " VSout_t.xy = i_uv * TextureScale;\n" + " VSout_t.xy = vec2(i_uv) * TextureScale;\n" " VSout_t.w = 1.0f;\n" " }\n" " else\n" @@ -806,7 +826,7 @@ static const char* tfx_glsl = "\n" "#ifdef FRAGMENT_SHADER\n" "\n" - "#if __VERSION__ > 140\n" + "#if !GL_ES && __VERSION__ > 140\n" "\n" "in SHADER\n" "{\n" @@ -907,7 +927,7 @@ static const char* tfx_glsl = " }\n" " else if(PS_WMS == 3)\n" " {\n" - " uv_out = vec4(((ivec4(uv * WH.xyxy) & ivec4(MskFix.xyxy)) | ivec4(MskFix.zwzw)) / WH.xyxy);\n" + " uv_out = vec4((ivec4(uv * WH.xyxy) & ivec4(MskFix.xyxy)) | ivec4(MskFix.zwzw)) / WH.xyxy;\n" " }\n" " }\n" " else\n" @@ -918,7 +938,7 @@ static const char* tfx_glsl = " }\n" " else if(PS_WMS == 3)\n" " {\n" - " uv_out.xz = vec2(((ivec2(uv.xz * WH.xx) & ivec2(MskFix.xx)) | ivec2(MskFix.zz)) / WH.xx);\n" + " uv_out.xz = vec2((ivec2(uv.xz * WH.xx) & ivec2(MskFix.xx)) | ivec2(MskFix.zz)) / WH.xx;\n" " }\n" " if(PS_WMT == 2)\n" " {\n" @@ -926,7 +946,7 @@ static const char* tfx_glsl = " }\n" " else if(PS_WMT == 3)\n" " {\n" - " uv_out.yw = vec2(((ivec2(uv.yw * WH.yy) & ivec2(MskFix.yy)) | ivec2(MskFix.ww)) / WH.yy);\n" + " uv_out.yw = vec2((ivec2(uv.yw * WH.yy) & ivec2(MskFix.yy)) | ivec2(MskFix.ww)) / WH.yy;\n" " }\n" " }\n" "\n" @@ -976,7 +996,7 @@ static const char* tfx_glsl = " c.z = sample_c(uv.xw).r;\n" " c.w = sample_c(uv.zw).r;\n" "\n" - " return c * 255./256 + 0.5/256;\n" + " return c * 255.0/256.0 + 0.5/256.0;\n" "}\n" "\n" "mat4 sample_4p(vec4 u)\n" @@ -1067,11 +1087,11 @@ static const char* tfx_glsl = " {\n" " if(PS_TCC != 0) \n" " {\n" - " c_out = c * t * 255.0f / 128;\n" + " c_out = c * t * 255.0f / 128.0f;\n" " }\n" " else\n" " {\n" - " c_out.rgb = c.rgb * t.rgb * 255.0f / 128;\n" + " c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f;\n" " }\n" " }\n" " else if(PS_TFX == 1)\n" @@ -1087,7 +1107,7 @@ static const char* tfx_glsl = " }\n" " else if(PS_TFX == 2)\n" " {\n" - " c_out.rgb = c.rgb * t.rgb * 255.0f / 128 + c.a;\n" + " c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f + c.a;\n" "\n" " if(PS_TCC != 0) \n" " {\n" @@ -1096,7 +1116,7 @@ static const char* tfx_glsl = " }\n" " else if(PS_TFX == 3)\n" " {\n" - " c_out.rgb = c.rgb * t.rgb * 255.0f / 128 + c.a;\n" + " c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f + c.a;\n" "\n" " if(PS_TCC != 0) \n" " {\n" @@ -1111,7 +1131,7 @@ static const char* tfx_glsl = "{\n" "#if PS_DATE > 0\n" " float alpha = sample_rt(PSin_tp.xy).a;\n" - " float alpha0x80 = 128. / 255;\n" + " float alpha0x80 = 128.0 / 255;\n" "\n" " if (PS_DATE == 1 && alpha >= alpha0x80)\n" " discard;\n" @@ -1122,7 +1142,7 @@ static const char* tfx_glsl = "\n" "void atst(vec4 c)\n" "{\n" - " float a = trunc(c.a * 255 + 0.01);\n" + " float a = trunc(c.a * 255.0 + 0.01);\n" "\n" " if(PS_ATST == 0) // never\n" " {\n" @@ -1212,11 +1232,11 @@ static const char* tfx_glsl = "{\n" " vec4 c = ps_color();\n" "\n" - " float alpha = c.a * 2;\n" + " float alpha = c.a * 2.0;\n" "\n" " if(PS_AOUT != 0) // 16 bit output\n" " {\n" - " float a = 128.0f / 255; // alpha output will be 0x80\n" + " float a = 128.0f / 255.0; // alpha output will be 0x80\n" "\n" " c.a = (PS_FBA != 0) ? a : step(0.5, c.a) * a;\n" " }\n" @@ -1321,7 +1341,7 @@ static const char* fxaa_fx = "layout(binding = 0) uniform sampler2D TextureSampler;\n" "#endif\n" "\n" - "#if __VERSION__ > 140\n" + "#if !GL_ES && __VERSION__ > 140\n" "\n" "in SHADER\n" "{\n" diff --git a/plugins/GSdx/res/interlace.glsl b/plugins/GSdx/res/interlace.glsl index 824b138a00..b152b85863 100644 --- a/plugins/GSdx/res/interlace.glsl +++ b/plugins/GSdx/res/interlace.glsl @@ -6,7 +6,7 @@ struct vertex_basic vec2 t; }; -#if __VERSION__ > 140 +#if !GL_ES && __VERSION__ > 140 in SHADER { @@ -80,7 +80,7 @@ void ps_main2() vec4 c1 = texture(TextureSampler, PSin_t); vec4 c2 = texture(TextureSampler, PSin_t + ZrH); - SV_Target0 = (c0 + c1 * 2 + c2) / 4; + SV_Target0 = (c0 + c1 * 2.0f + c2) / 4.0f; } void ps_main3() diff --git a/plugins/GSdx/res/merge.glsl b/plugins/GSdx/res/merge.glsl index c689aacabb..fdcb94f77c 100644 --- a/plugins/GSdx/res/merge.glsl +++ b/plugins/GSdx/res/merge.glsl @@ -6,7 +6,7 @@ struct vertex_basic vec2 t; }; -#if __VERSION__ > 140 +#if !GL_ES && __VERSION__ > 140 in SHADER { @@ -53,7 +53,7 @@ layout(binding = 0) uniform sampler2D TextureSampler; void ps_main0() { vec4 c = texture(TextureSampler, PSin_t); - c.a = min(c.a * 2, 1.0); + c.a = min(c.a * 2.0, 1.0); SV_Target0 = c; } diff --git a/plugins/GSdx/res/shadeboost.glsl b/plugins/GSdx/res/shadeboost.glsl index 35136142a2..48e8112af5 100644 --- a/plugins/GSdx/res/shadeboost.glsl +++ b/plugins/GSdx/res/shadeboost.glsl @@ -14,7 +14,7 @@ struct vertex_basic #ifdef FRAGMENT_SHADER -#if __VERSION__ > 140 +#if !GL_ES && __VERSION__ > 140 in SHADER { diff --git a/plugins/GSdx/res/tfx.glsl b/plugins/GSdx/res/tfx.glsl index 8b4009d320..c581eafbf0 100644 --- a/plugins/GSdx/res/tfx.glsl +++ b/plugins/GSdx/res/tfx.glsl @@ -60,7 +60,7 @@ layout(location = 4) in uint i_z; layout(location = 5) in uvec2 i_uv; layout(location = 6) in vec4 i_f; -#if __VERSION__ > 140 +#if !GL_ES && __VERSION__ > 140 out SHADER { @@ -90,7 +90,7 @@ layout(location = 2) out vec4 SHADERc; #endif -#if __VERSION__ > 140 +#if !GL_ES && __VERSION__ > 140 out gl_PerVertex { invariant vec4 gl_Position; float gl_PointSize; @@ -140,7 +140,7 @@ void vs_main() { if(VS_FST != 0) { - VSout_t.xy = i_uv * TextureScale; + VSout_t.xy = vec2(i_uv) * TextureScale; VSout_t.w = 1.0f; } else @@ -318,7 +318,7 @@ void gs_main() #ifdef FRAGMENT_SHADER -#if __VERSION__ > 140 +#if !GL_ES && __VERSION__ > 140 in SHADER { @@ -419,7 +419,7 @@ vec4 wrapuv(vec4 uv) } else if(PS_WMS == 3) { - uv_out = vec4(((ivec4(uv * WH.xyxy) & ivec4(MskFix.xyxy)) | ivec4(MskFix.zwzw)) / WH.xyxy); + uv_out = vec4((ivec4(uv * WH.xyxy) & ivec4(MskFix.xyxy)) | ivec4(MskFix.zwzw)) / WH.xyxy; } } else @@ -430,7 +430,7 @@ vec4 wrapuv(vec4 uv) } else if(PS_WMS == 3) { - uv_out.xz = vec2(((ivec2(uv.xz * WH.xx) & ivec2(MskFix.xx)) | ivec2(MskFix.zz)) / WH.xx); + uv_out.xz = vec2((ivec2(uv.xz * WH.xx) & ivec2(MskFix.xx)) | ivec2(MskFix.zz)) / WH.xx; } if(PS_WMT == 2) { @@ -438,7 +438,7 @@ vec4 wrapuv(vec4 uv) } else if(PS_WMT == 3) { - uv_out.yw = vec2(((ivec2(uv.yw * WH.yy) & ivec2(MskFix.yy)) | ivec2(MskFix.ww)) / WH.yy); + uv_out.yw = vec2((ivec2(uv.yw * WH.yy) & ivec2(MskFix.yy)) | ivec2(MskFix.ww)) / WH.yy; } } @@ -488,7 +488,7 @@ vec4 sample_4a(vec4 uv) c.z = sample_c(uv.xw).r; c.w = sample_c(uv.zw).r; - return c * 255./256 + 0.5/256; + return c * 255.0/256.0 + 0.5/256.0; } mat4 sample_4p(vec4 u) @@ -579,11 +579,11 @@ vec4 tfx(vec4 t, vec4 c) { if(PS_TCC != 0) { - c_out = c * t * 255.0f / 128; + c_out = c * t * 255.0f / 128.0f; } else { - c_out.rgb = c.rgb * t.rgb * 255.0f / 128; + c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f; } } else if(PS_TFX == 1) @@ -599,7 +599,7 @@ vec4 tfx(vec4 t, vec4 c) } else if(PS_TFX == 2) { - c_out.rgb = c.rgb * t.rgb * 255.0f / 128 + c.a; + c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f + c.a; if(PS_TCC != 0) { @@ -608,7 +608,7 @@ vec4 tfx(vec4 t, vec4 c) } else if(PS_TFX == 3) { - c_out.rgb = c.rgb * t.rgb * 255.0f / 128 + c.a; + c_out.rgb = c.rgb * t.rgb * 255.0f / 128.0f + c.a; if(PS_TCC != 0) { @@ -623,7 +623,7 @@ void datst() { #if PS_DATE > 0 float alpha = sample_rt(PSin_tp.xy).a; - float alpha0x80 = 128. / 255; + float alpha0x80 = 128.0 / 255; if (PS_DATE == 1 && alpha >= alpha0x80) discard; @@ -634,7 +634,7 @@ void datst() void atst(vec4 c) { - float a = trunc(c.a * 255 + 0.01); + float a = trunc(c.a * 255.0 + 0.01); if(PS_ATST == 0) // never { @@ -724,11 +724,11 @@ void ps_main() { vec4 c = ps_color(); - float alpha = c.a * 2; + float alpha = c.a * 2.0; if(PS_AOUT != 0) // 16 bit output { - float a = 128.0f / 255; // alpha output will be 0x80 + float a = 128.0f / 255.0; // alpha output will be 0x80 c.a = (PS_FBA != 0) ? a : step(0.5, c.a) * a; }