Improve pipeline building

This commit is contained in:
Lynix 2020-03-03 22:26:57 +01:00
parent d5c75926c6
commit 7bf734cdd4
16 changed files with 360 additions and 217 deletions

View File

@ -223,8 +223,15 @@ int main()
descriptorSet.WriteUniformDescriptor(0, uniformBufferImpl->GetBufferHandle(), 0, uniformSize); descriptorSet.WriteUniformDescriptor(0, uniformBufferImpl->GetBufferHandle(), 0, uniformSize);
Nz::RenderPipelineInfo pipelineInfo; Nz::RenderPipelineInfo pipelineInfo;
pipelineInfo.shaderStages.emplace_back(fragmentShader);
pipelineInfo.shaderStages.emplace_back(vertexShader);
std::unique_ptr<Nz::RenderPipeline> pipeline = device->InstantiateRenderPipeline(pipelineInfo); auto& vertexBuffer = pipelineInfo.vertexBuffers.emplace_back();
vertexBuffer.binding = 0;
vertexBuffer.declaration = drfreakVB->GetVertexDeclaration();
//std::unique_ptr<Nz::RenderPipeline> pipeline = device->InstantiateRenderPipeline(pipelineInfo);
VkDescriptorSetLayout descriptorSetLayout = descriptorLayout; VkDescriptorSetLayout descriptorSetLayout = descriptorLayout;
@ -241,150 +248,12 @@ int main()
Nz::Vk::PipelineLayout pipelineLayout; Nz::Vk::PipelineLayout pipelineLayout;
pipelineLayout.Create(vulkanDevice.shared_from_this(), layout_create_info); pipelineLayout.Create(vulkanDevice.shared_from_this(), layout_create_info);
Nz::VulkanRenderPipeline::CreateInfo pipelineCreateInfo = Nz::VulkanRenderPipeline::BuildCreateInfo(pipelineInfo);
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStageCreateInfo = { pipelineCreateInfo.pipelineInfo.layout = pipelineLayout;
{ pipelineCreateInfo.pipelineInfo.renderPass = vulkanWindow.GetRenderPass();
{
VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
nullptr,
0,
VK_SHADER_STAGE_VERTEX_BIT,
static_cast<Nz::VulkanShaderStage*>(vertexShader.get())->GetHandle(),
"main",
nullptr
},
{
VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
nullptr,
0,
VK_SHADER_STAGE_FRAGMENT_BIT,
static_cast<Nz::VulkanShaderStage*>(fragmentShader.get())->GetHandle(),
"main",
nullptr
}
}
};
VkVertexInputBindingDescription bindingDescription = {
0,
drfreakVB->GetStride(),
VK_VERTEX_INPUT_RATE_VERTEX
};
std::array<VkVertexInputAttributeDescription, 2> attributeDescription =
{
{
{
0, // uint32_t location
0, // uint32_t binding;
VK_FORMAT_R32G32B32_SFLOAT, // VkFormat format;
0 // uint32_t offset;
},
{
1, // uint32_t location
0, // uint32_t binding;
VK_FORMAT_R32G32B32_SFLOAT, // VkFormat format;
sizeof(float) * 3 // uint32_t offset;
}
}
};
VkPipelineVertexInputStateCreateInfo vertex_input_state_create_info = {
VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType
nullptr, // const void *pNext
0, // VkPipelineVertexInputStateCreateFlags flags;
1, // uint32_t vertexBindingDescriptionCount
&bindingDescription, // const VkVertexInputBindingDescription *pVertexBindingDescriptions
Nz::UInt32(attributeDescription.size()), // uint32_t vertexAttributeDescriptionCount
attributeDescription.data() // const VkVertexInputAttributeDescription *pVertexAttributeDescriptions
};
VkPipelineViewportStateCreateInfo viewport_state_create_info = {
VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType
nullptr, // const void *pNext
0, // VkPipelineViewportStateCreateFlags flags
1, // uint32_t viewportCount
nullptr, // const VkViewport *pViewports
1, // uint32_t scissorCount
nullptr // const VkRect2D *pScissors
};
VkPipelineInputAssemblyStateCreateInfo input_assembly_state_create_info = Nz::VulkanRenderPipeline::BuildInputAssemblyInfo(pipelineInfo);
VkPipelineRasterizationStateCreateInfo rasterization_state_create_info = Nz::VulkanRenderPipeline::BuildRasterizationInfo(pipelineInfo);
VkPipelineDepthStencilStateCreateInfo depthStencilInfo = Nz::VulkanRenderPipeline::BuildDepthStencilInfo(pipelineInfo);
VkPipelineMultisampleStateCreateInfo multisample_state_create_info = {
VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType
nullptr, // const void *pNext
0, // VkPipelineMultisampleStateCreateFlags flags
VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits rasterizationSamples
VK_FALSE, // VkBool32 sampleShadingEnable
1.0f, // float minSampleShading
nullptr, // const VkSampleMask *pSampleMask
VK_FALSE, // VkBool32 alphaToCoverageEnable
VK_FALSE // VkBool32 alphaToOneEnable
};
VkPipelineColorBlendAttachmentState color_blend_attachment_state = {
VK_FALSE, // VkBool32 blendEnable
VK_BLEND_FACTOR_ONE, // VkBlendFactor srcColorBlendFactor
VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstColorBlendFactor
VK_BLEND_OP_ADD, // VkBlendOp colorBlendOp
VK_BLEND_FACTOR_ONE, // VkBlendFactor srcAlphaBlendFactor
VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstAlphaBlendFactor
VK_BLEND_OP_ADD, // VkBlendOp alphaBlendOp
VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | // VkColorComponentFlags colorWriteMask
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT
};
VkPipelineColorBlendStateCreateInfo color_blend_state_create_info = {
VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType
nullptr, // const void *pNext
0, // VkPipelineColorBlendStateCreateFlags flags
VK_FALSE, // VkBool32 logicOpEnable
VK_LOGIC_OP_COPY, // VkLogicOp logicOp
1, // uint32_t attachmentCount
&color_blend_attachment_state, // const VkPipelineColorBlendAttachmentState *pAttachments
{0.0f, 0.0f, 0.0f, 0.0f} // float blendConstants[4]
};
std::array<VkDynamicState, 2> dynamicStates = {
VK_DYNAMIC_STATE_SCISSOR,
VK_DYNAMIC_STATE_VIEWPORT,
};
VkPipelineDynamicStateCreateInfo dynamicStateInfo = {
VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, // VkStructureType sType;
nullptr, // const void* pNext;
0, // VkPipelineDynamicStateCreateFlags flags;
Nz::UInt32(dynamicStates.size()), // uint32_t dynamicStateCount;
dynamicStates.data() // const VkDynamicState* pDynamicStates;
};
VkGraphicsPipelineCreateInfo pipeline_create_info = {
VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType
nullptr, // const void *pNext
0, // VkPipelineCreateFlags flags
static_cast<uint32_t>(shaderStageCreateInfo.size()), // uint32_t stageCount
shaderStageCreateInfo.data(), // const VkPipelineShaderStageCreateInfo *pStages
&vertex_input_state_create_info, // const VkPipelineVertexInputStateCreateInfo *pVertexInputState;
&input_assembly_state_create_info, // const VkPipelineInputAssemblyStateCreateInfo *pInputAssemblyState
nullptr, // const VkPipelineTessellationStateCreateInfo *pTessellationState
&viewport_state_create_info, // const VkPipelineViewportStateCreateInfo *pViewportState
&rasterization_state_create_info, // const VkPipelineRasterizationStateCreateInfo *pRasterizationState
&multisample_state_create_info, // const VkPipelineMultisampleStateCreateInfo *pMultisampleState
&depthStencilInfo, // const VkPipelineDepthStencilStateCreateInfo *pDepthStencilState
&color_blend_state_create_info, // const VkPipelineColorBlendStateCreateInfo *pColorBlendState
&dynamicStateInfo, // const VkPipelineDynamicStateCreateInfo *pDynamicState
pipelineLayout, // VkPipelineLayout layout
vulkanWindow.GetRenderPass(), // VkRenderPass renderPass
0, // uint32_t subpass
VK_NULL_HANDLE, // VkPipeline basePipelineHandle
-1 // int32_t basePipelineIndex
};
Nz::Vk::Pipeline vkPipeline; Nz::Vk::Pipeline vkPipeline;
if (!vkPipeline.CreateGraphics(vulkanDevice.shared_from_this(), pipeline_create_info)) if (!vkPipeline.CreateGraphics(vulkanDevice.shared_from_this(), pipelineCreateInfo.pipelineInfo))
{ {
NazaraError("Failed to create pipeline"); NazaraError("Failed to create pipeline");
return __LINE__; return __LINE__;
@ -501,7 +370,7 @@ int main()
// Gestion de la caméra free-fly (Rotation) // Gestion de la caméra free-fly (Rotation)
float sensitivity = 0.3f; // Sensibilité de la souris float sensitivity = 0.3f; // Sensibilité de la souris
// On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris // On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris
camAngles.yaw = Nz::NormalizeAngle(camAngles.yaw - event.mouseMove.deltaX*sensitivity); camAngles.yaw = Nz::NormalizeAngle(camAngles.yaw - event.mouseMove.deltaX*sensitivity);
// Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles // Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles

View File

@ -3,7 +3,7 @@
#extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable #extension GL_ARB_shading_language_420pack : enable
layout (location = 0) in vec4 inPos; layout (location = 0) in vec3 inPos;
layout (location = 1) in vec3 inColor; layout (location = 1) in vec3 inColor;
layout (binding = 0) uniform UBO layout (binding = 0) uniform UBO
@ -24,5 +24,5 @@ out gl_PerVertex
void main() void main()
{ {
outColor = inColor; outColor = inColor;
gl_Position = ubo.projectionMatrix * ubo.viewMatrix * ubo.modelMatrix * vec4(inPos.xyz, 1.0); gl_Position = ubo.projectionMatrix * ubo.viewMatrix * ubo.modelMatrix * vec4(inPos, 1.0);
} }

View File

@ -30,6 +30,7 @@ namespace Nz
template<typename T> std::size_t CountOf(const T& c); template<typename T> std::size_t CountOf(const T& c);
template<typename T> void HashCombine(std::size_t& seed, const T& v); template<typename T> void HashCombine(std::size_t& seed, const T& v);
template<typename T> T ReverseBits(T integer); template<typename T> T ReverseBits(T integer);
template<typename T> auto UnderlyingCast(T value) -> std::underlying_type_t<T>;
template<typename T> template<typename T>
struct AlwaysFalse : std::false_type {}; struct AlwaysFalse : std::false_type {};

View File

@ -195,6 +195,12 @@ namespace Nz
return reversed; return reversed;
} }
template<typename T>
auto UnderlyingCast(T value) -> std::underlying_type_t<T>
{
return static_cast<std::underlying_type_t<T>>(value);
}
template<typename T> struct PointedType<T*> { using type = T; }; template<typename T> struct PointedType<T*> { using type = T; };
template<typename T> struct PointedType<T* const> { using type = T; }; template<typename T> struct PointedType<T* const> { using type = T; };
template<typename T> struct PointedType<T* volatile> { using type = T; }; template<typename T> struct PointedType<T* volatile> { using type = T; };

