Skip to content

Commit 9dc6adb

Browse files
Merge pull request #1 from warriormaster12/refactor
SpeedEngineVk has been refactored
2 parents c2e05af + 278b9a6 commit 9dc6adb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1313
-1238
lines changed

EngineAssets/Shaders/Shader.frag

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33

44
layout(location = 0) in vec3 fragColor;
55
layout(location = 1) in vec2 fragTexCoord;
6-
layout(binding = 1) uniform sampler2D texSampler;
6+
77
layout(location = 0) out vec4 outColor;
8+
layout(binding = 1) uniform sampler2D texSampler;
9+
810

911
void main() {
10-
outColor = texture(texSampler, fragTexCoord * 1.0);
12+
outColor = texture(texSampler, fragTexCoord);
1113
}
14+
15+

EngineAssets/Shaders/Shader.vert

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ void main() {
1919
fragColor = inColor;
2020
fragTexCoord = inTexCoord;
2121
}
22+

Include/Engine/ModelLoader/ModelLoader.h

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
#include "../VkIncludes.h"
4+
#include "../VkSetup.h"
5+
#include "../VkMemory.h"
6+
7+
8+
9+
10+
namespace VkRenderer
11+
{
12+
class VkBufferCreation
13+
{
14+
public:
15+
void createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& bufferMemory);
16+
void copyBuffer(VkCommandPool& commandPool, VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize size);
17+
18+
VkCommandBuffer beginSingleTimeCommands(VkCommandPool& commandPool);
19+
void endSingleTimeCommands(VkCommandBuffer commandBuffer, VkCommandPool& commandPool);
20+
21+
VkSetup *setup_ref;
22+
VkMemory *memory_ref;
23+
24+
};
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
#include "../VkIncludes.h"
4+
#include "../VkSetup.h"
5+
#include "../VkGraphicsPipeline.h"
6+
#include "VkIndexbuffers.h"
7+
8+
9+
10+
namespace VkRenderer
11+
{
12+
class VkcommandBuffer
13+
{
14+
public:
15+
VkCommandPool commandPool;
16+
void createCommandPool(VkSurfaceKHR& surface);
17+
void createCommandBuffers(std::vector<VkFramebuffer> swapChainFramebuffers, VkExtent2D& swapChainExtent,std::vector<VkDescriptorSet> descriptorSets, VkBuffer& vertexBuffer, VkBuffer& indexBuffer);
18+
std::vector<VkCommandBuffer> commandBuffers;
19+
20+
VkSetup *setup_ref;
21+
VkGPipeline *gpipeline_ref;
22+
VkindexBuffer *Ibuffer_ref;
23+
24+
};
25+
}
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
#pragma once
22

3-
#include "VkIncludes.h"
3+
#include "../VkIncludes.h"
4+
#include "../VkSetup.h"
5+
#include "../VkTextureManager.h"
46

