More pipelining
This commit is contained in:
@@ -36,10 +36,24 @@ namespace cve {
|
|||||||
std::cout << "Fragment shader code size: " << fragCode.size() << '\n';
|
std::cout << "Fragment shader code size: " << fragCode.size() << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
void createShaderModule(const std::vector<char>& code, VkShaderModule *shaderModule) {
|
void CvePipeline::createShaderModule(const std::vector<char>& code, VkShaderModule *shaderModule) {
|
||||||
VkShaderModuleCreateInfo createInfo{};
|
VkShaderModuleCreateInfo createInfo{};
|
||||||
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||||
createInfo.codeSize = code.size();
|
createInfo.codeSize = code.size();
|
||||||
createInfo.pCode = reinterpret_cast<const uint32_t*>(code.data());
|
createInfo.pCode = reinterpret_cast<const uint32_t*>(code.data());
|
||||||
|
|
||||||
|
if (vkCreateShaderModule(cveDevice.device(), &createInfo, nullptr, shaderModule) != VK_SUCCESS) {
|
||||||
|
throw std::runtime_error("Failed to create shader module.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PipelineConfigInfo CvePipeline::defaultPipelineConfigInfo(uint32_t width, uint32_t height) {
|
||||||
|
PipelineConfigInfo configInfo{};
|
||||||
|
|
||||||
|
configInfo.inputAssemblyInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
||||||
|
configInfo.inputAssemblyInfo.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||||
|
configInfo.inputAssemblyInfo.primitiveRestartEnable = VK_FALSE;
|
||||||
|
|
||||||
|
return configInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace cve {
|
namespace cve {
|
||||||
struct PipelineConfigInfo {
|
struct PipelineConfigInfo {
|
||||||
|
VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo{};
|
||||||
};
|
};
|
||||||
class CvePipeline {
|
class CvePipeline {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "cve_window.hpp"
|
#include "cve_window.hpp"
|
||||||
#include "cve_pipeline.hpp"
|
#include "cve_pipeline.hpp"
|
||||||
|
#include "cve_device.hpp"
|
||||||
|
|
||||||
namespace cve {
|
namespace cve {
|
||||||
class FirstApp {
|
class FirstApp {
|
||||||
@@ -12,7 +13,8 @@ namespace cve {
|
|||||||
void run();
|
void run();
|
||||||
private:
|
private:
|
||||||
CveWindow cveWindow{WIDTH, HEIGHT, "Hello Vulkan!"};
|
CveWindow cveWindow{WIDTH, HEIGHT, "Hello Vulkan!"};
|
||||||
CvePipeline cvePipeline{"shaders/simple_shader.vert.spv",
|
CveDevice cveDevice{cveWindow};
|
||||||
"shaders/simple_shader.frag.spv"};
|
CvePipeline cvePipeline{cveDevice, "shaders/simple_shader.vert.spv",
|
||||||
|
"shaders/simple_shader.frag.spv", CvePipeline::defaultPipelineConfigInfo(WIDTH, HEIGHT)};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user