Streamline frame_count usage

(Android/Griffin) Fix build
This commit is contained in:
twinaphex 2012-12-14 20:33:07 +01:00
parent c891bc353a
commit dbb962e946
18 changed files with 45 additions and 65 deletions

View File

@ -1160,8 +1160,8 @@ void menu_loop(void)
rarch_render_cached_frame();
else
{
device_ptr->ctx_driver->clear();
device_ptr->frame_count++;
device_ptr->ctx_driver->clear();
g_extern.frame_count++;
}
XINPUT_STATE state;

View File

@ -89,7 +89,6 @@ typedef struct gl
struct XenosShader * g_pVertexShader;
struct XenosShader * g_pPixelTexturedShader;
struct XenosSurface * g_pTexture;
unsigned frame_count;
} gl_t;
static float ScreenUv[4] = {0.f, 1.0f, 1.0f, 0.f};
@ -196,8 +195,6 @@ static bool xenon360_gfx_frame(void *data, const void *frame, unsigned width, un
{
gl_t *vid = data;
vid->frame_count++;
ScreenUv[UV_TOP] = ((float) (width) / (float) XE_W)*2;
ScreenUv[UV_LEFT] = ((float) (height) / (float) XE_H)*2;

View File

@ -49,7 +49,7 @@ ifeq ($(PERF_TEST), 1)
LOCAL_CFLAGS += -DPERF_TEST
endif
LOCAL_CFLAGS += -O3 -fno-stack-protector -funroll-loops -DNDEBUG -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_VID_CONTEXT -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_GLSL -DHAVE_ZLIB -DWANT_RZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREAD -D__LIBRETRO__ -DHAVE_CONFIGFILE=1 -DRARCH_PERFORMANCE_MODE -DRARCH_GPU_PERFORMANCE_MODE -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -std=gnu99 -DHAVE_FREETYPE
LOCAL_CFLAGS += -O3 -fno-stack-protector -funroll-loops -DNDEBUG -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_VID_CONTEXT -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_GLSL -DHAVE_ZLIB -DWANT_RZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREAD -D__LIBRETRO__ -DHAVE_CONFIGFILE=1 -DRARCH_PERFORMANCE_MODE -DRARCH_GPU_PERFORMANCE_MODE -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -std=gnu99
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -landroid -lEGL -lGLESv2 -llog -ldl
LOCAL_C_INCLUDES += $(LIBXML_PATH)

View File

@ -202,9 +202,13 @@ FONTS
#include "../../gfx/fonts/freetype.c"
#endif
#if defined(HAVE_FREETYPE) && !defined(ANDROID)
#include "../../gfx/fonts/fonts.c"
#elif defined(HAVE_FREETYPE) && defined(ANDROID)
#ifdef HAVE_OPENGL
#include "../../gfx/fonts/gl_font.c"
#endif
#if defined(ANDROID)
#include "../../gfx/fonts/bitmapfont.c"
#elif defined(HAVE_LIBDBGFONT)
#include "../../gfx/fonts/ps_libdbgfont.c"

View File

@ -17,9 +17,9 @@
#ifndef RARCH_CONSOLE_VIDEO_H__
#define RARCH_CONSOLE_VIDEO_H__
#define IS_TIMER_NOT_EXPIRED(handle, index) ((handle)->frame_count < g_extern.console.general_timers[(index)].expire_frame)
#define IS_TIMER_EXPIRED(handle, index) (!(IS_TIMER_NOT_EXPIRED((handle), (index))))
#define SET_TIMER_EXPIRATION(handle, index, value) (g_extern.console.general_timers[(index)].expire_frame = (handle)->frame_count + (value))
#define IS_TIMER_NOT_EXPIRED(index) (g_extern.frame_count < g_extern.console.general_timers[(index)].expire_frame)
#define IS_TIMER_EXPIRED(index) (!(IS_TIMER_NOT_EXPIRED(index)))
#define SET_TIMER_EXPIRATION(index, value) (g_extern.console.general_timers[(index)].expire_frame = g_extern.frame_count + (value))
#define MIN_SCALING_FACTOR (1.0f)

View File

@ -2260,10 +2260,10 @@ void menu_loop(void)
if(!first_held)
{
first_held = true;
SET_TIMER_EXPIRATION(device_ptr, 1, 7);
SET_TIMER_EXPIRATION(1, 7);
}
if(IS_TIMER_EXPIRED(device_ptr, 1))
if(IS_TIMER_EXPIRED(1))
{
first_held = false;
trig_state = input_state; //second input frame set as current frame
@ -2344,7 +2344,7 @@ void menu_loop(void)
old_state = input_state_first_frame;
if(IS_TIMER_EXPIRED(device_ptr, 0))
if(IS_TIMER_EXPIRED(0))
{
// if we want to force goto the emulation loop, skip this
if(g_extern.console.rmenu.mode != MODE_EMULATION)
@ -2372,7 +2372,7 @@ void menu_loop(void)
// press and holding L3 + R3 in the emulation loop (lasts for 30 frame ticks)
if(g_extern.console.rmenu.mode == MODE_EMULATION && !g_extern.console.screen.state.frame_advance.enable)
{
SET_TIMER_EXPIRATION(device_ptr, 0, 30);
SET_TIMER_EXPIRATION(0, 30);
}
const char * message = msg_queue_pull(g_extern.msg_queue);

View File

@ -234,9 +234,7 @@ typedef struct rarch_boolean_state
typedef struct rarch_frame_count
{
bool is_expired;
unsigned expire_frame;
unsigned current;
} rarch_frame_count_t;
typedef struct rarch_resolution
@ -456,6 +454,7 @@ struct global
size_t pitch;
} frame_cache;
unsigned frame_count;
char title_buf[64];
struct

View File

@ -414,7 +414,7 @@ static void gfx_ctx_rmenu_frame(void *data)
gl->shader->set_params(gl->win_width, gl->win_height,
gl->win_width, gl->win_height,
gl->win_width, gl->win_height,
gl->frame_count, NULL, NULL, NULL, 0);
g_extern.frame_count, NULL, NULL, NULL, 0);
}
glActiveTexture(GL_TEXTURE0);

View File

@ -374,7 +374,7 @@ static void gfx_ctx_rmenu_frame(void *data)
gl->shader->set_params(gl->win_width, gl->win_height,
gl->win_width, gl->win_height,
gl->win_width, gl->win_height,
gl->frame_count, NULL, NULL, NULL, 0);
g_extern.frame_count, NULL, NULL, NULL, 0);
}
glActiveTexture(GL_TEXTURE0);