View File

@ -9,6 +9,7 @@
#include <Nazara/Prerequisites.hpp> #include <Nazara/Prerequisites.hpp>
#include <Nazara/Utility/Enums.hpp> #include <Nazara/Utility/Enums.hpp>
#include <Nazara/Utility/VertexDeclaration.hpp>
#include <memory> #include <memory>
#include <vector> #include <vector>
@ -36,7 +37,14 @@ namespace Nz
UInt32 writeMask = 0xFFFFFFFF; UInt32 writeMask = 0xFFFFFFFF;
} stencilBack, stencilFront; } stencilBack, stencilFront;
struct VertexBufferData
{
std::size_t binding;
VertexDeclarationConstRef declaration;
};
std::vector<std::shared_ptr<ShaderStageImpl>> shaderStages; std::vector<std::shared_ptr<ShaderStageImpl>> shaderStages;
std::vector<VertexBufferData> vertexBuffers;
bool blending = false; bool blending = false;
bool colorWrite = true; bool colorWrite = true;

View File

@ -53,7 +53,7 @@ namespace Nz
VertexDeclaration& operator=(const VertexDeclaration&) = delete; VertexDeclaration& operator=(const VertexDeclaration&) = delete;
VertexDeclaration& operator=(VertexDeclaration&&) noexcept = default; VertexDeclaration& operator=(VertexDeclaration&&) noexcept = default;
static const VertexDeclarationRef& Get(VertexLayout layout); static inline const VertexDeclarationRef& Get(VertexLayout layout);
static bool IsTypeSupported(ComponentType type); static bool IsTypeSupported(ComponentType type);
template<typename... Args> static VertexDeclarationRef New(Args&&... args); template<typename... Args> static VertexDeclarationRef New(Args&&... args);

