parent
f12a9bf441
commit
9e0b0af5e8
8 changed files with 208 additions and 87 deletions
@ -1,16 +1,34 @@ |
||||
#pragma once |
||||
|
||||
#include <vulkan/vulkan.h> |
||||
#include <glm/gtc/matrix_transform.hpp> |
||||
|
||||
class Instance; |
||||
class Buffer; |
||||
|
||||
struct UniformBufferObject { |
||||
alignas(16) glm::mat4 model; |
||||
glm::mat4 view; |
||||
glm::mat4 projection; |
||||
}; |
||||
|
||||
|
||||
class Pipeline { |
||||
public: |
||||
explicit Pipeline(Instance* instance, VkRenderPass renderPass); |
||||
~Pipeline(); |
||||
VkPipeline graphicsPipeline = VK_NULL_HANDLE; |
||||
VkPipeline handle = VK_NULL_HANDLE; |
||||
VkPipelineLayout layout = VK_NULL_HANDLE; |
||||
VkDescriptorSet descriptorSet = VK_NULL_HANDLE; |
||||
void createDescriptorSet(Buffer* buffer); |
||||
private: |
||||
VkShaderModule createShaderModule(const std::vector<char> &code); |
||||
VkPipelineLayout pipelineLayout = VK_NULL_HANDLE; |
||||
|
||||
VkDescriptorPool descriptorPool = VK_NULL_HANDLE; |
||||
VkDescriptorSetLayout descriptorSetLayout = VK_NULL_HANDLE; |
||||
|
||||
Instance* instance = nullptr; |
||||
void createDescriptorSetLayout(); |
||||
void createDescriptorPool(); |
||||
|
||||
}; |
@ -1 +1,25 @@ |
||||
#include "vertex.hpp" |
||||
#include "vertex.hpp" |
||||
|
||||
VkVertexInputBindingDescription Vertex::getBindingDescription() { |
||||
VkVertexInputBindingDescription bindingDescription {}; |
||||
bindingDescription.binding = 0; |
||||
bindingDescription.stride = sizeof(Vertex); |
||||
bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; |
||||
return bindingDescription; |
||||
} |
||||
|
||||
std::array<VkVertexInputAttributeDescription, 2> Vertex::getAttributeDescriptions() { |
||||
std::array<VkVertexInputAttributeDescription, 2> attributeDescriptions {}; |
||||
|
||||
attributeDescriptions[0].binding = 0; |
||||
attributeDescriptions[0].location = 0; |
||||
attributeDescriptions[0].format = VK_FORMAT_R32G32B32_SFLOAT; |
||||
attributeDescriptions[0].offset = offsetof(Vertex, pos); |
||||
|
||||
attributeDescriptions[1].binding = 0; |
||||
attributeDescriptions[1].location = 1; |
||||
attributeDescriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT; |
||||
attributeDescriptions[1].offset = offsetof(Vertex, color); |
||||
|
||||
return attributeDescriptions; |
||||
} |
||||
|
Loading…
Reference in new issue