Code Monkey home page Code Monkey logo

vktut's Introduction

Shabi's Vulkan Tutorials

Travis-CI: Build Status

This is a repository of tutorials on Vulkan. It starts with the basics, enumerating your GPUs, allocating memory and getting computation done. It then moves on to actually displaying things and using shaders. Along the way, some of the optional Vulkan layers are explored.

Each tutorial may use functions implemented in a previous tutorial. The functions are thus named as tutX_*() so that it would be immediately obvious which tutorial you should refer to, if you don't remember what that function does.

These tutorials were developed in Linux, and I have no intention of trying them on Windows. Feel free to send a pull request for the tweaks they would need to run on that. You would need the following external libraries:

  • Vulkan, of course
  • SDL2
  • X11-xcb
  • ncurses (optional for Tutorial 12)

The tutorials are source code themselves, with enough comments in them to explain how things are done and/or why. I strongly recommend reading the Vulkan specifications alongside the tutorials. It is well-written and easy to grasp. Also note that Vulkan is not for the faint of heart. I expect you are not struggling with reading C code and have some understanding of computer graphics and operating systems.

The main.c of each tutorial glues together the functionalities implemented in the tut*.c files, and may include uninteresting things like printing out information. The core usage of Vulkan is usually in tut[0-9]\+.c files, with tut[0-9]\+_render.c files containing utilities useful for rendering based on top of the core functions.

Build and Execution

This project uses autotools. If you have received the project as a release tarball, you can go through the usual procedure:

mkdir build && cd build
../configure --enable-silent-rules
make -j

If your Vulkan SDK installation is not in the standard locations, you would need to have the VULKAN_SDK variable set, for example set it in your environment:

export VULKAN_SDK=/path/to/vulkan/arch

Or run configure file with this environment:

VULKAN_SDK=/path/to/vulkan/arch ../configure

If you are building from source, you would need autotools installed as well as autoconf-archive and do the following step beforehand:

autoreconf -i

Each tutorial will have an executable in its own directory that you can run.


Disclaimer: I am writing these tutorials as I am learning Vulkan myself. I am in no way an expert in computer graphics and my own knowledge of OpenGL barely passes 1.2. Please do not consider these tutorials as "best practices" in Vulkan. They are intended to merely ease you in Vulkan, getting you familiar with the API. How to best utilize the API is beyond me at this point.

vktut's People

Contributors

shabbyx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vktut's Issues

tut8 error

I've got this error in tut8:

Could not create graphics pipeline: Incomplete
Segmentation fault (core dumped)

All other tuts are working fine.
My system: Ubuntu 14.04, GeForce GTX 970, driver version 367.27

tut4 memory

  • If the memory is not host-coherent, then we need to flush application writes, invalidate application caches
    • before reads, and insert memory barriers after device writes. For the sake of simplicity, as this tutorial
    • is already huge, let's just ask for host-coherent memory. Such a memory may not be available on all
    • devices, so ideally you would want to look for host-coherent memory, and if not found be prepared to do the
    • above flushes, cache invalidations and barriers.

Even with coherent memory you must still insert the appropriate memory barriers after device writes (and indeed, before device reads (note: QueueSubmit effectively performs an implicit invalidate)).

All devices must support at least one memory type that is coherent.

Configure script fails

When I try to run the configure script, it works fine except for these three output lines:
checking vulkan/vulkan.h usability... no
checking vulkan/vulkan.h presence... no
checking for vulkan/vulkan.h... no

Then it exits with this message:
configure: error: Vulkan header not found

I downloaded the Vulkan SDK directly from LunarG, let the self-extracting archive do its thing and then followed the setup instructions in the Getting_Started.html file included in the SDK.
I set up my environment variables by adding these lines to my .bashrc file:
VULKAN_SDK=~/VulkanSDK/1.0.17.0/x86_64
export PATH=$PATH:$VULKAN_SDK/bin
export LD_LIBRARY_PATH=$VULKAN_SDK/lib
export VK_LAYER_PATH=$VULKAN_SDK/etc/explicit_layer.d

I've also tried copying "explicit_layer.d" directly into my "~/.local/share/vulkan/" directory and copying the "/vulkan/" directory that contains the header files directly into "/usr/include/". The former had no effect whatsoever, the latter removed the first two lines, but then threw an error that it couldn't find the Vulkan library.

I'm running Ubuntu 16.04 (4.4.0-28-generic), using an Nvidia GTX 760 with the proprietary drivers (version 364.16). I can confirm that Vulkan works on my system, I've ran "vulkaninfo" and tried "The Talos Principle".

I'm not sure what to do and while I'm fairly certain that I missed something obvious, I'm simply out of ideas... thanks in advance for any tips!

Autoreconf fails

Just downloaded the latest version of the project, now trying to run "autoreconf -i" throws a warning and an error:

aclocal: warning: couldn't open directory 'm4': No such file or directory
configure.ac:21: error: possibly undefined macro: AC_MSG_ERROR
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1

tut4 events

Events cannot be used between queues, they are fine grained synchronisation for the same queue. They can be used (with limitations) between the device and the host.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.