Giter VIP home page Giter VIP logo

shvulkan's Introduction

shvulkan

linux_badge windows_badge

shvulkan is a lightweight and flexible wrapper around the Vulkan API written completely in C, that makes it easier to work with graphics efficiently without writing thousands of lines of code.

alpha-blend


See the linux and windows build logs

linux_badge windows_badge

The examples are frequently being tested on Windows 11, Linux Mint (virtual machine and pc) with different compilers (MSVC, gcc), and hardware configurations (RX580 4GB GDDR5, Radeon V Carrizo 500MB).


To do

  • texture examples (graphics and plain data)
  • Error/debug/info logging to file
  • read spirv assembly (not sure about this)
  • ray tracing example

Index


Clone and Build

Open the terminal and run the following commands:

git clone --recursive https://github.com/mrsinho/shvulkan.git
cd shvulkan
mkdir build
cd build
cmake -DSH_VULKAN_BUILD_EXAMPLES=ON ..
cmake --build .

If you are having some trouble with building the targets and compiling the code, check the Linux and Windows build logs.

top


CMake targets

CMake target type
shvulkan library
shvulkan-clear-color executable
shvulkan-scene executable
shvulkan-compute-example executable

If the cmake option SH_VULKAN_BUILD_EXAMPLES is enabled, the additional glfw target will be generated as a static library.

top


This example demonstrates how to setup a vulkan environment, allocate, write and bind memory to the GPU, enable multisampled anti aliasing, write a vertex and a fragment shader, build a graphics pipeline, bind inputs with a command buffer, query draw calls (with indexing and without indexing, with instancing and without instancing) to a graphics queue and synchronize data between host and graphics card.

The first draw call will require some quad vertices, which are going to be combined with two per instance model matrices located on an instance buffer, which was bound with and offset of 0 bytes, and produce different vertex positions (see gl_PerVertex_var.gl_Position):

quad input vertex positions: 1st quad instance input matrix and output fragment positions: 2nd quad instance input matrix and output fragment position:

Through the renderpass, the first draw call will produce the following framebuffers on the swapchain (the fragment color is calculated by determining the distance between the fragment position and the light source, which properties were defined on the descriptor set 0):

The second draw call requires three triangle vertices, which are going to be combined with the last raw matrix on the instance buffer, that was bound with an offset of 128 bytes, and return the following vertex positions (see gl_PerVertex_var.gl_Position):

triangle input vertex positions: triangle input matrix and output fragment positions:

Through the renderpass, the second draw call will produce the following framebuffers on the swapchain (as you can see, all the fragments are located at the same z distance from the origin):

What could the graphics example be improved with

  • textures
  • read framebuffer attachments memory
  • offline rendering
  • raytracing using compute shader
  • update graphics examples maps for a quick look

top


The compute examples shows how setup a vulkan environment, allocate, write and bind memory to the GPU, setup a compute shader, write a compute shader and build a compute pipeline (the program takes 64 decimal numbers as inputs and square their values), bind and dispatch inputs to compute workgroups, manage parallel invocations, submit to a compute queue, synchronize data between host and graphics card and read the output values. The following diagram briefly shows what happens in this example program:

top


shvulkan's People

Contributors

mrsinho avatar topazz8658u avatar

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.