Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ VKFS Public
forked from MHDtA-dev/VKFS

Cross-platform C++ framework that allows you to quickly initialize Vulkan

Notifications You must be signed in to change notification settings

mfkiwl/VKFS

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VKFS - Vulkan Fast Setup Framework

Logo

VKFS is a cross-platform and window system independ C++ framework that allows you to quickly create basic Vulkan objects for further work, such as Instance, Physical Device, Device, Command queues, Command buffer and synchronization objects.

Note: The framework is currently under development and may contain bugs or some missing functionality.

The framework is fully working. If you notice a bug/missing functionality, write about it in issues tab. I will add new features as needed.

Tutorials:

Note: These tutorials assume that you already have a working environment with a configured compiler and linked libraries.

Brief description of objects:

Instance:

The object that creates an Instance of your application.

Example:

   auto instance = new VKFS::Instance("Application Name", "Engine name", [instanceExtensions: std::vector<const char*>], [enableValidationLayers: bool], [OPTIONAL API_VERSION=VK_API_VERSION_1_2: uint32_t]);

Device:

The object that picks up VkPhysicalDevice, creates VkDevice based on it, as well as command queues.

Example:

   auto device = new VKFS::Device(instance, [deviceExtensions: std::vector<const char*>]);

Swapchain

An object that creates a swap chain and renderpass for it.

Example:

   auto swapchain = new VKFS::Swapchain(device, [windowWidth: int], [windowHeight: int]);

Descriptor

The object that creates VkDescriptorSetLayout, VkDescriptorSet and everything necessary for this. Allows you to create a Descriptor for UBO, Sampler or Storage Buffer in just two lines.

Example:

   auto descriptor = new VKFS::Descriptor(device, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, [shaderStage: VkShaderStageFlagBits]);
   descriptor->createUBOSet(sizeof(YourUBOStructure));

OR

   auto descriptor = new VKFS::Descriptor(device, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, [shaderStage: VkShaderStageFlagBits]);
   descriptor->createSamplerSet([imageInfo: VkDescriptorImageInfo]);

Shader Module

An object that allows you to conveniently load and create a VkShaderModule

Example:

   auto vertex = new VKFS::ShaderModule(device, "path/to/spv");

Pipeline

A simple abstraction over VkPipeline and VkPipelineLayout objects. Perfect for those who want to get rid of the confusing boilerplate code and those who do not need a lot of settings

Example:

   auto pipeline = new VKFS::Pipeline(device, [vertexBindingDescription: VkVertexInputBindingDescription], [attributesDescription: std::vector<VkVertexInputAttributeDescription>],
      [renderPass: VkRenderPass], [descriptors: std::vector<VKFS::Descriptor*>]);

   pipeline->addShader(VKFS::VERTEX, vertex);
   pipeline->addShader(VKFS::FRAGMENT, fragment);
   ...
   pipeline->addShader([type: VKFS::ShaderType], [vertexShader: VKFS::ShaderModule*]); // You can add vertex, fragment and geometry shaders to pipeline

   pipeline->build(); // Build the pipeline

After building you can get your ready to use objects:

   pipeline->getPipelineLayout(); // Returns VkPipelineLayout
   pipeline->getPipeline(); // Returns VkPipeline

You can also set some additional parameters(before pipeline->build();):

   pipeline->enablePushConstants(sizeof(YourPushConstantsStruct), [shaderType: VKFS::ShaderType]); // Enables push constants for your pipeline.
   pipeline->enableDepthTest([state: bool]); // Enables or disables depth test. Enabled by default
   pipeline->setCullMode([mode: VKFS::CullMode]); // Enables specified culling mode
   pipeline->disableAttachment([attachment: VKFS::Attachment]); // Disables color or depth attachment. For example, you can disable color attachment if you need pipeline for shadow mapping
   pipeline->enableAlphaChannel([state: bool]); // Enables or disables alpha blending
   pipeline->setPolygonMode([mode: VKFS::PolygonMode]); // Changes polygon mode. VKFS::FILL by default

Vertex Buffer

This object allows you to create a buffer of vertices and indices using your vertex structure

Example:

   auto vb = new VKFS::VertexBuffer<YourVertexStruct>(device, [vertices: std::vector<YourVertexStruct>], [indices: std::vector<uint32_t>]);

You can also use this with Push Constants:

   auto vb = new VKFS::VertexBuffer<YourVertexStruct, YourPushConstantsStruct>(device, [vertices: std::vector<YourVertexStruct>], [indices: std::vector<uint32_t>]);

Next, before you draw, call

   vb->pushPushConstants(yourPushConstants);

Tested on

Platform Status
Windows(MSYS2) ✔️
MacOS ✔️
Linux(Debian 11) ✔️

Building

To build a framework, use CMake:

git clone https://github.com/MHDtA-dev/VKFS.git
cd VKFS
mkdir build
cd build
cmake -DVULKAN_INCLUDE_PATH=[Vulkan SDK include path] ..
make

About

Cross-platform C++ framework that allows you to quickly initialize Vulkan

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 99.0%
  • CMake 1.0%