View File

@ -79,8 +79,6 @@ static float tv_to_fps(const struct timeval *tv, const struct timeval *new_tv, i
return frames/time;
}
static unsigned gl_frames;
static bool gfx_get_fps(char *buf, size_t size, bool always_write)
{
static struct timeval tv;
@ -88,13 +86,13 @@ static bool gfx_get_fps(char *buf, size_t size, bool always_write)
struct timeval new_tv;
bool ret = false;
if (gl_frames == 0)
if (g_extern.frame_count == 0)
{
gettimeofday(&tv, NULL);
snprintf(buf, size, "%s", g_extern.title_buf);
ret = true;
}
else if ((gl_frames % 180) == 0)
else if ((g_extern.frame_count % 180) == 0)
{
gettimeofday(&new_tv, NULL);
struct timeval tmp_tv = tv;
@ -103,18 +101,18 @@ static bool gfx_get_fps(char *buf, size_t size, bool always_write)
last_fps = tv_to_fps(&tmp_tv, &new_tv, 180);
#ifdef RARCH_CONSOLE
snprintf(buf, size, "FPS: %6.1f || Frames: %d", last_fps, gl_frames);
snprintf(buf, size, "FPS: %6.1f || Frames: %d", last_fps, g_extern.frame_count);
#else
snprintf(buf, size, "%s || FPS: %6.1f || Frames: %d", g_extern.title_buf, last_fps, gl_frames);
snprintf(buf, size, "%s || FPS: %6.1f || Frames: %d", g_extern.title_buf, last_fps, g_extern.frame_count);
#endif
ret = true;
}
else if (always_write)
{
#ifdef RARCH_CONSOLE
snprintf(buf, size, "FPS: %6.1f || Frames: %d", last_fps, gl_frames);
snprintf(buf, size, "FPS: %6.1f || Frames: %d", last_fps, g_extern.frame_count);
#else
snprintf(buf, size, "%s || FPS: %6.1f || Frames: %d", g_extern.title_buf, last_fps, gl_frames);
snprintf(buf, size, "%s || FPS: %6.1f || Frames: %d", g_extern.title_buf, last_fps, g_extern.frame_count);
#endif
}
@ -123,21 +121,17 @@ static bool gfx_get_fps(char *buf, size_t size, bool always_write)
void gfx_window_title_reset(void)
{
gl_frames = 0;
g_extern.frame_count = 0;
}
bool gfx_window_title(char *buf, size_t size)
{
bool ret = gfx_get_fps(buf, size, false);
gl_frames++;
return ret;
return gfx_get_fps(buf, size, false);
}
void gfx_fps_title(char *buf, size_t size)
{
gfx_get_fps(buf, size, true);
gl_frames++;
}
#if defined(_WIN32) && !defined(_XBOX)

View File

@ -791,7 +791,7 @@ static void gl_frame_fbo(gl_t *gl, const struct gl_tex_info *tex_info)
gl_set_viewport(gl, rect->img_width, rect->img_height, true, false);
gl_shader_set_params_func(gl, prev_rect->img_width, prev_rect->img_height,
prev_rect->width, prev_rect->height,
gl->vp.width, gl->vp.height, gl->frame_count,
gl->vp.width, gl->vp.height, g_extern.frame_count,
tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt);
gl_shader_set_coords_func(gl, &gl->coords, &gl->mvp);
@ -817,7 +817,7 @@ static void gl_frame_fbo(gl_t *gl, const struct gl_tex_info *tex_info)
gl_set_viewport(gl, gl->win_width, gl->win_height, false, true);
gl_shader_set_params_func(gl, prev_rect->img_width, prev_rect->img_height,
prev_rect->width, prev_rect->height,
gl->vp.width, gl->vp.height, gl->frame_count,
gl->vp.width, gl->vp.height, g_extern.frame_count,
tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt);
gl->coords.vertex = vertex_ptr;
@ -1106,7 +1106,6 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
gl_t *gl = (gl_t*)data;
gl_shader_use_func(gl, 1);
gl->frame_count++;
#ifdef HAVE_FBO
// Render to texture in first pass.
@ -1156,7 +1155,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
gl_shader_set_params_func(gl, width, height,
gl->tex_w, gl->tex_h,
gl->vp.width, gl->vp.height,
gl->frame_count,
g_extern.frame_count,
&tex_info, gl->prev_info, NULL, 0);
gl_shader_set_coords_func(gl, &gl->coords, &gl->mvp);
@ -1563,7 +1562,7 @@ static bool gl_alive(void *data)
context_check_window_func(&quit,
&resize, &gl->win_width, &gl->win_height,
gl->frame_count);
g_extern.frame_count);
if (quit)
gl->quitting = true;
@ -1749,10 +1748,10 @@ static void gl_restart(void)
#ifdef HAVE_RMENU
gl->draw_rmenu = should_draw_rmenu;
gl->block_swap = should_block_swap;
SET_TIMER_EXPIRATION(gl, 0, 30);
SET_TIMER_EXPIRATION(0, 30);
#endif
gl->frame_count = 0;
g_extern.frame_count = 0;
}
static void gl_apply_state_changes(void)