57
namespace VkRenderer
68
{
79
class VkDepthBuffer
810
{
9-
public:
10-
11-
VkFormat findSupportedFormat(const std::vector<VkFormat>& candidates, VkImageTiling tiling, VkFormatFeatureFlags features, VkPhysicalDevice physicalDevice);
12-
VkFormat findDepthFormat(VkPhysicalDevice physicalDevice);
11+
public:
1312
VkImage depthImage;
1413
VkDeviceMemory depthImageMemory;
1514
VkImageView depthImageView;
15+
16+
VkSetup *setup_ref;
17+
VkTextureManager *texture_m_ref;
18+
19+
void createDepthResources(VkExtent2D& swapChainExtent);
20+
VkFormat findSupportedFormat(const std::vector<VkFormat>& candidates, VkImageTiling tiling, VkFormatFeatureFlags features);
21+
VkFormat findDepthFormat();
1622
bool hasStencilComponent(VkFormat format);
1723
};
1824
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
#include "../VkIncludes.h"
4+
#include "../VkSetup.h"
5+
#include "../VkGraphicsPipeline.h"
6+
#include "../VkSwapChain.h"
7+
#include "VkDepthBuffer.h"
8+
9+
namespace VkRenderer
10+
{
11+
class VkframeBuffer
12+
{
13+
public:
14+
std::vector<VkFramebuffer> swapChainFramebuffers;
15+
void createFramebuffers();
16+
17+
VkSetup *setup_ref;
18+
VkSwapChain *swap_ref;
19+
VkGPipeline *gpipeline_ref;
20+
VkDepthBuffer *Dbuffer_ref;
21+
};
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include "../VkIncludes.h"
4+
#include "../VkSetup.h"
5+
#include "VkBufferCreation.h"
6+
#include "../VkMemory.h"
7+
8+
namespace VkRenderer
9+
{
10+
11+
12+
class VkindexBuffer
13+
{
14+
public:
15+
VkBuffer indexBuffer;
16+
VkDeviceMemory indexBufferMemory;
17+
std::vector<uint32_t> indices;
18+
19+
void createIndexBuffer(VkCommandPool& commandPool);
20+
21+
VkSetup *setup_ref;
22+
VkBufferCreation *buffer_ref;
23+
};
24+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#pragma once
2+
3+
#include "../VkIncludes.h"
4+
#include "../VkSetup.h"
5+
#include "../VkMemory.h"
6+
#include "VkBufferCreation.h"
7+
8+
9+
10+
namespace VkRenderer
11+
{
12+
struct UniformBufferObject {
13+
glm::mat4 model;
14+
glm::mat4 view;
15+
glm::mat4 proj;
16+
};
17+
class VkUbuffer
18+
{
19+
public:
20+
void createDescriptorSetLayout();
21+
void createDescriptorPool(std::vector<VkImage>& swapChainImages);
22+
void createDescriptorSets(std::vector<VkImage>& swapChainImages, VkImageView& textureImageView, VkSampler& textureSampler);
23+
void createUniformBuffers(VkBufferCreation& buffer_ref, std::vector<VkImage>& swapChainImages);
24+
void updateUniformBuffer(uint32_t currentImage, VkExtent2D& swapChainExtent);
25+
26+
VkDescriptorSetLayout descriptorSetLayout;
27+
VkDescriptorPool descriptorPool;
28+
std::vector<VkDescriptorSet> descriptorSets;
29+
std::vector<VkBuffer> uniformBuffers;
30+
std::vector<VkDeviceMemory> uniformBuffersMemory;
31+
32+
VkSetup *setup_ref;
33+
VkMemory *memory_ref;
34+
35+
};
36+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#pragma once
2+
3+
#include "../VkIncludes.h"
4+
#include "../VkSetup.h"
5+
#include "../VkMemory.h"
6+
#include "VkBufferCreation.h"
7+
8+
namespace VkRenderer
9+
{
10+
struct Vertex
11+
{
12+
glm::vec3 pos;
13+
glm::vec3 color;
14+
glm::vec2 texCoord;
15+
16+
static VkVertexInputBindingDescription getBindingDescription() {
17+
VkVertexInputBindingDescription bindingDescription{};
18+
bindingDescription.binding = 0;
19+
bindingDescription.stride = sizeof(Vertex);
20+
bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
21+
22+
return bindingDescription;
23+
}
24+
25+
static std::array<VkVertexInputAttributeDescription, 3> getAttributeDescriptions() {
26+
std::array<VkVertexInputAttributeDescription, 3> attributeDescriptions{};
27+
28+
attributeDescriptions[0].binding = 0;
29+
attributeDescriptions[0].location = 0;
30+
attributeDescriptions[0].format = VK_FORMAT_R32G32B32_SFLOAT;
31+
attributeDescriptions[0].offset = offsetof(Vertex, pos);
32+
33+
attributeDescriptions[1].binding = 0;
34+
attributeDescriptions[1].location = 1;
35+
attributeDescriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT;
36+
attributeDescriptions[1].offset = offsetof(Vertex, color);
37+
38+
attributeDescriptions[2].binding = 0;
39+
attributeDescriptions[2].location = 2;
40+
attributeDescriptions[2].format = VK_FORMAT_R32G32_SFLOAT;
41+
attributeDescriptions[2].offset = offsetof(Vertex, texCoord);
42+
43+
return attributeDescriptions;
44+
}
45+
bool operator==(const Vertex& other) const {
46+
return pos == other.pos && color == other.color && texCoord == other.texCoord;
47+
}
48+
};
49+
50+
51+
52+
class VkVbuffer
53+
{
54+
public:
55+
void createVertexBuffer(VkCommandPool& commandPool);
56+
VkBuffer vertexBuffer;
57+
VkDeviceMemory vertexBufferMemory;
58+
VkSetup *setup_ref;
59+
VkBufferCreation *buffer_ref;
60+
std::vector<Vertex> vertices;
61+
};
62+
}

0 commit comments

Comments
 (0)