Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

GinShio/vulkan-learn

Repository files navigation

Vulkan-Learn

Learning vulkan C++ binding repo

requirement

project structure

/
├── cmake/
├── CMakeLists.txt
├── images/
├── include/
├── projects/
│   ├── canvas/
│   ├── test/
│   ├── texture/
│   └── triangle/
├── README.org
├── src/
├── video/
├── xmake/
└── xmake.lua
cmake
cmake files
CMakeLists.txt
cmake project configuration file
include
common utility definition
projects
dirtargetcomment
canvasVulkanCanvasglslang canvas (learn builtin functions)
testVulkanTesttest vulkan SDK
textureVulkanTexturelearn VTF pipeline
triangleVulkanTriangledraw a triangle (learn VF pipeline)
src
common utility implement, target VulkanBase
video
project display
xmake
xmake files
xmake.lua
xmake project configuration file

.pc file

.pc file is libraries configuration file, it record the library’s compile-options, link-options, and etc. pkg-config can parse .pc file, and return the library’s information.

Like this, it print the link options

pkg-config --libs vulkan

this command will print the compile options

pkg-config --cflags sdl2

but Windows haven’t .pc file, so we need write .pc files. e.g. vulkan.pc

prefix=/usr
exec_prefix=/usr
libdir=/usr/lib/x86_64-linux-gnu
includedir=/usr/include

Name: Vulkan-Loader
Description: Vulkan Loader
Version: 1.3.204
Libs: -L${libdir} -lvulkan
Libs.private:  -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
Cflags: -I${includedir}

Good. setup environment variable PKG_CONFIG_PATH.

build and run

cmake

cmake need to special the source directory, build directory, and build tool (default is Unix Makefiles), you can use the below command to generate build script

cmake -S. -Bbuild -GNinja

set build release mode

cmake -S. -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release

use clang toolchains not gcc

cmake -S. -Bbuild -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++

Okay, generated the build script, you can build your application

cmake --build build

if you want to special the target, run

cmake --build build --target TARGET_NAME

Nice, generated and built the application, next run it! But cmake not provide run command, you must run it manually

build/bin/VulkanTest

xmake

if you want to build the application by xmake, run below command

xmake build

next, special target

xmake build TARGET_NAME

set debug mode or release mode, you need

xmake f --mode=debug

if you want to use clang toolchain

xmake f --toolchain=clang

if you need compile_command, run

xmake project -k compile_commands

last, run the application

xmake run -w. TARGET_NAME

Shader Input

Canvas

setbinding / idstoragenametypeoffset (in byte)comment
push_constanttimefloat0shader playback time (in seconds)
push_constantextentvec28viewport resolution (in pixels)
push_constantmousevec216mouse pixel coords
0special_constantPIfloat

C++ technical

LICENSE

3-clause BSD License © Xin ‘Russell’ Liu

About

Learning Vulkan C++ binding

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published