Crate vulkanology [] [src]

This crate provides macros for writing simple vulkan compute shader tests using the tomaka/vulkano library.

About

A core problem of developing shaders is the rather difficult environment in which they are executed. Even simple things can go wrong and cost the developer a lot of time to fix. This crate aims at providing a simple-to-use environment for writing vulkan compute shader tests. It uses the vulkano rust-vulkan bindings end exports macros for a fast implementation of tests. These macros mostly generate vulkano boilerplate instantiation code. The interface to the shader are CPU accessible buffers which you can read and write at will and a function for executing the shader code and waiting for the result.

Import (Usage in integration test modules)

Due to the reexport of utility function from the vulkano crate (which you don't need to access, unless you want to) you need to use the following crates in your test module header:

#[macro_use]
extern crate vulkano;
#[macro_use]
extern crate vulkanology;

For basic usage of the library you can refer to the doc-tests and tests/shaders/example.comp. For a working example of a fairly elaborate shader test please refer to: tests/random.rs and tests/shaders/random.comp.

Building GLSL shaders

This utility pack is built around the vulkano library, which also provides vulkano-shaders, a library which compiles GLSL shaders into Rust interface modules. For examples on how to build shaders with vulkano-shaders see build.rs and this.

Composite shader tests

vulkanology also provides some build utilities for working with segmented shaders. src/build_utils.rs contains working examples on how to use these utilities in your build.rs.

Modules

build_utils

This module exports shader building tools which simplify the test shader building process.

Macros

cpu_array_buffer

Creates a new uninitialized buffer of type $buf_type of length $buf_len.

device_and_queue

Creates a Device and a Queue for compute operations.

gen_simple_test_shader

A simple macro for generating the build code which concatenates the correct test shader segments.

instance

Creates a vulkano. Does not enable any instance extensions.

physical_device

This macro generates code for loading a PhysicalDevice. It takes the instance variable name and an optional list of features which the device should support. All available features are defined here.

pipeline

This macro is the core of the shader-testing framework. It generates code for initializing the vulkano environment, it allocates CpuAccessibleBuffers, it compiles the shader, it sets up a ComputePipeline and provides a function for executing the shader.