Magnum::Vk::Shader class new in Git master

Shader.

Wraps a VkShaderModule, which contains a SPIR-V binary with one or more shader entrypoints.

Shader creation

The ShaderCreateInfo structure takes a single required parameter, which is the SPIR-V binary. Besides accepting a Corrade::Containers::ArrayView<const void>, to which any container is convertible, it can also take ownership of a Corrade::Containers::Array, which means you don't need to worry about keeping a loaded file in scope until it's consumed by the Shader constructor:

#include <Magnum/Vk/ShaderCreateInfo.h>



Vk::ShaderCreateInfo info{
    *CORRADE_INTERNAL_ASSERT_EXPRESSION(Utility::Path::read("shader.spv"))
};



Vk::Shader shader{device, info};

Public static functions

static auto wrap(Device& device, VkShaderModule handle, HandleFlags flags = {}) -> Shader
Wrap existing Vulkan handle.

Constructors, destructors, conversion operators

Shader(Device& device, const ShaderCreateInfo& info) explicit
Constructor.
Shader(NoCreateT) explicit
Construct without creating the shader.
Shader(const Shader&) deleted
Copying is not allowed.
Shader(Shader&& other) noexcept
Move constructor.
~Shader()
Destructor.
operator VkShaderModule()

Public functions

auto operator=(const Shader&) -> Shader& deleted
Copying is not allowed.
auto operator=(Shader&& other) -> Shader& noexcept
Move assignment.
auto handle() -> VkShaderModule
Underlying VkBuffer handle.
auto handleFlags() const -> HandleFlags
Handle flags.
auto release() -> VkShaderModule
Release the underlying Vulkan shader.

Function documentation

static Shader Magnum::Vk::Shader::wrap(Device& device, VkShaderModule handle, HandleFlags flags = {})

Wrap existing Vulkan handle.

Parameters
device Vulkan device the shader is created on
handle The VkShaderModule handle
flags Handle flags

The handle is expected to be originating from device. Unlike a shader created using a constructor, the Vulkan shader is by default not deleted on destruction, use flags for different behavior.

Magnum::Vk::Shader::Shader(Device& device, const ShaderCreateInfo& info) explicit

Constructor.

Parameters
device Vulkan device to create the shader on
info Shader creation info

Magnum::Vk::Shader::Shader(NoCreateT) explicit

Construct without creating the shader.

The constructed instance is equivalent to moved-from state. Useful in cases where you will overwrite the instance later anyway. Move another object over it to make it useful.

Magnum::Vk::Shader::~Shader()

Destructor.

Destroys associated VkShaderModule handle, unless the instance was created using wrap() without HandleFlag::DestroyOnDestruction specified.

Magnum::Vk::Shader::operator VkShaderModule()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

VkShaderModule Magnum::Vk::Shader::release()

Release the underlying Vulkan shader.

Releases ownership of the Vulkan shader and returns its handle so vkDestroyShaderModule() is not called on destruction. The internal state is then equivalent to moved-from state.