Showing posts with label Vulkan. Show all posts
Showing posts with label Vulkan. Show all posts

Monday, November 2, 2020

Vulkan Lavapipe Software render

Sequence commands to compile lavapipe from mesa upstream:
  • PWD=${PWD}
  • git clone git://anongit.freedesktop.org/mesa/mesa
  • mkdir mesa-build
  • meson ../mesa --prefix=${PWD}/install
  • ninja -j 4
  • ninja install
  • cd ..
  • VK_ICD_FILENAMES=${PWD}/mesa-build/install/share/vulkan/icd.d/lvp_icd.x86_64.json vulkaninfo
Sequence commands to compile yquake for check vulkan render:
  • wget -cv https://deponie.yamagi.org/quake2/idstuff/q2-314-demo-x86.exe
  • unzip q2-314-demo-x86.exe
  • git clone git@github.com:yquake2/yquake2.git -b ref_vk
  • cd yquake2
  • make
  • cd ..
  • cp -rv Install/Data/baseq2/pak0.pak yquake2/release/baseq2/
  • cp -rv Install/Data/baseq2/players yquake2/release/baseq2
Sequence commands to check Vulkan render:
  • cd yquake2/release
  • VK_ICD_FILENAMES=${PWD}/mesa-build/install/share/vulkan/icd.d/lvp_icd.x86_64.json ./quake2

Tuesday, March 31, 2020

Vulkan Software render (amd64+Windows)

There are small list of commands for compile Vulkan soft render library on amd64 debian, sequence is fully same as in the previous post related to check quake2 run on the arm64
  • git clone git@github.com:google/swiftshader.git
  • cd swiftshader/build
  • cmake ..
  • make -j 2 vk_swiftshader
  • sudo cp libvk_swiftshader.so /usr/lib/x86_64-linux-gnu/libvulkan_swiftshader.so
  • sed -i "s|./libvk_swiftshader.so|/usr/lib/x86_64-linux-gnu/libvulkan_swiftshader.so|g" Linux/vk_swiftshader_icd.json
  • sudo cp Linux/vk_swiftshader_icd.json /usr/share/vulkan/icd.d/swiftshader_icd.x86_64.json
  • sudo chmod 644 /usr/share/vulkan/icd.d/swiftshader_icd.x86_64.json
  • sudo chown root:root /usr/share/vulkan/icd.d/swiftshader_icd.x86_64.json
  • sudo chmod 644 /usr/lib/x86_64-linux-gnu/libvulkan_swiftshader.so
  • sudo chown root:root /usr/lib/x86_64-linux-gnu/libvulkan_swiftshader.so
And same story for Windows, It will be a little bit different story as result of different logic of package distribution. User have installed Vulkan drivers with Vulkan loader as part graphical drivers by default.

Compilation of code has required to install Vulkan SDK, CMake and Visual Studio.

And sequence of commands for build loader will be such for 64bit platform if no drivers installed with Vulkan.
  • git clone https://github.com/KhronosGroup/Vulkan-Loader.git
  • cd Vulkan-Loader/
  • cd external/
  • git clone https://github.com/google/googletest.git
  • git clone https://github.com/KhronosGroup/Vulkan-Headers.git
  • cd googletest
  • git checkout tags/release-1.8.1
  • cd ../..
  • mkdir build
  • cd build
  • cmake -A x64 --config Release ..
  • cmake --build . --config Release
  • cd ../..
  • Copy resulted library to C:\windows\System32 as vulkan-1.dll
Same commands but for 32 bit library
  • git clone https://github.com/KhronosGroup/Vulkan-Loader.git
  • cd Vulkan-Loader/
  • cd external/
  • git clone https://github.com/google/googletest.git
  • git clone https://github.com/KhronosGroup/Vulkan-Headers.git
  • cd googletest
  • git checkout tags/release-1.8.1
  • cd ../..
  • mkdir build
  • cd build
  • cmake -A win32 --config Release ..
  • cmake --build . --config Release
  • cd ../..
  • Copy resulted library to C:\windows\sysWOW64 as vulkan-1.dll
And then compile Vulkan driver for 64 platform:
  • git clone https://github.com/google/swiftshader.git
  • cd swiftshader/
  • git submodule init
  • cd third_party/
  • git clone https://github.com/google/googletest.git
  • git clone https://github.com/google/benchmark.git
  • git clone https://github.com/google/cppdap
  • git clone https://github.com/nlohmann/json.git
  • git clone https://github.com/ianlancetaylor/libbacktrace.git libbacktrace/src
  • cd ../build
  • cmake -A x64 --config Release ..
  • cmake --build . --config Release
  • cd ../..
  • Copy resulted file to preferred place, as example C:\Program Files\SwiftShaderVulkan
Same commands but for 32 bit library
  • git clone https://github.com/google/swiftshader.git
  • cd swiftshader/
  • git submodule init
  • cd third_party/
  • git clone https://github.com/google/googletest.git
  • git clone https://github.com/google/benchmark.git
  • git clone https://github.com/google/cppdap
  • git clone https://github.com/nlohmann/json.git
  • git clone https://github.com/ianlancetaylor/libbacktrace.git libbacktrace/src
  • cd ../build
  • cmake -A win32 --config Release ..
  • cmake --build . --config Release
  • cd ../..
  • Copy resulted file to preferred place, as example C:\Program Files\SwiftShaderVulkan
