Coder Social home page Coder Social logo

exomia / vulkan-api Goto Github PK

View Code? Open in Web Editor NEW
27.0 4.0 0.0 5.48 MB

The exomia/vulkan-api repository contains .NET bindings providing low-level and cross-platform access to the Vulkan API.

Home Page: https://exomia.com

License: BSD 3-Clause "New" or "Revised" License

C# 100.00%
vulkan vulkan-api net6 net60 dotnet exomia csharp csharp-library vk vk-api

vulkan-api's Introduction

Information

The exomia/vulkan-api repository contains .NET bindings providing low-level and cross-platform access to the Vulkan API.
The bindings and documentation are generated using the KhronosGroup/Vulkan-Docs repository.

It is meant to be as close as possible to the original Vulkan API written in C. see example

Features

  • Vulkan 1.0, 1.1, 1.2, 1.3, 0.0
  • All platforms except provisional, sci
  • All extensions including vk_video
  • Raw low level bindings using unsafe C# code
  • cross platform

Example

With Exomia.Vulkan.Api you can create a Vulkan instance like this:

C#

using Exomia.Vulkan.Api.Core;
using static Exomia.Vulkan.Api.Core.Vk;

// ...

VkApplicationInfo applicationInfo;
applicationInfo.sType              = VkApplicationInfo.STYPE;
applicationInfo.pNext              = null;
applicationInfo.pApplicationName   = Allocator.AllocateNtString("my app"); // "Allocator" not included in the Exomia.Vulkan.Api
applicationInfo.applicationVersion = new VkVersion(0, 1, 0, 0);
applicationInfo.pEngineName        = Allocator.AllocateNtString("my engine"); // "Allocator" not included in the Exomia.Vulkan.Api
applicationInfo.engineVersion      = new VkVersion(0, 1, 0, 0);
applicationInfo.apiVersion         = VkVersion.VulkanApiVersion13;

VkInstanceCreateInfo instanceCreateInfo;
instanceCreateInfo.sType                   = VkInstanceCreateInfo.STYPE;
instanceCreateInfo.pNext                   = null;
instanceCreateInfo.flags                   = 0;
instanceCreateInfo.pApplicationInfo        = &applicationInfo;
instanceCreateInfo.enabledLayerCount       = 0u;
instanceCreateInfo.ppEnabledLayerNames     = null;
instanceCreateInfo.enabledExtensionCount   = 0u;
instanceCreateInfo.ppEnabledExtensionNames = null;

VkInstance instance;
VkResult result = vkCreateInstance(&instanceCreateInfo, null, &instance);

C/C++ comparison

VkApplicationInfo applicationInfo = {};
applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
applicationInfo.pApplicationName = "my app";
applicationInfo.applicationVersion = VK_MAKE_VERSION(0, 1, 0, 0);
applicationInfo.pEngineName = "my engine";
applicationInfo.engineVersion = VK_MAKE_VERSION(0, 1, 0, 0);
applicationInfo.apiVersion = VK_API_VERSION_1_3;

VkInstanceCreateInfo instanceCreateInfo = {};
instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
instanceCreateInfo.pApplicationInfo = &applicationInfo;
instanceCreateInfo.enabledLayerCount = 0;
instanceCreateInfo.enabledExtensionCount = 0;

VkInstance instance;
VkResult result = vkCreateInstance(&instanceCreateInfo, nullptr, &instance)

Extensions

loading extensions is also possible (do not forget to enable them first):

// <extension name>.Load(instance[, device]);
VkExtDebugUtils.Load(instance);

after loading the extension functions can be used:

using static Exomia.Vulkan.Api.Core.VkExtDebugUtils;

// ...

VkDebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfoExt;
debugUtilsMessengerCreateInfoExt.sType = VkDebugUtilsMessengerCreateInfoEXT.STYPE;
debugUtilsMessengerCreateInfoExt.pNext = null;
debugUtilsMessengerCreateInfoExt.flags = 0u;

// ...

VkDebugUtilsMessengerEXT debugUtilsMessengerExt;
VkResult result = vkCreateDebugUtilsMessengerEXT(instance, &debugUtilsMessengerCreateInfoExt, null, &debugUtilsMessengerExt);

// ...

Installing

Core

[Package Manager]
PM> Install-Package Exomia.Vulkan.Api.Core

Platform

[Package Manager]
PM> Install-Package Exomia.Vulkan.Api.<Platform>

replace <Platform> with a platform name of the following table

platform name comment
Xlib X Window System, Xlib client library
Xlib_xrandr X Window System, Xlib client library, XRandR extension
Xcb X Window System, Xcb client library
Wayland Wayland display server protocol
Directfb DirectFB library
Android Android OS
Win32 Microsoft Win32 API (also refers to Win64 apps)
Vi Nintendo Vi
Ios Apple IOS
Macos Apple MacOS
Metal Metal on CoreAnimation on Apple platforms
Fuchsia Fuchsia
Ggp Google Games Platform
Screen QNX Screen Graphics Subsystem

see Exomia.Vulkan.Api packages on nuget

Changelog

can be found here

Building

Core

To build Exomia.Vulkan.Api.Core, open Exomia.Vulkan.Api.Core.sln in Visual Studio 2022 and build the solution. Alternatively you can also build it on the command line, run the dotnet build Exomia.Vulkan.Api.Core.sln command.

Platforms

In order to be able to build Exomia.Vulkan.Api.Platforms, make sure that the core package is available in one of your nuget feeds. To build Exomia.Vulkan.Api.Platforms, open Exomia.Vulkan.Api.Platforms.sln in Visual Studio 2022 and build the solution. Alternatively you can also build it on the command line, run the dotnet build Exomia.Vulkan.Api.Platforms.sln command.

Q&A, Ideas or Show & tell us

You have questions, ideas or want to show or tell us something?
Open a new discussion or join an existing one!


Social

Discord Twitch

vulkan-api's People

Contributors

baetz-daniel avatar danielbaumert avatar exomia-bot 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

Watchers

 avatar  avatar  avatar  avatar

vulkan-api's Issues

Only keep the newest "X" releases and tags

In order to keep the repository clean, we should think about removing old release branches and tags;
-> The packages will be kept.
(-> we could also keep the tags!?)

Describe the solution you'd like
We could perform this cleanup with a github action running after a release removing the oldest ones until we have reached our number we want to keep.

Describe alternatives you've considered
In the case somebody would need an older version we could also regenerate it and make it available for download again.

Some extensions will not load.

Some device extensions that also provide VkInstance based commands are not loaded due to errors in the loading function and will throw entry point not found error.

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.