View File

@ -67,7 +67,7 @@ namespace Nz
return GetComponentByType<T>(vertexComponent, componentIndex) != nullptr; return GetComponentByType<T>(vertexComponent, componentIndex) != nullptr;
} }
const VertexDeclarationRef& VertexDeclaration::Get(VertexLayout layout) inline const VertexDeclarationRef& VertexDeclaration::Get(VertexLayout layout)
{ {
NazaraAssert(layout <= VertexLayout_Max, "Vertex layout out of enum"); NazaraAssert(layout <= VertexLayout_Max, "Vertex layout out of enum");
@ -84,4 +84,19 @@ namespace Nz
} }
} }
namespace std
{
inline const Nz::VertexDeclaration::Component* begin(const Nz::VertexDeclaration& declaration)
{
assert(declaration.GetComponentCount() != 0);
return &declaration.GetComponent(0);
}
inline const Nz::VertexDeclaration::Component* end(const Nz::VertexDeclaration& declaration)
{
assert(declaration.GetComponentCount() != 0);
return (&declaration.GetComponent(declaration.GetComponentCount() - 1) + 1);
}
}
#include <Nazara/Utility/DebugOff.hpp> #include <Nazara/Utility/DebugOff.hpp>

View File

@ -26,7 +26,7 @@ namespace Nz
VertexMapper(const VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadOnly); VertexMapper(const VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadOnly);
~VertexMapper(); ~VertexMapper();
template<typename T> SparsePtr<T> GetComponentPtr(VertexComponent component); template<typename T> SparsePtr<T> GetComponentPtr(VertexComponent component, std::size_t componentIndex = 0);
inline const VertexBuffer* GetVertexBuffer() const; inline const VertexBuffer* GetVertexBuffer() const;
inline std::size_t GetVertexCount() const; inline std::size_t GetVertexCount() const;

View File

@ -10,19 +10,13 @@
namespace Nz namespace Nz
{ {
template <typename T> template <typename T>
SparsePtr<T> VertexMapper::GetComponentPtr(VertexComponent component) SparsePtr<T> VertexMapper::GetComponentPtr(VertexComponent component, std::size_t componentIndex)
{ {
// On récupère la déclaration depuis le buffer // On récupère la déclaration depuis le buffer
const VertexDeclaration* declaration = m_mapper.GetBuffer()->GetVertexDeclaration(); const VertexDeclaration* declaration = m_mapper.GetBuffer()->GetVertexDeclaration();
// Ensuite le composant qui nous intéresse if (const auto* componentData = declaration->GetComponentByType<T>(component, componentIndex))
bool enabled; return SparsePtr<T>(static_cast<UInt8*>(m_mapper.GetPointer()) + componentData->offset, declaration->GetStride());
ComponentType type;
std::size_t offset;
declaration->GetComponent(component, &enabled, &type, &offset);
if (enabled && GetComponentTypeOf<T>() == type)
return SparsePtr<T>(static_cast<UInt8*>(m_mapper.GetPointer()) + offset, declaration->GetStride());
else else
return SparsePtr<T>(); return SparsePtr<T>();
} }

View File

@ -15,12 +15,15 @@
namespace Nz namespace Nz
{ {
inline VkFormat ToVulkan(ComponentType componentType);
inline VkCullModeFlagBits ToVulkan(FaceSide faceSide); inline VkCullModeFlagBits ToVulkan(FaceSide faceSide);
inline VkPolygonMode ToVulkan(FaceFilling faceFilling); inline VkPolygonMode ToVulkan(FaceFilling faceFilling);
inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode); inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode);
inline VkCompareOp ToVulkan(RendererComparison comparison); inline VkCompareOp ToVulkan(RendererComparison comparison);
inline VkShaderStageFlagBits ToVulkan(ShaderStageType stageType); inline VkShaderStageFlagBits ToVulkan(ShaderStageType stageType);
inline VkStencilOp ToVulkan(StencilOperation stencilOp); inline VkStencilOp ToVulkan(StencilOperation stencilOp);
inline VkVertexInputRate ToVulkan(VertexInputRate inputRate);
NAZARA_VULKANRENDERER_API String TranslateVulkanError(VkResult code); NAZARA_VULKANRENDERER_API String TranslateVulkanError(VkResult code);
} }

