From 80702109f53968b45d947bdd4495585b68e54220 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Wed, 16 Oct 2013 00:47:57 +0200 Subject: [PATCH] Move gpu vendor detection to native with the rest of the gl init. Also disable vertical layout for mainscreen entirely. --- GPU/Directx9/FramebufferDX9.h | 1 - GPU/GLES/FragmentShaderGenerator.cpp | 20 +++++++++------- GPU/GLES/Framebuffer.cpp | 35 ++++------------------------ GPU/GLES/Framebuffer.h | 11 --------- GPU/GLES/ShaderManager.cpp | 4 ++-- GPU/GPUState.h | 1 - UI/MainScreen.cpp | 5 ++-- native | 2 +- 8 files changed, 20 insertions(+), 59 deletions(-) diff --git a/GPU/Directx9/FramebufferDX9.h b/GPU/Directx9/FramebufferDX9.h index 5488dc9ee..ce85a4a50 100644 --- a/GPU/Directx9/FramebufferDX9.h +++ b/GPU/Directx9/FramebufferDX9.h @@ -152,7 +152,6 @@ private: // Used by ReadFramebufferToMemory void BlitFramebuffer_(VirtualFramebufferDX9 *src, VirtualFramebufferDX9 *dst, bool flip = false, float upscale = 1.0f, float vscale = 1.0f); void PackFramebufferDirectx9_(VirtualFramebufferDX9 *vfb); - int gpuVendor; std::vector bvfbs_; // blitting FBOs // Used by DrawPixels diff --git a/GPU/GLES/FragmentShaderGenerator.cpp b/GPU/GLES/FragmentShaderGenerator.cpp index cac6dd7c8..b57cc26c1 100644 --- a/GPU/GLES/FragmentShaderGenerator.cpp +++ b/GPU/GLES/FragmentShaderGenerator.cpp @@ -27,13 +27,15 @@ #endif #endif -#include "FragmentShaderGenerator.h" -#include "Framebuffer.h" -#include "../ge_constants.h" -#include "../GPUState.h" -#include "Core/Reporting.h" #include +#include "gfx_es2/gl_state.h" +#include "Core/Reporting.h" +#include "GPU/GLES/FragmentShaderGenerator.h" +#include "GPU/GLES/Framebuffer.h" +#include "GPU/ge_constants.h" +#include "GPU/GPUState.h" + #define WRITE p+=sprintf // #define DEBUG_SHADER @@ -250,13 +252,13 @@ void GenerateFragmentShader(char *buffer) { } if (enableAlphaTest) { - if (gstate_c.gpuVendor == GPU_VENDOR_POWERVR) + if (gl_extensions.gpuVendor == GPU_VENDOR_POWERVR) WRITE(p, "float roundTo255thf(in mediump float x) { mediump float y = x + (0.5/255.0); return y - fract(y * 255.0) * (1.0 / 255.0); }\n"); else WRITE(p, "float roundAndScaleTo255f(in float x) { return floor(x * 255.0 + 0.5); }\n"); } if (enableColorTest) { - if (gstate_c.gpuVendor == GPU_VENDOR_POWERVR) + if (gl_extensions.gpuVendor == GPU_VENDOR_POWERVR) WRITE(p, "vec3 roundTo255thv(in vec3 x) { vec3 y = x + (0.5/255.0); return y - fract(y * 255.0) * (1.0 / 255.0); }\n"); else WRITE(p, "vec3 roundAndScaleTo255v(in vec3 x) { return floor(x * 255.0 + 0.5); }\n"); @@ -326,7 +328,7 @@ void GenerateFragmentShader(char *buffer) { GEComparison alphaTestFunc = gstate.getAlphaTestFunction(); const char *alphaTestFuncs[] = { "#", "#", " != ", " == ", " >= ", " > ", " <= ", " < " }; // never/always don't make sense if (alphaTestFuncs[alphaTestFunc][0] != '#') { - if (gstate_c.gpuVendor == GPU_VENDOR_POWERVR) { + if (gl_extensions.gpuVendor == GPU_VENDOR_POWERVR) { // Work around bad PVR driver problem where equality check + discard just doesn't work. if (alphaTestFunc != 3) WRITE(p, " if (roundTo255thf(v.a) %s u_alphacolorref.a) discard;\n", alphaTestFuncs[alphaTestFunc]); @@ -351,7 +353,7 @@ void GenerateFragmentShader(char *buffer) { WARN_LOG_REPORT_ONCE(colortest, G3D, "Color test function : %s", colorTestFuncs[colorTestFunc]); u32 colorTestMask = gstate.getColorTestMask(); if (colorTestFuncs[colorTestFunc][0] != '#') { - if (gstate_c.gpuVendor == GPU_VENDOR_POWERVR) + if (gl_extensions.gpuVendor == GPU_VENDOR_POWERVR) WRITE(p, "if (roundTo255thv(v.rgb) %s u_alphacolorref.rgb) discard;\n", colorTestFuncs[colorTestFunc]); else WRITE(p, "if (roundAndScaleTo255v(v.rgb) %s u_alphacolorref.rgb) discard;\n", colorTestFuncs[colorTestFunc]); diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index cfa91d69f..f7cbe87bc 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -263,36 +263,6 @@ FramebufferManager::FramebufferManager() : useBufferedRendering_ = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; - // Check vendor string to try and guess GPU - const char *cvendor = (char *)glGetString(GL_VENDOR); - if (cvendor) { - const std::string vendor(cvendor); - if (vendor == "NVIDIA Corporation" - || vendor == "Nouveau" - || vendor == "nouveau") { - gpuVendor = GPU_VENDOR_NVIDIA; - } else if (vendor == "Advanced Micro Devices, Inc." - || vendor == "ATI Technologies Inc.") { - gpuVendor = GPU_VENDOR_AMD; - } else if (vendor == "Intel" - || vendor == "Intel Inc." - || vendor == "Intel Corporation" - || vendor == "Tungsten Graphics, Inc") { // We'll assume this last one means Intel - gpuVendor = GPU_VENDOR_INTEL; - } else if (vendor == "ARM") { - gpuVendor = GPU_VENDOR_ARM; - } else if (vendor == "Imagination Technologies") { - gpuVendor = GPU_VENDOR_POWERVR; - } else if (vendor == "Qualcomm") { - gpuVendor = GPU_VENDOR_ADRENO; - } else { - gpuVendor = GPU_VENDOR_UNKNOWN; - } - } else { - gpuVendor = GPU_VENDOR_UNKNOWN; - } - gstate_c.gpuVendor = gpuVendor; - NOTICE_LOG(SCEGE, "GPU Vendor : %s", cvendor); SetLineWidth(); } @@ -715,6 +685,9 @@ void FramebufferManager::SetRenderFrameBuffer() { if (useBufferedRendering_) { if (vfb->fbo) { fbo_bind_as_render_target(vfb->fbo); + // adreno needs us to reset the viewport after switching render targets. + + glstate.viewport.restore(); } else { // wtf? This should only happen very briefly when toggling bBufferedRendering fbo_unbind(); @@ -1113,7 +1086,7 @@ void FramebufferManager::PackFramebufferAsync_(VirtualFramebuffer *vfb) { if (vfb) { int pixelType, pixelSize, pixelFormat, align; - bool reverseOrder = (gpuVendor == GPU_VENDOR_NVIDIA) || (gpuVendor == GPU_VENDOR_AMD); + bool reverseOrder = (gl_extensions.gpuVendor == GPU_VENDOR_NVIDIA) || (gl_extensions.gpuVendor == GPU_VENDOR_AMD); switch (vfb->format) { // GL_UNSIGNED_INT_8_8_8_8 returns A B G R (little-endian, tested in Nvidia card/x86 PC) // GL_UNSIGNED_BYTE returns R G B A in consecutive bytes ("big-endian"/not treated as 32-bit value) diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index 1022824ed..755d335e6 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -38,16 +38,6 @@ enum { FB_USAGE_TEXTURE = 4, }; -enum { - GPU_VENDOR_NVIDIA = 1, - GPU_VENDOR_AMD = 2, - GPU_VENDOR_INTEL = 3, - GPU_VENDOR_ARM = 4, - GPU_VENDOR_POWERVR = 5, - GPU_VENDOR_ADRENO = 6, - GPU_VENDOR_UNKNOWN = 0, -}; - enum { FB_NON_BUFFERED_MODE = 0, FB_BUFFERED_MODE = 1, @@ -200,7 +190,6 @@ private: void PackFramebufferAsync_(VirtualFramebuffer *vfb); #endif void PackFramebufferSync_(VirtualFramebuffer *vfb); - int gpuVendor; std::vector bvfbs_; // blitting FBOs std::set> knownFramebufferCopies_; diff --git a/GPU/GLES/ShaderManager.cpp b/GPU/GLES/ShaderManager.cpp index 3a962ea9f..988661d2a 100644 --- a/GPU/GLES/ShaderManager.cpp +++ b/GPU/GLES/ShaderManager.cpp @@ -25,8 +25,8 @@ #include - #include "base/logging.h" +#include "gfx_es2/gl_state.h" #include "math/lin/matrix4x4.h" #include "Core/Config.h" @@ -227,7 +227,7 @@ static void SetColorUniform3Alpha(int uniform, u32 color, u8 alpha) { // This passes colors unscaled (e.g. 0 - 255 not 0 - 1.) static void SetColorUniform3Alpha255(int uniform, u32 color, u8 alpha) { - if (gstate_c.gpuVendor == GPU_VENDOR_POWERVR) { + if (gl_extensions.gpuVendor == GPU_VENDOR_POWERVR) { const float col[4] = { (float)((color & 0xFF)) * (1.0f / 255.0f), (float)((color & 0xFF00) >> 8) * (1.0f / 255.0f), diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 7652a7d6a..434f45eb4 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -454,7 +454,6 @@ struct GPUStateCache u32 curRTHeight; u32 getRelativeAddress(u32 data) const; - int gpuVendor; }; // TODO: Implement support for these. diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 355632327..9b688a7f7 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -480,9 +480,8 @@ void MainScreen::CreateViews() { // Scrolling action menu to the right. using namespace UI; - bool vertical = dp_yres > dp_xres; - - ILOG("Vertical? %c : %i %i", vertical ? 'Y' : 'N', dp_xres, dp_yres); + // Vertical mode is not finished. + bool vertical = false; // dp_yres > dp_xres; I18NCategory *m = GetI18NCategory("MainMenu"); diff --git a/native b/native index 5e1a52a84..aa67389dc 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 5e1a52a84146f17e010dfbe8191f14eaf2d99dab +Subproject commit aa67389dcd0be4ae00af1f048a7111804081a0f8