All Projects → vcoda → basic-graphics-samples

vcoda / basic-graphics-samples

Licence: GPL-3.0 License
Basic C++ sample usages of Magma library and Vulkan graphics API

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
GLSL
2045 projects
Makefile
30231 projects

Projects that are alternatives of or similar to basic-graphics-samples

RTX-Mesh-Shaders
Different mesh shading techniques using the NVIDIA RTX (Turing) technology.
Stars: ✭ 84 (+366.67%)
Mutual labels:  vulkan, vulkan-demos
Vulkan Samples
One stop solution for all Vulkan samples
Stars: ✭ 2,009 (+11061.11%)
Mutual labels:  vulkan, vulkan-samples
Jin-Engine-2.1
No description or website provided.
Stars: ✭ 63 (+250%)
Mutual labels:  vulkan, vulkan-demos
clustered forward demo vk
Clustered forward rendering demo with Vulkan
Stars: ✭ 50 (+177.78%)
Mutual labels:  vulkan, vulkan-demos
kompute
General purpose GPU compute framework built on Vulkan to support 1000s of cross vendor graphics cards (AMD, Qualcomm, NVIDIA & friends). Blazing fast, mobile-enabled, asynchronous and optimized for advanced GPU data processing usecases. Backed by the Linux Foundation.
Stars: ✭ 872 (+4744.44%)
Mutual labels:  vulkan, vulkan-demos
gearoenix
Cross-platform C++ 3D game engine.
Stars: ✭ 33 (+83.33%)
Mutual labels:  vulkan
vuk
vuk - A rendergraph-based abstraction for Vulkan
Stars: ✭ 167 (+827.78%)
Mutual labels:  vulkan
solo
Small C++ game engine with Lua scripting
Stars: ✭ 26 (+44.44%)
Mutual labels:  vulkan
YALCT
Yet Another Live Coding Tool - Powered by Veldrid and elbow grease
Stars: ✭ 25 (+38.89%)
Mutual labels:  vulkan
FidelityFX-SPD
Single Pass Downsampler (SPD)
Stars: ✭ 94 (+422.22%)
Mutual labels:  vulkan
flame
An ECS Game Engine
Stars: ✭ 16 (-11.11%)
Mutual labels:  vulkan
nanovg vulkan
Antialiased 2D vector drawing library on top of OpenGL for UI and visualizations. (added Vulkan support)
Stars: ✭ 26 (+44.44%)
Mutual labels:  vulkan
CrossWindow-Graphics
A header only library to simplify creating 🌋 Vulkan / ⚪ OpenGL / 🌐 WebGL / ❎DirectX / 🤖 Metal data structures with CrossWindow.
Stars: ✭ 48 (+166.67%)
Mutual labels:  vulkan
kool
A Vulkan/OpenGL engine for Desktop Java and Javascript written in Kotlin
Stars: ✭ 76 (+322.22%)
Mutual labels:  vulkan
osre
An open source render engine
Stars: ✭ 95 (+427.78%)
Mutual labels:  vulkan
Usagi
A hierarchical component entity system based game engine
Stars: ✭ 44 (+144.44%)
Mutual labels:  vulkan
pygfx
Like ThreeJS but for Python and based on wgpu
Stars: ✭ 72 (+300%)
Mutual labels:  vulkan
Vulkan.jl
Simplify usage of Vulkan in Julia
Stars: ✭ 77 (+327.78%)
Mutual labels:  vulkan
vulkan-raytracing
"Simple" Vulkan raytracing
Stars: ✭ 27 (+50%)
Mutual labels:  vulkan
hms-computer-graphics-demo
This is the demo project of CGKit(Short for computer graphics kit). CGKit is a vulkan-based rendering framework, which is designed to improve performance of vulkan devices, especially for Android platform. This project will show you how to load textures, models, add pbr effects and render with vulkan.
Stars: ✭ 19 (+5.56%)
Mutual labels:  vulkan

Basic C++ sample usages of Magma library and Vulkan graphics API

Cloning

To clone this repository with external submodules:

git clone --recursive https://github.com/vcoda/basic-graphics-samples.git

or clone this repository only and update submodules manually:

git clone https://github.com/vcoda/basic-graphics-samples.git
cd basic-graphics-samples
git submodule update --init --recursive

Build tools and SDK

Windows

Check that VK_SDK_PATH environment variable is present after SDK installation:

echo %VK_SDK_PATH%

Shaders are automatically compiled using glslangValidator as Custom Build Tool. If you use Visual Studio newer than 2017, change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".

Ubuntu Linux

Install GCC and Git (if not available):

sudo apt update
sudo apt install gcc
sudo apt install g++
sudo apt install make
sudo apt install git

Install XCB headers and libraries:

sudo apt install xcb
sudo apt install libxcb-icccm4-dev

For Xlib, install X11 headers and libraries (optional):

sudo apt install libx11-dev

Go to the directory where .run file was saved:

chmod ugo+x vulkansdk-linux-x86_64-<version>.run
./vulkansdk-linux-x86_64-<version>.run
cd VulkanSDK/<version>/
source ./setup-env.sh

