diff --git a/README_OpenHarmony.md b/README_OpenHarmony.md index 44d0ba694d0f19f216b017bd8019c08ea5a2230f..390a1f8e003f45100a59ef0894ea56f7178212de 100644 --- a/README_OpenHarmony.md +++ b/README_OpenHarmony.md @@ -25,7 +25,7 @@ Vulkan-ValidationLayers被实现为一个Vulkan Layer,由Vulkan-Loader加载 hdc target mount #root模式下,开启权限 hdc shell mkdir /system/etc/vulkan/implicity.d/ #为隐式层创建文件夹 hdc file push VkLayer_khronos_validation.json /system/etc/vulkan/implicity.d/ #推送json文件到隐式层下 - hdc file push libVkLayer_khronos_validation.so /system/lib{64} + hdc file push libVkLayer_khronos_validation.so /system/lib64 hdc shell reboot #重启设备 ``` ### 三方应用 @@ -46,6 +46,26 @@ Vulkan-ValidationLayers被实现为一个Vulkan Layer,由Vulkan-Loader加载 ![usermode-use-debug-layer-1.jpg](docs/images/usermode-use-debug-layer-1.jpg) + Note: 当前Vulkan-Loader模块不支持直接读取rawfile,需要通过js层将json文件复制到应用的sandbox路径下. +``` + // 在Index.ets文件中 + import fs from '@ohos.file.fs'; + // ...... + aboutToAppear(): void { // Copy VkLayer_khronos_validation.json to hap sandbox + let path = getContext(this).filesDir; + if (!fs.accessSync(path)) { + fs.mkdirSync(path); + } + + buffer = getContext(this).resourceManager.getRawFileContentSync('VkLayer_khronos_validation.json'); + file = fs.openSync(path + '/VkLayer_khronos_validation.json', fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + fs.writeSync(file.fd, buffer.buffer); + } + // ...... + +``` + + 工程中路径:{your_project}\entry\src\main\resources\rawfile\VkLayer_khronos_validation.json hdc开发视角下json文件的路径:/data/app/el2/100/base/{your_pakage_name}/file/VkLayer_khronos_validation.json @@ -80,6 +100,12 @@ hdc开发视角下so文件的路径:/data/app/el1/bundle/public/{your_pakage_n hdc shell param set debug.graphic.debug_hap '' ``` +##### 5. 查看Vulkan-ValidationLayers的打印 + +``` + hdc shell + hilog | grep VulkanValidationLayer +``` ## 构建指导 @@ -108,7 +134,7 @@ e.g.: ``` set OHOS_SDK=C:/Users/Administrator/AppData/Local/OpenHarmony/Sdk/12/native set VVL_DIR=E:/WorkSpace/Vulkan/VVL/third_party_vulkan-validationlayers - set BUILD_THREADS=8 + set BUILD_THREADS=64 set buildDir=%VVL_DIR%/build-ohos/intermediate set libDir=%VVL_DIR%/build-ohos/libs set PATH=%OHOS_SDK%/build-tools/cmake/bin;%PATH% @@ -120,25 +146,19 @@ e.g.: ``` cd /d %VVL_DIR% - - cmake -S . ^ - -B %buildDir% ^ - -G Ninja ^ - -D OHOS_STL=c++_static ^ - -D CMAKE_INSTALL_LIBDIR=%libDir% ^ - -D CMAKE_TOOLCHAIN_FILE=%OHOS_SDK%/build/cmake/ohos.toolchain.cmake ^ - -D CMAKE_BUILD_TYPE=Release ^ - -D VVL_CODEGEN=OFF ^ - -D UPDATE_DEPS=ON ^ - -D UPDATE_DEPS_DIR=%buildDir% + python scripts/update_deps.py --dir %buildDir% --known_good_dir scripts --no-build ``` 将[patches](scripts/ohos-patches)逐一应用到对应的依赖仓中 e.g.: ``` - cd build-ohos\intermediate\Vulkan-Headers - git apply Vulkan-Headers.patch + cd /d %VVL_DIR%/build-ohos/intermediate/SPIRV-Tools + git apply ../../../scripts/ohos-patches/SPIRV-Tools.patch + cd /d %VVL_DIR%/build-ohos/intermediate/Vulkan-Headers + git apply ../../../scripts/ohos-patches/Vulkan-Headers.patch + cd /d %VVL_DIR%/build-ohos/intermediate/Vulkan-Utility-Libraries + git apply ../../../scripts/ohos-patches/Vulkan-Utility-Libraries.patch ``` @@ -160,12 +180,6 @@ so生成位置:build-ohos\libs -D UPDATE_DEPS=ON ^ -D UPDATE_DEPS_DIR=%buildDir% - - cmake ^ - --build %buildDir% ^ - --target vvl_codegen - - cmake ^ --build %buildDir% ^ --parallel %BUILD_THREADS% diff --git a/scripts/ohos-patches/VkLayer_khronos_validation.json b/scripts/ohos-patches/VkLayer_khronos_validation.json index 6f8ff1a424edf1bc057d4957ddc7c55498b04a72..58728ef911afddf14cd8f8b10fe5d12f178c801e 100644 --- a/scripts/ohos-patches/VkLayer_khronos_validation.json +++ b/scripts/ohos-patches/VkLayer_khronos_validation.json @@ -3,7 +3,7 @@ "layer": { "name": "VK_LAYER_KHRONOS_validation", "type": "GLOBAL", - "library_path": "/data/storage/el1/bundle/lib/arm64/libVkLayer_khronos_validation.so", + "library_path": "libVkLayer_khronos_validation.so", "api_version": "1.3.275", "implementation_version": "1", "description": "Khronos Validation Layer", diff --git a/scripts/ohos-patches/Vulkan-Headers.patch b/scripts/ohos-patches/Vulkan-Headers.patch index 7a5adaaa45d272bcaa37e4145020fe8aa16d5748..7dc9393d20d789f0de3c0b09e28abe808293e713 100644 Binary files a/scripts/ohos-patches/Vulkan-Headers.patch and b/scripts/ohos-patches/Vulkan-Headers.patch differ diff --git a/scripts/ohos-patches/Vulkan-Utility-Libraries.patch b/scripts/ohos-patches/Vulkan-Utility-Libraries.patch index 5d233eaa748aa6f922e2c6ef39aafce6e60b066f..112b0a0862db5a55bc24eeaea7e6bc66c8360381 100644 Binary files a/scripts/ohos-patches/Vulkan-Utility-Libraries.patch and b/scripts/ohos-patches/Vulkan-Utility-Libraries.patch differ diff --git a/scripts/ohos-patches/glslang.patch b/scripts/ohos-patches/glslang.patch deleted file mode 100644 index b63c9bbe4563ebe0c9aa412b9910e9a5b61a4152..0000000000000000000000000000000000000000 --- a/scripts/ohos-patches/glslang.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 5cdd3e31..6931b850 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -30,7 +30,7 @@ - # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - # POSSIBILITY OF SUCH DAMAGE. --cmake_minimum_required(VERSION 3.17.2) -+cmake_minimum_required(VERSION 3.16.5) - project(glslang) - - if (CMAKE_VERSION VERSION_LESS "3.21")