luna engine
software engine
Loading...
Searching...
No Matches
luna::vulkan::vulkanPipeline Class Reference

vulkan pipline implementation class. More...

#include <vulkanPipeline.h>

Inheritance diagram for luna::vulkan::vulkanPipeline:
Collaboration diagram for luna::vulkan::vulkanPipeline:

Classes

struct  drawCommand
 
struct  shaderStage
 
struct  Vertex
 
struct  vertexInputDescription
 

Public Member Functions

 vulkanPipeline (const renderer::pipelineLayout &layout)
 creates a vulkan pipeline. More...
 
virtual ~vulkanPipeline ()
 pipeline destructor. More...
 
virtual void createPipeline (const renderer::pipelineLayout &layout) override
 creates the vulkan pipeline. More...
 
virtual void destroyPipeline () override
 destroys the vulkan pipeline. More...
 
virtual void createCommands () override
 creates the renderer commands for the pipeline. More...
 
virtual void begin () override
 starts recording the pipline input. More...
 
virtual void end () const override
 ends recording the pipline input. More...
 
virtual void flush () override
 executes the pipeline commands. More...
 
virtual void bindTextures (const std::vector< uint64_t > textureHandles, const uint64_t indexSet) override
 binds vulkan textures in to there respective textureArrays. More...
 
virtual void clear () override
 clears all the vulkan pipeline draw commands. More...
 
VkRenderPass getRenderPass ()
 return the pipeline renderpass. More...
 
virtual void drawIndexed (const ref< renderer::vertexArray > &vertexArray, std::vector< uint64_t > textures, int indexCount=0) override
 draw a vertexArray indexed. More...
 
- Public Member Functions inherited from luna::renderer::pipeline
virtual ~pipeline ()
 
virtual void createPipeline (const pipelineLayout &layout)=0
 creates graphics a pipeline. More...
 
virtual void destroyPipeline ()=0
 destroys the graphics pipeline. More...
 
virtual void createCommands ()=0
 creates platform specific commands for the rendererPipeline using engine drawCommands. More...
 
virtual void begin ()=0
 starts recording pipeline input. More...
 
virtual void end () const =0
 ends recording end. More...
 
virtual void flush ()=0
 flush the renderer pipline and render a frame. More...
 
virtual void drawIndexed (const ref< vertexArray > &vertexArray, std::vector< uint64_t > textures, int indexCount)=0
 draw vertexBuffer with and indexBuffer. More...
 
virtual void bindTextures (const std::vector< uint64_t > textureHandles, const uint64_t indexSet)=0
 binds textures in to there respective textureArrays. More...
 
virtual void clear ()=0
 clears all drawCommands. More...
 
glm::vec2 getDimensions ()
 
glm::vec2 getWindowMousePos ()
 

Public Attributes

renderer::pipelineLayout layout
 
uint32_t maxFramesInFlight = 0
 
- Public Attributes inherited from luna::renderer::pipeline
int test
 

Private Member Functions

void createPipeLineLayout ()
 creates the pipeline layout. More...
 
VkResult buildPipeline (VkDevice device, VkRenderPass pass)
 build the vulkan pipline. More...
 
void createShaderStages ()
 creates the shader stages to be used in the pipeline. More...
 
void createInputStates ()
 creates the vertex input. More...
 
VkPipelineVertexInputStateCreateInfo createVertexInputState (const ref< renderer::shader > shader)
 creates the vertex input state for a single shader. More...
 
void createBindingDescription (const ref< renderer::shader > shader)
 creates the binding descriptio for a single shader. More...
 
void createAttributeDescription (const ref< renderer::shader > shader)
 creates the attribute description for a single shader. More...
 
VkResult createShaderModule (ref< renderer::shader > shader, VkShaderModule *shaderModule)
 creates a shader module from a shader ref. More...
 
VkFormat getResourceFormat (renderer::typeId resourceType)
 returns the corresponding resource type for a given . More...
 