Check that Vulkan environment variables are present:

printenv | grep Vulkan

Systems with AMD graphics hardware

Check whether AMDGPU-PRO stack is installed:

dpkg -l amdgpu-pro

If not, download and install it from an official web page:

NOTE: You have to make sure that graphics driver is compatible with current Linux kernel. Some of the driver's libraries are compiled against installed kernel headers, and if kernel API changed since driver release, compilation will fail and driver become malfunction after reboot. I used a combination of AMDGPU-PRO Driver Version 17.10 and Ubuntu 16.04.2 with kernel 4.8.0-36. Also disable system update as it may upgrade kernel to the version that is incompatible with installed graphics driver. Successfull AMDGPU-PRO installation should look like this:

Loading new amdgpu-pro-17.10-446706 DKMS files...
First Installation: checking all kernels...
Building only for 4.8.0-36-generic
Building for architecture x86_64
Building initial module for 4.8.0-36-generic
Done.
Forcing installation of amdgpu-pro

After reboot check that driver stack is installed:

dpkg -l amdgpu-pro
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                            Version              Architecture         Description
+++-===============================-====================-====================-====================================================================
ii  amdgpu-pro                      17.10-446706         amd64                Meta package to install amdgpu Pro components.

To build all samples, go to the repo root directory and run Make script:

make magma
make quadric
make all

or to build particular sample, type

make <NN-sample-name>

Optionally use can use -jN flag (where N is the number of threads) to run multi-threaded compilation. There is debug build by default. For release build, set DEBUG variable to 0, e. g.:

make all DEBUG=0

Android

macOS and iOS

Examples

01 - Clear framebuffer

Shows how to setup command buffer for simple framebuffer clear.




02 - Triangle

Draws triangle primitive from the vertices generated in the vertex shader.




03 - Vertex buffer

Draws triangle primitive with per-vertex color using vertex buffer.




04 - Vertex transform

Shows how to setup perspective transformation and apply it to the vertices in the vertex shader.




05 - Mesh

Generates famous Utah Teapot from the set of patches and draws wireframe mesh with perspective transformation. Smoothness of the surface could be controlled using subdivision degree.



06 - Texture

Shows how to load DXT texture data (using Gliml), create Vulkan images and combine them in the fragment shader using image samplers.



07 - Texture array

Utilizes "texture array" hardware feature to apply multiple textures inside single draw call. Different texture LODs could be viewed.



08 - Cubemap texture

Shows how to load cubemap .dds textures and perform environment mapping in the fragment shader.



09 - Volume texture

Loads volumetric data into 3D texture and performs ray casting with large number of samples to accomodate resulting color.



10.a - Render to texture

Performs render to texture using color and depth attachments. Framebuffer defines render pass, color/depth image views and dimensions. Looks like AMD hardware uses compute queue for resolving, because it slows down my machine when ethereum miner is running.


10.b - Render to multisample texture

Performs render to multisample texture with resolve operation using RenderPass.




11 - Occlusion query

Simple usage of hardware occlusion queries.




12 - Alpha blending

Good old alpha blending.




13 - Specialization constants

Shows how to force shader compiler to perform static branching using specialization constants. For each fragment shader branch, there is a separate pipeline instance.



14 - Push constants

Uses push constants - a limited storage inside command buffer. Push constants are updated when command buffer is recorded.



15 - Particles

This sample shows how to use gl_PointSize built-in variable to draw particles that are properly scaled with distance. As number of particles varies, vertex count put to indirect buffer to fetch from instead of specify it in vkCmdDraw() function with command buffer rebuild. Particle engine initially implemented by Kevin Harris and adopted by me for rendering with Vulkan.

16 - Immediate mode

Sometimes I miss immediate render mode from OpenGL 1.x era, apparently it was useful to (quickly) draw something on the screen. This sample shows how to use Magma's ImmediateRender to draw different primitives without VB mapping, data copy, state management etc.


17 - ShaderToy

Unlike OpenGL, where shader compiler is provided by the graphics driver, Vulkan uses pre-compiled SPIR-V bytecode. This sample shows how to use https://github.com/google/shaderc compiler from Google to compile GLSL shaders on fly and apply changes immediately, which may be useful for shader development. This sample only for Release x64 build configuration. Example fragment shader taken from https://www.shadertoy.com/view/4tl3z4 (written by Reinder Nijhofftaken).

18 - Compute shader

Compute shaders are core part of Vulkan. This sample performs arithmetic computations on two set of numbers using GPU compute shader.

Known issues

  • vkCreateSwapchainKHR() may fail on Linux due to unresolved issues with alignment.

Credits

This framework uses a few third-party libraries:

  • Microsoft DirectXMath
    Linear algebra library with fantastic CPU optimizations using SSE2/SSE3/SSE4/AVX/AVX2 intrinsics.
    I wrote a simple wrapper over it to make its usage more OOP friendly.

  • Gliml
    Minimalistic image loader library by Andre Weissflog.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].