View File

@ -45,7 +45,6 @@ typedef struct
unsigned mRenderWidth;
unsigned mRenderHeight;
unsigned x1, y1, x2, y2;
unsigned frame_count;
VGImageFormat mTexType;
VGImage mImage;
math_matrix_3x3 mTransformMatrix;
@ -357,7 +356,6 @@ static bool vg_frame(void *data, const void *frame, unsigned width, unsigned hei
RARCH_PERFORMANCE_INIT(vg_fr);
RARCH_PERFORMANCE_START(vg_fr);
vg_t *vg = (vg_t*)data;
vg->frame_count++;
if (width != vg->mRenderWidth || height != vg->mRenderHeight || vg->should_resize)
{
@ -401,7 +399,7 @@ static bool vg_alive(void *data)
vg->driver->check_window(&quit,
&vg->should_resize, &vg->mScreenWidth, &vg->mScreenHeight,
vg->frame_count);
g_extern.frame_count);
return !quit;
}

View File

@ -810,11 +810,7 @@ static bool gx_frame(void *data, const void *frame,
return true;
if (!frame)
{
width = height = 4; // draw a black square in the background
}
gx->frame_count++;
if(should_resize)
{

View File

@ -25,7 +25,6 @@ typedef struct gx_video
bool keep_aspect;
bool double_strike;
bool rgb32;
uint32_t frame_count;
uint32_t *menu_data;
unsigned win_width;
unsigned win_height;

View File

@ -442,9 +442,6 @@ static void ps3_input_post_init(void)
static bool ps3_input_key_pressed(void *data, int key)
{
(void)data;
#ifdef HAVE_OPENGL
gl_t *gl = driver.video_data;
#endif
if(g_extern.lifecycle_state & (1ULL << key))
return true;
@ -460,19 +457,19 @@ static bool ps3_input_key_pressed(void *data, int key)
}
return false;
case RARCH_QUIT_KEY:
#ifdef HAVE_OPENGL
if(IS_TIMER_EXPIRED(gl, 0))
#ifdef HAVE_RMENU
if(IS_TIMER_EXPIRED(0))
{
uint32_t r3_pressed = state[0] & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3);
uint32_t l3_pressed = state[0] & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3);
bool retval = false;
g_extern.console.rmenu.state.rmenu.enable = (r3_pressed && l3_pressed && IS_TIMER_EXPIRED(gl, 0));
g_extern.console.rmenu.state.rmenu.enable = (r3_pressed && l3_pressed && IS_TIMER_EXPIRED(0));
g_extern.console.rmenu.state.ingame_menu.enable = r3_pressed && !l3_pressed;
if(g_extern.console.rmenu.state.rmenu.enable || (g_extern.console.rmenu.state.ingame_menu.enable && !g_extern.console.rmenu.state.rmenu.enable))
{
g_extern.console.rmenu.mode = MODE_MENU;
SET_TIMER_EXPIRATION(gl, 0, 30);
SET_TIMER_EXPIRATION(0, 30);
retval = g_extern.console.rmenu.state.rmenu.enable;
}

View File

@ -122,8 +122,7 @@ static void check_window(xdk_d3d_video_t *d3d)
bool quit, resize;
d3d->ctx_driver->check_window(&quit,
&resize, NULL, NULL,
d3d->frame_count);
&resize, NULL, NULL, g_extern.frame_count);
if (quit)
d3d->quitting = true;
@ -693,7 +692,6 @@ static bool xdk_d3d_frame(void *data, const void *frame,
if (d3d->should_resize)
xdk_d3d_set_viewport(false);
d3d->frame_count++;
#ifdef _XBOX360
d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET,
0xff000000, 1.0f, 0);
@ -710,7 +708,7 @@ static bool xdk_d3d_frame(void *data, const void *frame,
{
#ifdef HAVE_HLSL
hlsl_set_params(width, height, d3d->tex_w, d3d->tex_h, g_settings.video.fbo.scale_x * width,
g_settings.video.fbo.scale_y * height, d3d->frame_count);
g_settings.video.fbo.scale_y * height, g_extern.frame_count);
#endif
D3DVIEWPORT vp = {0};
vp.Width = g_settings.video.fbo.scale_x * width;
@ -726,7 +724,7 @@ static bool xdk_d3d_frame(void *data, const void *frame,
{
#ifdef HAVE_HLSL
hlsl_set_params(width, height, d3d->tex_w, d3d->tex_h, d3d->win_width,
d3d->win_height, d3d->frame_count);
d3d->win_height, g_extern.frame_count);
#endif
}
@ -780,7 +778,7 @@ static bool xdk_d3d_frame(void *data, const void *frame,
#ifdef HAVE_HLSL
hlsl_use(2);
hlsl_set_params(g_settings.video.fbo.scale_x * width, g_settings.video.fbo.scale_y * height, g_settings.video.fbo.scale_x * d3d->tex_w, g_settings.video.fbo.scale_y * d3d->tex_h, d3d->win_width,
d3d->win_height, d3d->frame_count);
d3d->win_height, g_extern.frame_count);
#endif
xdk_d3d_set_viewport(false);

View File

@ -59,7 +59,6 @@ typedef struct xdk_d3d_video
bool should_resize;
bool quitting;
bool vsync;
unsigned frame_count;
unsigned last_width;
unsigned last_height;
unsigned win_width;

View File

@ -338,18 +338,18 @@ static bool xdk_input_key_pressed(void *data, int key)
case RARCH_REWIND:
return ((state[0] & XINPUT1_GAMEPAD_RSTICK_UP_MASK) && !(state[0] & XINPUT1_GAMEPAD_RIGHT_TRIGGER));
case RARCH_QUIT_KEY:
if(IS_TIMER_EXPIRED(d3d, 0))
if(IS_TIMER_EXPIRED(0))
{
uint32_t left_thumb_pressed = (state[0] & (1 << RETRO_DEVICE_ID_JOYPAD_L3));
uint32_t right_thumb_pressed = (state[0] & (1 << RETRO_DEVICE_ID_JOYPAD_R3));
g_extern.console.rmenu.state.rmenu.enable = right_thumb_pressed && left_thumb_pressed && IS_TIMER_EXPIRED(d3d, 0);
g_extern.console.rmenu.state.rmenu.enable = right_thumb_pressed && left_thumb_pressed && IS_TIMER_EXPIRED(0);
g_extern.console.rmenu.state.ingame_menu.enable = right_thumb_pressed && !left_thumb_pressed;
if(g_extern.console.rmenu.state.rmenu.enable || (g_extern.console.rmenu.state.ingame_menu.enable && !g_extern.console.rmenu.state.rmenu.enable))
{
g_extern.console.rmenu.mode = MODE_MENU;
SET_TIMER_EXPIRATION(d3d, 0, 30);
SET_TIMER_EXPIRATION(0, 30);
retval = g_extern.console.rmenu.state.rmenu.enable;
}
retval = g_extern.console.rmenu.state.ingame_menu.enable ? g_extern.console.rmenu.state.ingame_menu.enable : g_extern.console.rmenu.state.rmenu.enable;