Mountain::Window¶
-
struct mountain::Window¶
Window Wrapper around GLFW
Public Functions
-
Window(std::string_view title, unsigned width, unsigned height)¶
Window ctor
- Parameters
title – Window title
width – width of the window
height – height of the window
-
std::vector<const char*> get_instance_extension() const¶
- Returns
vector of supported extension by this window
-
GLFWwindow *get_window() const¶
-
inline std::string_view get_title() const¶
-
bool window_should_close() const¶
-
~Window()¶
-
Window(std::string_view title, unsigned width, unsigned height)
-
std::vector<const char*> get_instance_extension() const
-
SDL_Window *get_window() const
-
inline std::string_view get_title() const
-
~Window()
-
Window(std::string_view title, unsigned width, unsigned height)¶
Mountain::Context¶
-
struct mountain::Context¶
Context class will hold the Vulkan context and so will be necessary to all other classes
Public Functions
-
Context(Window const &window, std::vector<const char*> const &devicesExtension)¶
- Parameters
window – The window we want to us
devicesExtension – : extensions we need. Example : VK_KHR_SWAPCHAIN_EXTENSION_NAME
-
inline vk::Device const &operator*() const¶
Useful to use vk::Device method through Context object
- Returns
The vulkan device
-
inline vk::Device const *operator->() const¶
Useful to use vk::Device method through Context object
- Returns
The vulkan device
-
std::pair<vk::UniqueDeviceMemory, vk::UniqueBuffer> create_buffer_and_memory(vk::DeviceSize const &size, vk::BufferUsageFlags usage, vk::MemoryPropertyFlags properties) const¶
Helper function which create a buffer and it’s associated memory
- Parameters
size – Size of the buffer
usage – Usage of the buffer. example: eHostCoherent
properties – Properties that we want for the memories. example: eTransferDst
-
void copy_buffer(vk::UniqueBuffer &destination, vk::UniqueBuffer const &source, vk::DeviceSize const &size) const¶
Copy a fixed size content of source into destination
- Parameters
destination –
source –
size – Fixed size data to copied
-
void copy_buffer_to_image(vk::Buffer buffer, vk::Image image, uint32_t width, uint32_t height) const¶
Copy the content of buffer inside image
- Parameters
buffer –
image –
width – width of the image
height – height of the image
-
vk::UniqueImageView create_2d_image_views(vk::Image image, const vk::Format &format, vk::ImageAspectFlags aspectFlags, uint32_t mipmap_levels) const¶
Create a 2d Image view from an Image
- Parameters
image – The image you’d want to create image view from
format – Format of the image view
aspectFlags –
mipmap_levels – mipmap level of the image
- Returns
ImageView with automatic resource managment
-
std::pair<vk::UniqueImage, vk::UniqueDeviceMemory> create_image(uint32_t width, uint32_t height, vk::Format format, vk::ImageTiling tiling, const vk::ImageUsageFlags &usage, vk::MemoryPropertyFlagBits, uint32_t mipmap_levels) const¶
Create an image and it’s associated memory
- Parameters
width –
height –
format –
tiling – eOptimal or eLinear. Linear -> you have direct access to texel. Optimal: optimise for speed
usage – usage of memory. example eTransferDst
mipmap_levels – level of mipmap you’ll be using
- Returns
Image and memory with automatic resources management
-
vk::SurfaceFormatKHR choose_swap_surface_format() const¶
- Returns
adequate swap chain format
-
struct QueueFamilyIndices¶
-
struct SwapChainSupportDetails¶
-
Context(Window const &window, std::vector<const char*> const &devicesExtension)¶
Mountain::RenderPass¶
-
struct mountain::RenderPass¶
A render pass specify what will be use when we render something. To be short it define, if we want to use Color, Depth, Stencil
Public Functions
-
RenderPass(Context const &context, const unsigned int sub_pass)¶
Create a render pass
- Parameters
context – Vulkan context
sub_pass – Define the subpass we will be using
-
inline bool has_depth_or_stencil() const¶
- Returns
true if renderpass will use depth
-
RenderPass operator=(RenderPass const&) = delete¶
Deleted copy operation
-
RenderPass(RenderPass const&) = delete¶
Deleted copy constructor
-
RenderPass operator=(RenderPass&&) = delete¶
Deleted move operation
-
RenderPass(RenderPass&&) = delete¶
Deleted move constructor
-
RenderPass(Context const &context, const unsigned int sub_pass)¶
Mountain::SwapChain¶
-
struct mountain::SwapChain¶
Public Functions
-
SwapChain(Context const &context, RenderPass const &render_pass, int width, int height)¶
Construct a Vulkan swap chain for graphics purpose
- Parameters
context – Vulkan context
render_pass –
width – width of the output image
height – height of the output image
-
const std::vector<vk::UniqueImageView> &get_swap_chain_image_views() const¶
-
std::vector<vk::Framebuffer> get_framebuffers() const¶
-
vk::Format get_swap_chain_image_format() const¶
-
const vk::Extent2D &get_swap_chain_extent() const¶
-
vk::SwapchainKHR get_swap_chain() const¶
-
~SwapChain()¶
-
SwapChain(Context const &context, RenderPass const &render_pass, int width, int height)¶
Mountain::GraphicsPipeline¶
-
template<PushConstantType>
struct mountain::PushConstant¶ - tparam PushConstantType
type of the value we want to be a push constant
Public Members
-
vk::ShaderStageFlagBits shader_stage¶
the stage in which the push constant will be use
-
struct mountain::shader¶
-
struct mountain::GraphicsPipeline¶
Public Functions
-
GraphicsPipeline() = default¶
-
inline vk::Pipeline const &get_pipeline() const¶
- Returns
: The vulkan pipeline object
-
inline vk::PipelineLayout const &get_pipeline_layout() const¶
-
inline std::vector<vk::PushConstantRange> const &get_push_constant_ranges() const¶
-
vk::PushConstantRange const &get_push_constant(const vk::ShaderStageFlagBits shader_stage) const¶
-
GraphicsPipeline() = default¶
Mountain::CommandBuffer¶
-
struct mountain::CommandBuffer¶
Public Functions
-
CommandBuffer(const Context &context, const SwapChain &swap_chain, RenderPass const &renderpass, int nb_uniform = 0)¶
Create CommandBuffer object
- Parameters
context – Vulkan context
swap_chain –
renderpass –
nb_uniform – number of uniform we want to use (image sample count as uniform)
-
inline std::pair<vk::DescriptorSet const*, std::uint32_t> get_descriptor_set_size(std::size_t const i) const¶
- Deprecated:
this method will surely be removed at one point To bind a descriptor set we need several things like the a pointer to descriptor and a size to determine how many descriptor we will bind. This function provide this two things for the ith image of swapchain
- Parameters
i – the index we want
- Returns
a pair that contain a pointer to descriptor set and the number of descriptor set to bind
-
void allocate_descriptor_set(std::vector<vk::DescriptorSetLayout> &&descriptor_set_layouts)¶
Allocate the number of descriptor set layout we need, the size of vector parameter X the number of image in swap chain
- Parameters
descriptor_set_layouts –
-
template<class T>
void update_descriptor_set(int first_descriptor_set_index, int binding, const buffer::uniform<T> &uniform_buffer)¶ Update uniform descriptor set
- Template Parameters
T – type of value for the uniform
- Parameters
first_descriptor_set_index – set value for this descriptor
binding – binding value
uniform_buffer – uniform buffer to associate with this descriptor
-
void update_descriptor_set(int first_descriptor_set_index, int binding, buffer::image2d const &image, image::sampler const &sampler)¶
Update image descriptor set
- Parameters
first_descriptor_set_index – set value for this descriptor
binding – binding value
image – image to associate with this descriptor
sampler – sample to associate with this image
-
void drawFrame(std::vector<buffer::uniform_updater> &&updaters)¶
- Deprecated:
: see mountain::Present Draw frame with the record command buffers and update uniform values
- Parameters
updaters – vector of uniform_updater. uniform_updater are created by calling
get_uniform_updateron a mountain::buffer::uniform object
Public Members
- template<class Function> void record(Function &&record_function) requires std vk::CommandBuffer const & get_command_buffer (std::size_t const i) const
This parameter will contain a function that implement the drawing logic like bind Vertex buffer, bind Index buffer, drawing command etc..
the std::size_t const parameter of the passed function is use to retrieve a vuilkan command buffer. It’s an index of the command buffer currently used
- Template Parameters
Function – type of the function
- Parameters
record_function – function that take two parameters a CommandBuffer const& and std::size_t const
i – the index we want
- Returns
The ith vulkan command buffer
-
CommandBuffer(const Context &context, const SwapChain &swap_chain, RenderPass const &renderpass, int nb_uniform = 0)¶
Mountain::buffer::uniform¶
-
template<class T>
struct mountain::buffer::uniform¶ The uniform class in Mountain-API packed two vulkan things:
vk::Buffer
vk::MemoryDevice It’s purpose is to encapsulate the creation of this two things.
- tparam T
type of the value we want in our uniform
Public Functions
-
uniform(Context const &context, size_t swap_chain_nb_images)¶
Construct a uniform object
- Parameters
context – Vulkan context
swap_chain_nb_images – nb of uniform to create, one for each swap chain image
-
uniform_updater get_uniform_updater(const T &value)¶
- Parameters
value – value for this uniform
- Returns
an uniform_updater object, it has to be passed to the draw function of CommandBuffer to be effective
Mountain::buffer::vertex¶
-
struct mountain::buffer::vertex_description¶
Public Functions
-
template<class T, auto N>
inline vertex_description(uint32_t binding, uint32_t location_start_from, std::array<format_offset<T>, N> &&format_offsets)¶ - Template Parameters
T – Type of the structure use to create vertex buffer
N – number of attributes in the structure
- Parameters
binding – must be unique by pipeline
location_start_from – location refer to location in shaders. The first attribute will have location=location_start_from and then we increment by 1 for every others attribute.
format_offsets – contains information about attributes, theirs offset inside the structure. This is not create by hand and you should use the CLASS_DESCRIPTION macro.
-
template<class T, auto N>
-
template<class T, class ...Ts>
auto mountain::get_format_offsets(Ts T::*... args)¶ - Template Parameters
T – type of the structure
Ts – type of the attributes
- Parameters
args – member pointer to attributes
- Returns
an array of offset by attribute. Use to create a buffer::vertex
-
struct mountain::buffer::vertex¶
Public Functions
-
template<Container container, Container_uint32_t indices_container>
vertex(Context const &context, vertex_description &&description, container &&vertices, indices_container &&indices)¶ Construct a vertex bufer
- Template Parameters
container – a container
indices_container – a container of uint32_t
- Parameters
context – vulkan context
description – the vertex_description
vertices – the vertices to include inside the buffer
indices – the corresponding indices
-
template<Container container, Container_uint32_t indices_container>
Mountain::buffer::image2d¶
-
struct mountain::buffer::image2d¶
A image2d in Mountain-API correspond to three vulkan things:
vk::Image
vk::MemoryDevice
vk::ImageView This three things are packed in this only structure. image2d will be required when you want to add texture in your shaders
Public Functions
-
image2d(Context const &context, fs::path const &image_path, uint32_t mipmap_level)¶
Construct an image and it’s associated Memory and imageview. After the image2d has been construct, it can be use directly
- Parameters
context – Vulkan context
image_path – Path to the texture image
mipmap_level – : mipmap level wanted (automatically compute)
Free Functions¶
-
std::pair<std::vector<Vertex>, std::vector<uint32_t>> mountain::model::load_obj(fs::path const &model_path)¶
- Parameters
model_path – path to the obj to load
- Returns
a vector of vertices and a vector of the corresponding indices
-
vk::DescriptorSetLayoutBinding mountain::descriptorset_layout::create_descriptor_uniform(int binding, vk::ShaderStageFlags const &shader)¶
Create descriptor layout to be use as a uniform
- Parameters
binding – number inside shader
shader – The stage of the shader this descriptor will be use
- Returns
Corresponding descriptor set layout binding
-
vk::DescriptorSetLayoutBinding mountain::descriptorset_layout::create_descriptor_image_sampler(int binding, vk::ShaderStageFlags const &shader)¶
Create descriptor layout to be use for image sampler
- Parameters
binding – number inside shader
shader – The stage of the shader this descriptor will be use
- Returns
Corresponding descriptor set layout binding
-
vk::DescriptorSetLayout mountain::descriptorset_layout::create_descriptorset_layout(Context const &context, std::vector<vk::DescriptorSetLayoutBinding> &&set_layout_bindings)¶
Create a descriptor set layout from descriptor set layout binding pass as parameters
- Parameters
context – Vulkan context
set_layout_bindings – vector of descriptor set layout binding
- Returns
Corresponding descriptor set layout