gpu_neon: fix x86 build
[pcsx_rearmed.git] / plugins / gpu_neon / vout_sdl.c
... / ...
CommitLineData
1/*
2 * (C) GraÅžvydas "notaz" Ignotas, 2011
3 *
4 * This work is licensed under the terms of any of these licenses
5 * (at your option):
6 * - GNU GPL, version 2 or later.
7 * - GNU LGPL, version 2.1 or later.
8 * See the COPYING file in the top-level directory.
9 */
10
11#include <stdio.h>
12#include <SDL.h>
13#include <SDL_syswm.h>
14#include "gpu.h"
15
16static SDL_Surface *screen;
17static Display *x11_display;
18
19int vout_init(void)
20{
21 SDL_SysWMinfo wminfo;
22 int ret;
23
24 ret = SDL_Init(SDL_INIT_VIDEO);
25 if (ret != 0) {
26 fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
27 return ret;
28 }
29
30 screen = SDL_SetVideoMode(1024, 512, 32, 0);
31 if (screen == NULL) {
32 fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
33 SDL_Quit();
34 return -1;
35 }
36
37 SDL_VERSION(&wminfo.version);
38 ret = SDL_GetWMInfo(&wminfo);
39 if (ret == 1)
40 x11_display = wminfo.info.x11.display;
41
42 return 0;
43}
44
45int vout_finish(void)
46{
47 SDL_Quit();
48 return 0;
49}
50
51static void blit(void)
52{
53 uint32_t *d;
54 int i;
55
56 SDL_LockSurface(screen);
57 if (gpu.status.rgb24)
58 {
59 uint8_t *s;
60 int y;
61 for (y = 0; y < 512; y++) {
62 s = (uint8_t *)gpu.vram + y * 2*1024;
63 d = (uint32_t *)screen->pixels + y * 1024;
64 for (i = 0; i < 1024 * 2 / 3; i++, s += 3)
65 d[i] = (s[0] << 16) | (s[1] << 8) | s[2];
66 }
67 }
68 else
69 {
70 uint16_t *s = gpu.vram;
71 d = (uint32_t *)screen->pixels;
72 for (i = 0; i < 1024 * 512; i++)
73 d[i] = (((uint32_t)s[i] << 19) & 0xf80000) | ((s[i] << 6) & 0xf800) |
74 ((s[i] >> 7) & 0xf8);
75 }
76 SDL_UnlockSurface(screen);
77 SDL_UpdateRect(screen, 0, 0, 1024, 512);
78}
79
80void GPUupdateLace(void)
81{
82 if (!gpu.status.blanking && gpu.state.fb_dirty) {
83 if (gpu.cmd_len > 0)
84 flush_cmd_buffer();
85 renderer_flush_queues();
86 blit();
87 gpu.state.fb_dirty = 0;
88 }
89}
90
91long GPUopen(void **dpy)
92{
93 *dpy = x11_display;
94 return 0;
95}
96
97long GPUclose(void)
98{
99 return 0;
100}
101
102#include "../../frontend/plugin_lib.h"
103
104void GPUrearmedCallbacks(const struct rearmed_cbs *cbs)
105{
106 gpu.state.hcnt = cbs->gpu_hcnt;
107 gpu.state.frame_count = cbs->gpu_frame_count;
108
109 if (cbs->pl_vout_set_raw_vram)
110 cbs->pl_vout_set_raw_vram(gpu.vram);
111 renderer_set_config(cbs);
112}
113
114// vim:shiftwidth=2:expandtab