Code Monkey home page Code Monkey logo

vkspecgen's Introduction

Overview

VkSpecGen is a toolkit for generating code from the Vulkan specification XML. While VkSpecGen can be used by it's own, to generate flatbuffers schema for example, it also supports Jinja2 template rendering engine. Support for other or custom template rendering engines can be added and to VkSpecGen conveniently.

Please note that VkSpecGen is not an officially supported Google product.

Setup

  1. Install Jinja2

    pip install Jinja2

  2. Download Vulkan API registry

  3. Generate the C++ code with

    python3 generator_script.py

Examples

Multiple examples are provided in examples directory. The code will be generated in the root folder. You need python3 to run the examples. You can pass the path to the Vulkan API registry file (vk.xml) using -s or --spec. If the path is not provided, the generator scripts expect to find the registry file in the root directory of the VkSpecGen. You can pass the target platform for the layer using -p or --platform. The default platform is the core platform. For the list of valid Vulkan platforms please see <platforms> node in vk.xml file.

Generate Flatbuffers Schema

examples/flatbuffer/vkflat.py generates flatbuffers schema for Vulkan types in C++. The schema is printed to stdout. Note that this script is not accompanied with a Jinja2 template and uses VkSpecGen to directly generate the output code.

Generate Vulkan Layer to Print Vulkan Call Parameters

examples/print_layer/vklayerpint.py generates the code for a Vulkan layer that intercepts all the Vulkan calls and prints the parameters to stdout. The generator script uses multiple Jinja2 templates in templates directory to generate the layer dispatch tables and the interceptors.

You can use CMake to build the layer from the example folder. However note that for the build to be successful, you need to have the proper version of the Vulkan headers installed. The headers should match the version of the vk.xml that you used to generate the layer.

Test

The tests currently require a real vk.xml, which makes them version-dependent. The supported version is v1.2.202.

Run tests with:

./run_tests.sh <path to vk.xml>

Code formatting

This project uses yapf Python formatter. The settings for VSCode is as follows:

"python.formatting.provider": "yapf",
"python.formatting.yapfArgs": [
  "--style",
  "{based_on_style: google, indent_width: 2}"
],

vkspecgen's People

Contributors

aellem avatar bjoeris avatar renfengliu avatar zakerinasab 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.