-
Notifications
You must be signed in to change notification settings - Fork 8
/
ump.diff
2046 lines (1989 loc) · 67.6 KB
/
ump.diff
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
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
deleted file mode 100644
index d1b66ef4cad..00000000000
--- a/.github/workflows/macos.yml
+++ /dev/null
@@ -1,60 +0,0 @@
-name: macOS-CI
-on: push
-
-permissions:
- contents: read
-
-jobs:
- macOS-CI:
- strategy:
- matrix:
- glx_option: ['dri', 'xlib']
- runs-on: macos-11
- env:
- GALLIUM_DUMP_CPU: true
- MESON_EXEC: /Users/runner/Library/Python/3.11/bin/meson
- steps:
- - name: Checkout
- uses: actions/checkout@v3
- - name: Install Dependencies
- run: |
- cat > Brewfile <<EOL
- brew "bison"
- brew "expat"
- brew "gettext"
- brew "libx11"
- brew "libxcb"
- brew "libxdamage"
- brew "libxext"
- brew "molten-vk"
- brew "ninja"
- brew "pkg-config"
- brew "[email protected]"
- EOL
-
- brew update
- brew bundle --verbose
- - name: Install Mako and meson
- run: pip3 install --user mako meson
- - name: Configure
- run: |
- cat > native_config <<EOL
- [binaries]
- llvm-config = '/usr/local/opt/llvm/bin/llvm-config'
- EOL
- $MESON_EXEC . build --native-file=native_config -Dmoltenvk-dir=$(brew --prefix molten-vk) -Dbuild-tests=true -Dosmesa=true -Dgallium-drivers=swrast,zink -Dglx=${{ matrix.glx_option }}
- - name: Build
- run: $MESON_EXEC compile -C build
- - name: Test
- run: $MESON_EXEC test -C build --print-errorlogs
- - name: Install
- run: $MESON_EXEC install -C build --destdir $PWD/install
- - name: 'Upload Artifact'
- if: always()
- uses: actions/upload-artifact@v3
- with:
- name: macos-${{ matrix.glx_option }}-result
- path: |
- build/meson-logs/
- install/
- retention-days: 5
diff --git a/.github/workflows/ump-pojav-android.yml b/.github/workflows/ump-pojav-android.yml
new file mode 100644
index 00000000000..06e8aac0695
--- /dev/null
+++ b/.github/workflows/ump-pojav-android.yml
@@ -0,0 +1,89 @@
+name: Build UMP
+
+on:
+ [push, pull_request, workflow_dispatch]
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+ build:
+ strategy:
+ matrix:
+ arch: [ "arm32", "aarch64", "x86_64" ]
+ fail-fast: false
+
+ name: "Build for ${{matrix.arch}}"
+
+ runs-on: ubuntu-latest
+
+ steps:
+
+ - uses: actions/checkout@v2
+
+ - name: Build
+ run: |
+ sudo apt update
+ sudo apt install -y meson libxrandr-dev libxxf86vm-dev libxcb-*-dev libx11-xcb-dev libxfixes-dev libdrm-dev libx11-dev
+ pip3 install mako
+ export ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk-bundle"
+ envsubst <android-drm-${{matrix.arch}} >build-crossfile-drm
+ git clone --depth 1 https://gitlab.freedesktop.org/mesa/drm.git
+ cd drm
+ meson setup "build-android" \
+ --prefix=/tmp/drm-static \
+ --cross-file "../build-crossfile-drm" \
+ -Ddefault_library=static \
+ -Dintel=disabled \
+ -Dradeon=disabled \
+ -Damdgpu=disabled \
+ -Dnouveau=disabled \
+ -Dvmwgfx=disabled \
+ -Dfreedreno=enabled \
+ -Dvc4=disabled \
+ -Detnaviv=disabled \
+ -Dfreedreno-kgsl=true
+ ninja -C "build-android" install
+ cd ..
+ envsubst <android-${{matrix.arch}} >build-crossfile
+ meson setup "build-android" \
+ --prefix=/tmp/mesa \
+ --cross-file "build-crossfile" \
+ -Dplatforms=android \
+ -Dplatform-sdk-version=25 \
+ -Dandroid-stub=true \
+ -Dandroid-libbacktrace=disabled \
+ -Dandroid-strict=false \
+ -Dxlib-lease=disabled \
+ -Degl=disabled \
+ -Dgbm=disabled \
+ -Dglx=disabled \
+ -Dopengl=true \
+ -Dosmesa=true \
+ -Dvulkan-drivers= \
+ -Dgallium-drivers=freedreno,zink,panfrost,swrast \
+ -Dfreedreno-kmds=kgsl \
+ -Dshared-glapi=false \
+ -Dbuildtype=release
+ ninja -C "build-android" install
+ envsubst <android-turnip-${{matrix.arch}} >build-crossfile-turnip
+ meson setup "build-android-turnip" \
+ --cross-file "build-crossfile-turnip" \
+ -Dbuildtype=release \
+ --prefix=/tmp/mesa \
+ -Dplatforms=android \
+ -Dplatform-sdk-version=33 \
+ -Dandroid-stub=true \
+ -Dgallium-drivers= \
+ -Dvulkan-drivers=freedreno \
+ -Dfreedreno-kmds=kgsl \
+ -Dandroid-strict=false \
+ -Db_lto=true
+ ninja -C "build-android-turnip" install
+ mkdir /tmp/mesa/toupload
+ mv /tmp/mesa/lib/libOSMesa.so.8.0.0 /tmp/mesa/lib/libvulkan_freedreno.so /tmp/mesa/toupload/
+ cd /tmp/mesa/toupload
+ mv libOSMesa.so.8.0.0 libOSMesa.so
+ - name: Upload libraries
+ uses: actions/upload-artifact@v2
+ with:
+ name: UMP_${{matrix.arch}}
+ path: /tmp/mesa/toupload
diff --git a/.github/workflows/ump-pojav-android_debug.yml b/.github/workflows/ump-pojav-android_debug.yml
new file mode 100644
index 00000000000..c9952737403
--- /dev/null
+++ b/.github/workflows/ump-pojav-android_debug.yml
@@ -0,0 +1,89 @@
+name: Build UMP (debug)
+
+on:
+ [push, pull_request, workflow_dispatch]
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+ build:
+ strategy:
+ matrix:
+ arch: [ "arm32", "aarch64", "x86_64" ]
+ fail-fast: false
+
+ name: "Build for ${{matrix.arch}}"
+
+ runs-on: ubuntu-latest
+
+ steps:
+
+ - uses: actions/checkout@v2
+
+ - name: Build
+ run: |
+ sudo apt update
+ sudo apt install -y meson libxrandr-dev libxxf86vm-dev libxcb-*-dev libx11-xcb-dev libxfixes-dev libdrm-dev libx11-dev
+ pip3 install mako
+ export ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk-bundle"
+ envsubst <android-drm-${{matrix.arch}} >build-crossfile-drm
+ git clone --depth 1 https://gitlab.freedesktop.org/mesa/drm.git
+ cd drm
+ meson setup "build-android" \
+ --prefix=/tmp/drm-static \
+ --cross-file "../build-crossfile-drm" \
+ -Ddefault_library=static \
+ -Dintel=disabled \
+ -Dradeon=disabled \
+ -Damdgpu=disabled \
+ -Dnouveau=disabled \
+ -Dvmwgfx=disabled \
+ -Dfreedreno=enabled \
+ -Dvc4=disabled \
+ -Detnaviv=disabled \
+ -Dfreedreno-kgsl=true
+ ninja -C "build-android" install
+ cd ..
+ envsubst <android-${{matrix.arch}} >build-crossfile
+ meson setup "build-android" \
+ --prefix=/tmp/mesa \
+ --cross-file "build-crossfile" \
+ -Dplatforms=android \
+ -Dplatform-sdk-version=25 \
+ -Dandroid-stub=true \
+ -Dandroid-libbacktrace=disabled \
+ -Dandroid-strict=false \
+ -Dxlib-lease=disabled \
+ -Degl=disabled \
+ -Dgbm=disabled \
+ -Dglx=disabled \
+ -Dopengl=true \
+ -Dosmesa=true \
+ -Dvulkan-drivers= \
+ -Dgallium-drivers=freedreno,zink,panfrost,swrast \
+ -Dfreedreno-kmds=kgsl \
+ -Dshared-glapi=false \
+ -Dbuildtype=debug
+ ninja -C "build-android" install
+ envsubst <android-turnip-${{matrix.arch}} >build-crossfile-turnip
+ meson setup "build-android-turnip" \
+ --cross-file "build-crossfile-turnip" \
+ -Dbuildtype=debug \
+ --prefix=/tmp/mesa \
+ -Dplatforms=android \
+ -Dplatform-sdk-version=33 \
+ -Dandroid-stub=true \
+ -Dgallium-drivers= \
+ -Dvulkan-drivers=freedreno \
+ -Dfreedreno-kmds=kgsl \
+ -Dandroid-strict=false \
+ -Db_lto=true
+ ninja -C "build-android-turnip" install
+ mkdir /tmp/mesa/toupload
+ mv /tmp/mesa/lib/* /tmp/mesa/toupload/
+ cd /tmp/mesa/toupload
+ mv libOSMesa.so.8.0.0 libOSMesa.so
+ - name: Upload libraries
+ uses: actions/upload-artifact@v2
+ with:
+ name: UMP-dbg_${{matrix.arch}}
+ path: /tmp/mesa/toupload
\ No newline at end of file
diff --git a/android-aarch64 b/android-aarch64
new file mode 100644
index 00000000000..2737a2d01bd
--- /dev/null
+++ b/android-aarch64
@@ -0,0 +1,26 @@
+[binaries]
+ar = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
+c = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang', '-O3', '-DVK_USE_PLATFORM_ANDROID_KHR', '-fPIC']
+cpp = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang++', '-O3', '-DVK_USE_PLATFORM_ANDROID_KHR', '-fPIC', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-static-libstdc++']
+c_ld = 'lld'
+cpp_ld = 'lld'
+strip = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip'
+# Android doesn't come with a pkg-config, but we need one for meson to be happy not
+# finding all the optional deps it looks for. Use system pkg-config pointing at a
+# directory we get to populate with any .pc files we want to add for Android
+
+# Also, include the plain DRM lib we found earlier. Panfrost relies on it rather heavily, especially when
+# interacting with the panfrost DRM module and not kbase
+
+pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=.:/tmp/drm-static/lib/pkgconfig', '/usr/bin/pkg-config']
+
+[host_machine]
+system = 'linux'
+# cpu_family = 'x86_64'
+# cpu = 'amd64'
+
+# ik this is wrong but workaround sanity check
+cpu_family = 'arm'
+cpu = 'armv8'
+
+endian = 'little'
diff --git a/android-arm32 b/android-arm32
new file mode 100644
index 00000000000..6bd6af4e902
--- /dev/null
+++ b/android-arm32
@@ -0,0 +1,26 @@
+[binaries]
+ar = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
+c = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi26-clang', '-O3', '-DVK_USE_PLATFORM_ANDROID_KHR', '-fPIC']
+cpp = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi26-clang++', '-O3', '-DVK_USE_PLATFORM_ANDROID_KHR', '-fPIC', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-static-libstdc++']
+c_ld = 'lld'
+cpp_ld = 'lld'
+strip = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip'
+# Android doesn't come with a pkg-config, but we need one for meson to be happy not
+# finding all the optional deps it looks for. Use system pkg-config pointing at a
+# directory we get to populate with any .pc files we want to add for Android
+
+# Also, include the plain DRM lib we found earlier. Panfrost relies on it rather heavily, especially when
+# interacting with the panfrost DRM module and not kbase
+
+pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=.:/tmp/drm-static/lib/pkgconfig', '/usr/bin/pkg-config']
+
+[host_machine]
+system = 'linux'
+# cpu_family = 'x86_64'
+# cpu = 'amd64'
+
+# ik this is wrong but workaround sanity check
+cpu_family = 'arm'
+cpu = 'armv7'
+
+endian = 'little'
diff --git a/android-drm-aarch64 b/android-drm-aarch64
new file mode 100644
index 00000000000..d78f79edde3
--- /dev/null
+++ b/android-drm-aarch64
@@ -0,0 +1,22 @@
+[binaries]
+ar = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
+c = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang', '-O3', '-DVK_USE_PLATFORM_ANDROID_KHR', '-fPIC']
+cpp = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang++', '-O3', '-DVK_USE_PLATFORM_ANDROID_KHR', '-fPIC', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-static-libstdc++']
+c_ld = 'lld'
+cpp_ld = 'lld'
+strip = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip'
+# Android doesn't come with a pkg-config, but we need one for meson to be happy not
+# finding all the optional deps it looks for. Use system pkg-config pointing at a
+# directory we get to populate with any .pc files we want to add for Android
+pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=.', '/usr/bin/pkg-config']
+
+[host_machine]
+system = 'linux'
+# cpu_family = 'x86_64'
+# cpu = 'amd64'
+
+# ik this is wrong but workaround sanity check
+cpu_family = 'arm'
+cpu = 'armv8'
+
+endian = 'little'
diff --git a/android-drm-arm32 b/android-drm-arm32
new file mode 100644
index 00000000000..9ff8a6c4d30
--- /dev/null
+++ b/android-drm-arm32
@@ -0,0 +1,22 @@
+[binaries]
+ar = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
+c = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi26-clang', '-O3', '-DVK_USE_PLATFORM_ANDROID_KHR', '-fPIC']
+cpp = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi26-clang++', '-O3', '-DVK_USE_PLATFORM_ANDROID_KHR', '-fPIC', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-static-libstdc++']
+c_ld = 'lld'
+cpp_ld = 'lld'
+strip = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip'
+# Android doesn't come with a pkg-config, but we need one for meson to be happy not
+# finding all the optional deps it looks for. Use system pkg-config pointing at a
+# directory we get to populate with any .pc files we want to add for Android
+pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=.', '/usr/bin/pkg-config']
+
+[host_machine]
+system = 'linux'
+# cpu_family = 'x86_64'
+# cpu = 'amd64'
+
+# ik this is wrong but workaround sanity check
+cpu_family = 'arm'
+cpu = 'armv7'
+
+endian = 'little'
diff --git a/android-drm-x86_64 b/android-drm-x86_64
new file mode 100644
index 00000000000..dbd35a22ece
--- /dev/null
+++ b/android-drm-x86_64
@@ -0,0 +1,23 @@
+[binaries]
+ar = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
+c = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-clang', '-O3', '-DVK_USE_PLATFORM_ANDROID_KHR', '-fPIC']
+cpp = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-clang++', '-O3', '-DVK_USE_PLATFORM_ANDROID_KHR', '-fPIC', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-static-libstdc++']
+c_ld = 'lld'
+cpp_ld = 'lld'
+strip = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip'
+# Android doesn't come with a pkg-config, but we need one for meson to be happy not
+# finding all the optional deps it looks for. Use system pkg-config pointing at a
+# directory we get to populate with any .pc files we want to add for Android
+pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=.', '/usr/bin/pkg-config']
+
+[host_machine]
+system = 'linux'
+# cpu_family = 'x86_64'
+# cpu = 'amd64'
+
+# ik this is wrong but workaround sanity check
+cpu_family = 'arm'
+cpu = 'armv8'
+
+
+endian = 'little'
\ No newline at end of file
diff --git a/android-turnip-aarch64 b/android-turnip-aarch64
new file mode 100644
index 00000000000..a07dab511e5
--- /dev/null
+++ b/android-turnip-aarch64
@@ -0,0 +1,13 @@
+[binaries]
+ar = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
+c = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang']
+cpp = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang++', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-static-libstdc++']
+c_ld = 'lld'
+cpp_ld = 'lld'
+strip = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip'
+pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=.', '/usr/bin/pkg-config']
+[host_machine]
+system = 'android'
+cpu_family = 'aarch64'
+cpu = 'armv8'
+endian = 'little'
\ No newline at end of file
diff --git a/android-turnip-arm32 b/android-turnip-arm32
new file mode 100644
index 00000000000..c1461b2bc0a
--- /dev/null
+++ b/android-turnip-arm32
@@ -0,0 +1,13 @@
+[binaries]
+ar = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
+c = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi26-clang']
+cpp = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi26-clang++', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-static-libstdc++']
+c_ld = 'lld'
+cpp_ld = 'lld'
+strip = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi-strip'
+pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=.', '/usr/bin/pkg-config']
+[host_machine]
+system = 'android'
+cpu_family = 'arm'
+cpu = 'armv7'
+endian = 'little'
\ No newline at end of file
diff --git a/android-turnip-x86_64 b/android-turnip-x86_64
new file mode 100644
index 00000000000..6775f7b605c
--- /dev/null
+++ b/android-turnip-x86_64
@@ -0,0 +1,13 @@
+[binaries]
+ar = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
+c = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-clang']
+cpp = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-clang++', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-static-libstdc++']
+c_ld = 'lld'
+cpp_ld = 'lld'
+strip = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android-strip'
+pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=.', '/usr/bin/pkg-config']
+[host_machine]
+system = 'android'
+cpu_family = 'x86_64'
+cpu = 'amd64'
+endian = 'little'
\ No newline at end of file
diff --git a/android-x86_64 b/android-x86_64
new file mode 100644
index 00000000000..b67ca9a44ea
--- /dev/null
+++ b/android-x86_64
@@ -0,0 +1,27 @@
+[binaries]
+ar = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
+c = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-clang', '-O3', '-DVK_USE_PLATFORM_ANDROID_KHR', '-fPIC']
+cpp = ['ccache', '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-clang++', '-O3', '-DVK_USE_PLATFORM_ANDROID_KHR', '-fPIC', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-static-libstdc++']
+c_ld = 'lld'
+cpp_ld = 'lld'
+strip = '$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip'
+# Android doesn't come with a pkg-config, but we need one for meson to be happy not
+# finding all the optional deps it looks for. Use system pkg-config pointing at a
+# directory we get to populate with any .pc files we want to add for Android
+
+# Also, include the plain DRM lib we found earlier. Panfrost relies on it rather heavily, especially when
+# interacting with the panfrost DRM module and not kbase
+
+pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=.:/tmp/drm-static/lib/pkgconfig', '/usr/bin/pkg-config']
+
+[host_machine]
+system = 'linux'
+# cpu_family = 'x86_64'
+# cpu = 'amd64'
+
+# ik this is wrong but workaround sanity check
+cpu_family = 'arm'
+cpu = 'armv8'
+
+
+endian = 'little'
\ No newline at end of file
diff --git a/meson.build b/meson.build
index 8963b314256..16e3c149e72 100644
--- a/meson.build
+++ b/meson.build
@@ -196,6 +196,10 @@ foreach gallium_driver : gallium_drivers
pre_args += '-DHAVE_@0@'.format(gallium_driver.to_upper())
endforeach
+if get_option('freedreno-kmds').contains('kgsl')
+ pre_args += '-DHAVE_FREEDRENO_KGSL'
+endif
+
with_gallium = gallium_drivers.length() != 0
with_gallium_kmsro = system_has_kms_drm and [
with_gallium_asahi,
@@ -1974,9 +1978,6 @@ if dep_unwind.found()
endif
if with_osmesa
- if not with_gallium_softpipe
- error('OSMesa gallium requires gallium softpipe or llvmpipe.')
- endif
if host_machine.system() == 'windows'
osmesa_lib_name = 'osmesa'
else
diff --git a/src/android_stub/meson.build b/src/android_stub/meson.build
index 6097ae8ef07..0e3f27bc4a5 100644
--- a/src/android_stub/meson.build
+++ b/src/android_stub/meson.build
@@ -1,6 +1,6 @@
if with_android_stub
stub_libs = []
- lib_names = ['cutils', 'hardware', 'log', 'nativewindow', 'sync']
+ lib_names = ['hardware', 'log', 'nativewindow', 'sync']
if with_libbacktrace
lib_names += ['backtrace']
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 8e2b705ea9b..db99c0271c1 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -1056,9 +1056,46 @@ droid_probe_device(_EGLDisplay *disp, bool swrast)
return EGL_TRUE;
}
+static EGLBoolean droid_open_device_kgsl(_EGLDisplay *disp, bool swrast)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ static const char path[] = "/dev/kgsl-3d0";
+ static const char driver_name[] = "kgsl";
+
+ dri2_dpy->fd_render_gpu = loader_open_device(path);
+ if (dri2_dpy->fd_render_gpu < 0) {
+ _eglLog(_EGL_WARNING, "Failed to open kgsl");
+ return EGL_FALSE;
+ }
+
+ dri2_dpy->driver_name = strdup(driver_name);
+ dri2_dpy->loader_extensions = droid_image_loader_extensions;
+ if (!dri2_load_driver_dri3(disp)) {
+ free(dri2_dpy->driver_name);
+ dri2_dpy->driver_name = NULL;
+ goto error;
+ }
+
+ if (!dri2_create_screen(disp)) {
+ _eglLog(_EGL_WARNING, "DRI2: Failed to create screen");
+ droid_unload_driver(disp);
+ goto error;
+ }
+
+ return EGL_TRUE;
+error:
+ close(dri2_dpy->fd_render_gpu);
+ dri2_dpy->fd_render_gpu = -1;
+ return EGL_FALSE;
+}
+
static EGLBoolean
droid_open_device(_EGLDisplay *disp, bool swrast)
{
+#ifdef HAVE_FREEDRENO_KGSL
+ if (droid_open_device_kgsl(disp, swrast))
+ goto done;
+#endif
#define MAX_DRM_DEVICES 64
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
_EGLDevice *dev_list = _eglGlobal.DeviceList;
@@ -1168,6 +1205,15 @@ dri2_initialize_android(_EGLDisplay *disp)
goto cleanup;
}
+ /* Only add a egl device if this is not the kgsl driver */
+ if (strcmp(dri2_dpy->driver_name, "kgsl") != 0) {
+ dev = _eglAddDevice(dri2_dpy->fd_render_gpu, false);
+ if (!dev) {
+ err = "DRI2: failed to find EGLDevice";
+ goto cleanup;
+ }
+ }
+
if (!dri2_setup_device(disp, false)) {
err = "DRI2: failed to setup EGLDevice";
goto cleanup;
diff --git a/src/freedreno/drm/freedreno_device.c b/src/freedreno/drm/freedreno_device.c
index 367e499b732..8b0c8ed6917 100644
--- a/src/freedreno/drm/freedreno_device.c
+++ b/src/freedreno/drm/freedreno_device.c
@@ -37,22 +37,25 @@ struct fd_device *msm_device_new(int fd, drmVersionPtr version);
#ifdef HAVE_FREEDRENO_VIRTIO
struct fd_device *virtio_device_new(int fd, drmVersionPtr version);
#endif
+#ifdef HAVE_FREEDRENO_KGSL
+struct fd_device *kgsl_device_new(int fd);
+#endif
struct fd_device *
fd_device_new(int fd)
{
struct fd_device *dev = NULL;
- drmVersionPtr version;
+ drmVersionPtr version = NULL;
bool use_heap = false;
+ bool support_use_heap = true;
+#ifdef HAVE_LIBDRM
/* figure out if we are kgsl or msm drm driver: */
version = drmGetVersion(fd);
- if (!version) {
- ERROR_MSG("cannot get version: %s", strerror(errno));
- return NULL;
- }
-
- if (!strcmp(version->name, "msm")) {
+ if (!version)
+ DEBUG_MSG("cannot get version: %s", strerror(errno));
+#endif
+ if (version && !strcmp(version->name, "msm")) {
DEBUG_MSG("msm DRM device");
if (version->version_major != 1) {
ERROR_MSG("unsupported version: %u.%u.%u", version->version_major,
@@ -62,7 +65,7 @@ fd_device_new(int fd)
dev = msm_device_new(fd, version);
#ifdef HAVE_FREEDRENO_VIRTIO
- } else if (!strcmp(version->name, "virtio_gpu")) {
+ } else if (version && !strcmp(version->name, "virtio_gpu")) {
DEBUG_MSG("virtio_gpu DRM device");
dev = virtio_device_new(fd, version);
/* Only devices that support a hypervisor are a6xx+, so avoid the
@@ -71,9 +74,12 @@ fd_device_new(int fd)
use_heap = true;
#endif
#if HAVE_FREEDRENO_KGSL
- } else if (!strcmp(version->name, "kgsl")) {
+ } else {
DEBUG_MSG("kgsl DRM device");
dev = kgsl_device_new(fd);
+ support_use_heap = false;
+ if (dev)
+ goto out;
#endif
}
@@ -116,7 +122,7 @@ out:
fd_pipe_del(pipe);
}
- if (use_heap) {
+ if (support_use_heap && use_heap) {
dev->ring_heap = fd_bo_heap_new(dev, RING_FLAGS);
dev->default_heap = fd_bo_heap_new(dev, 0);
}
@@ -233,6 +239,12 @@ fd_dbg(void)
return debug_get_option_libgl();
}
+uint32_t
+fd_get_features(struct fd_device *dev)
+{
+ return dev->features;
+}
+
bool
fd_has_syncobj(struct fd_device *dev)
{
diff --git a/src/freedreno/drm/freedreno_drmif.h b/src/freedreno/drm/freedreno_drmif.h
index 30490b12c30..d717cc0dbca 100644
--- a/src/freedreno/drm/freedreno_drmif.h
+++ b/src/freedreno/drm/freedreno_drmif.h
@@ -67,6 +67,13 @@ enum fd_param_id {
FD_VA_SIZE, /* GPU virtual address size */
};
+enum fd_reset_status {
+ FD_RESET_NO_ERROR,
+ FD_RESET_GUILTY,
+ FD_RESET_INNOCENT,
+ FD_RESET_UNKNOWN,
+};
+
/**
* Helper for fence/seqno comparisions which deals properly with rollover.
* Returns true if fence 'a' is before fence 'b'
@@ -183,6 +190,12 @@ enum fd_version {
};
enum fd_version fd_device_version(struct fd_device *dev);
+enum fd_features {
+ FD_FEATURE_DIRECT_RESET = 1,
+ FD_FEATURE_IMPORT_DMABUF = 2,
+};
+
+uint32_t fd_get_features(struct fd_device *dev);
bool fd_has_syncobj(struct fd_device *dev);
/* pipe functions:
@@ -204,6 +217,7 @@ int fd_pipe_wait(struct fd_pipe *pipe, const struct fd_fence *fence);
/* timeout in nanosec */
int fd_pipe_wait_timeout(struct fd_pipe *pipe, const struct fd_fence *fence,
uint64_t timeout);
+int fd_pipe_get_reset_status(struct fd_pipe *pipe, enum fd_reset_status *status);
/* buffer-object functions:
*/
@@ -285,6 +299,7 @@ struct fd_bo *fd_bo_from_handle(struct fd_device *dev, uint32_t handle,
uint32_t size);
struct fd_bo *fd_bo_from_name(struct fd_device *dev, uint32_t name);
struct fd_bo *fd_bo_from_dmabuf(struct fd_device *dev, int fd);
+struct fd_bo *fd_bo_from_dmabuf_drm(struct fd_device *dev, int fd);
void fd_bo_mark_for_dump(struct fd_bo *bo);
static inline uint64_t
diff --git a/src/freedreno/drm/freedreno_pipe.c b/src/freedreno/drm/freedreno_pipe.c
index 13e8ad979e8..9fd443a9631 100644
--- a/src/freedreno/drm/freedreno_pipe.c
+++ b/src/freedreno/drm/freedreno_pipe.c
@@ -213,6 +213,12 @@ fd_pipe_emit_fence(struct fd_pipe *pipe, struct fd_ringbuffer *ring)
return fence;
}
+int
+fd_pipe_get_reset_status(struct fd_pipe *pipe, enum fd_reset_status *status)
+{
+ return pipe->funcs->reset_status(pipe, status);
+}
+
struct fd_fence *
fd_fence_new(struct fd_pipe *pipe, bool use_fence_fd)
{
diff --git a/src/freedreno/drm/freedreno_priv.h b/src/freedreno/drm/freedreno_priv.h
index 95bf0478330..73a0e631c37 100644
--- a/src/freedreno/drm/freedreno_priv.h
+++ b/src/freedreno/drm/freedreno_priv.h
@@ -207,6 +207,7 @@ struct fd_device {
int fd;
enum fd_version version;
int32_t refcnt;
+ uint32_t features;
/* tables to keep track of bo's, to avoid "evil-twin" fd_bo objects:
*
@@ -308,6 +309,7 @@ struct fd_pipe_funcs {
struct fd_ringbuffer *(*ringbuffer_new_object)(struct fd_pipe *pipe,
uint32_t size);
struct fd_submit *(*submit_new)(struct fd_pipe *pipe);
+ int (*reset_status)(struct fd_pipe *pipe, enum fd_reset_status *status);
/**
* Flush any deferred submits (if deferred submits are supported by
diff --git a/src/freedreno/drm/kgsl/kgsl_bo.c b/src/freedreno/drm/kgsl/kgsl_bo.c
new file mode 100644
index 00000000000..6e4124589fe
--- /dev/null
+++ b/src/freedreno/drm/kgsl/kgsl_bo.c
@@ -0,0 +1,208 @@
+#include "kgsl_priv.h"
+#include "util/os_mman.h"
+
+static uint64_t
+kgsl_bo_iova(struct fd_bo *bo)
+{
+ struct kgsl_bo *kgsl_bo = to_kgsl_bo(bo);
+ return kgsl_bo->iova;
+}
+
+static void
+kgsl_bo_set_name(struct fd_bo *bo, const char *fmt, va_list ap)
+{
+ /* This function is a no op for KGSL */
+ return;
+}
+
+static int
+kgsl_bo_offset(struct fd_bo *bo, uint64_t *offset)
+{
+ /* from tu_kgsl.c - offset for mmap needs to be */
+ /* the returned alloc id shifted over 12 */
+ *offset = bo->handle << 12;
+ return 0;
+}
+
+static int
+kgsl_bo_madvise(struct fd_bo *bo, int willneed)
+{
+ /* KGSL does not support this, so simply return willneed */
+ return willneed;
+}
+
+static int
+kgsl_bo_cpu_prep(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op)
+{
+ /* only need to handle implicit sync here which is a NOP for KGSL */
+ return 0;
+}
+
+void
+kgsl_bo_close_handle(struct fd_bo *bo)
+{
+ struct kgsl_gpumem_free_id req = {
+ .id = bo->handle
+ };
+
+ kgsl_pipe_safe_ioctl(bo->dev->fd, IOCTL_KGSL_GPUMEM_FREE_ID, &req);
+}
+
+static void
+kgsl_bo_destroy(struct fd_bo *bo)
+{
+ /* KGSL will immediately delete the BO when we close
+ * the handle, so wait on all fences to ensure
+ * the GPU is done using it before we destory it
+ */
+ for (uint32_t i = 0; i < bo->nr_fences; i++) {
+ struct fd_pipe *pipe = bo->fences[i]->pipe;
+ pipe->funcs->wait(pipe, bo->fences[i], ~0);
+ }
+
+ fd_bo_fini_common(bo);
+}
+
+static void *
+kgsl_bo_map(struct fd_bo *bo)
+{
+ struct kgsl_bo *kgsl_bo = to_kgsl_bo(bo);
+ if (!bo->map) {
+ if (kgsl_bo->bo_type == KGSL_BO_IMPORT) {
+ /* in `fd_bo_map` if it tries to mmap this BO. mmap logic is copied from
+ * https://android.googlesource.com/platform/hardware/libhardware/+/master/modules/gralloc/mapper.cpp#44
+ */
+ bo->map = os_mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, kgsl_bo->import_fd, 0);
+ } else {
+ uint64_t offset;
+ int ret;
+
+ ret = bo->funcs->offset(bo, &offset);
+ if (ret) {
+ return NULL;
+ }
+
+ bo->map = os_mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
+ bo->dev->fd, offset);
+ if (bo->map == MAP_FAILED) {
+ ERROR_MSG("mmap failed: %s", strerror(errno));
+ bo->map = NULL;
+ }
+ }
+
+ if (bo->map == MAP_FAILED) {
+ ERROR_MSG("mmap failed: %s", strerror(errno));
+ bo->map = NULL;
+ }
+ }
+ return bo->map;
+}
+
+static const struct fd_bo_funcs bo_funcs = {
+ .iova = kgsl_bo_iova,
+ .set_name = kgsl_bo_set_name,
+ .offset = kgsl_bo_offset,
+ .map = kgsl_bo_map,
+ .madvise = kgsl_bo_madvise,
+ .cpu_prep = kgsl_bo_cpu_prep,
+ .destroy = kgsl_bo_destroy,
+};
+
+/* Size is not used by KGSL */
+struct fd_bo *
+kgsl_bo_from_handle(struct fd_device *dev, uint32_t size, uint32_t handle)
+{
+ struct fd_bo *bo;
+ int ret;
+ struct kgsl_gpuobj_info req = {
+ .id = handle,
+ };
+
+ ret = kgsl_pipe_safe_ioctl(dev->fd,
+ IOCTL_KGSL_GPUOBJ_INFO, &req);
+
+ if (ret) {
+ ERROR_MSG("Failed to get handle info (%s)", strerror(errno));
+ return NULL;
+ }
+
+ struct kgsl_bo *kgsl_bo = calloc(1, sizeof(*kgsl_bo));
+ if (!kgsl_bo)
+ return NULL;
+
+ bo = &kgsl_bo->base;
+ bo->dev = dev;
+ bo->size = req.size;
+ bo->handle = req.id;
+ bo->funcs = &bo_funcs;
+
+ kgsl_bo->iova = req.gpuaddr;
+
+ fd_bo_init_common(bo, dev);
+
+ return bo;
+}
+
+struct fd_bo *
+kgsl_bo_from_dmabuf(struct fd_device *dev, int fd)
+{
+ struct fd_bo *bo;
+ struct kgsl_gpuobj_import_dma_buf import_dmabuf = {
+ .fd = fd,
+ };
+ struct kgsl_gpuobj_import req = {
+ .priv = (uintptr_t)&import_dmabuf,
+ .priv_len = sizeof(import_dmabuf),
+ .flags = 0,
+ .type = KGSL_USER_MEM_TYPE_DMABUF,
+ };
+ int ret;
+
+ ret = kgsl_pipe_safe_ioctl(dev->fd,
+ IOCTL_KGSL_GPUOBJ_IMPORT, &req);
+
+ if (ret) {
+ ERROR_MSG("Failed to import dma-buf (%s)", strerror(errno));
+ return NULL;
+ }
+
+ bo = fd_bo_from_handle(dev, req.id, 0);
+
+ struct kgsl_bo *kgsl_bo = to_kgsl_bo(bo);
+ kgsl_bo->bo_type = KGSL_BO_IMPORT;
+ kgsl_bo->import_fd = fd;
+
+ return bo;
+}
+
+struct fd_bo *
+kgsl_bo_new(struct fd_device *dev, uint32_t size, uint32_t flags)
+{
+ int ret;
+ struct fd_bo *bo;
+ struct kgsl_gpumem_alloc_id req = {
+ .size = size,
+ };
+
+ if (flags & FD_BO_GPUREADONLY)
+ req.flags |= KGSL_MEMFLAGS_GPUREADONLY;
+
+ ret = kgsl_pipe_safe_ioctl(dev->fd, IOCTL_KGSL_GPUMEM_ALLOC_ID, &req);
+
+ if (ret) {
+ ERROR_MSG("GPUMEM_ALLOC_ID failed (%s)", strerror(errno));
+ return NULL;
+ }
+
+ bo = kgsl_bo_from_handle(dev, size, req.id);
+
+ struct kgsl_bo *kgsl_bo = to_kgsl_bo(bo);
+ kgsl_bo->bo_type = KGSL_BO_NATIVE;
+
+ if (!bo) {
+ ERROR_MSG("Failed to allocate buffer object");
+ return NULL;
+ }
+
+ return bo;
+}
diff --git a/src/freedreno/drm/kgsl/kgsl_device.c b/src/freedreno/drm/kgsl/kgsl_device.c
new file mode 100644
index 00000000000..702b6666731
--- /dev/null
+++ b/src/freedreno/drm/kgsl/kgsl_device.c
@@ -0,0 +1,44 @@
+#include "kgsl_priv.h"
+
+static const struct fd_device_funcs funcs = {
+ .bo_new = kgsl_bo_new,
+ .pipe_new = kgsl_pipe_new,
+ .bo_from_handle = kgsl_bo_from_handle,
+ .bo_from_dmabuf = kgsl_bo_from_dmabuf,
+ .bo_close_handle = kgsl_bo_close_handle,
+ .destroy = kgsl_device_destroy,