mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-21 17:30:46 +00:00
Add some disabled code to use EGL_NV_system_time for timing.
This gives NV PerfHud ES some interesting capabilities (can pause, speedup, slow down from the debugger UI).
This commit is contained in:
parent
96d7a58ba0
commit
5d3f2e8b5d
@ -77,7 +77,7 @@ LOCAL_SRC_FILES :=\
|
||||
util/random/perlin.cpp \
|
||||
util/text/utf8.cpp
|
||||
|
||||
LOCAL_CFLAGS := -O3 -DGL_GLEXT_PROTOTYPES -DUSING_GLES2 -fsigned-char -fno-strict-aliasing
|
||||
LOCAL_CFLAGS := -O3 -DUSING_GLES2 -fsigned-char -fno-strict-aliasing
|
||||
LOCAL_CPPFLAGS := -fno-exceptions -std=gnu++11 -frtti
|
||||
LOCAL_LDLIBS := -lz
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ext/libzip
|
||||
|
@ -3,7 +3,7 @@
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
|
@ -2,6 +2,9 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/timeutil.h"
|
||||
|
||||
// For NV time functions. Ugly!
|
||||
#include "gfx_es2/gl_state.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
@ -31,7 +34,23 @@ double real_time_now(){
|
||||
|
||||
#else
|
||||
|
||||
uint64_t _frequency = 0;
|
||||
uint64_t _starttime = 0;
|
||||
|
||||
double real_time_now() {
|
||||
if (false && gl_extensions.EGL_NV_system_time) {
|
||||
// This is needed to profile using PerfHUD on Tegra
|
||||
if (_frequency == 0) {
|
||||
_frequency = eglGetSystemTimeFrequencyNV();
|
||||
_starttime = eglGetSystemTimeNV();
|
||||
}
|
||||
|
||||
uint64_t cur = eglGetSystemTimeNV();
|
||||
int64_t diff = cur - _starttime;
|
||||
|
||||
return (double)diff / (double)_frequency;
|
||||
}
|
||||
|
||||
static time_t start;
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
|
@ -10,24 +10,6 @@
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
// Additional extensions not included in GLES2/gl2ext.h from the NDK
|
||||
|
||||
/* GL_QCOM_alpha_test */
|
||||
#ifndef GL_QCOM_alpha_test
|
||||
#define GL_ALPHA_TEST_QCOM 0x0BC0
|
||||
#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1
|
||||
#define GL_ALPHA_TEST_REF_QCOM 0x0BC2
|
||||
#endif
|
||||
|
||||
#ifndef GL_QCOM_alpha_test
|
||||
#define GL_QCOM_alpha_test 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
//GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref);
|
||||
#endif
|
||||
typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
|
||||
extern PFNGLALPHAFUNCQCOMPROC glAlphaFuncQCOM;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#else // OpenGL
|
||||
#include <GL/glew.h>
|
||||
|
@ -7,6 +7,9 @@
|
||||
|
||||
#if defined(USING_GLES2) && !defined(IOS)
|
||||
PFNGLALPHAFUNCQCOMPROC glAlphaFuncQCOM;
|
||||
PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC eglGetSystemTimeFrequencyNV;
|
||||
PFNEGLGETSYSTEMTIMENVPROC eglGetSystemTimeNV;
|
||||
PFNGLDISCARDFRAMEBUFFEREXTPROC glDiscardFramebufferEXT;
|
||||
#endif
|
||||
|
||||
|
||||
@ -77,16 +80,34 @@ void CheckGLExtensions() {
|
||||
gl_extensions.OES_depth24 = strstr(extString, "GL_OES_depth24") != 0;
|
||||
gl_extensions.OES_depth_texture = strstr(extString, "GL_OES_depth_texture") != 0;
|
||||
gl_extensions.OES_mapbuffer = strstr(extString, "GL_OES_mapbuffer") != 0;
|
||||
gl_extensions.EXT_discard_framebuffer = strstr(extString, "GL_EXT_discard_framebuffer") != 0;
|
||||
|
||||
#ifdef USING_GLES2
|
||||
gl_extensions.EXT_discard_framebuffer = strstr(extString, "GL_EXT_discard_framebuffer");
|
||||
if (gl_extensions.EXT_discard_framebuffer) {
|
||||
glDiscardFramebufferEXT = (PFNGLDISCARDFRAMEBUFFEREXTPROC)eglGetProcAddress("glDiscardFramebufferEXT");
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: Change to USING_GLES2 if it works on those other platforms too
|
||||
#ifdef ANDROID
|
||||
gl_extensions.QCOM_alpha_test = strstr(extString, "GL_QCOM_alpha_test") != 0;
|
||||
// Load extensions that are not auto-loaded by Android.
|
||||
if (gl_extensions.QCOM_alpha_test) {
|
||||
glAlphaFuncQCOM = (PFNGLALPHAFUNCQCOMPROC)eglGetProcAddress("glAlphaFuncQCOM");
|
||||
}
|
||||
|
||||
// Look for EGL extensions
|
||||
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
|
||||
const char *eglString = eglQueryString(display, EGL_EXTENSIONS);
|
||||
|
||||
gl_extensions.EGL_NV_system_time = strstr(eglString, "EGL_NV_system_time") != 0;
|
||||
gl_extensions.EGL_NV_coverage_sample = strstr(eglString, "EGL_NV_coverage_sample") != 0;
|
||||
|
||||
if (gl_extensions.EGL_NV_system_time) {
|
||||
eglGetSystemTimeNV = (PFNEGLGETSYSTEMTIMENVPROC) eglGetProcAddress("eglGetSystemTimeNV");
|
||||
eglGetSystemTimeFrequencyNV = (PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) eglGetProcAddress("eglGetSystemTimeFrequencyNV");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USING_GLES2
|
||||
|
@ -4,6 +4,31 @@
|
||||
#include <string.h>
|
||||
#include "gfx/gl_common.h"
|
||||
|
||||
#ifdef USING_GLES2
|
||||
|
||||
#ifdef ANDROID
|
||||
// Additional extensions not included in GLES2/gl2ext.h from the NDK
|
||||
|
||||
/* GL_QCOM_alpha_test */
|
||||
#define GL_ALPHA_TEST_QCOM 0x0BC0
|
||||
#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1
|
||||
#define GL_ALPHA_TEST_REF_QCOM 0x0BC2
|
||||
|
||||
typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
|
||||
extern PFNGLALPHAFUNCQCOMPROC glAlphaFuncQCOM;
|
||||
|
||||
#endif
|
||||
|
||||
typedef uint64_t EGLuint64NV;
|
||||
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void);
|
||||
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void);
|
||||
extern PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC eglGetSystemTimeFrequencyNV;
|
||||
extern PFNEGLGETSYSTEMTIMENVPROC eglGetSystemTimeNV;
|
||||
|
||||
extern PFNGLDISCARDFRAMEBUFFEREXTPROC glDiscardFramebufferEXT;
|
||||
|
||||
#endif /* EGL_NV_system_time */
|
||||
|
||||
|
||||
// OpenGL state cache. Should convert all code to use this instead of directly calling glEnable etc,
|
||||
// as GL state changes can be expensive on some hardware.
|
||||
@ -210,6 +235,11 @@ struct GLExtensions {
|
||||
bool EXT_swap_control_tear;
|
||||
bool QCOM_alpha_test;
|
||||
bool OES_mapbuffer;
|
||||
|
||||
// EGL extensions
|
||||
|
||||
bool EGL_NV_system_time;
|
||||
bool EGL_NV_coverage_sample;
|
||||
};
|
||||
|
||||
extern GLExtensions gl_extensions;
|
||||
|
Loading…
x
Reference in New Issue
Block a user