Compare commits
2 Commits
405411337c
...
9e0b0af5e8
Author | SHA1 | Date |
---|---|---|
Benjamin Kraft | 9e0b0af5e8 | 2 months ago |
Benjamin Kraft | f12a9bf441 | 2 months ago |
10 changed files with 253 additions and 98 deletions
@ -1,16 +1,34 @@ |
|||||||
#pragma once |
#pragma once |
||||||
|
|
||||||
#include <vulkan/vulkan.h> |
#include <vulkan/vulkan.h> |
||||||
|
#include <glm/gtc/matrix_transform.hpp> |
||||||
|
|
||||||
class Instance; |
class Instance; |
||||||
|
class Buffer; |
||||||
|
|
||||||
|
struct UniformBufferObject { |
||||||
|
alignas(16) glm::mat4 model; |
||||||
|
glm::mat4 view; |
||||||
|
glm::mat4 projection; |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
class Pipeline { |
class Pipeline { |
||||||
public: |
public: |
||||||
explicit Pipeline(Instance* instance, VkRenderPass renderPass); |
explicit Pipeline(Instance* instance, VkRenderPass renderPass); |
||||||
~Pipeline(); |
~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: |
private: |
||||||
VkShaderModule createShaderModule(const std::vector<char> &code); |
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; |
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