nihui / waifu2x-ncnn-vulkan

waifu2x converter ncnn version, runs fast on intel / amd / nvidia / apple-silicon GPU with vulkan
MIT License
2.98k stars 205 forks source link

Can't build in WSL? #23

Closed darkskygit closed 5 years ago

darkskygit commented 5 years ago

System: Ubuntu 18 LTS

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DVulkan_LIBRARY=/mnt/c/Users/vm/Desktop/Vulkan-Loader-1.1.114 -DVulkan_INCLUDE_DIR=/mnt/c/Users/vm/Desktop/Vulkan-Headers-1.1.114/

-- Found OpenMP_C: -fopenmp -- Found OpenMP_CXX: -fopenmp -- Found OpenMP: TRUE -- Found Vulkan: /mnt/c/Users/vm/Desktop/Vulkan-Loader-1.1.114 -- Found glslangValidator: /usr/bin/glslangValidator -- Configuring done WARNING: Target "waifu2x-ncnn-vulkan" requests linking to directory "/mnt/c/Users/vm/Desktop/Vulkan-Loader-1.1.114". Targets may link only to libraries. CMake is dropping the item. -- Generating done -- Build files have been written to: /mnt/c/Users/vm/Desktop/waifu2x-ncnn-vulkan

cmake --build .

Scanning dependencies of target generate-spirv [ 12%] Building SPIR-V module waifu2x_preproc.spv [ 25%] Building SPIR-V module waifu2x_preproc_fp16s.spv [ 37%] Building SPIR-V module waifu2x_preproc_int8s.spv SPIR-V is not generated for failed compile or link CMakeFiles/generate-spirv.dir/build.make:73: recipe for target 'waifu2x_preproc_int8s.spv.hex.h' failed make[2]: [waifu2x_preproc_int8s.spv.hex.h] Error 2 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/generate-spirv.dir/all' failed make[1]: [CMakeFiles/generate-spirv.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2

i try to build waifu2x_preproc.comp, get some error:

glslangValidator -DNCNN_fp16_storage=1 -DNCNN_int8_storage=1 -V -e waifu2x_preproc.comp_int8s --source-entrypoint main -x -o waifu2x_preproc.comp_int8s.spv.hex.h waifu2x_preproc.comp

waifu2x_preproc.comp ERROR: waifu2x_preproc.comp:65: 'constructor' : can't convert ERROR: waifu2x_preproc.comp:65: ' temp float' : cannot construct with these arguments ERROR: waifu2x_preproc.comp:65: '' : missing #endif ERROR: waifu2x_preproc.comp:65: '' : compilation terminated ERROR: 4 compilation errors. No code generated.

SPIR-V is not generated for failed compile or link

nihui commented 5 years ago

glslangValidator is too old to compile this shader source you can download the latest vulkan sdk at https://vulkan.lunarg.com/sdk/home

darkskygit commented 5 years ago

image it's look like latest version cannot complie left one is bundle in android studio,right one install by vulkan's latest sdk(VulkanSDK-1.1.108.0-Installer.exe) but latest one cannot complie image @nihui

nihui commented 5 years ago

construct float from uint8 is not allowed in new glsl tool with https://github.com/KhronosGroup/glslang/pull/1832

please try patching waifu2x_preproc.comp file and see if it works

modify waifu2x_preproc.comp as follows

    if (bgr == 1)
        v = float(bottom_blob_data[v_offset * 3 + 2 - gz]);
    else
        v = float(bottom_blob_data[v_offset * 3 + gz]);
    if (bgr == 1)
        v = float(uint(bottom_blob_data[v_offset * 3 + 2 - gz]));
    else
        v = float(uint(bottom_blob_data[v_offset * 3 + gz]));
darkskygit commented 5 years ago

construct float from uint8 is not allowed in new glsl tool with KhronosGroup/glslang#1832

please try patching waifu2x_preproc.comp file and see if it works

modify waifu2x_preproc.comp as follows

    if (bgr == 1)
        v = float(bottom_blob_data[v_offset * 3 + 2 - gz]);
    else
        v = float(bottom_blob_data[v_offset * 3 + gz]);
    if (bgr == 1)
        v = float(uint(bottom_blob_data[v_offset * 3 + 2 - gz]));
    else
        v = float(uint(bottom_blob_data[v_offset * 3 + gz]));

this work fine for me! thanks for fix :)