Move GLExtensions to a new header that is not pulling in GL headers.

Start moving out detection functionality that does not need GL headers to gpu_features.cpp.
This commit is contained in:
Henrik Rydgård 2013-10-25 10:57:26 +02:00
parent 421261de82
commit 4c676c3904
5 changed files with 80 additions and 42 deletions

View File

@ -55,6 +55,7 @@ LOCAL_SRC_FILES :=\
thread/prioritizedworkqueue.cpp \
thread/threadpool.cpp \
gfx_es2/glsl_program.cpp \
gfx_es2/gpu_features.cpp \
gfx_es2/gl_state.cpp.arm \
gfx_es2/gl3stub.c \
gfx_es2/draw_buffer.cpp.arm \

View File

@ -1,6 +1,7 @@
#include <stdlib.h>
#include "base/logging.h"
#include "base/NativeApp.h"
#include "gl_state.h"
#ifdef _WIN32
@ -104,6 +105,7 @@ void CheckGLExtensions() {
// Check vendor string to try and guess GPU
const char *cvendor = (char *)glGetString(GL_VENDOR);
// TODO: move this stuff to gpu_features.cpp
if (cvendor) {
const std::string vendor(cvendor);
if (vendor == "NVIDIA Corporation"
@ -293,6 +295,8 @@ void CheckGLExtensions() {
gl_extensions.ATIClampBug = ((strncmp (renderer, "ATI RADEON X", 12) != 0) || (strncmp (renderer, "ATI MOBILITY RADEON X",21) != 0));
}
#endif
ProcessGPUFeatures();
}
void OpenGLState::SetVSyncInterval(int interval) {

View File

@ -4,6 +4,7 @@
#include <string.h>
#include <string>
#include "gfx/gl_common.h"
#include "gfx_es2/gpu_features.h"
#ifdef USING_GLES2
@ -303,50 +304,8 @@ public:
extern OpenGLState glstate;
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,
};
// Extensions to look at using:
// GL_NV_map_buffer_range (same as GL_ARB_map_buffer_range ?)
// WARNING: This gets memset-d - so no strings please
struct GLExtensions {
int ver[3];
int gpuVendor;
bool GLES3; // true if the full OpenGL ES 3.0 is supported
bool OES_depth24;
bool OES_packed_depth_stencil;
bool OES_depth_texture;
bool EXT_discard_framebuffer;
bool FBO_ARB;
bool FBO_EXT;
bool PBO_ARB;
bool EXT_swap_control_tear;
bool QCOM_alpha_test;
bool OES_mapbuffer;
bool OES_vertex_array_object;
bool EXT_shader_framebuffer_fetch;
bool EXT_blend_minmax;
bool ATIClampBug;
bool NV_draw_texture;
bool NV_copy_image;
// EGL extensions
bool EGL_NV_system_time;
bool EGL_NV_coverage_sample;
};
extern std::string g_all_gl_extensions;
extern std::string g_all_egl_extensions;
extern GLExtensions gl_extensions;
void CheckGLExtensions();

9
gfx_es2/gpu_features.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "gfx_es2/gpu_features.h"
void ProcessGPUFeatures() {
gl_extensions.bugs = 0;
// Should be table driven instead, this is a quick hack for Galaxy Y
if (System_GetProperty(SYSPROP_NAME) == "samsung:GT-S5360") {
gl_extensions.bugs |= BUG_FBO_UNUSABLE;
}
}

65
gfx_es2/gpu_features.h Normal file
View File

@ -0,0 +1,65 @@
// This file will not pull in the OpenGL headers but will still let you
// access information about the features of the current GPU, for auto-config
// and similar purposes.
#pragma once
#include "base/NativeApp.h"
enum {
GPU_VENDOR_NVIDIA = 1,
GPU_VENDOR_AMD = 2,
GPU_VENDOR_INTEL = 3,
GPU_VENDOR_ARM = 4, // Mali
GPU_VENDOR_POWERVR = 5,
GPU_VENDOR_ADRENO = 6,
GPU_VENDOR_BROADCOM = 7,
GPU_VENDOR_UNKNOWN = 0,
};
enum {
BUG_FBO_UNUSABLE=1
};
// Extensions to look at using:
// GL_NV_map_buffer_range (same as GL_ARB_map_buffer_range ?)
// WARNING: This gets memset-d - so no strings please
// TODO: Rename this GLFeatures or something.
struct GLExtensions {
int ver[3];
int gpuVendor;
bool GLES3; // true if the full OpenGL ES 3.0 is supported
bool OES_depth24;
bool OES_packed_depth_stencil;
bool OES_depth_texture;
bool EXT_discard_framebuffer;
bool FBO_ARB;
bool FBO_EXT;
bool PBO_ARB;
bool EXT_swap_control_tear;
bool QCOM_alpha_test;
bool OES_mapbuffer;
bool OES_vertex_array_object;
bool EXT_shader_framebuffer_fetch;
bool EXT_blend_minmax;
bool ATIClampBug;
bool NV_draw_texture;
bool NV_copy_image;
// EGL extensions
bool EGL_NV_system_time;
bool EGL_NV_coverage_sample;
// Bugs
int bugs;
};
extern GLExtensions gl_extensions;
// Call this after filling out vendor etc to lookup the bugs etc.
// Only needs to be called ones. Currently called by CheckGLExtensions().
void ProcessGPUFeatures();