VkPipelineInputAssemblyStateCreateInfo inputAssemblyCreateInfo (VkPrimitiveTopology topology)
 creates the input Assembly More...
 
VkPipelineRasterizationStateCreateInfo rasterizationStateCreateInfo (VkPolygonMode polygonMode)
 creates the rasterizer state create info. More...
 
VkPipelineMultisampleStateCreateInfo multisamplingStateCreateInfo ()
 creates the multisampling info. More...
 
VkPipelineColorBlendAttachmentState colorBlendAttachmentState ()
 the color blend attachment state(color writemask). More...
 
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo ()
 creates the pipeline layout info. More...
 
void initDefaultRenderpass ()
 initialzes the dafault pipeline renderPass. More...
 
void initSyncStructures ()
 initializes the the pipeline syncronization structures. (VkFence and VkSemaphore) More...
 
void destroySyncStructures ()
 destroys all pipeline sync structures. (VkFence and VkSemaphore) More...
 
void transitionImageLayout (VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout, VkCommandBuffer commandBufffer)
 transitions the image layout. More...
 
void fnDrawIndexed (const ref< renderer::vertexArray > &vertexArray, const uint64_t &descriptorIndex, const std::vector< uint64_t > &textures, const int &indexCount)
 executes draw command. More...
 
VkResult createDescriptorSetLayout ()
 
VkAccessFlags getAccessFlag (VkImageLayout layout)
 
VkPipelineStageFlags getStageFlag (VkImageLayout layout)
 

Private Attributes

ref< renderer::vulkanSamplersampler
 
VkRenderPass renderPass
 
VkRenderPass imGuiRenderPass
 
VkPipelineLayout pipelineLayout
 
VkPipeline pipeline
 
std::vector< VkPipelineShaderStageCreateInfo > shaderStages
 
std::vector< VkShaderModule > shaderModules
 
std::unordered_map< std::string, vertexInputDescriptioninputDescriptions
 
std::vector< VkPipelineVertexInputStateCreateInfo > vertexInputStates
 
VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCreateInfo
 
VkPipelineRasterizationStateCreateInfo pipelineRasterizationStateCreateInfo
 
VkPipelineMultisampleStateCreateInfo pipelineMultisampleStateCreateInfo
 
VkPipelineColorBlendAttachmentState pipelineColorBlendAttachementState
 
std::vector< VkSemaphore > imageAvailableSemaphores
 
std::vector< VkSemaphore > renderFinishedSemaphores
 
std::vector< VkFence > inFlightFences
 
std::vector< VkFence > imagesInFlight
 
ref< vulkanCmdPoolcommandPool = nullptr
 
std::vector< virtualCmdBuffercommandBuffers
 
uint32_t swapchainImageIndex = 0
 
uint32_t currentFrame = 0
 
uint32_t prevFrame = 0
 
VkQueue presentQueue
 
uint64_t _frameNumber = 0
 
bool justResized = false
 
std::vector< drawCommanddrawCommands
 
ref< utils::vulkanDescriptorPooldescriptorPool
 
std::vector< ref< utils::vulkanDescriptorSet > > descriptorSets
 
uint64_t descriptorsetIndex = 1
 

Additional Inherited Members

- Protected Attributes inherited from luna::renderer::pipeline
glm::vec2 windowMousePos
 
glm::vec2 windowDimensions
 

Detailed Description

vulkan pipline implementation class.

See also
renderer::pipeline.

Constructor & Destructor Documentation

◆ vulkanPipeline()

luna::vulkan::vulkanPipeline::vulkanPipeline ( const renderer::pipelineLayout layout)

creates a vulkan pipeline.

Parameters
renderer::pipelineLayoutlayout struct

◆ ~vulkanPipeline()

virtual luna::vulkan::vulkanPipeline::~vulkanPipeline ( )
inlinevirtual

pipeline destructor.

Member Function Documentation

◆ begin()

void luna::vulkan::vulkanPipeline::begin ( )
overridevirtual

