-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
00-qemu82x-mesa-glide.patch
731 lines (708 loc) · 21.7 KB
/
00-qemu82x-mesa-glide.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
diff -Nru ../orig/qemu-8.2.1/accel/kvm/kvm-all.c ./accel/kvm/kvm-all.c
--- ../orig/qemu-8.2.1/accel/kvm/kvm-all.c
+++ ./accel/kvm/kvm-all.c
@@ -1488,6 +1488,42 @@
return 0;
}
+void kvm_update_guest_pa_range(uint64_t start_pa, uint64_t size, void *host_va, int readonly, int add)
+{
+ KVMState *s = kvm_state;
+ KVMMemoryListener *kml = &s->memory_listener;
+
+ MemoryRegion mr;
+ MemoryRegionSection section;
+ RAMBlock ram_block;
+
+ memset(&ram_block, 0, sizeof(RAMBlock));
+ ram_block.mr = &mr;
+ ram_block.used_length = REAL_HOST_PAGE_ALIGN(size);
+ ram_block.max_length = REAL_HOST_PAGE_ALIGN(size);
+ ram_block.fd = -1;
+ ram_block.page_size = getpagesize();
+ ram_block.host = host_va;
+ ram_block.flags |= RAM_PREALLOC;
+
+ memory_region_init(&mr, NULL, NULL, REAL_HOST_PAGE_ALIGN(size));
+ mr.ram = true;
+ mr.ram_block = &ram_block;
+ mr.readonly = readonly;
+ mr.nonvolatile = false;
+
+ section.mr = &mr;
+ section.fv = 0;
+ section.offset_within_region = 0;
+ section.size = mr.size;
+ section.offset_within_address_space = start_pa;
+ section.readonly = mr.readonly;
+ section.nonvolatile = mr.nonvolatile;
+
+ kvm_set_phys_mem(kml, §ion, add);
+ object_unref(OBJECT(&mr));
+}
+
static void kvm_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
diff -Nru ../orig/qemu-8.2.1/hw/i386/pc.c ./hw/i386/pc.c
--- ../orig/qemu-8.2.1/hw/i386/pc.c
+++ ./hw/i386/pc.c
@@ -1288,6 +1288,28 @@
/* Super I/O */
pc_superio_init(isa_bus, create_fdctrl, pcms->i8042_enabled,
pcms->vmport != ON_OFF_AUTO_ON);
+ /* Glide pass-through */
+ glidept_mm_init();
+ /* MESA pass-through */
+ mesapt_mm_init();
+}
+
+void glidept_mm_init(void)
+{
+ DeviceState *glidept_dev = NULL;
+
+ glidept_dev = qdev_new(TYPE_GLIDEPT);
+ sysbus_realize(SYS_BUS_DEVICE(glidept_dev), &error_fatal);
+ sysbus_mmio_map(SYS_BUS_DEVICE(glidept_dev), 0, GLIDEPT_MM_BASE);
+}
+
+void mesapt_mm_init(void)
+{
+ DeviceState *mesapt_dev = NULL;
+
+ mesapt_dev = qdev_new(TYPE_MESAPT);
+ sysbus_realize(SYS_BUS_DEVICE(mesapt_dev), &error_fatal);
+ sysbus_mmio_map(SYS_BUS_DEVICE(mesapt_dev), 0, MESAPT_MM_BASE);
}
void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus,
diff -Nru ../orig/qemu-8.2.1/include/hw/i386/pc.h ./include/hw/i386/pc.h
--- ../orig/qemu-8.2.1/include/hw/i386/pc.h
+++ ./include/hw/i386/pc.h
@@ -195,6 +195,25 @@
#define TYPE_PORT92 "port92"
+#if (((QEMU_VERSION_MAJOR << 12) | (QEMU_VERSION_MINOR << 8) \
+ | QEMU_VERSION_MICRO) < 0x5100)
+#define qdev_new(x) qdev_create(NULL,x)
+#define sysbus_realize(x,y) qdev_init_nofail((DeviceState *)x)
+#endif
+#if (((QEMU_VERSION_MAJOR << 12) | (QEMU_VERSION_MINOR << 8) \
+ | QEMU_VERSION_MICRO) < 0x9132)
+#define device_class_set_legacy_reset(x,y) x->reset = y
+#endif
+/* GLIDE pass-through */
+#define TYPE_GLIDEPT "glidept"
+#define GLIDEPT_MM_BASE 0xfbdff000
+void glidept_mm_init(void);
+
+/* MESA pass-through */
+#define TYPE_MESAPT "mesapt"
+#define MESAPT_MM_BASE 0xefffe000
+void mesapt_mm_init(void);
+
/* pc_sysfw.c */
void pc_system_flash_create(PCMachineState *pcms);
void pc_system_flash_cleanup_unused(PCMachineState *pcms);
diff -Nru ../orig/qemu-8.2.1/include/sysemu/kvm.h ./include/sysemu/kvm.h
--- ../orig/qemu-8.2.1/include/sysemu/kvm.h
+++ ./include/sysemu/kvm.h
@@ -437,6 +437,8 @@
#endif /* NEED_CPU_H */
+void kvm_update_guest_pa_range(uint64_t start_pa, uint64_t size, void *host_va, int readonly, int add);
+
void kvm_cpu_synchronize_state(CPUState *cpu);
void kvm_init_cpu_signals(CPUState *cpu);
diff -Nru ../orig/qemu-8.2.1/include/sysemu/whpx.h ./include/sysemu/whpx.h
--- ../orig/qemu-8.2.1/include/sysemu/whpx.h
+++ ./include/sysemu/whpx.h
@@ -19,6 +19,8 @@
#ifdef CONFIG_WHPX
+void whpx_update_guest_pa_range(uint64_t start_pa, uint64_t size, void *host_va, int readonly, int add);
+
int whpx_enabled(void);
bool whpx_apic_in_platform(void);
diff -Nru ../orig/qemu-8.2.1/include/ui/console.h ./include/ui/console.h
--- ../orig/qemu-8.2.1/include/ui/console.h
+++ ./include/ui/console.h
@@ -154,6 +154,8 @@
uint32_t width;
uint32_t height;
uint32_t refresh_rate;
+ /* passthrough */
+ bool passthrough;
} QemuUIInfo;
/* cursor data format is 32bit RGBA */
@@ -403,6 +405,7 @@
void *opaque);
void graphic_console_close(QemuConsole *con);
+void graphic_hw_passthrough(QemuConsole *con, bool passthrough);
void graphic_hw_update(QemuConsole *con);
void graphic_hw_update_done(QemuConsole *con);
void graphic_hw_invalidate(QemuConsole *con);
@@ -497,4 +500,19 @@
size_t size,
Error **errp);
+/* glidewnd.c */
+void glide_prepare_window(uint32_t, int, void *, void *);
+void glide_release_window(void *, void *);
+int glide_window_stat(const int);
+int glide_gui_fullscreen(int *, int *);
+void glide_renderer_stat(const int);
+
+/* mglcntx.c */
+void mesa_renderer_stat(const int);
+void mesa_prepare_window(int, int, int, void *);
+void mesa_release_window(void);
+void mesa_cursor_define(int, int, int, int, const void *);
+void mesa_mouse_warp(int, int, const int);
+int mesa_gui_fullscreen(int *);
+
#endif
diff -Nru ../orig/qemu-8.2.1/meson.build ./meson.build
--- ../orig/qemu-8.2.1/meson.build
+++ ./meson.build
@@ -1266,6 +1266,7 @@
error('sdl-image required, but SDL was @0@'.format(
get_option('sdl').disabled() ? 'disabled' : 'not found'))
endif
+ error('Featuring qemu-3dfx required SDL2')
sdl_image = not_found
endif
@@ -3432,6 +3433,8 @@
arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@'])
subdir('libdecnumber')
subdir('target')
+ subdir('hw/3dfx')
+ subdir('hw/mesa')
endif
subdir('audio')
@@ -3768,6 +3771,11 @@
target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
if targetos == 'linux'
target_inc += include_directories('linux-headers', is_system: true)
+ link_args += ['-ldl', '-lX11', '-lXxf86vm', '-lGL']
+ endif
+ if targetos == 'darwin'
+ c_args += ['-I/opt/X11/include']
+ link_args += ['-L/opt/X11/lib', '-lX11', '-lXxf86vm', '-lGL', '-Wl,-framework,OpenGL']
endif
if target.endswith('-softmmu')
target_type='system'
diff -Nru ../orig/qemu-8.2.1/system/vl.c ./system/vl.c
--- ../orig/qemu-8.2.1/system/vl.c
+++ ./system/vl.c
@@ -864,6 +864,13 @@
return default_machineclass;
}
+static void feature(void)
+{
+ const char rev_[ALIGNED(1)]
+ ;
+ printf(" featuring qemu-3dfx@%s"__TIME__" "__DATE__" build\n", rev_);
+}
+
static void version(void)
{
printf("QEMU emulator version " QEMU_FULL_VERSION "\n"
@@ -3002,6 +3009,7 @@
break;
case QEMU_OPTION_version:
version();
+ feature();
exit(0);
break;
case QEMU_OPTION_m:
diff -Nru ../orig/qemu-8.2.1/target/i386/whpx/whpx-all.c ./target/i386/whpx/whpx-all.c
--- ../orig/qemu-8.2.1/target/i386/whpx/whpx-all.c
+++ ./target/i386/whpx/whpx-all.c
@@ -10,6 +10,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
+#include "exec/ram_addr.h"
#include "exec/address-spaces.h"
#include "exec/ioport.h"
#include "gdbstub/helpers.h"
@@ -2370,6 +2371,39 @@
memory_region_is_rom(mr), mr->name);
}
+void whpx_update_guest_pa_range(uint64_t start_pa, uint64_t size, void *host_va, int readonly, int add)
+{
+ MemoryRegion mr;
+ MemoryRegionSection section;
+ RAMBlock ram_block;
+
+ memset(&ram_block, 0, sizeof(RAMBlock));
+ ram_block.mr = &mr;
+ ram_block.used_length = REAL_HOST_PAGE_ALIGN(size);
+ ram_block.max_length = REAL_HOST_PAGE_ALIGN(size);
+ ram_block.fd = -1;
+ ram_block.page_size = getpagesize();
+ ram_block.host = host_va;
+ ram_block.flags |= RAM_PREALLOC;
+
+ memory_region_init(&mr, NULL, NULL, REAL_HOST_PAGE_ALIGN(size));
+ mr.ram = true;
+ mr.ram_block = &ram_block;
+ mr.readonly = readonly;
+ mr.nonvolatile = false;
+
+ section.mr = &mr;
+ section.fv = 0;
+ section.offset_within_region = 0;
+ section.size = mr.size;
+ section.offset_within_address_space = start_pa;
+ section.readonly = mr.readonly;
+ section.nonvolatile = mr.nonvolatile;
+
+ whpx_process_section(§ion, add);
+ object_unref(OBJECT(&mr));
+}
+
static void whpx_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
diff -Nru ../orig/qemu-8.2.1/ui/console.c ./ui/console.c
--- ../orig/qemu-8.2.1/ui/console.c
+++ ./ui/console.c
@@ -125,6 +125,11 @@
}
}
+void graphic_hw_passthrough(QemuConsole *con, bool passthrough)
+{
+ con->ui_info.passthrough = passthrough;
+}
+
void graphic_hw_update_done(QemuConsole *con)
{
if (con) {
@@ -140,6 +145,8 @@
return;
}
if (con->hw_ops->gfx_update) {
+ if (con->ui_info.passthrough) { }
+ else
con->hw_ops->gfx_update(con->hw);
async = con->hw_ops->gfx_update_async;
}
diff -Nru ../orig/qemu-8.2.1/ui/sdl2.c ./ui/sdl2.c
--- ../orig/qemu-8.2.1/ui/sdl2.c
+++ ./ui/sdl2.c
@@ -25,6 +25,7 @@
#include "qemu/osdep.h"
#include "qemu/module.h"
+#include "qemu/error-report.h"
#include "qemu/cutils.h"
#include "ui/console.h"
#include "ui/input.h"
@@ -581,6 +582,29 @@
qemu_input_event_sync();
}
+static int fxui_grab_val(const int grab)
+{
+ static int fxui_grab;
+ fxui_grab = (grab & 0x80U)? (grab & 0x01U):fxui_grab;
+ return fxui_grab;
+}
+static int fxui_focus_lost(void)
+{
+ int ret = fxui_grab_val(0);
+ fxui_grab_val(0x80);
+ return ret;
+}
+static void fxui_focus_gained(struct sdl2_console *scon)
+{
+ if (fxui_grab_val(0)) {
+ if (gui_grab) {
+ sdl_grab_end(scon);
+ fxui_grab_val(0x80);
+ }
+ sdl_grab_start(scon);
+ }
+}
+
static void handle_windowevent(SDL_Event *ev)
{
struct sdl2_console *scon = get_scon_from_window(ev->window.windowID);
@@ -605,6 +629,7 @@
sdl2_redraw(scon);
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
+ fxui_focus_gained(scon);
win32_kbd_set_grab(gui_grab);
if (qemu_console_is_graphic(scon->dcl.con)) {
win32_kbd_set_window(sdl2_win32_get_hwnd(scon));
@@ -627,7 +652,7 @@
if (qemu_console_is_graphic(scon->dcl.con)) {
win32_kbd_set_window(NULL);
}
- if (gui_grab && !gui_fullscreen) {
+ if (!fxui_focus_lost() && gui_grab && !gui_fullscreen) {
sdl_grab_end(scon);
}
break;
@@ -794,6 +819,361 @@
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
+static void sdl_display_valid(const char *feat)
+{
+ if (!sdl2_console) {
+ error_report("%s: invalid sdl display. Use -display sdl", feat);
+ exit(1);
+ }
+}
+
+static struct sdl_console_cb {
+ QEMUTimer *ts;
+ SDL_Surface *icon;
+ struct sdl2_console *scon;
+ int glide_on_mesa;
+ int gui_saved_res;
+ int render_pause;
+ int res, msaa, alpha, dtimer, GLon12;
+ void *opaque;
+ void *hnwnd;
+ void (*cwnd_fn)(void *, void *, void *);
+} scon_cb;
+static void sdl_gui_restart(struct sdl2_console *scon, SDL_Surface *icon)
+{
+ if (!gui_fullscreen)
+ SDL_GetWindowPosition(scon->real_window, &scon->x, &scon->y);
+ fxui_grab_val(0x80 | gui_grab);
+ sdl_grab_end(scon);
+ sdl2_window_destroy(scon);
+ sdl2_window_create(scon);
+ if (icon)
+ SDL_SetWindowIcon(scon->real_window, icon);
+ if (!gui_fullscreen)
+ SDL_SetWindowPosition(scon->real_window, scon->x, scon->y);
+}
+static void sched_wndproc(void *opaque)
+{
+ struct sdl_console_cb *s = opaque;
+
+ if (s->res == -1) {
+ if (s->render_pause) {
+ SDL_DestroyTexture(s->scon->texture);
+ s->scon->texture = 0;
+ }
+ else {
+ if (!s->scon->real_renderer)
+ s->scon->real_renderer = SDL_CreateRenderer(s->scon->real_window, -1 ,0);
+ if (!s->scon->opengl) {
+ sdl2_2d_switch(&s->scon->dcl, s->scon->surface);
+ if (!gui_fullscreen)
+ SDL_SetWindowPosition(s->scon->real_window, s->scon->x, s->scon->y);
+ }
+ }
+ }
+ else if (s->gui_saved_res) {
+ SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
+ SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
+ SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
+#ifdef CONFIG_DARWIN
+ if (!s->dtimer)
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
+#endif
+ if (s->alpha)
+ SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
+ if (s->msaa) {
+ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, SDL_TRUE);
+ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, s->msaa);
+ }
+ const char hint[] = "opengl";
+ if (!SDL_GetHint(SDL_HINT_RENDER_DRIVER) ||
+ memcmp(SDL_GetHint(SDL_HINT_RENDER_DRIVER), hint, sizeof(hint) - 1)) {
+ SDL_SetHint(SDL_HINT_RENDER_DRIVER, hint);
+ sdl_gui_restart(s->scon, s->icon);
+ }
+ SDL_SysWMinfo wmi;
+ SDL_VERSION(&wmi.version);
+ if (SDL_GetWindowWMInfo(s->scon->real_window, &wmi)) {
+ switch(wmi.subsystem) {
+#if defined(SDL_VIDEO_DRIVER_WINDOWS)
+ case SDL_SYSWM_WINDOWS:
+ s->hnwnd = (void *)wmi.info.win.window;
+ break;
+#endif
+#if defined(SDL_VIDEO_DRIVER_X11)
+ case SDL_SYSWM_X11:
+ s->hnwnd = (void *)wmi.info.x11.window;
+ break;
+#endif
+#if defined(SDL_VIDEO_DRIVER_COCOA)
+ case SDL_SYSWM_COCOA:
+ s->hnwnd = (void *)wmi.info.cocoa.window;
+ break;
+#endif
+ default:
+ s->hnwnd = 0;
+ break;
+ }
+ }
+ SDL_DestroyRenderer(s->scon->real_renderer);
+ s->scon->real_renderer = 0;
+ s->scon->winctx = SDL_GL_GetCurrentContext();
+ s->scon->winctx = (s->scon->winctx)? s->scon->winctx:SDL_GL_CreateContext(s->scon->real_window);
+ if (!s->scon->winctx) {
+ error_report("%s", SDL_GetError());
+ exit(1);
+ }
+ s->render_pause = 1;
+ if (!s->opaque)
+ s->cwnd_fn(s->scon->real_window, s->hnwnd, opaque);
+ }
+ else {
+ SDL_GL_MakeCurrent(s->scon->real_window, NULL);
+ SDL_GL_DeleteContext(s->scon->winctx);
+ s->scon->winctx = 0;
+ s->render_pause = 0;
+ SDL_GL_ResetAttributes();
+ if (!s->GLon12) {
+ if (s->scon->texture) {
+ SDL_DestroyTexture(s->scon->texture);
+ s->scon->texture = 0;
+ }
+ SDL_SetHint(SDL_HINT_RENDER_DRIVER, "");
+ sdl_gui_restart(s->scon, s->icon);
+ }
+ else {
+ if (!s->scon->real_renderer)
+ s->scon->real_renderer = SDL_CreateRenderer(s->scon->real_window, -1 ,0);
+ }
+ if (!s->scon->opengl)
+ sdl2_2d_switch(&s->scon->dcl, s->scon->surface);
+ timer_del(s->ts);
+ timer_free(s->ts);
+ s->ts = 0;
+ }
+ if (s->res > 0)
+ SDL_SetWindowSize(s->scon->real_window, (s->res & 0xFFFFU), (s->res >> 0x10));
+ if (s->opaque || !s->render_pause)
+ graphic_hw_passthrough(s->scon->dcl.con, s->render_pause);
+}
+
+static int sdl_gui_fullscreen(int *sizev, const char *feat)
+{
+ struct sdl_console_cb *s = &scon_cb;
+
+ sdl_display_valid(feat);
+ s->scon = &sdl2_console[0];
+ if (sizev) {
+ sizev[0] = surface_width(s->scon->surface);
+ sizev[1] = surface_height(s->scon->surface);
+ if (!memcmp(feat, "mesapt", sizeof("mesapt")))
+ SDL_GL_GetDrawableSize(s->scon->real_window, &sizev[2], &sizev[3]);
+ }
+ return gui_fullscreen;
+}
+
+static void sdl_renderer_stat(const int activate, const char *feat)
+{
+ struct sdl_console_cb *s = &scon_cb;
+
+ if (activate == s->render_pause)
+ return;
+
+ sdl_display_valid(feat);
+ s->scon = &sdl2_console[0];
+ s->res = -1;
+ s->render_pause = activate;
+
+ if (!s->ts)
+ s->ts = timer_new_ms(QEMU_CLOCK_REALTIME, &sched_wndproc, s);
+ timer_mod(s->ts, qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
+}
+
+void glide_prepare_window(uint32_t res, int msaa, void *opaque, void *cwnd_fn)
+{
+ int scr_w, scr_h;
+ struct sdl_console_cb *s = &scon_cb;
+
+ sdl_display_valid("glidept");
+ s->scon = &sdl2_console[0];
+ s->opaque = opaque;
+ s->cwnd_fn = (void (*)(void *, void *, void *))cwnd_fn;
+ if (s->render_pause) {
+ s->glide_on_mesa = 1;
+ s->gui_saved_res = 0;
+ }
+ else {
+ SDL_GetWindowSize(s->scon->real_window, &scr_w, &scr_h);
+ s->gui_saved_res = ((scr_h & 0x7FFFU) << 0x10) | scr_w;
+ s->res = res;
+ s->msaa = msaa;
+ s->alpha = 1;
+#ifdef CONFIG_DARWIN
+ s->dtimer = s->alpha;
+#endif
+ if (!s->ts)
+ s->ts = timer_new_ms(QEMU_CLOCK_REALTIME, &sched_wndproc, s);
+ timer_mod(s->ts, qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
+ }
+}
+
+void glide_release_window(void *opaque, void *cwnd_fn)
+{
+ struct sdl_console_cb *s = &scon_cb;
+
+ sdl_display_valid("glidept");
+ s->scon = &sdl2_console[0];
+ s->opaque = opaque;
+ s->cwnd_fn = (void (*)(void *, void *, void *))cwnd_fn;
+ if (s->gui_saved_res) {
+ s->res = s->gui_saved_res;
+ s->gui_saved_res = 0;
+ if (s->ts)
+ timer_mod(s->ts, qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
+ }
+}
+
+int glide_window_stat(const int activate)
+{
+ int stat;
+ struct sdl_console_cb *s = &scon_cb;
+
+ if (activate) {
+ if (s->scon->winctx) {
+ int scr_w, scr_h;
+ SDL_GetWindowSize(s->scon->real_window, &scr_w, &scr_h);
+#ifdef CONFIG_DARWIN
+ if (SDL_GL_MakeCurrent(s->scon->real_window, s->scon->winctx))
+ fprintf(stderr, "%s\n", SDL_GetError());
+#endif
+ stat = ((scr_h & 0x7FFFU) << 0x10) | scr_w;
+ s->cwnd_fn(s->scon->real_window, s->hnwnd, s->opaque);
+ }
+ else
+ stat = 1;
+ }
+ else {
+ s->cwnd_fn(s->scon->real_window, s->hnwnd, s->opaque);
+ stat = s->glide_on_mesa;
+ s->glide_on_mesa = 0;
+ stat ^= (s->scon->winctx)? 1:0;
+ }
+ return stat;
+}
+
+int glide_gui_fullscreen(int *width, int *height)
+{
+ int ret, v[2];
+ ret = sdl_gui_fullscreen(v, "glidept");
+ if (width)
+ *width = v[0];
+ if (height)
+ *height = v[1];
+ return ret;
+}
+
+void glide_renderer_stat(const int activate)
+{
+ sdl_renderer_stat(activate, "glidept");
+}
+
+void mesa_renderer_stat(const int activate)
+{
+ struct sdl_console_cb *s = &scon_cb;
+ sdl_renderer_stat(activate, "mesapt");
+ if (s->glide_on_mesa && !activate)
+ glide_renderer_stat(1);
+}
+
+void mesa_prepare_window(int msaa, int alpha, int scale_x, void *cwnd_fn)
+{
+ int scr_w, scr_h;
+ struct sdl_console_cb *s = &scon_cb;
+
+ sdl_display_valid("mesapt");
+ s->scon = &sdl2_console[0];
+ s->msaa = msaa;
+ s->alpha = alpha;
+#ifdef CONFIG_WIN32
+ s->GLon12 = s->alpha;
+ s->alpha = 1;
+#endif
+#ifdef CONFIG_DARWIN
+ s->dtimer = s->alpha;
+ s->alpha = 1;
+#endif
+ s->opaque = 0;
+ s->cwnd_fn = (void (*)(void *, void *, void *))cwnd_fn;
+
+ SDL_GetWindowSize(s->scon->real_window, &scr_w, &scr_h);
+ s->gui_saved_res = ((scr_h & 0x7FFFU) << 0x10) | scr_w;
+ s->res = (((int)(scale_x * ((1.f * scr_h) / scr_w)) & 0x7FFFU) << 0x10) | scale_x;
+
+ if (!s->ts)
+ s->ts = timer_new_ms(QEMU_CLOCK_REALTIME, &sched_wndproc, s);
+ timer_mod(s->ts, qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
+}
+
+void mesa_release_window(void)
+{
+ struct sdl_console_cb *s = &scon_cb;
+
+ sdl_display_valid("mesapt");
+ s->scon = &sdl2_console[0];
+ s->res = 0;
+ s->opaque = 0;
+ s->cwnd_fn = 0;
+ s->gui_saved_res = 0;
+
+ if (guest_sprite)
+ SDL_FreeCursor(guest_sprite);
+ guest_sprite = SDL_CreateSystemCursor(0);
+
+ if (s->ts)
+ timer_mod(s->ts, qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
+}
+
+void mesa_cursor_define(int hot_x, int hot_y, int width, int height, const void *data)
+{
+ struct sdl_console_cb *s = &scon_cb;
+
+ QemuConsole *con = s->scon ? s->scon->dcl.con : NULL;
+ if (con) {
+ QEMUCursor *c = cursor_alloc(width, (height & 1)? (height >> 1):height);
+ c->hot_x = hot_x;
+ c->hot_y = hot_y;
+ if (height & 1) {
+ uint8_t *and_mask = (uint8_t *)data,
+ *xor_mask = and_mask + cursor_get_mono_bpl(c) * c->height;
+ cursor_set_mono(c, 0xffffff, 0x000000, xor_mask, 1, and_mask);
+ }
+ else
+ memcpy(c->data, data, (width * height * sizeof(uint32_t)));
+ dpy_cursor_define(con, c);
+ cursor_unref(c);
+ }
+}
+
+void mesa_mouse_warp(int x, int y, const int on)
+{
+ struct sdl_console_cb *s = &scon_cb;
+
+ QemuConsole *con = s->scon ? s->scon->dcl.con : NULL;
+ if (con /*&& !qemu_input_is_absolute(con)*/) {
+ static int64_t last_update;
+ int64_t curr_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
+ if (!on || (curr_time >= (last_update + GUI_REFRESH_INTERVAL_DEFAULT))) {
+ last_update = curr_time;
+ dpy_mouse_set(con, x, y, on);
+ }
+ }
+}
+
+int mesa_gui_fullscreen(int *sizev)
+{
+ return sdl_gui_fullscreen(sizev, "mesapt");
+}
+
static const DisplayChangeListenerOps dcl_2d_ops = {
.dpy_name = "sdl2-2d",
.dpy_gfx_update = sdl2_2d_update,
@@ -948,6 +1328,7 @@
g_free(dir);
if (icon) {
SDL_SetWindowIcon(sdl2_console[0].real_window, icon);
+ scon_cb.icon = icon;
}
mouse_mode_notifier.notify = sdl_mouse_mode_change;