VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
vex::VulkanPipeline Class Reference

A class managing creating vulkan pipelines. Both form meshes and UI elements. More...

#include <Pipeline.hpp>

Public Member Functions

 VulkanPipeline (VulkanContext &r_context)
 Constructor for VulkanPipeline.
void createGraphicsPipeline (const std::string &vertShaderPath, const std::string &fragShaderPath, const VkVertexInputBindingDescription &bindingDescription, const std::vector< VkVertexInputAttributeDescription > &attributeDescriptions)
 Creates a standard Opaque Graphics Pipeline.
void createTransparentPipeline (const std::string &vertShaderPath, const std::string &fragShaderPath, const VkVertexInputBindingDescription &bindingDescription, const std::vector< VkVertexInputAttributeDescription > &attributeDescriptions)
 Creates a Transparent Graphics Pipeline.
void createMaskedPipeline (const std::string &vertShaderPath, const std::string &fragShaderPath, const VkVertexInputBindingDescription &bindingDescription, const std::vector< VkVertexInputAttributeDescription > &attributeDescriptions)
 Creates a Masked Graphics Pipeline (Alpha Cutout).
void createSpritePipeline (const std::string &vertPath, const std::string &fragPath, bool isTransparent, bool isInstanced)
 Creates a Sprite Graphics Pipeline (used for Billboards and Particles).
void createUIPipeline (const std::string &vertShaderPath, const std::string &fragShaderPath, const VkVertexInputBindingDescription &bindingDesc, const std::vector< VkVertexInputAttributeDescription > &attrDesc)
 Creates a UI Pipeline.
void createFullscreenPipeline (const std::string &vertPath, const std::string &fragPath)
 Creates a Fullscreen Quad Pipeline.
VkPipeline get () const
 Returns the VkPipeline handle.
VkPipelineLayout layout () const
 Returns the VkPipelineLayout handle.
void updateViewport (glm::uvec2 resolution)
 Updates viewport to new resolution.

Private Member Functions

std::vector< char > readFile (const std::string &filename)
 Reads a file and returns its contents as a vector of characters.

Private Attributes

VulkanContextm_r_context
 Creates a debug VkPipeline.
VkPipeline m_pipeline = VK_NULL_HANDLE
VkPipelineLayout m_layout = VK_NULL_HANDLE
glm::uvec2 m_currentRenderResolution

Detailed Description

A class managing creating vulkan pipelines. Both form meshes and UI elements.

Definition at line 20 of file Pipeline.hpp.

Constructor & Destructor Documentation

◆ VulkanPipeline()

vex::VulkanPipeline::VulkanPipeline ( VulkanContext & r_context)

Constructor for VulkanPipeline.

Parameters
VulkanContext&r_context - Reference to the VulkanContext.

Definition at line 8 of file Pipeline.cpp.

◆ ~VulkanPipeline()

vex::VulkanPipeline::~VulkanPipeline ( )

Definition at line 10 of file Pipeline.cpp.

Member Function Documentation

◆ createFullscreenPipeline()

void vex::VulkanPipeline::createFullscreenPipeline ( const std::string & vertPath,
const std::string & fragPath )

Creates a Fullscreen Quad Pipeline.

Used for post-processing or upscaling the low-res render to the swapchain.

Parameters
conststd::string& vertPath - Vertex shader path.
conststd::string& fragPath - Fragment shader path.

Definition at line 935 of file Pipeline.cpp.

◆ createGraphicsPipeline()

void vex::VulkanPipeline::createGraphicsPipeline ( const std::string & vertShaderPath,
const std::string & fragShaderPath,
const VkVertexInputBindingDescription & bindingDescription,
const std::vector< VkVertexInputAttributeDescription > & attributeDescriptions )

Creates a standard Opaque Graphics Pipeline.

Compiles shaders, sets up input assembly, viewport, rasterizer (Cull Back), depth stencil (Write/Test), and color blending (Off/Replace).

Parameters
conststd::string& vertShaderPath - Vertex shader path.
conststd::string& fragShaderPath - Fragment shader path.
constVkVertexInputBindingDescription& bindingDescription - Vertex input setup.
conststd::vector<VkVertexInputAttributeDescription>& attributeDescriptions - Vertex attribute setup.

Definition at line 39 of file Pipeline.cpp.

◆ createMaskedPipeline()

void vex::VulkanPipeline::createMaskedPipeline ( const std::string & vertShaderPath,
const std::string & fragShaderPath,
const VkVertexInputBindingDescription & bindingDescription,
const std::vector< VkVertexInputAttributeDescription > & attributeDescriptions )

Creates a Masked Graphics Pipeline (Alpha Cutout).

Similar to Opaque, but typically uses a shader that discards fragments based on alpha.

