前言
本次采用的开发板为扬帆“竞”开发板,扬帆“竞”采用瑞芯微RK3568(Cortex-A55)四核64位超强CPU,搭载OpenHarmony最新操作系统,主频最高达2.0GHz。采用 Mali-G52 GPU,支持4K、H.265/H.264视频解码。
OpenHarmony最新版本的L2标准版图形子系统相比之前版本有着非常大的改动,使用了全新设计的框架,并使用Render Service替换了原来的Weston。图形栈整体上分为三层,从上到下依次为接口层、框架层和引擎层。设计上更加清晰,可以更加的灵活的适配不同的底层图形库和不同的显示硬件,最大限度的发挥硬件性能而不用影响到整体图形栈。
框架层的整体功能如下表,框架层的核心就是Render Service渲染服务。
模块 | 能力描述 |
---|---|
Render Servicel (渲染服务) | 提供UI框架的绘制能力,其核心职责是将ArkUI的控件描述转换成绘制树信息,根据对应的渲染策略,进行最佳路径渲染。同时,负责多窗口流畅和空间态下UI共享的核心底层机制。 |
Drawing (绘制) | 提供图形子系统内部的标准化接口,主要完成2D渲染、3D渲染和渲染引擎的管理等基本功能。 |
Animation (动画) | 提供动画引擎的相关能力。 |
Effect (效果) | 主要完成图片效果、渲染特效等效果处理的能力,包括:多效果的串联、并联处理,在布局时加入渲染特效、控件交互特效等相关能力。 |
显示与内存管理 | 此模块是图形栈与硬件解耦的主要模块,主要定义了OpenHarmony 显示与内存管理的能力,其定义的南向HDI 接口需要让不同的OEM厂商完成对OpenHarmony图形栈的适配。 |
新的Render Service图形框架默认提供了对OpenGL的支持,并使用API HOOK技术,实现了OpenGL接口和实现的分离,大幅度降低了OpenGL库的适配难度。
扬帆“竞”开发板默认使用的是闭源的libmali-bifrost-g52-g2p0-ohos库,也可以使用开源的Mesa 3D库,实现对OpenGL的支持,在高级图形应用的开发和调试方面非常方便。
使用Mesa库
编译Mesa库
OpenHarmony已经在三方库中集成Mesa库。下载OpenHarmony全量代码,Mesa库在third_party/mesa3d。
进入third_party/mesa3d/目录,OpenHarmony已经提供了编译脚本。其中ohos/build_ohos.py就是针对新图形框架的编译脚本,参考README_zh.md文档,先进行一次全量编译,然后执行。
#python ohos/build_ohos.py </path/to/openharmony> yangfan-j </path/to/openharmony>/third_party/mesa3d
文章来源地址https://www.toymoban.com/news/detail-761311.html
命令编译出mesa库。
生成Mesa组件
1.在device/soc/rockchip/rk3568/hardware/gpu/目录下新建lib-mesa目录,用于存放Mesa 3D库文件。
#mkdir …/device/soc/rockchip/rk3568/hardware/gpu/lib-mesa
2.将编译生成的Mesa 3D库文件拷贝到lib-mesa目录:
#cp build-ohos/install/lib/libgbm.so.1.0.0 ../device/soc/rockchip/rk3568/hardware/gpu/lib-mesa/
#cp build-ohos/install/lib/libglapi.so.0.0.0 ../device/soc/rockchip/rk3568/hardware/gpu/lib-mesa/
#cp build-ohos/src/egl/libEGL.so.1.0.0 ../device/soc/rockchip/rk3568/hardware/gpu/lib-mesa/
#cp build-ohos/install/lib/libGLESv1_CM.so.1.1.0 ../device/soc/rockchip/rk3568/hardware/gpu/lib-mesa/
#cp build-ohos/install/lib/libGLESv2.so.2.0.0 ../device/soc/rockchip/rk3568/hardware/gpu/lib-mesa/
#cp build-ohos/src/gallium/targets/dri/libgallium_dri.so ../ device/soc/rockchip/rk3568/hardware/gpu/lib-mesa/
#cp build-ohos/install/lib/dri/panfrost_dri.so ../device/soc/rockchip/rk3568/hardware/gpu/lib-mesa/
3.修改device/soc/rockchip/rk3568/hardware/gpu/BUILD.gn
index 7d269ac..690a69d 100644
--- a/rk3568/hardware/gpu/BUILD.gn
+++ b/rk3568/hardware/gpu/BUILD.gn
@@ -47,3 +47,108 @@ ohos_prebuilt_shared_library("mali-bifrost-g52-g2p0-ohos") {
"libmali.so.1",
]
}
+
+ohos_prebuilt_shared_library("mesa_gbm") {
+ source = "lib-mesa/libgbm.so.1.0.0"
+ install_enable = true
+ install_images = [ chipset_base_dir ]
+ relative_install_dir = "chipsetsdk"
+ subsystem_name = "rockchip_products"
+ part_name = "rockchip_products"
+ symlink_target_name = [
+ "libgbm.so.1",
+ "libgbm.so",
+ ]
+}
+
+ohos_prebuilt_shared_library("mesa_egl") {
+ source = "lib-mesa/libEGL.so.1.0.0"
+ install_enable = true
+ install_images = [ chipset_base_dir ]
+ relative_install_dir = "chipsetsdk"
+ subsystem_name = "rockchip_products"
+ part_name = "rockchip_products"
+ symlink_target_name = [
+ "libEGL.so.1",
+ "libEGL.so",
+ "libGLESv1.so",
+ "libEGL_impl.so",
+ ]
+}
+
+ohos_prebuilt_shared_library("mesa_glapi") {
+ source = "lib-mesa/libglapi.so.0.0.0"
+ install_enable = true
+ install_images = [ chipset_base_dir ]
+ relative_install_dir = "chipsetsdk"
+ subsystem_name = "rockchip_products"
+ part_name = "rockchip_products"
+ symlink_target_name = [
+ "libglapi.so.0",
+ "libglapi.so",
+ ]
+}
+
+ohos_prebuilt_shared_library("mesa_glesv1") {
+ source = "lib-mesa/libGLESv1_CM.so.1.1.0"
+ install_enable = true
+ install_images = [ chipset_base_dir ]
+ relative_install_dir = "chipsetsdk"
+ subsystem_name = "rockchip_products"
+ part_name = "rockchip_products"
+ symlink_target_name = [
+ "libGLESv1_CM.so.1",
+ "libGLESv1_CM.so",
+ "libGLESv1_impl.so",
+ ]
+}
+
+ohos_prebuilt_shared_library("mesa_glesv2") {
+ source = "lib-mesa/libGLESv2.so.2.0.0"
+ install_enable = true
+ install_images = [ chipset_base_dir ]
+ relative_install_dir = "chipsetsdk"
+ subsystem_name = "rockchip_products"
+ part_name = "rockchip_products"
+ symlink_target_name = [
+ "libGLESv2.so.2",
+ "libGLESv2.so",
+ "libGLESv2_impl.so",
+ "libGLESv3_impl.so",
+ ]
+}
+
+ohos_prebuilt_shared_library("libgallium_dri") {
+ source = "lib-mesa/libgallium_dri.so"
+ install_enable = true
+ install_images = [ chipset_base_dir ]
+ relative_install_dir = "chipsetsdk"
+ subsystem_name = "rockchip_products"
+ part_name = "rockchip_products"
+ symlink_target_name = [ "libgallium_dri.so" ]
+}
+
+ohos_prebuilt_shared_library("panfrost_dri") {
+ source = "lib-mesa/panfrost_dri.so"
+ install_enable = true
+ install_images = [ "system" ]
+ subsystem_name = "rockchip_products"
+ part_name = "rockchip_products"
+ symlink_target_name = [
+ "rockchip_dri.so",
+ "libmali.so.0",
+ "libmali.so.1",
+ ]
+}
+
+group("mesa-gpu") {
+ public_deps = [
+ ":mesa_egl",
+ ":mesa_gbm",
+ ":mesa_glapi",
+ ":mesa_glesv1",
+ ":mesa_glesv2",
+ ":libgallium_dri",
+ ":panfrost_dri",
+ ]
+}
4.修改device/soc/rockchip/rk3568/hardware/BUILD.gn,使用Mesa 3D库
index 479847d..e778fb0 100644
--- a/rk3568/hardware/BUILD.gn
+++ b/rk3568/hardware/BUILD.gn
@@ -15,7 +15,8 @@ import("//build/ohos.gni")
group("hardware_group") {
deps = [
- "//device/soc/rockchip/rk3568/hardware/gpu:mali-bifrost-g52-g2p0-ohos",
+ #"//device/soc/rockchip/rk3568/hardware/gpu:mali-bifrost-g52-g2p0-ohos",
+ "//device/soc/rockchip/rk3568/hardware/gpu:mesa-gpu",
"//device/soc/rockchip/rk3568/hardware/isp:isp",
"//device/soc/rockchip/rk3568/hardware/mpp:mpp",
"//device/soc/rockchip/rk3568/hardware/wifi:ap6xxx",
修改内核的配置文件
修改内核配置文件,启用panforst驱动。
index 9a9501c..52b3232 100644
--- a/linux-5.10/arch/arm64/configs/yangfan-j_standard_defconfig
+++ b/linux-5.10/arch/arm64/configs/yangfan-j_standard_defconfig
@@ -3622,7 +3622,7 @@ CONFIG_DVB_SP2=m
#
# CONFIG_VGA_ARB is not set
CONFIG_DRM=y
-CONFIG_DRM_IGNORE_IOTCL_PERMIT=y
+# CONFIG_DRM_IGNORE_IOTCL_PERMIT is not set
CONFIG_DRM_MIPI_DSI=y
# CONFIG_DRM_DP_AUX_CHARDEV is not set
# CONFIG_DRM_DEBUG_MM is not set
@@ -3636,6 +3636,8 @@ CONFIG_DRM_FBDEV_OVERALLOC=100
CONFIG_DRM_LOAD_EDID_FIRMWARE=y
# CONFIG_DRM_DP_CEC is not set
CONFIG_DRM_GEM_CMA_HELPER=y
+CONFIG_DRM_GEM_SHMEM_HELPER=y
+CONFIG_DRM_SCHED=y
#
# I2C encoder or helper chips
@@ -3793,7 +3795,7 @@ CONFIG_DRM_DW_MIPI_DSI=y
# CONFIG_TINYDRM_ST7735R is not set
# CONFIG_DRM_PL111 is not set
# CONFIG_DRM_LIMA is not set
-# CONFIG_DRM_PANFROST is not set
+CONFIG_DRM_PANFROST=y
# CONFIG_DRM_TIDSS is not set
# CONFIG_DRM_LEGACY is not set
CONFIG_DRM_PANEL_ORIENTATION_QUIRKS=y
修改扬帆“竞”内核补丁
内核补丁需要在Linux系统上使用vim编辑器修改,Windows编辑器修改可能导致编译错误。
index 41a7df5..1a5e5a3 100644
--- a/linux-5.10/yangfan-j_patch/kernel.patch
+++ b/linux-5.10/yangfan-j_patch/kernel.patch
@@ -100948,36 +100948,36 @@ index 000000000..372617fee
+ };
+
+ gpu: gpu@fde60000 {
-+ compatible = "arm,mali-bifrost";
-+ reg = <0x0 0xfde60000 0x0 0x4000>;
++ compatible = "rockchip, rk3568-mali","arm,mali-bifrost";
++ reg = <0x0 0xfde60000 0x0 0x20000>;
+
-+ interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
++ interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
-+ <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>;
-+ interrupt-names = "GPU", "MMU", "JOB";
++ <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
++ interrupt-names = "job", "mmu", "gpu";
+
-+ upthreshold = <40>;
-+ downdifferential = <10>;
++ /* upthreshold = <40>; */
++ /* downdifferential = <10>; */
+
+ clocks = <&scmi_clk 1>, <&cru CLK_GPU>;
-+ clock-names = "clk_mali", "clk_gpu";
++ clock-names = "core", "bus";
+ power-domains = <&power RK3568_PD_GPU>;
+ #cooling-cells = <2>;
+ operating-points-v2 = <&gpu_opp_table>;
+
+ status = "disabled";
-+ gpu_power_model: power-model {
-+ compatible = "simple-power-model";
-+ leakage-range= <5 15>;
-+ ls = <(-24002) 22823 0>;
-+ static-coefficient = <100000>;
-+ dynamic-coefficient = <953>;
-+ ts = <(-108890) 63610 (-1355) 20>;
-+ thermal-zone = "gpu-thermal";
-+ };
-+ };
-+
-+ gpu_opp_table: opp-table2 {
++ /* gpu_power_model: power-model { */
++ /* compatible = "simple-power-model"; */
++ /* leakage-range= <5 15>; */
++ /* ls = <(-24002) 22823 0>; */
++ /* static-coefficient = <100000>; */
++ /* dynamic-coefficient = <953>; */
++ /* ts = <(-108890) 63610 (-1355) 20>; */
++ /* thermal-zone = "gpu-thermal"; */
++ /* }; */
++ };
++
++ gpu_opp_table: gpu-opp-table {
+ compatible = "operating-points-v2";
+
+ mbist-vmin = <825000 900000 950000>;
测试和验证
1.查看GPU中断,panforst驱动已经正常工作。桌面显示和操作正常
2.游戏效果
测试表明,扬帆“竞”开发板的图形界面使用正常且流畅,基础应用都可以正常运行,体验与使用libmali-g52库基本一致。
文章来源:https://www.toymoban.com/news/detail-761311.html
到了这里,关于RK3568开发板上应用Mesa 3D的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!