diff --git a/gfx/drivers/gx2_gfx.c b/gfx/drivers/gx2_gfx.c index cad9967696..1f4c35be62 100644 --- a/gfx/drivers/gx2_gfx.c +++ b/gfx/drivers/gx2_gfx.c @@ -63,11 +63,12 @@ static const wiiu_render_mode_t wiiu_render_mode_map[] = }; static bool wiiu_gfx_set_shader(void *data, - enum rarch_shader_type type, const char *path); + enum rarch_shader_type type, const char *path); -static void wiiu_set_tex_coords(frame_vertex_t *v, GX2Texture *texture, float u0, float v0, - float u1, float v1, - unsigned rotation) +static void wiiu_set_tex_coords(frame_vertex_t *v, + GX2Texture *texture, float u0, float v0, + float u1, float v1, + unsigned rotation) { v[0].coord.u = u0 / texture->surface.width; v[0].coord.v = v0 / texture->surface.height; diff --git a/gfx/drivers/metal.m b/gfx/drivers/metal.m index 1703a44d2f..da2472d4e6 100644 --- a/gfx/drivers/metal.m +++ b/gfx/drivers/metal.m @@ -56,10 +56,11 @@ /* Temporary workaround for metal not being able to poll flags during init */ static gfx_ctx_driver_t metal_fake_context; + static uint32_t metal_get_flags(void *data); static bool metal_set_shader(void *data, - enum rarch_shader_type type, const char *path); + enum rarch_shader_type type, const char *path); static void *metal_init( const video_info_t *video, @@ -70,9 +71,7 @@ static void *metal_init( MetalDriver *md = [[MetalDriver alloc] initWithVideo:video input:input inputData:input_data]; if (md == nil) - { return NULL; - } { const char *shader_path; diff --git a/gfx/drivers/sdl_dingux_gfx.c b/gfx/drivers/sdl_dingux_gfx.c index 84cfe2b53b..bb2323d371 100644 --- a/gfx/drivers/sdl_dingux_gfx.c +++ b/gfx/drivers/sdl_dingux_gfx.c @@ -44,13 +44,12 @@ typedef struct sdl_dingux_video { - SDL_Surface *screen; bool rgb; bool menu_active; bool was_in_menu; bool quitting; char menu_frame[320*240*32]; - + SDL_Surface *screen; } sdl_dingux_video_t; static void sdl_dingux_gfx_free(void *data) diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 2e43333795..fd058c6180 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -54,18 +54,17 @@ typedef struct sdl_menu_frame typedef struct sdl_video { - SDL_Surface *screen; bool quitting; - - void *font; - const font_renderer_driver_t *font_driver; uint8_t font_r; uint8_t font_g; uint8_t font_b; struct scaler_ctx scaler; - sdl_menu_frame_t menu; + SDL_Surface *screen; + + void *font; + const font_renderer_driver_t *font_driver; } sdl_video_t; static void sdl_gfx_free(void *data) diff --git a/gfx/drivers/sixel_gfx.c b/gfx/drivers/sixel_gfx.c index 490a1e4e76..c5c2aa375c 100644 --- a/gfx/drivers/sixel_gfx.c +++ b/gfx/drivers/sixel_gfx.c @@ -79,24 +79,24 @@ static int sixel_write(char *data, int size, void *priv) static SIXELSTATUS output_sixel(unsigned char *pixbuf, int width, int height, int ncolors, int pixelformat) { - sixel_output_t *context; - sixel_dither_t *dither; - SIXELSTATUS status; - - context = sixel_output_create(sixel_write, stdout); - dither = sixel_dither_create(ncolors); - status = sixel_dither_initialize(dither, pixbuf, + sixel_output_t *context = sixel_output_create(sixel_write, stdout); + sixel_dither_t *dither = sixel_dither_create(ncolors); + SIXELSTATUS status = sixel_dither_initialize(dither, pixbuf, width, height, pixelformat, SIXEL_LARGE_AUTO, SIXEL_REP_AUTO, SIXEL_QUALITY_AUTO); + if (SIXEL_FAILED(status)) return status; + status = sixel_encode(pixbuf, width, height, pixelformat, dither, context); + if (SIXEL_FAILED(status)) return status; + sixel_output_unref(context); sixel_dither_unref(dither); @@ -104,7 +104,7 @@ static SIXELSTATUS output_sixel(unsigned char *pixbuf, int width, int height, } #ifdef HAVE_SYS_IOCTL_H -# ifdef HAVE_TERMIOS_H +#ifdef HAVE_TERMIOS_H static int wait_stdin(int usec) { #ifdef HAVE_SYS_SELECT_H @@ -114,7 +114,7 @@ static int wait_stdin(int usec) int ret = 0; #ifdef HAVE_SYS_SELECT_H - tv.tv_sec = usec / 1000000; + tv.tv_sec = usec / 1000000; tv.tv_usec = usec % 1000000; FD_ZERO(&rfds); FD_SET(STDIN_FILENO, &rfds); diff --git a/gfx/drivers/switch_gfx.c b/gfx/drivers/switch_gfx.c index 78071a038c..7fcdb322c6 100644 --- a/gfx/drivers/switch_gfx.c +++ b/gfx/drivers/switch_gfx.c @@ -54,30 +54,30 @@ typedef struct bool rgb32; unsigned width, height; unsigned rotation; + uint32_t last_width; + uint32_t last_height; + struct video_viewport vp; - struct { - bool enable; - bool fullscreen; + struct + { + bool enable; + bool fullscreen; - uint32_t *pixels; + uint32_t *pixels; - unsigned width; - unsigned height; + unsigned width; + unsigned height; - unsigned tgtw; - unsigned tgth; - - struct scaler_ctx scaler; - } menu_texture; + unsigned tgtw; + unsigned tgth; + struct scaler_ctx scaler; + } menu_texture; surface_t surface; revent_h vsync_h; uint32_t image[1280*720]; - struct scaler_ctx scaler; - uint32_t last_width; - uint32_t last_height; } switch_video_t; static void *switch_init(const video_info_t *video, @@ -92,17 +92,13 @@ static void *switch_init(const video_info_t *video, result_t r = display_init(); if (r != RESULT_OK) - { - free(sw); - return NULL; - } + goto error; r = display_open_layer(&sw->surface); if (r != RESULT_OK) { display_finalize(); - free(sw); - return NULL; + goto error; } r = display_get_vsync_event(&sw->vsync_h); @@ -110,8 +106,7 @@ static void *switch_init(const video_info_t *video, { display_close_layer(&sw->surface); display_finalize(); - free(sw); - return NULL; + goto error; } sw->vp.x = 0; @@ -122,13 +117,17 @@ static void *switch_init(const video_info_t *video, sw->vp.full_height = 720; video_driver_set_size(sw->vp.width, sw->vp.height); - sw->vsync = video->vsync; - sw->rgb32 = video->rgb32; + sw->vsync = video->vsync; + sw->rgb32 = video->rgb32; - *input = NULL; + *input = NULL; *input_data = NULL; return sw; + +error: + free(sw); + return NULL; } static void switch_wait_vsync(switch_video_t *sw) diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 6fccd6d289..47f0031bbf 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -47,26 +47,30 @@ typedef struct { bool should_resize; - float mScreenAspect; bool keep_aspect; bool mEglImageBuf; + bool mFontsOn; + + float mScreenAspect; + unsigned mTextureWidth; unsigned mTextureHeight; unsigned mRenderWidth; unsigned mRenderHeight; unsigned x1, y1, x2, y2; + uint32_t mFontHeight; + + char *mLastMsg; + + VGint scissor[4]; VGImageFormat mTexType; VGImage mImage; math_matrix_3x3 mTransformMatrix; - VGint scissor[4]; EGLImageKHR last_egl_image; - char *mLastMsg; - uint32_t mFontHeight; VGFont mFont; void *mFontRenderer; const font_renderer_driver_t *font_driver; - bool mFontsOn; VGuint mMsgLength; VGuint mGlyphIndices[1024]; VGPaint mPaintFg; diff --git a/gfx/drivers/xenon360_gfx.c b/gfx/drivers/xenon360_gfx.c index 0372858840..8fcdb7cbe7 100644 --- a/gfx/drivers/xenon360_gfx.c +++ b/gfx/drivers/xenon360_gfx.c @@ -79,42 +79,42 @@ typedef struct DrawVerticeFormats typedef struct xenon360_video xenon360_video_t; -static bool g_quitting; - -typedef struct gl +typedef struct xenos { + bool quitting; unsigned char *screen; struct XenosVertexBuffer *vb; - struct XenosDevice * gl_device; + struct XenosDevice *device; struct XenosDevice real_device; - struct XenosShader * g_pVertexShader; - struct XenosShader * g_pPixelTexturedShader; - struct XenosSurface * g_pTexture; -} gl_t; + struct XenosShader *g_pVertexShader; + struct XenosShader *g_pPixelTexturedShader; + struct XenosSurface *g_pTexture; +} xenos_t; static float ScreenUv[4] = {0.f, 1.0f, 1.0f, 0.f}; static void xenon360_gfx_free(void *data) { - gl_t *vid = data; - if (!vid) + xenos_t *xenos = data; + if (!xenos) return; - free(vid); + free(xenos); } static void *xenon360_gfx_init(const video_info_t *video, input_driver_t **input, void **input_data) { - gl_t * gl = calloc(1, sizeof(gl_t)); - if (!gl) + int i = 0; + xenos_t *xenos = calloc(1, sizeof(xenos_t)); + if (!xenos) return NULL; - gl->gl_device = &gl->real_device; + xenos->device = &xenos->real_device; - Xe_Init(gl->gl_device); + Xe_Init(xenos->device); - Xe_SetRenderTarget(gl->gl_device, Xe_GetFramebufferSurface(gl->gl_device)); + Xe_SetRenderTarget(xenos->device, Xe_GetFramebufferSurface(xenos->device)); static const struct XenosVBFFormat vbf = { @@ -126,17 +126,18 @@ static void *xenon360_gfx_init(const video_info_t *video, } }; - gl->g_pPixelTexturedShader = Xe_LoadShaderFromMemory(gl->gl_device, (void*)g_xps_PS); - Xe_InstantiateShader(gl->gl_device, gl->g_pPixelTexturedShader, 0); + xenos->g_pPixelTexturedShader = Xe_LoadShaderFromMemory( + xenos->device, (void*)g_xps_PS); + Xe_InstantiateShader(xenos->device, xenos->g_pPixelTexturedShader, 0); - gl->g_pVertexShader = Xe_LoadShaderFromMemory(gl->gl_device, (void*)g_xvs_VS); - Xe_InstantiateShader(gl->gl_device, gl->g_pVertexShader, 0); - Xe_ShaderApplyVFetchPatches(gl->gl_device, gl->g_pVertexShader, 0, &vbf); + xenos->g_pVertexShader = Xe_LoadShaderFromMemory(xenos->device, (void*)g_xvs_VS); + Xe_InstantiateShader(xenos->device, xenos->g_pVertexShader, 0); + Xe_ShaderApplyVFetchPatches(xenos->device, xenos->g_pVertexShader, 0, &vbf); - gl->g_pTexture = Xe_CreateTexture(gl->gl_device, XE_W, XE_H, 1, XE_FMT_5551 | XE_FMT_16BE, 0); - gl->g_pTexture->use_filtering = 1; + xenos->g_pTexture = Xe_CreateTexture(xenos->device, XE_W, XE_H, 1, XE_FMT_5551 | XE_FMT_16BE, 0); + xenos->g_pTexture->use_filtering = 1; - edram_init(gl->gl_device); + edram_init(xenos->device); /* enable filtering for now */ @@ -145,8 +146,9 @@ static void *xenon360_gfx_init(const video_info_t *video, float w = 4.0f; float h = 4.0f; - gl->vb = Xe_CreateVertexBuffer(gl->gl_device, 3 * sizeof(DrawVerticeFormats)); - DrawVerticeFormats *Rect = Xe_VB_Lock(gl->gl_device, gl->vb, 0, 3 * sizeof (DrawVerticeFormats), XE_LOCK_WRITE); + xenos->vb = Xe_CreateVertexBuffer(xenos->device, 3 * sizeof(DrawVerticeFormats)); + DrawVerticeFormats *Rect = Xe_VB_Lock(xenos->device, + xenos->vb, 0, 3 * sizeof (DrawVerticeFormats), XE_LOCK_WRITE); ScreenUv[UV_TOP] = ScreenUv[UV_TOP] * 2; ScreenUv[UV_LEFT] = ScreenUv[UV_LEFT] * 2; @@ -178,70 +180,73 @@ static void *xenon360_gfx_init(const video_info_t *video, Rect[3].v = ScreenUv[UV_RIGHT]; Rect[3].color = 0; - int i = 0; for (i = 0; i < 3; i++) { Rect[i].z = 0.0; Rect[i].w = 1.0; } - Xe_VB_Unlock(gl->gl_device, gl->vb); + Xe_VB_Unlock(xenos->device, xenos->vb); - Xe_SetClearColor(gl->gl_device, 0); + Xe_SetClearColor(xenos->device, 0); - return gl; + return xenos; } -static bool xenon360_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, - uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) +static bool xenon360_gfx_frame(void *data, + const void *frame, unsigned width, unsigned height, + uint64_t frame_count, unsigned pitch, const char *msg, + video_frame_info_t *video_info) { - gl_t *vid = data; + xenos_t *xenos = (xenos_t*)data; ScreenUv[UV_TOP] = ((float) (width) / (float) XE_W)*2; ScreenUv[UV_LEFT] = ((float) (height) / (float) XE_H)*2; - DrawVerticeFormats * Rect = Xe_VB_Lock(vid->gl_device, vid->vb, 0, 3 * sizeof(DrawVerticeFormats), XE_LOCK_WRITE); + DrawVerticeFormats * Rect = Xe_VB_Lock( + xenos->device, + xenos->vb, 0, 3 * sizeof(DrawVerticeFormats), XE_LOCK_WRITE); /* bottom left */ Rect[1].v = ScreenUv[UV_LEFT]; Rect[2].u = ScreenUv[UV_TOP]; - Xe_VB_Unlock(vid->gl_device, vid->vb); + Xe_VB_Unlock(xenos->device, xenos->vb); /* Refresh texture cache */ - uint16_t *dst = Xe_Surface_LockRect(vid->gl_device, vid->g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE); + uint16_t *dst = Xe_Surface_LockRect(xenos->device, xenos->g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE); const uint16_t *src = frame; unsigned stride_in = pitch >>1; - unsigned stride_out = vid->g_pTexture->wpitch >> 1; + unsigned stride_out = xenos->g_pTexture->wpitch >> 1; unsigned copy_size = width << 1; for (unsigned y = 0; y < height; y++, dst += stride_out, src += stride_in) memcpy(dst, src, copy_size); - Xe_Surface_Unlock(vid->gl_device, vid->g_pTexture); + Xe_Surface_Unlock(xenos->device, xenos->g_pTexture); /* Reset states */ - Xe_InvalidateState(vid->gl_device); - Xe_SetClearColor(vid->gl_device, 0); + Xe_InvalidateState(xenos->device); + Xe_SetClearColor(xenos->device, 0); /* Select stream */ - Xe_SetTexture(vid->gl_device, 0, vid->g_pTexture); - Xe_SetCullMode(vid->gl_device, XE_CULL_NONE); - Xe_SetStreamSource(vid->gl_device, 0, vid->vb, 0, sizeof(DrawVerticeFormats)); + Xe_SetTexture(xenos->device, 0, xenos->g_pTexture); + Xe_SetCullMode(xenos->device, XE_CULL_NONE); + Xe_SetStreamSource(xenos->device, 0, xenos->vb, 0, sizeof(DrawVerticeFormats)); /* Select shaders */ - Xe_SetShader(vid->gl_device, SHADER_TYPE_PIXEL, vid->g_pPixelTexturedShader, 0); - Xe_SetShader(vid->gl_device, SHADER_TYPE_VERTEX, vid->g_pVertexShader, 0); + Xe_SetShader(xenos->device, SHADER_TYPE_PIXEL, xenos->g_pPixelTexturedShader, 0); + Xe_SetShader(xenos->device, SHADER_TYPE_VERTEX, xenos->g_pVertexShader, 0); #ifdef HAVE_MENU menu_driver_frame(video_info); #endif /* Draw */ - Xe_DrawPrimitive(vid->gl_device, XE_PRIMTYPE_TRIANGLELIST, 0, 1); + Xe_DrawPrimitive(xenos->device, XE_PRIMTYPE_TRIANGLELIST, 0, 1); /* Resolve */ - Xe_Resolve(vid->gl_device); - Xe_Sync(vid->gl_device); + Xe_Resolve(xenos->device); + Xe_Sync(xenos->device); return true; } @@ -250,8 +255,8 @@ static void xenon360_gfx_set_nonblock_state(void *a, bool b, bool c, unsigned d) static bool xenon360_gfx_alive(void *data) { - (void)data; - return !g_quitting; + xenos_t *xenos = (xenos_t*)data; + return !xenos->quitting; } static bool xenon360_gfx_focus(void *data)