global_get_ptr update pt. 3

This commit is contained in:
twinaphex 2015-03-21 05:55:31 +01:00
parent 5a443d229a
commit 2409da4afe
15 changed files with 60 additions and 42 deletions

View File

@ -32,7 +32,6 @@
#endif
static settings_t *g_config;
struct global g_extern;
struct defaults g_defaults;
/**

View File

@ -248,6 +248,7 @@ static void android_gfx_ctx_check_window(void *data, bool *quit,
bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
{
unsigned new_width, new_height;
global_t *global = global_get_ptr();
(void)frame_count;
@ -263,7 +264,7 @@ static void android_gfx_ctx_check_window(void *data, bool *quit,
}
/* Check if we are exiting. */
if (g_extern.system.shutdown)
if (global->system.shutdown)
*quit = true;
}

View File

@ -324,6 +324,7 @@ static void gfx_ctx_qnx_check_window(void *data, bool *quit,
bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
{
unsigned new_width, new_height;
global_t *global = global_get_ptr();
(void)data;
(void)frame_count;
@ -339,7 +340,7 @@ static void gfx_ctx_qnx_check_window(void *data, bool *quit,
}
/* Check if we are exiting. */
if (g_extern.system.shutdown)
if (global->system.shutdown)
*quit = true;
}

View File

@ -169,6 +169,7 @@ void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS
{
d3d_video_t *d3d =(d3d_video_t*)data;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
memset(d3dpp, 0, sizeof(*d3dpp));
@ -204,7 +205,7 @@ void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS
#ifdef _XBOX
d3dpp->BackBufferFormat =
#ifdef _XBOX360
g_extern.console.screen.gamma_correction ?
global->console.screen.gamma_correction ?
(D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) :
#endif
info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5;
@ -271,7 +272,7 @@ void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS
if (!widescreen_mode)
d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX;
if (g_extern.console.screen.gamma_correction)
if (global->console.screen.gamma_correction)
d3dpp->FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8);
else
d3dpp->FrontBufferFormat = D3DFMT_LE_X8R8G8B8;

View File

@ -598,11 +598,12 @@ static EGLint *egl_fill_attribs(EGLint *attr)
case GFX_CTX_OPENGL_API:
{
unsigned version = g_major * 1000 + g_minor;
bool core = version >= 3001;
bool core = version >= 3001;
#ifdef GL_DEBUG
bool debug = true;
bool debug = true;
#else
bool debug = g_extern.system.hw_render_callback.debug_context;
global_t *global = global_get_ptr();
bool debug = global->system.hw_render_callback.debug_context;
#endif
if (core)

View File

@ -345,9 +345,10 @@ static bool gfx_ctx_glx_init(void *data)
None
};
int nelements, major, minor;
GLXFBConfig *fbcs = NULL;
GLXFBConfig *fbcs = NULL;
gfx_ctx_glx_data_t *glx = (gfx_ctx_glx_data_t*)calloc(1, sizeof(gfx_ctx_glx_data_t));
driver_t *driver = driver_get_ptr();
driver_t *driver = driver_get_ptr();
global_t *global = global_get_ptr();
if (!glx)
return false;
@ -373,7 +374,7 @@ static bool gfx_ctx_glx_init(void *data)
#ifdef GL_DEBUG
glx->g_debug = true;
#else
glx->g_debug = g_extern.system.hw_render_callback.debug_context;
glx->g_debug = global->system.hw_render_callback.debug_context;
#endif
glx->g_core = (g_major * 1000 + g_minor) >= 3001; /* Have to use ContextAttribs */

View File

@ -99,8 +99,9 @@ static void gfx_ctx_ps3_get_available_resolutions(void)
CELL_VIDEO_OUT_RESOLUTION_1600x1080,
CELL_VIDEO_OUT_RESOLUTION_1080
};
global_t *global = global_get_ptr();
if (g_extern.console.screen.resolutions.check)
if (global->console.screen.resolutions.check)
return;
defaultresolution = true;
@ -116,31 +117,31 @@ static void gfx_ctx_ps3_get_available_resolutions(void)
resolution_count++;
}
g_extern.console.screen.resolutions.list = malloc(resolution_count * sizeof(uint32_t));
g_extern.console.screen.resolutions.count = 0;
global->console.screen.resolutions.list = malloc(resolution_count * sizeof(uint32_t));
global->console.screen.resolutions.count = 0;
for (i = 0; i < num_videomodes; i++)
{
if (cellVideoOutGetResolutionAvailability(CELL_VIDEO_OUT_PRIMARY, videomode[i],
CELL_VIDEO_OUT_ASPECT_AUTO, 0))
{
g_extern.console.screen.resolutions.list[g_extern.console.screen.resolutions.count++] = videomode[i];
g_extern.console.screen.resolutions.initial.id = videomode[i];
global->console.screen.resolutions.list[global->console.screen.resolutions.count++] = videomode[i];
global->console.screen.resolutions.initial.id = videomode[i];
if (g_extern.console.screen.resolutions.current.id == videomode[i])
if (global->console.screen.resolutions.current.id == videomode[i])
{
defaultresolution = false;
g_extern.console.screen.resolutions.current.idx = g_extern.console.screen.resolutions.count-1;
global->console.screen.resolutions.current.idx = global->console.screen.resolutions.count-1;
}
}
}
/* In case we didn't specify a resolution - make the last resolution
that was added to the list (the highest resolution) the default resolution */
if (g_extern.console.screen.resolutions.current.id > num_videomodes || defaultresolution)
g_extern.console.screen.resolutions.current.idx = g_extern.console.screen.resolutions.count - 1;
if (global->console.screen.resolutions.current.id > num_videomodes || defaultresolution)
global->console.screen.resolutions.current.idx = global->console.screen.resolutions.count - 1;
g_extern.console.screen.resolutions.check = true;
global->console.screen.resolutions.check = true;
}
static void gfx_ctx_ps3_set_swap_interval(void *data, unsigned interval)
@ -244,15 +245,18 @@ static void gfx_ctx_ps3_get_video_size(void *data,
static bool gfx_ctx_ps3_init(void *data)
{
driver_t *driver = driver_get_ptr();
global_t *global = global_get_ptr();
gfx_ctx_ps3_data_t *ps3 = (gfx_ctx_ps3_data_t*)
calloc(1, sizeof(gfx_ctx_ps3_data_t));
(void)data;
(void)global;
if (!ps3)
return false;
#if defined(HAVE_PSGL)
PSGLdeviceParameters params;
PSGLinitOptions options = {
.enable = PSGL_INIT_MAX_SPUS | PSGL_INIT_INITIALIZE_SPUS,
.maxSPUs = 1,
@ -263,7 +267,6 @@ static bool gfx_ctx_ps3_init(void *data)
sys_spu_initialize(6, 1);
psglInit(&options);
PSGLdeviceParameters params;
params.enable = PSGL_DEVICE_PARAMETERS_COLOR_FORMAT |
PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT |
@ -272,21 +275,21 @@ static bool gfx_ctx_ps3_init(void *data)
params.depthFormat = GL_NONE;
params.multisamplingMode = GL_MULTISAMPLING_NONE_SCE;
if (g_extern.console.screen.resolutions.current.id)
if (global->console.screen.resolutions.current.id)
{
params.enable |= PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT;
params.width = gfx_ctx_ps3_get_resolution_width(g_extern.console.screen.resolutions.current.id);
params.height = gfx_ctx_ps3_get_resolution_height(g_extern.console.screen.resolutions.current.id);
g_extern.console.screen.pal_enable = false;
params.width = gfx_ctx_ps3_get_resolution_width(global->console.screen.resolutions.current.id);
params.height = gfx_ctx_ps3_get_resolution_height(global->console.screen.resolutions.current.id);
global->console.screen.pal_enable = false;
if (params.width == 720 && params.height == 576)
{
RARCH_LOG("[PSGL Context]: 720x576 resolution detected, setting MODE_VIDEO_PAL_ENABLE.\n");
g_extern.console.screen.pal_enable = true;
global->console.screen.pal_enable = true;
}
}
if (g_extern.console.screen.pal60_enable)
if (global->console.screen.pal60_enable)
{
RARCH_LOG("[PSGL Context]: Setting temporal PAL60 mode.\n");
params.enable |= PSGL_DEVICE_PARAMETERS_RESC_PAL_TEMPORAL_MODE;
@ -302,7 +305,7 @@ static bool gfx_ctx_ps3_init(void *data)
psglResetCurrentContext();
#endif
g_extern.console.screen.pal_enable =
global->console.screen.pal_enable =
cellVideoOutGetResolutionAvailability(
CELL_VIDEO_OUT_PRIMARY, CELL_VIDEO_OUT_RESOLUTION_576,
CELL_VIDEO_OUT_ASPECT_AUTO, 0);

View File

@ -522,7 +522,8 @@ static EGLint *egl_fill_attribs(EGLint *attr)
#ifdef GL_DEBUG
bool debug = true;
#else
bool debug = g_extern.system.hw_render_callback.debug_context;
global_t *global = global_get_ptr();
bool debug = global->system.hw_render_callback.debug_context;
#endif
if (core)

View File

@ -105,8 +105,9 @@ static void setup_pixel_format(HDC hdc)
static void create_gl_context(HWND hwnd)
{
bool core_context;
bool debug = g_extern.system.hw_render_callback.debug_context;
global_t *global = global_get_ptr();
driver_t *driver = driver_get_ptr();
bool debug = global->system.hw_render_callback.debug_context;
#ifdef _WIN32
dll_handle = LoadLibrary("OpenGL32.dll");

View File

@ -52,10 +52,13 @@ static bool win32_browser(HWND owner, char *filename, const char *extensions,
LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
{
WPARAM mode = wparam & 0xffff;
unsigned cmd = RARCH_CMD_NONE;
bool do_wm_close = false;
WPARAM mode = wparam & 0xffff;
unsigned cmd = RARCH_CMD_NONE;
bool do_wm_close = false;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
(void)global;
switch (mode)
{
@ -89,7 +92,7 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
cmd = RARCH_CMD_LOAD_CORE;
break;
case ID_M_LOAD_CONTENT:
strlcpy(g_extern.fullpath, win32_file, sizeof(g_extern.fullpath));
strlcpy(global->fullpath, win32_file, sizeof(global->fullpath));
cmd = RARCH_CMD_LOAD_CONTENT;
do_wm_close = true;
break;
@ -140,7 +143,7 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
if (mode >= ID_M_WINDOW_SCALE_1X && mode <= ID_M_WINDOW_SCALE_10X)
{
unsigned idx = (mode - (ID_M_WINDOW_SCALE_1X-1));
g_extern.pending.windowed_scale = idx;
global->pending.windowed_scale = idx;
cmd = RARCH_CMD_RESIZE_WINDOWED_SCALE;
}
else if (mode == ID_M_STATE_INDEX_AUTO)

View File

@ -385,7 +385,8 @@ static EGLint *xegl_fill_attribs(EGLint *attr)
{
unsigned version = g_major * 1000 + g_minor;
bool core = version >= 3001;
bool debug = g_extern.system.hw_render_callback.debug_context;
global_t *global = global_get_ptr();
bool debug = global->system.hw_render_callback.debug_context;
#ifdef GL_DEBUG
debug = true;

View File

@ -238,6 +238,7 @@ static void gl_cg_set_params(void *data, unsigned width, unsigned height,
const struct gl_tex_info *prev_info = (const struct gl_tex_info*)_prev_info;
const struct gl_tex_info *fbo_info = (const struct gl_tex_info*)_fbo_info;
driver_t *driver = driver_get_ptr();
global_t *global = global_get_ptr();
cg_shader_data_t *cg = (cg_shader_data_t*)driver->video_shader_data;
(void)data;
@ -250,13 +251,13 @@ static void gl_cg_set_params(void *data, unsigned width, unsigned height,
set_param_2f(cg->prg[cg->active_idx].tex_size_f, tex_width, tex_height);
set_param_2f(cg->prg[cg->active_idx].out_size_f, out_width, out_height);
set_param_1f(cg->prg[cg->active_idx].frame_dir_f,
g_extern.rewind.frame_is_reverse ? -1.0 : 1.0);
global->rewind.frame_is_reverse ? -1.0 : 1.0);
set_param_2f(cg->prg[cg->active_idx].vid_size_v, width, height);
set_param_2f(cg->prg[cg->active_idx].tex_size_v, tex_width, tex_height);
set_param_2f(cg->prg[cg->active_idx].out_size_v, out_width, out_height);
set_param_1f(cg->prg[cg->active_idx].frame_dir_v,
g_extern.rewind.frame_is_reverse ? -1.0 : 1.0);
global->rewind.frame_is_reverse ? -1.0 : 1.0);
if (cg->prg[cg->active_idx].frame_cnt_f || cg->prg[cg->active_idx].frame_cnt_v)
{

View File

@ -947,6 +947,7 @@ static void gl_glsl_set_params(void *data, unsigned width, unsigned height,
const struct gl_tex_info *fbo_info = (const struct gl_tex_info*)_fbo_info;
struct glsl_attrib *attr = (struct glsl_attrib*)attribs;
driver_t *driver = driver_get_ptr();
global_t *global = global_get_ptr();
glsl_shader_data_t *glsl = (glsl_shader_data_t*)driver->video_shader_data;
if (!glsl)
@ -985,7 +986,7 @@ static void gl_glsl_set_params(void *data, unsigned width, unsigned height,
}
if (uni->frame_direction >= 0)
glUniform1i(uni->frame_direction, g_extern.rewind.frame_is_reverse ? -1 : 1);
glUniform1i(uni->frame_direction, global->rewind.frame_is_reverse ? -1 : 1);
for (i = 0; i < glsl->glsl_shader->luts; i++)

View File

@ -115,6 +115,7 @@ static void hlsl_set_params(void *data, unsigned width, unsigned height,
const struct gl_tex_info *prev_info = (const struct gl_tex_info*)_prev_info;
const struct gl_tex_info *fbo_info = (const struct gl_tex_info*)_fbo_info;
driver_t *driver = driver_get_ptr();
global_t *global = global_get_ptr();
hlsl_shader_data_t *hlsl = (hlsl_shader_data_t*)driver->video_shader_data;
if (!hlsl)
@ -132,13 +133,13 @@ static void hlsl_set_params(void *data, unsigned width, unsigned height,
set_param_2f(hlsl->prg[hlsl->active_idx].tex_size_f, tex_size, hlsl->prg[hlsl->active_idx].f_ctable);
set_param_2f(hlsl->prg[hlsl->active_idx].out_size_f, out_size, hlsl->prg[hlsl->active_idx].f_ctable);
set_param_1f(hlsl->prg[hlsl->active_idx].frame_cnt_f, frame_cnt, hlsl->prg[hlsl->active_idx].f_ctable);
set_param_1f(hlsl->prg[hlsl->active_idx].frame_dir_f, g_extern.rewind.frame_is_reverse ? -1.0 : 1.0, hlsl->prg[hlsl->active_idx].f_ctable);
set_param_1f(hlsl->prg[hlsl->active_idx].frame_dir_f, global->rewind.frame_is_reverse ? -1.0 : 1.0, hlsl->prg[hlsl->active_idx].f_ctable);
set_param_2f(hlsl->prg[hlsl->active_idx].vid_size_v, ori_size, hlsl->prg[hlsl->active_idx].v_ctable);
set_param_2f(hlsl->prg[hlsl->active_idx].tex_size_v, tex_size, hlsl->prg[hlsl->active_idx].v_ctable);
set_param_2f(hlsl->prg[hlsl->active_idx].out_size_v, out_size, hlsl->prg[hlsl->active_idx].v_ctable);
set_param_1f(hlsl->prg[hlsl->active_idx].frame_cnt_v, frame_cnt, hlsl->prg[hlsl->active_idx].v_ctable);
set_param_1f(hlsl->prg[hlsl->active_idx].frame_dir_v, g_extern.rewind.frame_is_reverse ? -1.0 : 1.0, hlsl->prg[hlsl->active_idx].v_ctable);
set_param_1f(hlsl->prg[hlsl->active_idx].frame_dir_v, global->rewind.frame_is_reverse ? -1.0 : 1.0, hlsl->prg[hlsl->active_idx].v_ctable);
/* TODO - set lookup textures/FBO textures/state parameters/etc */
}

View File

@ -35,6 +35,8 @@
static struct runloop *g_runloop;
struct global g_extern;
/* Convenience macros. */
#define check_oneshot_func(trigger_input) (check_is_oneshot(BIT64_GET(trigger_input, RARCH_FRAMEADVANCE), BIT64_GET(trigger_input, RARCH_REWIND)))
#define check_slowmotion_func(input) (check_slowmotion(BIT64_GET(input, RARCH_SLOWMOTION)))