-
Notifications
You must be signed in to change notification settings - Fork 9
/
wine-d3d9.patch
5785 lines (5778 loc) · 202 KB
/
wine-d3d9.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
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From 3b06e430d1a1da2b50de4d8757dc4d5ef429dbd2 Mon Sep 17 00:00:00 2001
From: Nick Sarnie <[email protected]>
Date: Mon, 18 Feb 2019 10:01:15 -0500
Subject: [PATCH] Wine D3D9
Signed-off-by: Nick Sarnie <[email protected]>
---
configure.ac | 188 ++++
dlls/d3d9-nine/Makefile.in | 15 +
dlls/d3d9-nine/d3d9-nine.spec | 14 +
dlls/d3d9-nine/d3d9_main.c | 173 +++
dlls/d3d9-nine/d3dadapter9.c | 898 +++++++++++++++
dlls/d3d9-nine/d3dadapter9.h | 32 +
dlls/d3d9-nine/device_wrap.c | 500 +++++++++
dlls/d3d9-nine/device_wrap.h | 26 +
dlls/d3d9-nine/dri3.c | 1426 +++++++++++++++++++++++
dlls/d3d9-nine/dri3.h | 91 ++
dlls/d3d9-nine/present.c | 1748 +++++++++++++++++++++++++++++
dlls/d3d9-nine/present.h | 40 +
dlls/d3d9-nine/shader_validator.c | 88 ++
dlls/d3d9-nine/shader_validator.h | 29 +
dlls/d3d9-nine/version.rc | 26 +
dlls/d3d9-nine/wndproc.c | 277 +++++
dlls/d3d9-nine/wndproc.h | 41 +
17 files changed, 5612 insertions(+)
create mode 100644 dlls/d3d9-nine/Makefile.in
create mode 100644 dlls/d3d9-nine/d3d9-nine.spec
create mode 100644 dlls/d3d9-nine/d3d9_main.c
create mode 100644 dlls/d3d9-nine/d3dadapter9.c
create mode 100644 dlls/d3d9-nine/d3dadapter9.h
create mode 100644 dlls/d3d9-nine/device_wrap.c
create mode 100644 dlls/d3d9-nine/device_wrap.h
create mode 100644 dlls/d3d9-nine/dri3.c
create mode 100644 dlls/d3d9-nine/dri3.h
create mode 100644 dlls/d3d9-nine/present.c
create mode 100644 dlls/d3d9-nine/present.h
create mode 100644 dlls/d3d9-nine/shader_validator.c
create mode 100644 dlls/d3d9-nine/shader_validator.h
create mode 100644 dlls/d3d9-nine/version.rc
create mode 100644 dlls/d3d9-nine/wndproc.c
create mode 100644 dlls/d3d9-nine/wndproc.h
diff --git a/configure.ac b/configure.ac
index 1b425d22a2..ded3ac4d91 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,6 +68,14 @@ AC_ARG_WITH(openal, AS_HELP_STRING([--without-openal],[do not use OpenAL]),
AC_ARG_WITH(opencl, AS_HELP_STRING([--without-opencl],[do not use OpenCL]),
[if test "x$withval" = "xno"; then ac_cv_header_CL_cl_h=no; ac_cv_header_OpenCL_opencl_h=no; fi])
AC_ARG_WITH(opengl, AS_HELP_STRING([--without-opengl],[do not use OpenGL]))
+AC_ARG_WITH(d3d9-nine, AS_HELP_STRING([--without-d3d9-nine],[do not build d3d9-nine.dll (Gallium Nine support)]),
+ [], [with_d3d9_nine=auto])
+AC_ARG_WITH(d3d9-nine-module, AS_HELP_STRING([--with-d3d9-nine-module],
+ [Gallium Nine module location. Can be 'manual' (path to be filled in a register), 'auto' (default. use pkgconfig to detect the location) or a path]),
+ [], [with_d3d9_nine_module=auto])
+AC_ARG_WITH(d3d9-nine-headers-path, AS_HELP_STRING([--with-d3d9-nine-headers-path],
+ [Gallium Nine headers location. Can be 'auto' (default. use pkgconfig to detect the location) or a path]),
+ [], [with_d3d9_nine_headers_path=auto])
AC_ARG_WITH(osmesa, AS_HELP_STRING([--without-osmesa],[do not use the OSMesa library]))
AC_ARG_WITH(oss, AS_HELP_STRING([--without-oss],[do not use the OSS sound support]))
AC_ARG_WITH(pcap, AS_HELP_STRING([--without-pcap],[do not use the Packet Capture library]),
@@ -402,6 +410,8 @@ AC_CHECK_LIB(ossaudio,_oss_ioctl)
AC_SUBST(OPENGL_LIBS,"")
+AC_SUBST(D3D9NINE_LIBS,"")
+
dnl **** Check for header files ****
AC_SYS_LARGEFILE()
@@ -1240,6 +1250,183 @@ This probably prevents linking to OpenGL. Try deleting the file and restarting c
WINE_WARNING_WITH(opengl,[test -n "$opengl_msg"],[$opengl_msg
OpenGL and Direct3D won't be supported.])
+ dnl Check for d3d9-nine support
+ if test "x$with_d3d9_nine" = "xauto" && (test "x$with_d3d9_nine_module" = "xauto" || test "x$with_d3d9_nine_headers_path" = "xauto")
+ then
+ AC_MSG_CHECKING([whether d3dadapter9 package (Gallium Nine) is present])
+ D3DADAPTER9_MODULEDIR=`$PKG_CONFIG --variable=moduledir d3dadapter9 2>/dev/null`
+ D3DADAPTER9_LEGACY_MODULEDIR=`$PKG_CONFIG --variable=moduledir d3d 2>/dev/null`
+ if test "x$D3DADAPTER9_MODULEDIR" = "x" -a "x$D3DADAPTER9_LEGACY_MODULEDIR" = "x"
+ then
+ AC_MSG_RESULT([no, disabling support])
+ with_d3d9_nine=no
+ else
+ AC_MSG_RESULT([yes])
+ fi
+ fi
+
+ if test "x$with_d3d9_nine" != "xno"
+ then
+ AC_MSG_NOTICE([Checking for d3dadapter9 library dependencies])
+ D3D9NINE_LIBS=""
+ D3D9NINE_MISSING_LIBS=""
+ AC_CHECK_LIB(xcb,xcb_request_check,[AC_SUBST(D3D9NINE_LIBS,["$D3D9NINE_LIBS -lxcb"])])
+ test "x$ac_cv_lib_xcb_xcb_request_check" != xyes && D3D9NINE_MISSING_LIBS="libxcb "
+ AC_CHECK_LIB(xcb-dri3,xcb_dri3_open,[AC_SUBST(D3D9NINE_LIBS,["$D3D9NINE_LIBS -lxcb-dri3"])])
+ test "x$ac_cv_lib_xcb_dri3_xcb_dri3_open" != xyes && D3D9NINE_MISSING_LIBS="${D3D9NINE_MISSING_LIBS}libxcb-dri3 "
+ AC_CHECK_LIB(xcb-present,xcb_present_notify_msc,[AC_SUBST(D3D9NINE_LIBS,["$D3D9NINE_LIBS -lxcb-present"])])
+ test "x$ac_cv_lib_xcb_present_xcb_present_notify_msc" != xyes && D3D9NINE_MISSING_LIBS="${D3D9NINE_MISSING_LIBS}libxcb-present "
+ AC_CHECK_LIB(xcb-xfixes,xcb_xfixes_create_region,[AC_SUBST(D3D9NINE_LIBS,["$D3D9NINE_LIBS -lxcb-xfixes"])])
+ test "x$ac_cv_lib_xcb_xfixes_xcb_xfixes_create_region" != xyes && D3D9NINE_MISSING_LIBS="${D3D9NINE_MISSING_LIBS}libxcb-xfixes "
+ AC_CHECK_LIB(X11-xcb,XGetXCBConnection,[AC_SUBST(D3D9NINE_LIBS,["$D3D9NINE_LIBS -lX11-xcb"])])
+ test "x$ac_cv_lib_X11_xcb_XGetXCBConnection" != xyes && D3D9NINE_MISSING_LIBS="${D3D9NINE_MISSING_LIBS}libX11-xcb "
+ AC_CHECK_LIB(X11,XOpenDisplay,[AC_SUBST(D3D9NINE_LIBS,["$D3D9NINE_LIBS -lX11"])])
+ test "x$ac_cv_lib_X11_XOpenDisplay" != xyes && D3D9NINE_MISSING_LIBS="${D3D9NINE_MISSING_LIBS}libX11 "
+ AC_CHECK_LIB(Xext,XextRemoveDisplay,[AC_SUBST(D3D9NINE_LIBS,["$D3D9NINE_LIBS -lXext"])])
+ test "x$ac_cv_lib_Xext_XextRemoveDisplay" != xyes && D3D9NINE_MISSING_LIBS="${D3D9NINE_MISSING_LIBS}libXext "
+ # libs for the dri2 fallback
+ AC_CHECK_LIB(GL,glGenFramebuffers,[AC_SUBST(D3D9NINE_LIBS,["$D3D9NINE_LIBS -lGL"])])
+ test "x$ac_cv_lib_GL_glGenFramebuffers" != xyes && D3D9NINE_MISSING_LIBS="libGL "
+ AC_CHECK_LIB(EGL,eglCreateContext,[AC_SUBST(D3D9NINE_LIBS,["$D3D9NINE_LIBS -lEGL"])])
+ test "x$ac_cv_lib_EGL_eglCreateContext" != xyes && D3D9NINE_MISSING_LIBS="${D3D9NINE_MISSING_LIBS}libEGL"
+
+ if test "x$D3D9NINE_MISSING_LIBS" != x
+ then
+ if test "x$with_d3d9_nine" = "xyes"
+ then
+ AC_MSG_ERROR([Missing libraries to build d3d9-nine.dll: $D3D9NINE_MISSING_LIBS])
+ else
+ AC_MSG_NOTICE([Missing libraries to build d3d9-nine.dll: $D3D9NINE_MISSING_LIBS . disabling support])
+ with_d3d9_nine=no
+ fi
+ fi
+ fi
+
+ if test "x$with_d3d9_nine" != "xno"
+ then
+ AC_MSG_NOTICE([Checking d3dadapter9 header dependencies])
+ D3D9NINE_MISSING_HEADERS=""
+ AC_CHECK_HEADERS([X11/Xlib-xcb.h xcb/dri3.h xcb/present.h X11/Xutil.h X11/Xlib.h pthread.h])
+ test "x$ac_cv_header_X11_Xlib_xcb_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}X11/Xlib-xcb.h "
+ test "x$ac_cv_header_xcb_dri3_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}xcb/dri3.h "
+ test "x$ac_cv_header_xcb_present_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}xcb/present.h "
+ test "x$ac_cv_header_X11_Xutil_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}X11/Xutil.h "
+ test "x$ac_cv_header_X11_Xlib_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}X11/Xlib.h "
+ test "x$ac_cv_header_pthread_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}pthread.h "
+ # headers for the dri2 fallback
+ AC_CHECK_HEADERS([X11/Xmd.h X11/Xlibint.h X11/extensions/dri2tokens.h X11/extensions/dri2proto.h X11/extensions/extutil.h GL/gl.h GL/glext.h EGL/egl.h EGL/eglext.h libdrm/drm_fourcc.h libdrm/drm.h],
+ [],[],[[
+#include <X11/Xlibint.h>
+#include <X11/extensions/dri2tokens.h>
+#include <GL/gl.h>
+#include <EGL/egl.h>
+]])
+ test "x$ac_cv_header_X11_Xmd_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}X11/Xmd.h "
+ test "x$ac_cv_header_X11_Xlibint_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}X11/Xlibint.h "
+ test "x$ac_cv_header_X11_extensions_dri2tokens_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}X11/extensions/dri2tokens.h "
+ test "x$ac_cv_header_X11_extensions_dri2proto_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}X11/extensions/dri2proto.h "
+ test "x$ac_cv_header_X11_extensions_extutil_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}X11/extensions/extutil.h "
+ test "x$ac_cv_header_GL_gl_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}GL/gl.h "
+ test "x$ac_cv_header_GL_glext_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}GL/glext.h "
+ test "x$ac_cv_header_EGL_egl_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}EGL/egl.h "
+ test "x$ac_cv_header_EGL_eglext_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}EGL/eglext.h "
+ test "x$ac_cv_header_libdrm_drm_fourcc_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}libdrm/drm_fourcc.h "
+ test "x$ac_cv_header_libdrm_drm_h" != xyes && D3D9NINE_MISSING_HEADERS="${D3D9NINE_MISSING_HEADERS}libdrm/drm.h "
+ if test "x$D3D9NINE_MISSING_HEADERS" != x
+ then
+ if test "x$with_d3d9_nine" = "xyes"
+ then
+ AC_MSG_ERROR([Missing headers to build d3d9-nine.dll: $D3D9NINE_MISSING_HEADERS])
+ else
+ AC_MSG_NOTICE([Missing headers to build d3d9-nine.dll: $D3D9NINE_MISSING_HEADERS . disabling support])
+ with_d3d9_nine=no
+ fi
+ fi
+ fi
+
+ if test "x$with_d3d9_nine" != "xno"
+ then
+ # d3d9-nine.dll will be built and an option to use it
+ # added. The module path can always be overriden by
+ # a wine registry setting. If the module isn't found
+ # at execution time, the dll will refuse to load and
+ # print an error message to the user.
+ AC_DEFINE(HAVE_D3D9NINE, 1, [Whether d3d9-nine.dll is built])
+ # default: use pkgconfig to find the gallium nine module.
+ # Check the module is there.
+ if test "x$with_d3d9_nine_module" = "xauto"
+ then
+ D3DADAPTER9_MODULEDIR=`$PKG_CONFIG --variable=moduledir d3dadapter9 2>/dev/null`
+ if test "x$D3DADAPTER9_MODULEDIR" = x
+ then
+ # legacy path
+ D3DADAPTER9_MODULEDIR=`$PKG_CONFIG --variable=moduledir d3d 2>/dev/null`
+ if test "x$D3DADAPTER9_MODULEDIR" = x
+ then
+ AC_MSG_ERROR([pkg-config couldn't find Gallium Nine module])
+ fi
+ fi
+ AC_DEFINE_UNQUOTED(D3D9NINE_MODULEPATH, ["`echo ${D3DADAPTER9_MODULEDIR}/d3dadapter9.so.1`"], [Gallium Nine module path])
+ # Check module
+ CPPFLAGSBAK=$CPPFLAGS
+ # link against libdl
+ CPPFLAGS="$CPPFLAGS -Wl,--no-as-needed -ldl"
+
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <dlfcn.h>
+#include <stdlib.h>]],[[void *handle = dlopen("${D3DADAPTER9_MODULEDIR}/d3dadapter9.so.1", RTLD_GLOBAL | RTLD_NOW);
+exit((handle && dlsym(handle, "D3DAdapter9GetProc")) ? 0 : 1)]])],
+ [echo "d3dadapter9.so.1 found at '${D3DADAPTER9_MODULEDIR}/d3dadapter9.so.1'"],
+ [AC_MSG_ERROR([Couldn't load Gallium nine module at '${D3DADAPTER9_MODULEDIR}/d3dadapter9.so.1' (found by pkg-config)])])
+ CPPFLAGS=$CPPFLAGSBAK
+ else
+ # Manual : do not feed any path, the wine registry will have
+ # to be used to pass a path. Useful for wine builds
+ # that are distributed and will run on different
+ # distros.
+ # Else feed a path directly. Useful for distro maintainers who
+ # know where the package would be installed, but don't have
+ # it installed on their build.
+ # Don't check if the module is there.
+ if test "x$with_d3d9_nine_module" != "xmanual"
+ then
+ AC_DEFINE_UNQUOTED(D3D9NINE_MODULEPATH, ["`echo ${with_d3d9_nine_module}`"], [Gallium Nine module path])
+ fi
+ fi
+
+ # by default the headers are found with pkgconfig,
+ # but it is possible to pass a path to a specific directory.
+ # that directory must contain a d3dadapter directory
+ # with d3dadapter9.h, drm.h and present.h
+ if test "x$with_d3d9_nine_headers_path" = "xauto"
+ then
+ AC_PROG_SED
+ D3DADAPTER9_INCLUDEDIR=`$PKG_CONFIG --variable=includedir d3dadapter9 2>/dev/null`
+ D3DADAPTER9_MAJOR=`$PKG_CONFIG --modversion d3dadapter9 2>/dev/null | $SED -n 's/\([[^\.]]*\)\..*$/\1/p'`
+ if test "x$D3DADAPTER9_INCLUDEDIR" = x
+ then
+ # legacy path
+ D3DADAPTER9_INCLUDEDIR=`$PKG_CONFIG --variable=includedir d3d 2>/dev/null`
+ D3DADAPTER9_MAJOR=`$PKG_CONFIG --modversion d3d 2>/dev/null | $SED -n 's/\([[^\.]]*\)\..*$/\1/p'`
+ if test "x$D3DADAPTER9_INCLUDEDIR" = x
+ then
+ AC_MSG_ERROR([pkg-config couldn't find Gallium Nine headers])
+ fi
+ fi
+ # check major version of package. The major version number guarantees header compatibility.
+ if test "x$D3DADAPTER9_MAJOR" != x1
+ then
+ AC_MSG_ERROR([pkg-config found Gallium Nine Module and Headers, but version is incompatible])
+ fi
+ else
+ D3DADAPTER9_INCLUDEDIR=`echo ${with_d3d9_nine_headers_path}`
+ fi
+ AC_DEFINE_UNQUOTED(D3D9NINE_HEADERS_CFLAGS, ["`echo -I${D3DADAPTER9_INCLUDEDIR}`"], [Gallium Nine headers cflags])
+
+ AC_DEFINE(D3D9NINE_DRI2, 1, [Whether d3d9-nine DRI2 fallback is compiled])
+ else
+ enable_d3d9_nine=${enable_d3d9_nine:-no}
+ fi
+
CPPFLAGS="$ac_save_CPPFLAGS"
else
X_CFLAGS=""
@@ -3161,6 +3348,7 @@ WINE_CONFIG_MAKEFILE(dlls/d3d8)
WINE_CONFIG_MAKEFILE(dlls/d3d8/tests)
WINE_CONFIG_MAKEFILE(dlls/d3d9)
WINE_CONFIG_MAKEFILE(dlls/d3d9/tests)
+WINE_CONFIG_MAKEFILE(dlls/d3d9-nine)
WINE_CONFIG_MAKEFILE(dlls/d3dcompiler_33)
WINE_CONFIG_MAKEFILE(dlls/d3dcompiler_34)
WINE_CONFIG_MAKEFILE(dlls/d3dcompiler_35)
diff --git a/dlls/d3d9-nine/Makefile.in b/dlls/d3d9-nine/Makefile.in
new file mode 100644
index 0000000000..c6df8d7dbe
--- /dev/null
+++ b/dlls/d3d9-nine/Makefile.in
@@ -0,0 +1,15 @@
+MODULE = d3d9-nine.dll
+IMPORTS = dxguid uuid advapi32 gdi32 user32
+EXTRAINCL = $(X_CFLAGS) $(D3D9NINE_HEADERS_CFLAGS)
+EXTRALIBS = $(D3D9NINE_LIBS)
+
+C_SRCS = \
+ d3d9_main.c \
+ d3dadapter9.c \
+ device_wrap.c \
+ present.c \
+ dri3.c \
+ wndproc.c \
+ shader_validator.c
+
+RC_SRCS = version.rc
diff --git a/dlls/d3d9-nine/d3d9-nine.spec b/dlls/d3d9-nine/d3d9-nine.spec
new file mode 100644
index 0000000000..a33cba51e7
--- /dev/null
+++ b/dlls/d3d9-nine/d3d9-nine.spec
@@ -0,0 +1,14 @@
+@ stdcall Direct3DShaderValidatorCreate9()
+@ stub PSGPError
+@ stub PSGPSampleTexture
+@ stdcall D3DPERF_BeginEvent(long wstr)
+@ stdcall D3DPERF_EndEvent()
+@ stdcall D3DPERF_GetStatus()
+@ stdcall D3DPERF_QueryRepeatFrame()
+@ stdcall D3DPERF_SetMarker(long wstr)
+@ stdcall D3DPERF_SetOptions(long)
+@ stdcall D3DPERF_SetRegion(long wstr)
+@ stub DebugSetLevel
+@ stdcall DebugSetMute()
+@ stdcall Direct3DCreate9(long)
+@ stdcall Direct3DCreate9Ex(long ptr)
diff --git a/dlls/d3d9-nine/d3d9_main.c b/dlls/d3d9-nine/d3d9_main.c
new file mode 100644
index 0000000000..d1efdf4a71
--- /dev/null
+++ b/dlls/d3d9-nine/d3d9_main.c
@@ -0,0 +1,173 @@
+/*
+ * Direct3D 9
+ *
+ * Copyright 2002-2003 Jason Edmeades
+ * Copyright 2002-2003 Raphael Junqueira
+ * Copyright 2005 Oliver Stieber
+ * Copyright 2015 Patrick Rudolph
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#include "config.h"
+#include "wine/debug.h"
+
+#include <fcntl.h>
+#include <d3d9.h>
+
+#include "d3dadapter9.h"
+#include "wndproc.h"
+#include "shader_validator.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9nine);
+
+static int D3DPERF_event_level = 0;
+static Display *gdi_display;
+
+void WINAPI DebugSetMute(void)
+{
+ /* nothing to do */
+}
+
+IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version)
+{
+ IDirect3D9 *native;
+ TRACE("sdk_version %#x.\n", sdk_version);
+
+ if (SUCCEEDED(d3dadapter9_new(gdi_display, FALSE, (IDirect3D9Ex **)&native)))
+ return native;
+
+ return NULL;
+}
+
+HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9Ex **d3d9ex)
+{
+ TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex);
+
+ return d3dadapter9_new(gdi_display, TRUE, d3d9ex);
+}
+
+/*******************************************************************
+ * Direct3DShaderValidatorCreate9 (D3D9.@)
+ *
+ * No documentation available for this function.
+ * SDK only says it is internal and shouldn't be used.
+ */
+
+void* WINAPI Direct3DShaderValidatorCreate9(void)
+{
+ IDirect3DShaderValidator9Impl* object =
+ HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+ sizeof(IDirect3DShaderValidator9Impl));
+
+ object->lpVtbl = &IDirect3DShaderValidator9Vtbl;
+ object->ref = 1;
+
+ FIXME("Returning interface %p\n", object);
+ return (void*) object;
+}
+
+/*******************************************************************
+ * DllMain
+ */
+BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
+{
+ switch (reason)
+ {
+ case DLL_PROCESS_ATTACH:
+ if (!(gdi_display = XOpenDisplay( NULL )))
+ {
+ ERR("Failed to open display\n");
+ return FALSE;
+ }
+
+ fcntl( ConnectionNumber(gdi_display), F_SETFD, 1 ); /* set close on exec flag */
+
+ nine_dll_init(inst);
+ break;
+ case DLL_PROCESS_DETACH:
+ if (!reserved)
+ return nine_dll_destroy(inst);
+ break;
+ }
+
+ return TRUE;
+}
+
+/***********************************************************************
+ * D3DPERF_BeginEvent (D3D9.@)
+ */
+int WINAPI D3DPERF_BeginEvent(D3DCOLOR color, const WCHAR *name)
+{
+ TRACE("color 0x%08x, name %s.\n", color, debugstr_w(name));
+
+ return D3DPERF_event_level++;
+}
+
+/***********************************************************************
+ * D3DPERF_EndEvent (D3D9.@)
+ */
+int WINAPI D3DPERF_EndEvent(void)
+{
+ TRACE("(void) : stub\n");
+
+ return --D3DPERF_event_level;
+}
+
+/***********************************************************************
+ * D3DPERF_GetStatus (D3D9.@)
+ */
+DWORD WINAPI D3DPERF_GetStatus(void)
+{
+ FIXME("(void) : stub\n");
+
+ return 0;
+}
+
+/***********************************************************************
+ * D3DPERF_SetOptions (D3D9.@)
+ *
+ */
+void WINAPI D3DPERF_SetOptions(DWORD options)
+{
+ FIXME("(%#x) : stub\n", options);
+}
+
+/***********************************************************************
+ * D3DPERF_QueryRepeatFrame (D3D9.@)
+ */
+BOOL WINAPI D3DPERF_QueryRepeatFrame(void)
+{
+ FIXME("(void) : stub\n");
+
+ return FALSE;
+}
+
+/***********************************************************************
+ * D3DPERF_SetMarker (D3D9.@)
+ */
+void WINAPI D3DPERF_SetMarker(D3DCOLOR color, const WCHAR *name)
+{
+ FIXME("color 0x%08x, name %s stub!\n", color, debugstr_w(name));
+}
+
+/***********************************************************************
+ * D3DPERF_SetRegion (D3D9.@)
+ */
+void WINAPI D3DPERF_SetRegion(D3DCOLOR color, const WCHAR *name)
+{
+ FIXME("color 0x%08x, name %s stub!\n", color, debugstr_w(name));
+}
diff --git a/dlls/d3d9-nine/d3dadapter9.c b/dlls/d3d9-nine/d3dadapter9.c
new file mode 100644
index 0000000000..188eebf763
--- /dev/null
+++ b/dlls/d3d9-nine/d3dadapter9.c
@@ -0,0 +1,898 @@
+/*
+ * Wine IDirect3D9 interface using ID3DAdapter9
+ *
+ * Copyright 2013 Joakim Sindholt
+ * Christoph Bumiller
+ * Copyright 2014 David Heidelberger
+ * Copyright 2014-2015 Axel Davy
+ * Copyright 2015 Nick Sarnie
+ * Patrick Rudolph
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d9nine);
+
+#include <d3dadapter/d3dadapter9.h>
+#include "present.h"
+#include "device_wrap.h"
+
+/* this represents a snapshot taken at the moment of creation */
+struct output
+{
+ D3DDISPLAYROTATION rotation; /* current rotation */
+ D3DDISPLAYMODEEX *modes;
+ unsigned nmodes;
+ unsigned nmodesalloc;
+ unsigned current; /* current mode num */
+
+ HMONITOR monitor;
+};
+
+struct adapter_group
+{
+ struct output *outputs;
+ unsigned noutputs;
+ unsigned noutputsalloc;
+
+ /* override driver provided DeviceName with this to homogenize device names
+ * with wine */
+ WCHAR devname[32];
+
+ /* driver stuff */
+ ID3DAdapter9 *adapter;
+};
+
+struct adapter_map
+{
+ unsigned group;
+ unsigned master;
+};
+
+struct d3dadapter9
+{
+ /* COM vtable */
+ void *vtable;
+ /* IUnknown reference count */
+ LONG refs;
+
+ /* adapter groups and mappings */
+ struct adapter_group *groups;
+ struct adapter_map *map;
+ unsigned nadapters;
+ unsigned ngroups;
+ unsigned ngroupsalloc;
+
+ /* true if it implements IDirect3D9Ex */
+ boolean ex;
+ Display *gdi_display;
+};
+
+/* convenience wrapper for calls into ID3D9Adapter */
+#define ADAPTER_GROUP \
+ This->groups[This->map[Adapter].group]
+
+#define ADAPTER_PROC(name, ...) \
+ ID3DAdapter9_##name(ADAPTER_GROUP.adapter, ## __VA_ARGS__)
+
+#define ADAPTER_OUTPUT \
+ ADAPTER_GROUP.outputs[Adapter-This->map[Adapter].master]
+
+static HRESULT WINAPI d3dadapter9_CheckDeviceFormat(struct d3dadapter9 *This,
+ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
+ DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat);
+
+static ULONG WINAPI d3dadapter9_AddRef(struct d3dadapter9 *This)
+{
+ ULONG refs = InterlockedIncrement(&This->refs);
+ TRACE("%p increasing refcount to %u.\n", This, refs);
+ return refs;
+}
+
+static ULONG WINAPI d3dadapter9_Release(struct d3dadapter9 *This)
+{
+ ULONG refs = InterlockedDecrement(&This->refs);
+ TRACE("%p decreasing refcount to %u.\n", This, refs);
+ if (refs == 0)
+ {
+ /* dtor */
+ if (This->map)
+ {
+ HeapFree(GetProcessHeap(), 0, This->map);
+ }
+
+ if (This->groups)
+ {
+ int i, j;
+ for (i = 0; i < This->ngroups; ++i)
+ {
+ if (This->groups[i].outputs)
+ {
+ for (j = 0; j < This->groups[i].noutputs; ++j)
+ {
+ if (This->groups[i].outputs[j].modes)
+ {
+ HeapFree(GetProcessHeap(), 0,
+ This->groups[i].outputs[j].modes);
+ }
+ }
+ HeapFree(GetProcessHeap(), 0, This->groups[i].outputs);
+ }
+
+ if (This->groups[i].adapter)
+ ID3DAdapter9_Release(This->groups[i].adapter);
+ }
+ HeapFree(GetProcessHeap(), 0, This->groups);
+ }
+
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return refs;
+}
+
+static HRESULT WINAPI d3dadapter9_QueryInterface(struct d3dadapter9 *This,
+ REFIID riid, void **ppvObject)
+{
+ if (!ppvObject)
+ return E_POINTER;
+
+ if ((IsEqualGUID(&IID_IDirect3D9Ex, riid) && This->ex) ||
+ IsEqualGUID(&IID_IDirect3D9, riid) ||
+ IsEqualGUID(&IID_IUnknown, riid))
+ {
+ *ppvObject = This;
+ d3dadapter9_AddRef(This);
+ return S_OK;
+ }
+
+ WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
+ *ppvObject = NULL;
+
+ return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI d3dadapter9_RegisterSoftwareDevice(struct d3dadapter9 *This,
+ void *pInitializeFunction)
+{
+ FIXME("(%p, %p), stub!\n", This, pInitializeFunction);
+ return D3DERR_INVALIDCALL;
+}
+
+static UINT WINAPI d3dadapter9_GetAdapterCount(struct d3dadapter9 *This)
+{
+ return This->nadapters;
+}
+
+static HRESULT WINAPI d3dadapter9_GetAdapterIdentifier(struct d3dadapter9 *This,
+ UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier)
+{
+ HRESULT hr;
+ HKEY regkey;
+
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ hr = ADAPTER_PROC(GetAdapterIdentifier, Flags, pIdentifier);
+ if (SUCCEEDED(hr))
+ {
+ /* Override the driver provided DeviceName with what Wine provided */
+ ZeroMemory(pIdentifier->DeviceName, sizeof(pIdentifier->DeviceName));
+ if (!WideCharToMultiByte(CP_ACP, 0, ADAPTER_GROUP.devname, -1,
+ pIdentifier->DeviceName, sizeof(pIdentifier->DeviceName), NULL, NULL))
+ return D3DERR_INVALIDCALL;
+
+ TRACE("DeviceName overriden: %s\n", pIdentifier->DeviceName);
+
+ /* Override PCI IDs when wined3d registry keys are set */
+ if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Direct3DNine", ®key))
+ {
+ DWORD type, data;
+ DWORD size = sizeof(DWORD);
+
+ if (!RegQueryValueExA(regkey, "VideoPciDeviceID", 0, &type, (BYTE *)&data, &size) &&
+ (type == REG_DWORD) && (size == sizeof(DWORD)))
+ pIdentifier->DeviceId = data;
+ if (size != sizeof(DWORD))
+ {
+ ERR("VideoPciDeviceID is not a DWORD\n");
+ size = sizeof(DWORD);
+ }
+ if (!RegQueryValueExA(regkey, "VideoPciVendorID", 0, &type, (BYTE *)&data, &size) &&
+ (type == REG_DWORD) && (size == sizeof(DWORD)))
+ pIdentifier->VendorId = data;
+ if (size != sizeof(DWORD))
+ ERR("VideoPciVendorID is not a DWORD\n");
+ RegCloseKey(regkey);
+
+ TRACE("DeviceId:VendorId overridden: %04X:%04X\n", pIdentifier->DeviceId, pIdentifier->VendorId);
+ }
+ }
+ return hr;
+}
+
+static UINT WINAPI d3dadapter9_GetAdapterModeCount(struct d3dadapter9 *This,
+ UINT Adapter, D3DFORMAT Format)
+{
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ if (FAILED(d3dadapter9_CheckDeviceFormat(This, Adapter, D3DDEVTYPE_HAL,
+ Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, Format)))
+ {
+ WARN("DeviceFormat not available.\n");
+ return 0;
+ }
+
+ TRACE("%u modes.\n", ADAPTER_OUTPUT.nmodes);
+ return ADAPTER_OUTPUT.nmodes;
+}
+
+static HRESULT WINAPI d3dadapter9_EnumAdapterModes(struct d3dadapter9 *This,
+ UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE *pMode)
+{
+ HRESULT hr;
+
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ hr = d3dadapter9_CheckDeviceFormat(This, Adapter, D3DDEVTYPE_HAL,
+ Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, Format);
+
+ if (FAILED(hr))
+ {
+ TRACE("DeviceFormat not available.\n");
+ return hr;
+ }
+
+ if (Mode >= ADAPTER_OUTPUT.nmodes)
+ {
+ WARN("Mode %u does not exist.\n", Mode);
+ return D3DERR_INVALIDCALL;
+ }
+
+ pMode->Width = ADAPTER_OUTPUT.modes[Mode].Width;
+ pMode->Height = ADAPTER_OUTPUT.modes[Mode].Height;
+ pMode->RefreshRate = ADAPTER_OUTPUT.modes[Mode].RefreshRate;
+ pMode->Format = Format;
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI d3dadapter9_GetAdapterDisplayMode(struct d3dadapter9 *This,
+ UINT Adapter, D3DDISPLAYMODE *pMode)
+{
+ UINT Mode;
+
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ Mode = ADAPTER_OUTPUT.current;
+ pMode->Width = ADAPTER_OUTPUT.modes[Mode].Width;
+ pMode->Height = ADAPTER_OUTPUT.modes[Mode].Height;
+ pMode->RefreshRate = ADAPTER_OUTPUT.modes[Mode].RefreshRate;
+ pMode->Format = ADAPTER_OUTPUT.modes[Mode].Format;
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI d3dadapter9_CheckDeviceType(struct d3dadapter9 *This,
+ UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat,
+ D3DFORMAT BackBufferFormat, BOOL bWindowed)
+{
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ return ADAPTER_PROC(CheckDeviceType,
+ DevType, AdapterFormat, BackBufferFormat, bWindowed);
+}
+
+static HRESULT WINAPI d3dadapter9_CheckDeviceFormat(struct d3dadapter9 *This,
+ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
+ DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat)
+{
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ return ADAPTER_PROC(CheckDeviceFormat,
+ DeviceType, AdapterFormat, Usage, RType, CheckFormat);
+}
+
+static HRESULT WINAPI d3dadapter9_CheckDeviceMultiSampleType(struct d3dadapter9 *This,
+ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
+ BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels)
+{
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ return ADAPTER_PROC(CheckDeviceMultiSampleType, DeviceType, SurfaceFormat,
+ Windowed, MultiSampleType, pQualityLevels);
+}
+
+static HRESULT WINAPI d3dadapter9_CheckDepthStencilMatch(struct d3dadapter9 *This,
+ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
+ D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat)
+{
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ return ADAPTER_PROC(CheckDepthStencilMatch, DeviceType, AdapterFormat,
+ RenderTargetFormat, DepthStencilFormat);
+}
+
+static HRESULT WINAPI d3dadapter9_CheckDeviceFormatConversion(struct d3dadapter9 *This,
+ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat)
+{
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ return ADAPTER_PROC(CheckDeviceFormatConversion,
+ DeviceType, SourceFormat, TargetFormat);
+}
+
+static HRESULT WINAPI d3dadapter9_GetDeviceCaps(struct d3dadapter9 *This,
+ UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps)
+{
+ HRESULT hr;
+
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ hr = ADAPTER_PROC(GetDeviceCaps, DeviceType, pCaps);
+ if (FAILED(hr))
+ return hr;
+
+ pCaps->MasterAdapterOrdinal = This->map[Adapter].master;
+ pCaps->AdapterOrdinalInGroup = Adapter-This->map[Adapter].master;
+ pCaps->NumberOfAdaptersInGroup = ADAPTER_GROUP.noutputs;
+
+ return hr;
+}
+
+static HMONITOR WINAPI d3dadapter9_GetAdapterMonitor(struct d3dadapter9 *This,
+ UINT Adapter)
+{
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return (HMONITOR)0;
+
+ return (HMONITOR)ADAPTER_OUTPUT.monitor;
+}
+
+static HRESULT WINAPI DECLSPEC_HOTPATCH d3dadapter9_CreateDeviceEx(struct d3dadapter9 *This,
+ UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags,
+ D3DPRESENT_PARAMETERS *pPresentationParameters,
+ D3DDISPLAYMODEEX *pFullscreenDisplayMode,
+ IDirect3DDevice9Ex **ppReturnedDeviceInterface);
+
+static HRESULT WINAPI DECLSPEC_HOTPATCH d3dadapter9_CreateDevice(struct d3dadapter9 *This,
+ UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags,
+ D3DPRESENT_PARAMETERS *pPresentationParameters,
+ IDirect3DDevice9 **ppReturnedDeviceInterface)
+{
+ HRESULT hr;
+ hr = d3dadapter9_CreateDeviceEx(This, Adapter, DeviceType, hFocusWindow,
+ BehaviorFlags, pPresentationParameters, NULL,
+ (IDirect3DDevice9Ex **)ppReturnedDeviceInterface);
+ if (FAILED(hr))
+ return hr;
+
+ return D3D_OK;
+}
+
+static UINT WINAPI d3dadapter9_GetAdapterModeCountEx(struct d3dadapter9 *This,
+ UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter)
+{
+ FIXME("(%p, %u, %p), half stub!\n", This, Adapter, pFilter);
+ return d3dadapter9_GetAdapterModeCount(This, Adapter, pFilter->Format);
+}
+
+static HRESULT WINAPI d3dadapter9_EnumAdapterModesEx(struct d3dadapter9 *This,
+ UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter, UINT Mode,
+ D3DDISPLAYMODEEX *pMode)
+{
+ HRESULT hr;
+
+ FIXME("(%p, %u, %p, %u, %p), half stub!\n", This, Adapter, pFilter, Mode, pMode);
+
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ hr = d3dadapter9_CheckDeviceFormat(This, Adapter, D3DDEVTYPE_HAL,
+ pFilter->Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, pFilter->Format);
+
+ if (FAILED(hr))
+ {
+ TRACE("DeviceFormat not available.\n");
+ return hr;
+ }
+
+ if (Mode >= ADAPTER_OUTPUT.nmodes)
+ {
+ WARN("Mode %u does not exist.\n", Mode);
+ return D3DERR_INVALIDCALL;
+ }
+
+ pMode->Size = ADAPTER_OUTPUT.modes[Mode].Size;
+ pMode->Width = ADAPTER_OUTPUT.modes[Mode].Width;
+ pMode->Height = ADAPTER_OUTPUT.modes[Mode].Height;
+ pMode->RefreshRate = ADAPTER_OUTPUT.modes[Mode].RefreshRate;
+ pMode->Format = ADAPTER_OUTPUT.modes[Mode].Format;
+ pMode->ScanLineOrdering = ADAPTER_OUTPUT.modes[Mode].ScanLineOrdering;
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI d3dadapter9_GetAdapterDisplayModeEx(struct d3dadapter9 *This,
+ UINT Adapter, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation)
+{
+ UINT Mode;
+
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ if (pMode)
+ {
+ Mode = ADAPTER_OUTPUT.current;
+ pMode->Size = sizeof(D3DDISPLAYMODEEX);
+ pMode->Width = ADAPTER_OUTPUT.modes[Mode].Width;
+ pMode->Height = ADAPTER_OUTPUT.modes[Mode].Height;
+ pMode->RefreshRate = ADAPTER_OUTPUT.modes[Mode].RefreshRate;
+ pMode->Format = ADAPTER_OUTPUT.modes[Mode].Format;
+ pMode->ScanLineOrdering = ADAPTER_OUTPUT.modes[Mode].ScanLineOrdering;
+ }
+ if (pRotation)
+ *pRotation = ADAPTER_OUTPUT.rotation;
+
+ return D3D_OK;
+}
+
+static HRESULT WINAPI DECLSPEC_HOTPATCH d3dadapter9_CreateDeviceEx(struct d3dadapter9 *This,
+ UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags,
+ D3DPRESENT_PARAMETERS *pPresentationParameters,
+ D3DDISPLAYMODEEX *pFullscreenDisplayMode,
+ IDirect3DDevice9Ex **ppReturnedDeviceInterface)
+{
+ ID3DPresentGroup *present;
+ HRESULT hr;
+
+ if (Adapter >= d3dadapter9_GetAdapterCount(This))
+ return D3DERR_INVALIDCALL;
+
+ {
+ struct adapter_group *group = &ADAPTER_GROUP;
+ unsigned nparams, ordinal;
+
+ if (BehaviorFlags & D3DCREATE_ADAPTERGROUP_DEVICE)
+ {
+ nparams = group->noutputs;
+ ordinal = 0;
+ }
+ else
+ {
+ nparams = 1;
+ ordinal = Adapter - This->map[Adapter].master;
+ }
+ hr = present_create_present_group(This->gdi_display, group->devname, ordinal,
+ hFocusWindow, pPresentationParameters, nparams, &present, This->ex,
+ BehaviorFlags);
+ }
+
+ if (FAILED(hr))
+ {
+ WARN("Failed to create PresentGroup.\n");
+ return hr;
+ }
+
+ if (This->ex)
+ {
+ hr = ADAPTER_PROC(CreateDeviceEx, Adapter, DeviceType, hFocusWindow,
+ BehaviorFlags, pPresentationParameters, pFullscreenDisplayMode,
+ (IDirect3D9Ex *)This, present, ppReturnedDeviceInterface);
+ }
+ else
+ {
+ /* CreateDevice on non-ex */
+ hr = ADAPTER_PROC(CreateDevice, Adapter, DeviceType, hFocusWindow,
+ BehaviorFlags, pPresentationParameters, (IDirect3D9 *)This, present,
+ (IDirect3DDevice9 **)ppReturnedDeviceInterface);
+ }