starts recording the pipline input.

Implements luna::renderer::pipeline.

◆ bindTextures()

void luna::vulkan::vulkanPipeline::bindTextures ( const std::vector< uint64_t >  textureHandles,
const uint64_t  indexSet 
)
overridevirtual

binds vulkan textures in to there respective textureArrays.

Parameters
textureHandles
indexSet

Implements luna::renderer::pipeline.

◆ buildPipeline()

VkResult luna::vulkan::vulkanPipeline::buildPipeline ( VkDevice  device,
VkRenderPass  pass 
)
private

build the vulkan pipline.

Parameters
VkDevicedevice
VkRenderPasspass
Returns
VK_SUCCES when pipline was succesfully build

◆ clear()

void luna::vulkan::vulkanPipeline::clear ( )
overridevirtual

clears all the vulkan pipeline draw commands.

Implements luna::renderer::pipeline.

◆ colorBlendAttachmentState()

VkPipelineColorBlendAttachmentState luna::vulkan::vulkanPipeline::colorBlendAttachmentState ( )
private

the color blend attachment state(color writemask).

Returns
VkPipelineColorBlendAttachmentState struct
See also
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPipelineColorBlendAttachmentState.html

◆ createAttributeDescription()

void luna::vulkan::vulkanPipeline::createAttributeDescription ( const ref< renderer::shader shader)
private

creates the attribute description for a single shader.

Parameters
ref<renderer::shader>shader reference to a valid shader

◆ createBindingDescription()

void luna::vulkan::vulkanPipeline::createBindingDescription ( const ref< renderer::shader shader)
private

creates the binding descriptio for a single shader.

Parameters
ref<renderer::shader>shader reference to a valid shader

◆ createCommands()

void luna::vulkan::vulkanPipeline::createCommands ( )
overridevirtual

creates the renderer commands for the pipeline.

Implements luna::renderer::pipeline.

◆ createDescriptorSetLayout()

VkResult luna::vulkan::vulkanPipeline::createDescriptorSetLayout ( )
private

◆ createInputStates()

void luna::vulkan::vulkanPipeline::createInputStates ( )
private

creates the vertex input.

◆ createPipeline()

void luna::vulkan::vulkanPipeline::createPipeline ( const renderer::pipelineLayout layout)
overridevirtual

creates the vulkan pipeline.

Parameters
renderer::pipelineLayoutlayout struct

Implements luna::renderer::pipeline.

◆ createPipeLineLayout()

void luna::vulkan::vulkanPipeline::createPipeLineLayout ( )
private

creates the pipeline layout.

◆ createShaderModule()

VkResult luna::vulkan::vulkanPipeline::createShaderModule ( ref< renderer::shader shader,
VkShaderModule *  shaderModule 
)
private

creates a shader module from a shader ref.

Parameters
ref<renderer::shader>shader the source shader
shaderModulepointer to the vulkan shaderModule
Returns
VK_SUCCES when shaderModule was created sucessfully.

◆ createShaderStages()

void luna::vulkan::vulkanPipeline::createShaderStages ( )
private

creates the shader stages to be used in the pipeline.

◆ createVertexInputState()

VkPipelineVertexInputStateCreateInfo luna::vulkan::vulkanPipeline::createVertexInputState ( const ref< renderer::shader shader)
private

creates the vertex input state for a single shader.

Parameters
ref<renderer::shader>shader reference to a valid shader
Returns
VkPipelineVertexInputStateCreateInfo

◆ destroyPipeline()

void luna::vulkan::vulkanPipeline::destroyPipeline ( )
overridevirtual

destroys the vulkan pipeline.

Implements luna::renderer::pipeline.

◆ destroySyncStructures()

void luna::vulkan::vulkanPipeline::destroySyncStructures ( )
private

destroys all pipeline sync structures. (VkFence and VkSemaphore)

◆ drawIndexed()

