#define GLM_FORCE_RADIANS #include #include #include #include #include #include #include #include #include #include "Config.hpp" #include "Core/CameraModel.hpp" #include "Core/CgContext.hpp" #include "Core/CoreInitException.hpp" #include "Core/Model/AssimpModel.hpp" #include "Core/Model/Object.hpp" #include "Core/Model/SceneDescription.hpp" #include "Util/Logging.hpp" #include "Util/NameList.hpp" #include "Util/PredefinedMeshes.hpp" #include "Util/Utils.hpp" #include "VkUtil/VkUtil.hpp" #include "glm/glm.hpp" #include "glm/gtc/matrix_transform.hpp" #include "imgui_impl_vulkan.h" #include "imgui_impl_glfw.h" using lib::log::Log; using lib::log::LogDebug; using lib::log::LogError; using lib::log::LogWarning; bool lib::CgContext::TryCreateRasterizerPipeline() { auto success = true; auto vertexModule = this->LoadShader(this->appInfo.shaderTable.postProcessingVertexShader); success = success && vertexModule; auto fragmentModule = this->LoadShader(this->appInfo.shaderTable.postProcessingFragmentShader); success = success && vertexModule; if (success) { std::vector shaderStages{ vk::PipelineShaderStageCreateInfo{ vk::PipelineShaderStageCreateFlags{}, vk::ShaderStageFlagBits::eVertex, vertexModule, "main", }, vk::PipelineShaderStageCreateInfo{ vk::PipelineShaderStageCreateFlags{}, vk::ShaderStageFlagBits::eFragment, fragmentModule, "main", }, }; vk::PipelineVertexInputStateCreateInfo emptyInputCreateInfo; vk::PipelineInputAssemblyStateCreateInfo inputAssemblyCreateInfo; inputAssemblyCreateInfo.topology = vk::PrimitiveTopology::eTriangleList; inputAssemblyCreateInfo.primitiveRestartEnable = false; vk::Viewport viewport; viewport.width = static_cast(this->swapChainExtent.width); viewport.height = static_cast(this->swapChainExtent.height); viewport.minDepth = 0.f; viewport.maxDepth = 1.f; vk::Rect2D scissor; scissor.extent = this->swapChainExtent; vk::PipelineViewportStateCreateInfo viewportStateCreateInfo; viewportStateCreateInfo.viewportCount = 1; viewportStateCreateInfo.pViewports = &viewport; viewportStateCreateInfo.scissorCount = 1; viewportStateCreateInfo.pScissors = &scissor; vk::PipelineRasterizationStateCreateInfo rasterizationStateCreateInfo; rasterizationStateCreateInfo.cullMode = vk::CullModeFlagBits::eFront; rasterizationStateCreateInfo.frontFace = vk::FrontFace::eCounterClockwise; rasterizationStateCreateInfo.lineWidth = 1.f; rasterizationStateCreateInfo.polygonMode = vk::PolygonMode::eFill; vk::PipelineMultisampleStateCreateInfo multiSampleStageCreateInfo; multiSampleStageCreateInfo.sampleShadingEnable = false; multiSampleStageCreateInfo.rasterizationSamples = vk::SampleCountFlagBits::e1; vk::PipelineColorBlendAttachmentState colorBlendAttachmentState; colorBlendAttachmentState.colorWriteMask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA; colorBlendAttachmentState.blendEnable = false; vk::PipelineColorBlendStateCreateInfo colorBlendStateCreateInfo; colorBlendStateCreateInfo.logicOpEnable = false; colorBlendStateCreateInfo.logicOp = vk::LogicOp::eCopy; colorBlendStateCreateInfo.attachmentCount = 1; colorBlendStateCreateInfo.pAttachments = &colorBlendAttachmentState; vk::PipelineLayoutCreateInfo layoutCreateInfo; layoutCreateInfo.setLayoutCount = 1; layoutCreateInfo.pSetLayouts = &this->rasterizationStep.descriptorSetLayout; this->rasterizationStep.pipelineLayout = this->logicalDevice.createPipelineLayout(layoutCreateInfo); vk::GraphicsPipelineCreateInfo createInfo; createInfo.stageCount = static_cast(shaderStages.size()); createInfo.pStages = shaderStages.data(); createInfo.pVertexInputState = &emptyInputCreateInfo; createInfo.pInputAssemblyState = &inputAssemblyCreateInfo; createInfo.pViewportState = &viewportStateCreateInfo; createInfo.pRasterizationState = &rasterizationStateCreateInfo; createInfo.pMultisampleState = &multiSampleStageCreateInfo; createInfo.pColorBlendState = &colorBlendStateCreateInfo; createInfo.layout = this->rasterizationStep.pipelineLayout; this->rasterizationStep.pipeline = this->logicalDevice.createGraphicsPipeline(nullptr, createInfo); } if (vertexModule) { this->logicalDevice.destroyShaderModule(vertexModule); } if (fragmentModule) { this->logicalDevice.destroyShaderModule(fragmentModule); } return success; } void lib::CgContext::CreateRasterizationDescriptorSets() { // TODO } void lib::CgContext::CreateRasterizationDescriptorPool() { // TODO } void lib::CgContext::CreateRasterizationDescriptorSetLayout() { // TODO std::vector layoutBindings; } void lib::CgContext::CreateRasterizationRenderPass() { // TODO vk::RenderPassCreateInfo createInfo; }