Move gpu vendor detection to native with the rest of the gl init.

Also disable vertical layout for mainscreen entirely.
This commit is contained in:
Henrik Rydgard 2013-10-16 00:47:57 +02:00
parent bfea9bba4b
commit 80702109f5
8 changed files with 20 additions and 59 deletions

View File

@ -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<VirtualFramebufferDX9 *> bvfbs_; // blitting FBOs
// Used by DrawPixels

View File

@ -27,13 +27,15 @@
#endif
#endif
#include "FragmentShaderGenerator.h"
#include "Framebuffer.h"
#include "../ge_constants.h"
#include "../GPUState.h"
#include "Core/Reporting.h"
#include <cstdio>
#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]);

View File

@ -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)

View File

@ -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<VirtualFramebuffer *> bvfbs_; // blitting FBOs
std::set<std::pair<u32, u32>> knownFramebufferCopies_;

View File

@ -25,8 +25,8 @@
#include <map>
#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),

View File

@ -454,7 +454,6 @@ struct GPUStateCache
u32 curRTHeight;
u32 getRelativeAddress(u32 data) const;
int gpuVendor;
};
// TODO: Implement support for these.

View File

@ -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");

2
native

@ -1 +1 @@
Subproject commit 5e1a52a84146f17e010dfbe8191f14eaf2d99dab
Subproject commit aa67389dcd0be4ae00af1f048a7111804081a0f8