Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
Ковалев Роман Евгеньевич | 4a4788a73d | |
Ковалев Роман Евгеньевич | e20066344b |
|
@ -23,7 +23,8 @@ class Vulkan
|
|||
std::vector<VkImage> swapChainImages; // Изображения из списка показа
|
||||
std::vector<VkImageView> swapChainImageViews; // Информация об изображениях из списка показа
|
||||
VkRenderPass renderPass; // Проходы рендера
|
||||
VkPipelineLayout pipelineLayout;
|
||||
VkPipelineLayout pipelineLayout; // Раскладка конвейера
|
||||
VkPipeline graphicsPipeline; // Графический конвейер
|
||||
|
||||
// Структура для хранения флагов
|
||||
struct
|
||||
|
|
46
src/vk.cpp
46
src/vk.cpp
|
@ -24,6 +24,7 @@ void Vulkan::init(GLFWwindow* window)
|
|||
// завершение работы
|
||||
void Vulkan::destroy()
|
||||
{
|
||||
vkDestroyPipeline(logicalDevice, graphicsPipeline, nullptr);
|
||||
vkDestroyPipelineLayout(logicalDevice, pipelineLayout, nullptr);
|
||||
vkDestroyRenderPass(logicalDevice, renderPass, nullptr);
|
||||
|
||||
|
@ -670,4 +671,49 @@ void Vulkan::createGraphicPipeline()
|
|||
throw std::runtime_error("Unable to create pipeline layout");
|
||||
}
|
||||
|
||||
// Создание шейдеров
|
||||
VkShaderModule vertShaderModule = createShaderModule("shaders/vert.spv");
|
||||
VkShaderModule fragShaderModule = createShaderModule("shaders/frag.spv");
|
||||
|
||||
VkPipelineShaderStageCreateInfo vertShaderStageInfo{};
|
||||
vertShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||
vertShaderStageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
|
||||
vertShaderStageInfo.module = vertShaderModule;
|
||||
vertShaderStageInfo.pName = "main";
|
||||
|
||||
VkPipelineShaderStageCreateInfo fragShaderStageInfo{};
|
||||
fragShaderStageInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||
fragShaderStageInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
fragShaderStageInfo.module = fragShaderModule;
|
||||
fragShaderStageInfo.pName = "main";
|
||||
|
||||
// Шейдерные стадии
|
||||
VkPipelineShaderStageCreateInfo shaderStages[] = {vertShaderStageInfo, fragShaderStageInfo};
|
||||
|
||||
|
||||
// Информация о создаваемом конвейере
|
||||
VkGraphicsPipelineCreateInfo pipelineInfo{};
|
||||
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
||||
pipelineInfo.stageCount = 2;
|
||||
pipelineInfo.pStages = shaderStages;
|
||||
pipelineInfo.pVertexInputState = &vertexInputInfo;
|
||||
pipelineInfo.pInputAssemblyState = &inputAssembly;
|
||||
pipelineInfo.pViewportState = &viewportState;
|
||||
pipelineInfo.pRasterizationState = &rasterizer;
|
||||
pipelineInfo.pMultisampleState = &multisampling;
|
||||
pipelineInfo.pColorBlendState = &colorBlending;
|
||||
pipelineInfo.layout = pipelineLayout;
|
||||
pipelineInfo.renderPass = renderPass;
|
||||
pipelineInfo.subpass = 0;
|
||||
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
|
||||
|
||||
// Создание графического конвейера
|
||||
if (vkCreateGraphicsPipelines(logicalDevice, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &graphicsPipeline) != VK_SUCCESS)
|
||||
{
|
||||
throw std::runtime_error("Unable to create graphics pipeline");
|
||||
}
|
||||
|
||||
// Удаление шейдерных модулей
|
||||
vkDestroyShaderModule(logicalDevice, fragShaderModule, nullptr);
|
||||
vkDestroyShaderModule(logicalDevice, vertShaderModule, nullptr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue