diff --git a/GPU/Common/DepalettizeShaderCommon.cpp b/GPU/Common/DepalettizeShaderCommon.cpp index 36bd191a97..a6e52bdb4a 100644 --- a/GPU/Common/DepalettizeShaderCommon.cpp +++ b/GPU/Common/DepalettizeShaderCommon.cpp @@ -17,6 +17,7 @@ #include +#include "gfx_es2/gl_state.h" #include "Common/Log.h" #include "Core/Reporting.h" #include "GPU/GPUState.h" @@ -28,12 +29,12 @@ // Uses integer instructions available since OpenGL 3.0. Suitable for ES 3.0 as well. void GenerateDepalShader300(char *buffer, GEBufferFormat pixelFormat) { char *p = buffer; -#ifdef USING_GLES2 - WRITE(p, "#version 300 es\n"); - WRITE(p, "precision mediump float;\n"); -#else - WRITE(p, "#version 330\n"); -#endif + if (gl_extensions.IsGLES) { + WRITE(p, "#version 300 es\n"); + WRITE(p, "precision mediump float;\n"); + } else { + WRITE(p, "#version 330\n"); + } WRITE(p, "in vec2 v_texcoord0;\n"); WRITE(p, "out vec4 fragColor0;\n"); WRITE(p, "uniform sampler2D tex;\n"); @@ -218,12 +219,12 @@ void GenerateDepalShaderFloat(char *buffer, GEBufferFormat pixelFormat, ShaderLa sprintf(offset, " + %f", texel_offset); if (lang == GLSL_140) { -#ifdef USING_GLES2 - WRITE(p, "#version 100\n"); - WRITE(p, "precision mediump float;\n"); -#else - WRITE(p, "#version 110\n"); -#endif + if (gl_extensions.IsGLES) { + WRITE(p, "#version 100\n"); + WRITE(p, "precision mediump float;\n"); + } else { + WRITE(p, "#version 110\n"); + } WRITE(p, "varying vec2 v_texcoord0;\n"); WRITE(p, "uniform sampler2D tex;\n"); WRITE(p, "uniform sampler2D pal;\n"); diff --git a/GPU/GLES/FragmentShaderGenerator.cpp b/GPU/GLES/FragmentShaderGenerator.cpp index b518576262..858a200ca6 100644 --- a/GPU/GLES/FragmentShaderGenerator.cpp +++ b/GPU/GLES/FragmentShaderGenerator.cpp @@ -500,88 +500,78 @@ void GenerateFragmentShader(char *buffer) { bool bitwiseOps = false; const char *lastFragData = nullptr; -#if defined(USING_GLES2) - // Let's wait until we have a real use for this. - // ES doesn't support dual source alpha :( - if (gstate_c.featureFlags & GPU_SUPPORTS_GLSL_ES_300) { - WRITE(p, "#version 300 es\n"); // GLSL ES 3.0 - fragColor0 = "fragColor0"; - texture = "texture"; - glslES30 = true; - bitwiseOps = true; - texelFetch = "texelFetch"; - } else { - WRITE(p, "#version 100\n"); // GLSL ES 1.0 - if (gl_extensions.EXT_gpu_shader4) { - WRITE(p, "#extension GL_EXT_gpu_shader4 : enable\n"); + if (gl_extensions.IsGLES) { + // ES doesn't support dual source alpha :( + if (gstate_c.featureFlags & GPU_SUPPORTS_GLSL_ES_300) { + WRITE(p, "#version 300 es\n"); // GLSL ES 3.0 + fragColor0 = "fragColor0"; + texture = "texture"; + glslES30 = true; bitwiseOps = true; - texelFetch = "texelFetch2D"; + texelFetch = "texelFetch"; + } else { + WRITE(p, "#version 100\n"); // GLSL ES 1.0 + if (gl_extensions.EXT_gpu_shader4) { + WRITE(p, "#extension GL_EXT_gpu_shader4 : enable\n"); + bitwiseOps = true; + texelFetch = "texelFetch2D"; + } } - } - // PowerVR needs highp to do the fog in MHU correctly. - // Others don't, and some can't handle highp in the fragment shader. - highpFog = (gl_extensions.bugs & BUG_PVR_SHADER_PRECISION_BAD) ? true : false; - highpTexcoord = highpFog; + // PowerVR needs highp to do the fog in MHU correctly. + // Others don't, and some can't handle highp in the fragment shader. + highpFog = (gl_extensions.bugs & BUG_PVR_SHADER_PRECISION_BAD) ? true : false; + highpTexcoord = highpFog; - if (gstate_c.featureFlags & GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH) { - if (gl_extensions.EXT_shader_framebuffer_fetch) { - WRITE(p, "#extension GL_EXT_shader_framebuffer_fetch : require\n"); - lastFragData = "gl_LastFragData[0]"; - } else if (gl_extensions.NV_shader_framebuffer_fetch) { - // GL_NV_shader_framebuffer_fetch is available on mobile platform and ES 2.0 only but not on desktop. - WRITE(p, "#extension GL_NV_shader_framebuffer_fetch : require\n"); - lastFragData = "gl_LastFragData[0]"; - } else if (gl_extensions.ARM_shader_framebuffer_fetch) { - WRITE(p, "#extension GL_ARM_shader_framebuffer_fetch : require\n"); - lastFragData = "gl_LastFragColorARM"; + if (gstate_c.featureFlags & GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH) { + if (gl_extensions.EXT_shader_framebuffer_fetch) { + WRITE(p, "#extension GL_EXT_shader_framebuffer_fetch : require\n"); + lastFragData = "gl_LastFragData[0]"; + } else if (gl_extensions.NV_shader_framebuffer_fetch) { + // GL_NV_shader_framebuffer_fetch is available on mobile platform and ES 2.0 only but not on desktop. + WRITE(p, "#extension GL_NV_shader_framebuffer_fetch : require\n"); + lastFragData = "gl_LastFragData[0]"; + } else if (gl_extensions.ARM_shader_framebuffer_fetch) { + WRITE(p, "#extension GL_ARM_shader_framebuffer_fetch : require\n"); + lastFragData = "gl_LastFragColorARM"; + } } - } - WRITE(p, "precision lowp float;\n"); - -#elif !defined(FORCE_OPENGL_2_0) - if (gl_extensions.VersionGEThan(3, 3, 0)) { - fragColor0 = "fragColor0"; - texture = "texture"; - glslES30 = true; - bitwiseOps = true; - texelFetch = "texelFetch"; - WRITE(p, "#version 330\n"); - WRITE(p, "#define lowp\n"); - WRITE(p, "#define mediump\n"); - WRITE(p, "#define highp\n"); - } else if (gl_extensions.VersionGEThan(3, 0, 0)) { - fragColor0 = "fragColor0"; - bitwiseOps = true; - texelFetch = "texelFetch"; - WRITE(p, "#version 130\n"); - if (gl_extensions.EXT_gpu_shader4) { - WRITE(p, "#extension GL_EXT_gpu_shader4 : enable\n"); - } - // Remove lowp/mediump in non-mobile non-glsl 3 implementations - WRITE(p, "#define lowp\n"); - WRITE(p, "#define mediump\n"); - WRITE(p, "#define highp\n"); + WRITE(p, "precision lowp float;\n"); } else { - WRITE(p, "#version 110\n"); - if (gl_extensions.EXT_gpu_shader4) { - WRITE(p, "#extension GL_EXT_gpu_shader4 : enable\n"); + // TODO: Handle this in VersionGEThan? +#if !defined(FORCE_OPENGL_2_0) + if (gl_extensions.VersionGEThan(3, 3, 0)) { + fragColor0 = "fragColor0"; + texture = "texture"; + glslES30 = true; bitwiseOps = true; - texelFetch = "texelFetch2D"; + texelFetch = "texelFetch"; + WRITE(p, "#version 330\n"); + } else if (gl_extensions.VersionGEThan(3, 0, 0)) { + fragColor0 = "fragColor0"; + bitwiseOps = true; + texelFetch = "texelFetch"; + WRITE(p, "#version 130\n"); + if (gl_extensions.EXT_gpu_shader4) { + WRITE(p, "#extension GL_EXT_gpu_shader4 : enable\n"); + } + } else { + WRITE(p, "#version 110\n"); + if (gl_extensions.EXT_gpu_shader4) { + WRITE(p, "#extension GL_EXT_gpu_shader4 : enable\n"); + bitwiseOps = true; + texelFetch = "texelFetch2D"; + } } - // Remove lowp/mediump in non-mobile non-glsl 3 implementations - WRITE(p, "#define lowp\n"); - WRITE(p, "#define mediump\n"); - WRITE(p, "#define highp\n"); - } -#else - // Need to remove lowp/mediump for Mac - WRITE(p, "#define lowp\n"); - WRITE(p, "#define mediump\n"); - WRITE(p, "#define highp\n"); #endif + // We remove these everywhere - GL4, GL3, Mac-forced-GL2, etc. + WRITE(p, "#define lowp\n"); + WRITE(p, "#define mediump\n"); + WRITE(p, "#define highp\n"); + } + if (glslES30) { varying = "in"; } diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index c0ca056660..8164547c5c 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -705,15 +705,15 @@ void FramebufferManager::NotifyRenderFramebufferSwitched(VirtualFramebuffer *pre } textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_UPDATED); -#ifdef USING_GLES2 - // Some tiled mobile GPUs benefit IMMENSELY from clearing an FBO before rendering - // to it. This broke stuff before, so now it only clears on the first use of an - // FBO in a frame. This means that some games won't be able to avoid the on-some-GPUs - // performance-crushing framebuffer reloads from RAM, but we'll have to live with that. - if (vfb->last_frame_render != gpuStats.numFlips) { - ClearBuffer(); + if (gl_extensions.IsGLES) { + // Some tiled mobile GPUs benefit IMMENSELY from clearing an FBO before rendering + // to it. This broke stuff before, so now it only clears on the first use of an + // FBO in a frame. This means that some games won't be able to avoid the on-some-GPUs + // performance-crushing framebuffer reloads from RAM, but we'll have to live with that. + if (vfb->last_frame_render != gpuStats.numFlips) { + ClearBuffer(); + } } -#endif // Copy depth pixel value from the read framebuffer to the draw framebuffer if (prevVfb && !g_Config.bDisableSlowFramebufEffects) { @@ -1250,16 +1250,8 @@ void FramebufferManager::BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int fbo_bind_as_render_target(dst->fbo); glDisable(GL_SCISSOR_TEST); - bool useBlit = false; - bool useNV = false; - - if (gstate_c.Supports(GPU_SUPPORTS_ARB_FRAMEBUFFER_BLIT)) { - useNV = false; - useBlit = true; - } else if (gstate_c.Supports(GPU_SUPPORTS_NV_FRAMEBUFFER_BLIT)) { - useNV = true; - useBlit = true; - } + bool useBlit = gstate_c.Supports(GPU_SUPPORTS_ARB_FRAMEBUFFER_BLIT | GPU_SUPPORTS_NV_FRAMEBUFFER_BLIT); + bool useNV = useBlit && !gstate_c.Supports(GPU_SUPPORTS_ARB_FRAMEBUFFER_BLIT); float srcXFactor = useBlit ? (float)src->renderWidth / (float)src->bufferWidth : 1.0f; float srcYFactor = useBlit ? (float)src->renderHeight / (float)src->bufferHeight : 1.0f; diff --git a/GPU/GLES/StencilBuffer.cpp b/GPU/GLES/StencilBuffer.cpp index 8bc849267e..6cfd6ad52e 100644 --- a/GPU/GLES/StencilBuffer.cpp +++ b/GPU/GLES/StencilBuffer.cpp @@ -170,16 +170,8 @@ bool FramebufferManager::NotifyStencilUpload(u32 addr, int size, bool skipZero) glstate.stencilTest.enable(); glstate.stencilOp.set(GL_REPLACE, GL_REPLACE, GL_REPLACE); - bool useBlit = false; - bool useNV = false; - - if (gstate_c.Supports(GPU_SUPPORTS_ARB_FRAMEBUFFER_BLIT)) { - useNV = false; - useBlit = true; - } else if (gstate_c.Supports(GPU_SUPPORTS_NV_FRAMEBUFFER_BLIT)) { - useNV = true; - useBlit = true; - } + bool useBlit = gstate_c.Supports(GPU_SUPPORTS_ARB_FRAMEBUFFER_BLIT | GPU_SUPPORTS_NV_FRAMEBUFFER_BLIT); + bool useNV = useBlit && !gstate_c.Supports(GPU_SUPPORTS_ARB_FRAMEBUFFER_BLIT); // Our fragment shader (and discard) is slow. Since the source is 1x, we can stencil to 1x. // Then after we're done, we'll just blit it across and stretch it there. diff --git a/GPU/GLES/VertexShaderGenerator.cpp b/GPU/GLES/VertexShaderGenerator.cpp index 379043ca0b..9c25ddb1f9 100644 --- a/GPU/GLES/VertexShaderGenerator.cpp +++ b/GPU/GLES/VertexShaderGenerator.cpp @@ -192,48 +192,38 @@ void GenerateVertexShader(int prim, u32 vertType, char *buffer, bool useHWTransf bool highpFog = false; bool highpTexcoord = false; -#if defined(USING_GLES2) - // Let's wait until we have a real use for this. - // ES doesn't support dual source alpha :( - if (gl_extensions.GLES3) { - WRITE(p, "#version 300 es\n"); - glslES30 = true; + if (gl_extensions.IsGLES) { + // ES doesn't support dual source alpha :( + if (gl_extensions.GLES3) { + WRITE(p, "#version 300 es\n"); + glslES30 = true; + } else { + WRITE(p, "#version 100\n"); // GLSL ES 1.0 + } + WRITE(p, "precision highp float;\n"); + + // PowerVR needs highp to do the fog in MHU correctly. + // Others don't, and some can't handle highp in the fragment shader. + highpFog = (gl_extensions.bugs & BUG_PVR_SHADER_PRECISION_BAD) ? true : false; + highpTexcoord = highpFog; } else { - WRITE(p, "#version 100\n"); // GLSL ES 1.0 - } - WRITE(p, "precision highp float;\n"); - - // PowerVR needs highp to do the fog in MHU correctly. - // Others don't, and some can't handle highp in the fragment shader. - highpFog = (gl_extensions.bugs & BUG_PVR_SHADER_PRECISION_BAD) ? true : false; - highpTexcoord = highpFog; - -#elif !defined(FORCE_OPENGL_2_0) + // TODO: Handle this in VersionGEThan? +#if !defined(FORCE_OPENGL_2_0) if (gl_extensions.VersionGEThan(3, 3, 0)) { glslES30 = true; WRITE(p, "#version 330\n"); - WRITE(p, "#define lowp\n"); - WRITE(p, "#define mediump\n"); - WRITE(p, "#define highp\n"); } else if (gl_extensions.VersionGEThan(3, 0, 0)) { WRITE(p, "#version 130\n"); - // Remove lowp/mediump in non-mobile non-glsl 3 implementations - WRITE(p, "#define lowp\n"); - WRITE(p, "#define mediump\n"); - WRITE(p, "#define highp\n"); } else { WRITE(p, "#version 110\n"); - // Remove lowp/mediump in non-mobile non-glsl 3 implementations + } +#endif + + // We remove these everywhere - GL4, GL3, Mac-forced-GL2, etc. WRITE(p, "#define lowp\n"); WRITE(p, "#define mediump\n"); WRITE(p, "#define highp\n"); } -#else - // Need to remove lowp/mediump for Mac - WRITE(p, "#define lowp\n"); - WRITE(p, "#define mediump\n"); - WRITE(p, "#define highp\n"); -#endif if (glslES30) { attribute = "in"; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 61bfce2618..514e729751 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -365,11 +365,11 @@ void SystemInfoScreen::CreateViews() { deviceSpecs->Add(new ItemHeader("Version Information")); std::string apiVersion; if (g_Config.iGPUBackend == GPU_BACKEND_OPENGL) { -#ifdef USING_GLES2 - apiVersion = StringFromFormat("v%d.%d.%d ES", gl_extensions.ver[0], gl_extensions.ver[1], gl_extensions.ver[2]); -#else - apiVersion = StringFromFormat("v%d.%d.%d", gl_extensions.ver[0], gl_extensions.ver[1], gl_extensions.ver[2]); -#endif + if (gl_extensions.IsGLES) { + apiVersion = StringFromFormat("v%d.%d.%d ES", gl_extensions.ver[0], gl_extensions.ver[1], gl_extensions.ver[2]); + } else { + apiVersion = StringFromFormat("v%d.%d.%d", gl_extensions.ver[0], gl_extensions.ver[1], gl_extensions.ver[2]); + } } else { apiVersion = thin3d->GetInfoString(T3DInfo::APIVERSION); if (apiVersion.size() > 30) @@ -413,14 +413,13 @@ void SystemInfoScreen::CreateViews() { tabHolder->AddTab("OGL Extensions", oglExtensionsScroll); -#ifndef USING_GLES2 - oglExtensions->Add(new ItemHeader("OpenGL Extensions")); -#else - if (gl_extensions.GLES3) + if (!gl_extensions.IsGLES) { + oglExtensions->Add(new ItemHeader("OpenGL Extensions")); + } else if (gl_extensions.GLES3) { oglExtensions->Add(new ItemHeader("OpenGL ES 3.0 Extensions")); - else + } else { oglExtensions->Add(new ItemHeader("OpenGL ES 2.0 Extensions")); -#endif + } exts.clear(); SplitString(g_all_gl_extensions, ' ', exts);