Improve pipeline building
This commit is contained in:
@@ -15,12 +15,15 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline VkFormat ToVulkan(ComponentType componentType);
|
||||
inline VkCullModeFlagBits ToVulkan(FaceSide faceSide);
|
||||
inline VkPolygonMode ToVulkan(FaceFilling faceFilling);
|
||||
inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode);
|
||||
inline VkCompareOp ToVulkan(RendererComparison comparison);
|
||||
inline VkShaderStageFlagBits ToVulkan(ShaderStageType stageType);
|
||||
inline VkStencilOp ToVulkan(StencilOperation stencilOp);
|
||||
inline VkVertexInputRate ToVulkan(VertexInputRate inputRate);
|
||||
|
||||
NAZARA_VULKANRENDERER_API String TranslateVulkanError(VkResult code);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,37 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/Utils.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
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)
|
||||
{
|
||||
switch (faceSide)
|
||||
@@ -99,6 +124,18 @@ namespace Nz
|
||||
NazaraError("Unhandled RendererComparison 0x" + String::Number(stencilOp, 16));
|
||||
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>
|
||||
|
||||
@@ -29,10 +29,14 @@ namespace Nz
|
||||
static VkPipelineDynamicStateCreateInfo BuildDynamicStateInfo(const RenderPipelineInfo& pipelineInfo, const std::vector<VkDynamicState>& dynamicStates);
|
||||
static std::vector<VkDynamicState> BuildDynamicStateList(const RenderPipelineInfo& pipelineInfo);
|
||||
static VkPipelineInputAssemblyStateCreateInfo BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo);
|
||||
static VkPipelineMultisampleStateCreateInfo BuildMultisampleInfo(const RenderPipelineInfo& pipelineInfo);
|
||||
static VkPipelineRasterizationStateCreateInfo BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo);
|
||||
static VkPipelineViewportStateCreateInfo BuildViewportInfo(const RenderPipelineInfo& pipelineInfo);
|
||||
static VkStencilOpState BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front);
|
||||
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);
|
||||
|
||||
@@ -40,18 +44,21 @@ namespace Nz
|
||||
{
|
||||
struct StateData
|
||||
{
|
||||
VkPipelineVertexInputStateCreateInfo vertexInputState;
|
||||
VkPipelineInputAssemblyStateCreateInfo inputAssemblyState;
|
||||
VkPipelineViewportStateCreateInfo viewportState;
|
||||
VkPipelineRasterizationStateCreateInfo rasterizationState;
|
||||
VkPipelineDepthStencilStateCreateInfo depthStencilState;
|
||||
VkPipelineColorBlendStateCreateInfo colorBlendState;
|
||||
VkPipelineDepthStencilStateCreateInfo depthStencilState;
|
||||
VkPipelineDynamicStateCreateInfo dynamicState;
|
||||
VkPipelineMultisampleStateCreateInfo multiSampleState;
|
||||
VkPipelineInputAssemblyStateCreateInfo inputAssemblyState;
|
||||
VkPipelineRasterizationStateCreateInfo rasterizationState;
|
||||
VkPipelineVertexInputStateCreateInfo vertexInputState;
|
||||
VkPipelineViewportStateCreateInfo viewportState;
|
||||
};
|
||||
|
||||
std::vector<VkPipelineColorBlendAttachmentState> colorBlendAttachmentState;
|
||||
std::vector<VkDynamicState> dynamicStates;
|
||||
std::vector<VkPipelineShaderStageCreateInfo> shaderStages;
|
||||
std::vector<VkVertexInputAttributeDescription> vertexAttributesDescription;
|
||||
std::vector<VkVertexInputBindingDescription> vertexBindingDescription;
|
||||
std::unique_ptr<StateData> stateData;
|
||||
VkGraphicsPipelineCreateInfo pipelineInfo;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user