void luna::vulkan::vulkanPipeline::drawIndexed ( const ref< renderer::vertexArray > &  vertexArray,
std::vector< uint64_t >  textures,
int  indexCount = 0 
)
overridevirtual

draw a vertexArray indexed.

Parameters
constref<renderer::vertexArray>& vertexArray vertexArray to render
intindexCount the indices count to render;
Note
check if the indexCount variable is not zero when the rendered quad does not appear;

◆ end()

void luna::vulkan::vulkanPipeline::end ( ) const
overridevirtual

ends recording the pipline input.

Implements luna::renderer::pipeline.

◆ flush()

void luna::vulkan::vulkanPipeline::flush ( )
overridevirtual

executes the pipeline commands.

Implements luna::renderer::pipeline.

◆ fnDrawIndexed()

void luna::vulkan::vulkanPipeline::fnDrawIndexed ( const ref< renderer::vertexArray > &  vertexArray,
const uint64_t &  descriptorIndex,
const std::vector< uint64_t > &  textures,
const int &  indexCount 
)
private

executes draw command.

◆ getAccessFlag()

VkAccessFlags luna::vulkan::vulkanPipeline::getAccessFlag ( VkImageLayout  layout)
private

◆ getRenderPass()

VkRenderPass luna::vulkan::vulkanPipeline::getRenderPass ( )
inline

return the pipeline renderpass.

◆ getResourceFormat()

VkFormat luna::vulkan::vulkanPipeline::getResourceFormat ( renderer::typeId  resourceType)
private

returns the corresponding resource type for a given .

Parameters
renderer::typeIdresourceType
Returns
VkFormat the corresponding VkFormat for typeId

◆ getStageFlag()

VkPipelineStageFlags luna::vulkan::vulkanPipeline::getStageFlag ( VkImageLayout  layout)
private

◆ initDefaultRenderpass()

void luna::vulkan::vulkanPipeline::initDefaultRenderpass ( )
private

initialzes the dafault pipeline renderPass.

◆ initSyncStructures()

void luna::vulkan::vulkanPipeline::initSyncStructures ( )
private

◆ inputAssemblyCreateInfo()

VkPipelineInputAssemblyStateCreateInfo luna::vulkan::vulkanPipeline::inputAssemblyCreateInfo ( VkPrimitiveTopology  topology)
private

creates the input Assembly

Parameters
topology
Returns

◆ multisamplingStateCreateInfo()

VkPipelineMultisampleStateCreateInfo luna::vulkan::vulkanPipeline::multisamplingStateCreateInfo ( )
private

creates the multisampling info.

Returns
VkPipelineMultisampleStateCreateInfo struct
See also
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPipelineMultisampleStateCreateInfo.html

◆ pipelineLayoutCreateInfo()

VkPipelineLayoutCreateInfo luna::vulkan::vulkanPipeline::pipelineLayoutCreateInfo ( )
private

creates the pipeline layout info.

Returns
VkPipelineLayoutCreateInfo struct
See also
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreatePipelineLayout.html

◆ rasterizationStateCreateInfo()

VkPipelineRasterizationStateCreateInfo luna::vulkan::vulkanPipeline::rasterizationStateCreateInfo ( VkPolygonMode  polygonMode)
private

creates the rasterizer state create info.

Parameters
polygonMode
Returns
VkPipelineRasterizationStateCreateInfo struct
See also
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPipelineRasterizationStateCreateInfo.html

◆ transitionImageLayout()

void luna::vulkan::vulkanPipeline::transitionImageLayout ( VkImage  image,
VkFormat  format,
VkImageLayout  oldLayout,
VkImageLayout  newLayout,
VkCommandBuffer  commandBufffer 
)
private

transitions the image layout.

Parameters
VkImageimage imageHandle
VkFormatformat
VkImageLayoutoldLayout
VkImageLayoutnewLayout
VkCommandBuffercommandBufffer

Member Data Documentation

◆ _frameNumber

uint64_t luna::vulkan::vulkanPipeline::_frameNumber = 0
private