View File

@ -3,12 +3,37 @@
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/VulkanRenderer/Utils.hpp> #include <Nazara/VulkanRenderer/Utils.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
#include <Nazara/Core/String.hpp> #include <Nazara/Core/String.hpp>
#include <Nazara/VulkanRenderer/Debug.hpp> #include <Nazara/VulkanRenderer/Debug.hpp>
namespace Nz namespace Nz
{ {
VkFormat ToVulkan(ComponentType componentType)
{
switch (componentType)
{
case ComponentType_Color: return VK_FORMAT_R8G8B8A8_UINT;
case ComponentType_Double1: return VK_FORMAT_R64_SFLOAT;
case ComponentType_Double2: return VK_FORMAT_R64G64_SFLOAT;
case ComponentType_Double3: return VK_FORMAT_R64G64B64_SFLOAT;
case ComponentType_Double4: return VK_FORMAT_R64G64B64A64_SFLOAT;
case ComponentType_Float1: return VK_FORMAT_R32_SFLOAT;
case ComponentType_Float2: return VK_FORMAT_R32G32_SFLOAT;
case ComponentType_Float3: return VK_FORMAT_R32G32B32_SFLOAT;
case ComponentType_Float4: return VK_FORMAT_R32G32B32A32_SFLOAT;
case ComponentType_Int1: return VK_FORMAT_R32_SINT;
case ComponentType_Int2: return VK_FORMAT_R32G32_SINT;
case ComponentType_Int3: return VK_FORMAT_R32G32B32_SINT;
case ComponentType_Int4: return VK_FORMAT_R32G32B32A32_SINT;
case ComponentType_Quaternion: return VK_FORMAT_R32G32B32A32_SFLOAT;
}
NazaraError("Unhandled ComponentType 0x" + String::Number(componentType, 16));
return VK_FORMAT_UNDEFINED;
}
VkCullModeFlagBits ToVulkan(FaceSide faceSide) VkCullModeFlagBits ToVulkan(FaceSide faceSide)
{ {
switch (faceSide) switch (faceSide)
@ -99,6 +124,18 @@ namespace Nz
NazaraError("Unhandled RendererComparison 0x" + String::Number(stencilOp, 16)); NazaraError("Unhandled RendererComparison 0x" + String::Number(stencilOp, 16));
return VK_STENCIL_OP_KEEP; return VK_STENCIL_OP_KEEP;
} }
VkVertexInputRate ToVulkan(VertexInputRate inputRate)
{
switch (inputRate)
{
case VertexInputRate::Instance: return VK_VERTEX_INPUT_RATE_INSTANCE;
case VertexInputRate::Vertex: return VK_VERTEX_INPUT_RATE_VERTEX;
}
NazaraError("Unhandled VertexInputRate 0x" + String::Number(UnderlyingCast(inputRate), 16));
return VK_VERTEX_INPUT_RATE_VERTEX;
}
} }
#include <Nazara/VulkanRenderer/DebugOff.hpp> #include <Nazara/VulkanRenderer/DebugOff.hpp>

View File