Also need to create ICD files like such C:\\Program Files\\SwiftShaderVulkan\\vk_swiftshader32.json with:
{
  "file_format_version": "1.0.0",
  "ICD": {
    "library_path": "C:\\Program Files\\SwiftShaderVulkan\\vk_swiftshader_32.dll",
    "api_version": "1.0.5"
  }
}
And C:\\Program Files\\SwiftShaderVulkan\\vk_swiftshader64.json with such content:
{
  "file_format_version": "1.0.0",
  "ICD": {
    "library_path": "C:\\Program Files\\SwiftShaderVulkan\\vk_swiftshader_64.dll",
    "api_version": "1.0.5"
  }
}
After that need to correctly register drivers, or,that will be less complicated, create reg file and apply such by RegEdit.
   
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Khronos\Vulkan\Drivers]
"C:\\Program Files\\SwiftShaderVulkan\\vk_swiftshader32.json"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\Drivers]
"C:\\Program Files\\SwiftShaderVulkan\\vk_swiftshader64.json"=dword:00000000

Friday, January 31, 2020

Vulkan Software render

Google have created software based Vulkan implementation sometime ago as not a official project.
And i have decided to check how it was in compare to other soft rendering implementations. And here are some results with yquake:
  • ref_gl1: 632 frames, 24.4 seconds: 25.9 fps (mesa 19.3.2 llvmpipe LLVM 9.0.1, 128 bits)
  • ref_gl3: 632 frames, 28.9 seconds: 21.9 fps (mesa 19.3.2 llvmpipe LLVM 9.0.1, 128 bits)
  • ref_soft: 632 frames, 10.9 seconds: 57.8 fps (mesa 19.3.2)
  • ref_vk: 632 frames, 98.9 seconds: 6.4 fps (SwiftShader Device LLVM 7.0.1)
Used steps for build SwiftShader are:
  • git clone git@github.com:google/swiftshader.git
  • cd swiftshader/build
  • CC="ccache gcc-8" CXX="ccache g++-8" cmake ..
  • CC="ccache gcc-8" CXX="ccache g++-8" make -j 2 vk_swiftshader
  • sudo cp libvk_swiftshader.so /usr/lib/aarch64-linux-gnu/libvulkan_swiftshader.so
  • sed -i "s|./libvk_swiftshader.so|/usr/lib/aarch64-linux-gnu/libvulkan_swiftshader.so|g" Linux/vk_swiftshader_icd.json
  • sudo cp Linux/vk_swiftshader_icd.json /usr/share/vulkan/icd.d/swiftshader_icd.aarch64.json
  • sudo chmod 644 /usr/share/vulkan/icd.d/swiftshader_icd.aarch64.json
  • sudo chown root:root /usr/share/vulkan/icd.d/swiftshader_icd.aarch64.json
  • sudo chmod 644 /usr/lib/aarch64-linux-gnu/libvulkan_swiftshader.so
  • sudo chown root:root /usr/lib/aarch64-linux-gnu/libvulkan_swiftshader.so
Note: Gcc 8 is preferred compiler for now as gcc-9 produced error with current version of code base.

Used steps for build yQuake2 are:
  • wget -cv https://deponie.yamagi.org/quake2/idstuff/q2-314-demo-x86.exe
  • unzip q2-314-demo-x86.exe
  • git clone git@github.com:yquake2/yquake2.git -b ref_vk
  • cd yquake2
  • make
  • cd ..
  • cp -rv Install/Data/baseq2/pak0.pak yquake2/release/baseq2/
  • cp -rv Install/Data/baseq2/players yquake2/release/baseq2

Sunday, April 12, 2015

Vulkan или новый шанс

На данный момент реализация OpenGl для линукс отстает от последней версии на пару лет, расширения из новой версии присутствуют, но официальной поддержки четвертой версии так и нет. Есть на это две причины:
  1. intel который делает ставку на open source и постепенно реализует все версии opengl в полном объеме, но еще не опубликовал код с поддержкой этой версии;
  2. независимым разработчикам не интересно реализовывать расширения которые не являются популярными и реализуют только те части которые им кажутся нужными.
Также amd работает над драйвером для ядра который можно использовать для обоих реализаций графики: для проприетарных драйверов и открытого кода. Это позволит без обновления кода в ядра использовать проприетарные дрова с любым ядром, а для открытого кода возможность всегда иметь поддержку всех новых чипов и постараться получить максимально полную реализацию всех возможных стандартов.
Но существует шанс получить реализацию стандарта несколько быстрее: новая версия OpenGL Vulkan - базируется на открытых стандартах и должна иметь референсную реализацию всех частей для проверки валидности рендеринга. Особенность данного стандарта заключается в том что он пересматривает все традиции современного OpenGL, если традиционно библиотека полностью скрывает внутреннюю реализацию взаимодействия с видеокартой и сама следит за опустошением буферов и синхронизацией, то новый стандарт предоставляет программисту самому следить за буферами и дает абстракцию к буферам видеокарты и памяти максимально низкоуровнево и как следствие получаеться, что программист должен сам контролировать заполненость буферов и выделение памяти, ошибки не проверяються перед отправкой в устройство. И основой нового стандарта послужила API Mantle от AMD.
В результате доступно такие виды взаимодействия:
  1. апи описания памяти и флаги как обрабатывать эту память с отображением в виртуальную память процессора или использовать только внутреннюю память устройства реализуется через выбор пула памяти и характеристик сегмента;
  2. описание опкодов Spir V виртуальной машины базирующемся на байткоде llvm.
Valve c Intel уже имеют реализацию данных драйверов написанный LunarG, который они обещают полностью открыть в момент полного открытия стандарта.