◆ commandBuffers

std::vector<virtualCmdBuffer> luna::vulkan::vulkanPipeline::commandBuffers
private

◆ commandPool

ref<vulkanCmdPool> luna::vulkan::vulkanPipeline::commandPool = nullptr
private

◆ currentFrame

uint32_t luna::vulkan::vulkanPipeline::currentFrame = 0
private

◆ descriptorPool

ref<utils::vulkanDescriptorPool> luna::vulkan::vulkanPipeline::descriptorPool
private

◆ descriptorsetIndex

uint64_t luna::vulkan::vulkanPipeline::descriptorsetIndex = 1
private

◆ descriptorSets

std::vector<ref<utils::vulkanDescriptorSet> > luna::vulkan::vulkanPipeline::descriptorSets
private

◆ drawCommands

std::vector<drawCommand> luna::vulkan::vulkanPipeline::drawCommands
private

◆ imageAvailableSemaphores

std::vector<VkSemaphore> luna::vulkan::vulkanPipeline::imageAvailableSemaphores
private

◆ imagesInFlight

std::vector<VkFence> luna::vulkan::vulkanPipeline::imagesInFlight
private

◆ imGuiRenderPass

VkRenderPass luna::vulkan::vulkanPipeline::imGuiRenderPass
private

◆ inFlightFences

std::vector<VkFence> luna::vulkan::vulkanPipeline::inFlightFences
private

◆ inputAssemblyStateCreateInfo

VkPipelineInputAssemblyStateCreateInfo luna::vulkan::vulkanPipeline::inputAssemblyStateCreateInfo
private

◆ inputDescriptions

std::unordered_map<std::string,vertexInputDescription> luna::vulkan::vulkanPipeline::inputDescriptions
private

◆ justResized

bool luna::vulkan::vulkanPipeline::justResized = false
private

◆ layout

renderer::pipelineLayout luna::vulkan::vulkanPipeline::layout

◆ maxFramesInFlight

uint32_t luna::vulkan::vulkanPipeline::maxFramesInFlight = 0

◆ pipeline

VkPipeline luna::vulkan::vulkanPipeline::pipeline
private

◆ pipelineColorBlendAttachementState

VkPipelineColorBlendAttachmentState luna::vulkan::vulkanPipeline::pipelineColorBlendAttachementState
private

◆ pipelineLayout

VkPipelineLayout luna::vulkan::vulkanPipeline::pipelineLayout
private

◆ pipelineMultisampleStateCreateInfo

VkPipelineMultisampleStateCreateInfo luna::vulkan::vulkanPipeline::pipelineMultisampleStateCreateInfo
private

◆ pipelineRasterizationStateCreateInfo

VkPipelineRasterizationStateCreateInfo luna::vulkan::vulkanPipeline::pipelineRasterizationStateCreateInfo
private

◆ presentQueue

VkQueue luna::vulkan::vulkanPipeline::presentQueue
private

◆ prevFrame

uint32_t luna::vulkan::vulkanPipeline::prevFrame = 0
private

◆ renderFinishedSemaphores

std::vector<VkSemaphore> luna::vulkan::vulkanPipeline::renderFinishedSemaphores
private

◆ renderPass

VkRenderPass luna::vulkan::vulkanPipeline::renderPass
private

◆ sampler

ref<renderer::vulkanSampler> luna::vulkan::vulkanPipeline::sampler
private

◆ shaderModules

std::vector<VkShaderModule> luna::vulkan::vulkanPipeline::shaderModules
private

◆ shaderStages

std::vector<VkPipelineShaderStageCreateInfo> luna::vulkan::vulkanPipeline::shaderStages
private

◆ swapchainImageIndex

uint32_t luna::vulkan::vulkanPipeline::swapchainImageIndex = 0
private

◆ vertexInputStates

std::vector<VkPipelineVertexInputStateCreateInfo> luna::vulkan::vulkanPipeline::vertexInputStates
private

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