@ -29,10 +29,14 @@ namespace Nz
static VkPipelineDynamicStateCreateInfo BuildDynamicStateInfo(const RenderPipelineInfo& pipelineInfo, const std::vector<VkDynamicState>& dynamicStates); static VkPipelineDynamicStateCreateInfo BuildDynamicStateInfo(const RenderPipelineInfo& pipelineInfo, const std::vector<VkDynamicState>& dynamicStates);
static std::vector<VkDynamicState> BuildDynamicStateList(const RenderPipelineInfo& pipelineInfo); static std::vector<VkDynamicState> BuildDynamicStateList(const RenderPipelineInfo& pipelineInfo);
static VkPipelineInputAssemblyStateCreateInfo BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo); static VkPipelineInputAssemblyStateCreateInfo BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo);
static VkPipelineMultisampleStateCreateInfo BuildMultisampleInfo(const RenderPipelineInfo& pipelineInfo);
static VkPipelineRasterizationStateCreateInfo BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo); static VkPipelineRasterizationStateCreateInfo BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo);
static VkPipelineViewportStateCreateInfo BuildViewportInfo(const RenderPipelineInfo& pipelineInfo); static VkPipelineViewportStateCreateInfo BuildViewportInfo(const RenderPipelineInfo& pipelineInfo);
static VkStencilOpState BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front); static VkStencilOpState BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front);
static std::vector<VkPipelineShaderStageCreateInfo> BuildShaderStageInfo(const RenderPipelineInfo& pipelineInfo); static std::vector<VkPipelineShaderStageCreateInfo> BuildShaderStageInfo(const RenderPipelineInfo& pipelineInfo);
static std::vector<VkVertexInputAttributeDescription> BuildVertexAttributeDescription(const RenderPipelineInfo& pipelineInfo);
static std::vector<VkVertexInputBindingDescription> BuildVertexBindingDescription(const RenderPipelineInfo& pipelineInfo);
static VkPipelineVertexInputStateCreateInfo BuildVertexInputInfo(const RenderPipelineInfo& pipelineInfo, const std::vector<VkVertexInputAttributeDescription>& vertexAttributes, const std::vector<VkVertexInputBindingDescription>& bindingDescription);
static CreateInfo BuildCreateInfo(const RenderPipelineInfo& pipelineInfo); static CreateInfo BuildCreateInfo(const RenderPipelineInfo& pipelineInfo);
@ -40,18 +44,21 @@ namespace Nz
{ {
struct StateData struct StateData
{ {
VkPipelineVertexInputStateCreateInfo vertexInputState;
VkPipelineInputAssemblyStateCreateInfo inputAssemblyState;
VkPipelineViewportStateCreateInfo viewportState;
VkPipelineRasterizationStateCreateInfo rasterizationState;
VkPipelineDepthStencilStateCreateInfo depthStencilState;
VkPipelineColorBlendStateCreateInfo colorBlendState; VkPipelineColorBlendStateCreateInfo colorBlendState;
VkPipelineDepthStencilStateCreateInfo depthStencilState;
VkPipelineDynamicStateCreateInfo dynamicState; VkPipelineDynamicStateCreateInfo dynamicState;
VkPipelineMultisampleStateCreateInfo multiSampleState;
VkPipelineInputAssemblyStateCreateInfo inputAssemblyState;
VkPipelineRasterizationStateCreateInfo rasterizationState;
VkPipelineVertexInputStateCreateInfo vertexInputState;
VkPipelineViewportStateCreateInfo viewportState;
}; };
std::vector<VkPipelineColorBlendAttachmentState> colorBlendAttachmentState; std::vector<VkPipelineColorBlendAttachmentState> colorBlendAttachmentState;
std::vector<VkDynamicState> dynamicStates; std::vector<VkDynamicState> dynamicStates;
std::vector<VkPipelineShaderStageCreateInfo> shaderStages; std::vector<VkPipelineShaderStageCreateInfo> shaderStages;
std::vector<VkVertexInputAttributeDescription> vertexAttributesDescription;
std::vector<VkVertexInputBindingDescription> vertexBindingDescription;
std::unique_ptr<StateData> stateData; std::unique_ptr<StateData> stateData;
VkGraphicsPipelineCreateInfo pipelineInfo; VkGraphicsPipelineCreateInfo pipelineInfo;
}; };

View File

@ -106,86 +106,216 @@ namespace Nz
}); });
NazaraAssert(s_declarations[VertexLayout_XY_Color]->GetStride() == sizeof(VertexStruct_XY_Color), "Invalid stride for declaration VertexLayout_XY_Color"); NazaraAssert(s_declarations[VertexLayout_XY_Color]->GetStride() == sizeof(VertexStruct_XY_Color), "Invalid stride for declaration VertexLayout_XY_Color");
/*
// VertexLayout_XY_UV : VertexStruct_XY_UV // VertexLayout_XY_UV : VertexStruct_XY_UV
declaration = &s_declarations[VertexLayout_XY_UV]; s_declarations[VertexLayout_XY_UV] = NewDeclaration(VertexInputRate::Vertex, {
declaration->EnableComponent(VertexComponent_Position, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XY_UV, position)); {
declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XY_UV, uv)); VertexComponent_Position,
ComponentType_Float2,
0
},
{
VertexComponent_TexCoord,
ComponentType_Float2,
0
},
});
NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XY_UV), "Invalid stride for declaration VertexLayout_XY_UV"); NazaraAssert(s_declarations[VertexLayout_XY_UV]->GetStride() == sizeof(VertexStruct_XY_UV), "Invalid stride for declaration VertexLayout_XY_UV");
// VertexLayout_XYZ : VertexStruct_XYZ // VertexLayout_XYZ : VertexStruct_XYZ
declaration = &s_declarations[VertexLayout_XYZ]; s_declarations[VertexLayout_XYZ] = NewDeclaration(VertexInputRate::Vertex, {
declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ, position)); {
VertexComponent_Position,
ComponentType_Float3,
0
},
});
NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ), "Invalid stride for declaration VertexLayout_XYZ"); NazaraAssert(s_declarations[VertexLayout_XYZ]->GetStride() == sizeof(VertexStruct_XYZ), "Invalid stride for declaration VertexLayout_XYZ");
// VertexLayout_XYZ_Color : VertexStruct_XYZ_Color // VertexLayout_XYZ_Color : VertexStruct_XYZ_Color
declaration = &s_declarations[VertexLayout_XYZ_Color]; s_declarations[VertexLayout_XYZ_Color] = NewDeclaration(VertexInputRate::Vertex, {
declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Color, position)); {
declaration->EnableComponent(VertexComponent_Color, ComponentType_Color, NazaraOffsetOf(VertexStruct_XYZ_Color, color)); VertexComponent_Position,
ComponentType_Float3,
0
},
{
VertexComponent_Color,
ComponentType_Color,
0
}
});
NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Color), "Invalid stride for declaration VertexLayout_XYZ_Color"); NazaraAssert(s_declarations[VertexLayout_XYZ_Color]->GetStride() == sizeof(VertexStruct_XYZ_Color), "Invalid stride for declaration VertexLayout_XYZ_Color");
// VertexLayout_XYZ_Color_UV : VertexStruct_XYZ_Color_UV // VertexLayout_XYZ_Color_UV : VertexStruct_XYZ_Color_UV
declaration = &s_declarations[VertexLayout_XYZ_Color_UV]; s_declarations[VertexLayout_XYZ_Color_UV] = NewDeclaration(VertexInputRate::Vertex, {
declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Color_UV, position)); {
declaration->EnableComponent(VertexComponent_Color, ComponentType_Color, NazaraOffsetOf(VertexStruct_XYZ_Color_UV, color)); VertexComponent_Position,
declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XYZ_Color_UV, uv)); ComponentType_Float3,
0
},
{
VertexComponent_Color,
ComponentType_Color,
0
},
{
VertexComponent_TexCoord,
ComponentType_Float2,
0
},
});
NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Color_UV), "Invalid stride for declaration VertexLayout_XYZ_Color_UV"); NazaraAssert(s_declarations[VertexLayout_XYZ_Color_UV]->GetStride() == sizeof(VertexStruct_XYZ_Color_UV), "Invalid stride for declaration VertexLayout_XYZ_Color_UV");
// VertexLayout_XYZ_Normal : VertexStruct_XYZ_Normal // VertexLayout_XYZ_Normal : VertexStruct_XYZ_Normal
declaration = &s_declarations[VertexLayout_XYZ_Normal]; s_declarations[VertexLayout_XYZ_Normal] = NewDeclaration(VertexInputRate::Vertex, {
declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal, position)); {
declaration->EnableComponent(VertexComponent_Normal, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal, normal)); VertexComponent_Position,
ComponentType_Float3,
0
},
{
VertexComponent_Normal,
ComponentType_Float3,
0
}
});
NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Normal), "Invalid stride for declaration VertexLayout_XYZ_Normal"); NazaraAssert(s_declarations[VertexLayout_XYZ_Normal]->GetStride() == sizeof(VertexStruct_XYZ_Normal), "Invalid stride for declaration VertexLayout_XYZ_Normal");
// VertexLayout_XYZ_Normal_UV : VertexStruct_XYZ_Normal_UV // VertexLayout_XYZ_Normal_UV : VertexStruct_XYZ_Normal_UV
declaration = &s_declarations[VertexLayout_XYZ_Normal_UV]; s_declarations[VertexLayout_XYZ_Normal_UV] = NewDeclaration(VertexInputRate::Vertex, {
declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV, position)); {
declaration->EnableComponent(VertexComponent_Normal, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV, normal)); VertexComponent_Position,
declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV, uv)); ComponentType_Float3,
0
},
{
VertexComponent_Normal,
ComponentType_Float3,
0
},
{
VertexComponent_TexCoord,
ComponentType_Float2,
0
}
});
NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Normal_UV), "Invalid stride for declaration VertexLayout_XYZ_Normal_UV"); NazaraAssert(s_declarations[VertexLayout_XYZ_Normal_UV]->GetStride() == sizeof(VertexStruct_XYZ_Normal_UV), "Invalid stride for declaration VertexLayout_XYZ_Normal_UV");
// VertexLayout_XYZ_Normal_UV_Tangent : VertexStruct_XYZ_Normal_UV_Tangent // VertexLayout_XYZ_Normal_UV_Tangent : VertexStruct_XYZ_Normal_UV_Tangent
declaration = &s_declarations[VertexLayout_XYZ_Normal_UV_Tangent]; s_declarations[VertexLayout_XYZ_Normal_UV_Tangent] = NewDeclaration(VertexInputRate::Vertex, {
declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent, position)); {
declaration->EnableComponent(VertexComponent_Normal, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent, normal)); VertexComponent_Position,
declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent, uv)); ComponentType_Float3,
declaration->EnableComponent(VertexComponent_Tangent, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent, tangent)); 0
},
{
VertexComponent_Normal,
ComponentType_Float3,
0
},
{
VertexComponent_TexCoord,
ComponentType_Float2,
0
},
{
VertexComponent_Tangent,
ComponentType_Float3,
0
}
});
NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Normal_UV_Tangent), "Invalid stride for declaration VertexLayout_XYZ_Normal_UV_Tangent"); NazaraAssert(s_declarations[VertexLayout_XYZ_Normal_UV_Tangent]->GetStride() == sizeof(VertexStruct_XYZ_Normal_UV_Tangent), "Invalid stride for declaration VertexLayout_XYZ_Normal_UV_Tangent");
// VertexLayout_XYZ_Normal_UV_Tangent_Skinning : VertexStruct_XYZ_Normal_UV_Tangent_Skinning // VertexLayout_XYZ_Normal_UV_Tangent_Skinning : VertexStruct_XYZ_Normal_UV_Tangent_Skinning
declaration = &s_declarations[VertexLayout_XYZ_Normal_UV_Tangent_Skinning]; s_declarations[VertexLayout_XYZ_Normal_UV_Tangent_Skinning] = NewDeclaration(VertexInputRate::Vertex, {
declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, position)); {
declaration->EnableComponent(VertexComponent_Normal, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, normal)); VertexComponent_Position,
declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, uv)); ComponentType_Float3,
declaration->EnableComponent(VertexComponent_Tangent, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, tangent)); 0
declaration->EnableComponent(VertexComponent_Unused, ComponentType_Int1, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, weightCount)); },
declaration->EnableComponent(VertexComponent_Userdata0, ComponentType_Float4, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, weights)); {
declaration->EnableComponent(VertexComponent_Userdata1, ComponentType_Int4, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, jointIndexes)); VertexComponent_Normal,
ComponentType_Float3,
0
},
{
VertexComponent_TexCoord,
ComponentType_Float2,
0
},
{
VertexComponent_Tangent,
ComponentType_Float3,
0
},
{
VertexComponent_Userdata,
ComponentType_Int1,
0 // Weight count
},
{
VertexComponent_Userdata,
ComponentType_Float4,
1 // Weights
},
{
VertexComponent_Userdata,
ComponentType_Int4,
2 // Joint indexes
},
});
NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Normal_UV_Tangent_Skinning), "Invalid stride for declaration VertexLayout_XYZ_Normal_UV_Tangent_Skinning"); NazaraAssert(s_declarations[VertexLayout_XYZ_Normal_UV_Tangent_Skinning]->GetStride() == sizeof(VertexStruct_XYZ_Normal_UV_Tangent_Skinning), "Invalid stride for declaration VertexLayout_XYZ_Normal_UV_Tangent_Skinning");
// VertexLayout_XYZ_UV : VertexStruct_XYZ_UV // VertexLayout_XYZ_UV : VertexStruct_XYZ_UV
declaration = &s_declarations[VertexLayout_XYZ_UV]; s_declarations[VertexLayout_XYZ_UV] = NewDeclaration(VertexInputRate::Vertex, {
declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_UV, position)); {
declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XYZ_UV, uv)); VertexComponent_Position,
ComponentType_Float3,
0
},
{
VertexComponent_TexCoord,
ComponentType_Float2,
0
}
});
NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_UV), "Invalid stride for declaration VertexLayout_XYZ_UV"); NazaraAssert(s_declarations[VertexLayout_XYZ_UV]->GetStride() == sizeof(VertexStruct_XYZ_UV), "Invalid stride for declaration VertexLayout_XYZ_UV");
// VertexLayout_Matrix4 : Matrix4f // VertexLayout_Matrix4 : Matrix4f
declaration = &s_declarations[VertexLayout_Matrix4]; s_declarations[VertexLayout_Matrix4] = NewDeclaration(VertexInputRate::Vertex, {
declaration->EnableComponent(VertexComponent_InstanceData0, ComponentType_Float4, NazaraOffsetOf(Matrix4f, m11)); {
declaration->EnableComponent(VertexComponent_InstanceData1, ComponentType_Float4, NazaraOffsetOf(Matrix4f, m21)); VertexComponent_Userdata,
declaration->EnableComponent(VertexComponent_InstanceData2, ComponentType_Float4, NazaraOffsetOf(Matrix4f, m31)); ComponentType_Float4,
declaration->EnableComponent(VertexComponent_InstanceData3, ComponentType_Float4, NazaraOffsetOf(Matrix4f, m41)); 0
},
{
VertexComponent_Userdata,
ComponentType_Float4,
1
},
{
VertexComponent_Userdata,
ComponentType_Float4,
2
},
{
VertexComponent_Userdata,
ComponentType_Float4,
3
}
});
NazaraAssert(declaration->GetStride() == sizeof(Matrix4f), "Invalid stride for declaration VertexLayout_Matrix4");*/ NazaraAssert(s_declarations[VertexLayout_Matrix4]->GetStride() == sizeof(Matrix4f), "Invalid stride for declaration VertexLayout_Matrix4");
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {

View File

@ -7,6 +7,7 @@
#include <Nazara/VulkanRenderer/VulkanShaderStage.hpp> #include <Nazara/VulkanRenderer/VulkanShaderStage.hpp>
#include <Nazara/VulkanRenderer/Utils.hpp> #include <Nazara/VulkanRenderer/Utils.hpp>
#include <cassert> #include <cassert>
#include <iostream>
#include <Nazara/VulkanRenderer/Debug.hpp> #include <Nazara/VulkanRenderer/Debug.hpp>
namespace Nz namespace Nz
@ -21,7 +22,7 @@ namespace Nz
{ {
std::vector<VkPipelineColorBlendAttachmentState> colorBlendStates; std::vector<VkPipelineColorBlendAttachmentState> colorBlendStates;
VkPipelineColorBlendAttachmentState colorBlendState = colorBlendStates.emplace_back(); VkPipelineColorBlendAttachmentState& colorBlendState = colorBlendStates.emplace_back();
colorBlendState.blendEnable = pipelineInfo.blending; colorBlendState.blendEnable = pipelineInfo.blending;
colorBlendState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; //< TODO colorBlendState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; //< TODO
@ -94,6 +95,16 @@ namespace Nz
return createInfo; return createInfo;
} }
VkPipelineMultisampleStateCreateInfo VulkanRenderPipeline::BuildMultisampleInfo(const RenderPipelineInfo& pipelineInfo)
{
VkPipelineMultisampleStateCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
createInfo.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
createInfo.minSampleShading = 1.0f; //< TODO: Remove
return createInfo;
}
VkPipelineRasterizationStateCreateInfo VulkanRenderPipeline::BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo) VkPipelineRasterizationStateCreateInfo VulkanRenderPipeline::BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo)
{ {
VkPipelineRasterizationStateCreateInfo createInfo = {}; VkPipelineRasterizationStateCreateInfo createInfo = {};
@ -149,6 +160,58 @@ namespace Nz
return shaderStageCreateInfos; return shaderStageCreateInfos;
} }
std::vector<VkVertexInputAttributeDescription> VulkanRenderPipeline::BuildVertexAttributeDescription(const RenderPipelineInfo& pipelineInfo)
{
std::vector<VkVertexInputAttributeDescription> vertexAttributes;
std::uint32_t locationIndex = 0;
for (const auto& bufferData : pipelineInfo.vertexBuffers)
{
std::uint32_t binding = std::uint32_t(bufferData.binding);
for (const auto& componentInfo : *bufferData.declaration)
{
auto& bufferAttribute = vertexAttributes.emplace_back();
bufferAttribute.binding = binding;
bufferAttribute.location = locationIndex++;
bufferAttribute.offset = std::uint32_t(componentInfo.offset);
bufferAttribute.format = ToVulkan(componentInfo.type);
}
}
return vertexAttributes;
}
std::vector<VkVertexInputBindingDescription> VulkanRenderPipeline::BuildVertexBindingDescription(const RenderPipelineInfo& pipelineInfo)
{
std::vector<VkVertexInputBindingDescription> vertexBindings;
for (const auto& bufferData : pipelineInfo.vertexBuffers)
{
auto& bufferBinding = vertexBindings.emplace_back();
bufferBinding.binding = std::uint32_t(bufferData.binding);
bufferBinding.stride = std::uint32_t(bufferData.declaration->GetStride());
bufferBinding.inputRate = ToVulkan(bufferData.declaration->GetInputRate());
}
return vertexBindings;
}
VkPipelineVertexInputStateCreateInfo VulkanRenderPipeline::BuildVertexInputInfo(const RenderPipelineInfo& pipelineInfo, const std::vector<VkVertexInputAttributeDescription>& vertexAttributes, const std::vector<VkVertexInputBindingDescription>& bindingDescriptions)
{
VkPipelineVertexInputStateCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
createInfo.vertexAttributeDescriptionCount = std::uint32_t(vertexAttributes.size());
createInfo.pVertexAttributeDescriptions = vertexAttributes.data();
createInfo.vertexBindingDescriptionCount = std::uint32_t(bindingDescriptions.size());
createInfo.pVertexBindingDescriptions = bindingDescriptions.data();
return createInfo;
}
auto VulkanRenderPipeline::BuildCreateInfo(const RenderPipelineInfo& pipelineInfo) -> CreateInfo auto VulkanRenderPipeline::BuildCreateInfo(const RenderPipelineInfo& pipelineInfo) -> CreateInfo
{ {
CreateInfo createInfo = {}; CreateInfo createInfo = {};
@ -157,20 +220,30 @@ namespace Nz
createInfo.colorBlendAttachmentState = BuildColorBlendAttachmentStateList(pipelineInfo); createInfo.colorBlendAttachmentState = BuildColorBlendAttachmentStateList(pipelineInfo);
createInfo.dynamicStates = BuildDynamicStateList(pipelineInfo); createInfo.dynamicStates = BuildDynamicStateList(pipelineInfo);
createInfo.shaderStages = BuildShaderStageInfo(pipelineInfo); createInfo.shaderStages = BuildShaderStageInfo(pipelineInfo);
createInfo.vertexAttributesDescription = BuildVertexAttributeDescription(pipelineInfo);
createInfo.vertexBindingDescription = BuildVertexBindingDescription(pipelineInfo);
createInfo.stateData->colorBlendState = BuildColorBlendInfo(pipelineInfo, createInfo.colorBlendAttachmentState); createInfo.stateData->colorBlendState = BuildColorBlendInfo(pipelineInfo, createInfo.colorBlendAttachmentState);
createInfo.stateData->depthStencilState = BuildDepthStencilInfo(pipelineInfo); createInfo.stateData->depthStencilState = BuildDepthStencilInfo(pipelineInfo);
createInfo.stateData->dynamicState = BuildDynamicStateInfo(pipelineInfo, createInfo.dynamicStates); createInfo.stateData->dynamicState = BuildDynamicStateInfo(pipelineInfo, createInfo.dynamicStates);
createInfo.stateData->inputAssemblyState = BuildInputAssemblyInfo(pipelineInfo); createInfo.stateData->inputAssemblyState = BuildInputAssemblyInfo(pipelineInfo);
createInfo.stateData->multiSampleState = BuildMultisampleInfo(pipelineInfo);
createInfo.stateData->rasterizationState = BuildRasterizationInfo(pipelineInfo); createInfo.stateData->rasterizationState = BuildRasterizationInfo(pipelineInfo);
createInfo.stateData->viewportState = BuildViewportInfo(pipelineInfo); createInfo.stateData->viewportState = BuildViewportInfo(pipelineInfo);
createInfo.stateData->vertexInputState = BuildVertexInputInfo(pipelineInfo, createInfo.vertexAttributesDescription, createInfo.vertexBindingDescription);
createInfo.pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; createInfo.pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
createInfo.pipelineInfo.stageCount = std::uint32_t(createInfo.shaderStages.size()); createInfo.pipelineInfo.stageCount = std::uint32_t(createInfo.shaderStages.size());
createInfo.pipelineInfo.pStages = createInfo.shaderStages.data(); createInfo.pipelineInfo.pStages = createInfo.shaderStages.data();
createInfo.pipelineInfo.pColorBlendState = createInfo.colorBlendAttachmentState.data(); createInfo.pipelineInfo.pColorBlendState = &createInfo.stateData->colorBlendState;
createInfo.pipelineInfo. createInfo.pipelineInfo.pDepthStencilState = &createInfo.stateData->depthStencilState;
createInfo.pipelineInfo.pDynamicState = &createInfo.stateData->dynamicState;
createInfo.pipelineInfo.pInputAssemblyState = &createInfo.stateData->inputAssemblyState;
createInfo.pipelineInfo.pMultisampleState = &createInfo.stateData->multiSampleState;
createInfo.pipelineInfo.pRasterizationState = &createInfo.stateData->rasterizationState;
createInfo.pipelineInfo.pVertexInputState = &createInfo.stateData->vertexInputState;
createInfo.pipelineInfo.pViewportState = &createInfo.stateData->viewportState;
return createInfo; return createInfo;
} }