Parameters
conststd::string& vertShaderPath - Vertex shader path.
conststd::string& fragShaderPath - Fragment shader path.
constVkVertexInputBindingDescription& bindingDescription - Vertex input setup.
conststd::vector<VkVertexInputAttributeDescription>& attributeDescriptions - Vertex attribute setup.

Definition at line 428 of file Pipeline.cpp.

◆ createSpritePipeline()

void vex::VulkanPipeline::createSpritePipeline ( const std::string & vertPath,
const std::string & fragPath,
bool isTransparent,
bool isInstanced )

Creates a Sprite Graphics Pipeline (used for Billboards and Particles).

Configures a pipeline optimized for rendering 2D sprites in a 3D environment. It handles both transparent and masked blending modes, and supports instanced rendering for particles.

Parameters
conststd::string& vertPath - Path to the vertex shader.
conststd::string& fragPath - Path to the fragment shader.
boolisTransparent - If true, enables alpha blending. If false, uses alpha-cutout (masked).
boolisInstanced - If true, sets up the pipeline for instanced rendering (used by particles).

Definition at line 618 of file Pipeline.cpp.

◆ createTransparentPipeline()

void vex::VulkanPipeline::createTransparentPipeline ( const std::string & vertShaderPath,
const std::string & fragShaderPath,
const VkVertexInputBindingDescription & bindingDescription,
const std::vector< VkVertexInputAttributeDescription > & attributeDescriptions )

Creates a Transparent Graphics Pipeline.

Sets up blending (SrcAlpha/OneMinusSrcAlpha) and disables Depth Write (keeps Depth Test).

Parameters
conststd::string& vertShaderPath - Vertex shader path.
conststd::string& fragShaderPath - Fragment shader path.
constVkVertexInputBindingDescription& bindingDescription - Vertex input setup.
conststd::vector<VkVertexInputAttributeDescription>& attributeDescriptions - Vertex attribute setup.

Definition at line 229 of file Pipeline.cpp.

◆ createUIPipeline()

void vex::VulkanPipeline::createUIPipeline ( const std::string & vertShaderPath,
const std::string & fragShaderPath,
const VkVertexInputBindingDescription & bindingDesc,
const std::vector< VkVertexInputAttributeDescription > & attrDesc )

Creates a UI Pipeline.

Sets up blending for UI elements and ignores Depth Test/Write.

Parameters
conststd::string& vertShaderPath - Vertex shader path.
conststd::string& fragShaderPath - Fragment shader path.
constVkVertexInputBindingDescription& bindingDesc - UI vertex layout.
conststd::vector<VkVertexInputAttributeDescription>& attrDesc - UI attributes.

Definition at line 775 of file Pipeline.cpp.

◆ get()

VkPipeline vex::VulkanPipeline::get ( ) const
inline

Returns the VkPipeline handle.

Returns
VkPipeline - The created pipeline.

Definition at line 102 of file Pipeline.hpp.

◆ layout()

VkPipelineLayout vex::VulkanPipeline::layout ( ) const
inline

Returns the VkPipelineLayout handle.

Returns
VkPipelineLayout - The pipeline layout (push constants, descriptor sets).

Definition at line 106 of file Pipeline.hpp.

◆ readFile()

std::vector< char > vex::VulkanPipeline::readFile ( const std::string & filename)
private

Reads a file and returns its contents as a vector of characters.

Parameters
conststd::string& filename - The path to the file to read.
Returns
std::vector<char> - The contents of the file.

Definition at line 19 of file Pipeline.cpp.

◆ updateViewport()

void vex::VulkanPipeline::updateViewport ( glm::uvec2 resolution)

Updates viewport to new resolution.

Since dynamic state is used for Viewport/Scissor, this updates internal resolution state if needed (though mostly handled at draw time via vkCmdSetViewport).

Parameters
glm::uvec2resolution - New resolution.

Definition at line 35 of file Pipeline.cpp.

Member Data Documentation

◆ m_currentRenderResolution

glm::uvec2 vex::VulkanPipeline::m_currentRenderResolution
private

Definition at line 125 of file Pipeline.hpp.

◆ m_layout

VkPipelineLayout vex::VulkanPipeline::m_layout = VK_NULL_HANDLE
private

Definition at line 123 of file Pipeline.hpp.

◆ m_pipeline

VkPipeline vex::VulkanPipeline::m_pipeline = VK_NULL_HANDLE
private

Definition at line 122 of file Pipeline.hpp.

◆ m_r_context

VulkanContext& vex::VulkanPipeline::m_r_context
private

Creates a debug VkPipeline.

Parameters
std::string&vertPath - Path to the vertex shader.
std::string&fragPath - Path to the fragment shader.

Creates a debug pipeline using the provided shader paths and puts some needed data in the context for later use, like layouts.

Definition at line 121 of file Pipeline.hpp.


The documentation for this class was generated from the following files: