Skip to content

Commit 674f979

Browse files
authored
Merge pull request #25 from CapsCollective/feature/vulkan-shader
Refactored the Pipeline, Shader, and Material classes
2 parents 53f83a6 + da82489 commit 674f979

Some content is hidden

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

63 files changed

+3065
-2099
lines changed

engine/render/assets/shaders/billboard.vert

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ struct BillboardData
2424
vec3 scale;
2525
};
2626

27-
layout (set = 0, binding = 0) uniform GlobalData {
27+
layout (binding = 0) uniform GlobalData {
2828
CameraData cameraData;
2929
LightData lightData;
3030
} globalData;
3131

32-
layout (std140, set = 1, binding = 1) readonly buffer ObjectBuffer {
32+
layout (std140, binding = 1) readonly buffer ObjectBuffer {
3333
BillboardData data[];
3434
} objectBuffer;
3535

engine/render/assets/shaders/diffuseFragShader.frag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct LightData
1919
vec3 position;
2020
};
2121

22-
layout (set = 1, binding = 1) uniform GlobalData {
22+
layout (binding = 1) uniform GlobalData {
2323
CameraData cameraData;
2424
LightData lightData;
2525
} globalData;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#version 450
22

3-
layout(location = 0) in vec3 fragColor;
3+
layout(location = 0) in vec4 fragColor;
44

55
layout(location = 0) out vec4 outColor;
66

77
void main() {
8-
outColor = vec4(fragColor, 1.0);
8+
outColor = fragColor;
99
}

engine/render/assets/shaders/line.vert

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#version 450
22

33
layout(location = 0) in vec3 position;
4-
layout(location = 1) in vec3 colour;
4+
layout(location = 1) in vec4 colour;
55

6-
layout(location = 0) out vec3 outColour;
6+
layout(location = 0) out vec4 outColour;
77

88
struct CameraData
99
{
@@ -18,7 +18,7 @@ struct LightData
1818
vec3 position;
1919
};
2020

21-
layout (set = 0, binding = 0) uniform GlobalData {
21+
layout (binding = 0) uniform GlobalData {
2222
CameraData cameraData;
2323
LightData lightData;
2424
} globalData;

engine/render/assets/shaders/simpleShader.vert

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ struct LightData
2929
vec3 position;
3030
};
3131

32-
layout (std140, set = 0, binding = 0) readonly buffer ObjectBuffer {
32+
layout (std140, binding = 0) readonly buffer ObjectBuffer {
3333
ObjectData objects[];
3434
} objectBuffer;
3535

36-
layout (set = 1, binding = 1) uniform GlobalData {
36+
layout (binding = 1) uniform GlobalData {
3737
CameraData cameraData;
3838
LightData lightData;
3939
} globalData;

engine/render/assets/shaders/simpleShader2D.vert

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ layout(location = 1) in vec3 color;
66

77
layout(location = 0) out vec3 fragColor;
88

9-
layout (std140, set = 0, binding = 0) readonly buffer Transforms{
9+
layout (std140, binding = 0) readonly buffer Transforms{
1010
mat4 transforms[];
1111
} transforms;
1212

@@ -16,7 +16,7 @@ struct CameraData
1616
mat4 viewMatrix;
1717
};
1818

19-
layout (set = 1, binding = 1) uniform GlobalData {
19+
layout (binding = 1) uniform GlobalData {
2020
CameraData cameraData;
2121
} globalData;
2222

engine/render/renderer/Renderer.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Renderer::Renderer(Window& window) : window {window}
2828
Window::GetRequiredExtensions,
2929
Window::CreateWindowSurface);
3030

31-
DescriptorPool::AddPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 10);
32-
DescriptorPool::AddPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 10);
33-
DescriptorPool::AddPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 10);
34-
DescriptorPool::AddPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 10);
31+
DescriptorPool::AddPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1024);
32+
DescriptorPool::AddPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1024);
33+
DescriptorPool::AddPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1024);
34+
DescriptorPool::AddPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1024);
3535

3636
DescriptorPool::BuildPool();
3737

@@ -50,12 +50,10 @@ Renderer::~Renderer()
5050

5151
void Renderer::DrawFrame()
5252
{
53-
auto commandBuffer = commandBuffers.GetActiveCommandBuffer();
54-
5553
Renderer2D::GlobalData global2DData = {projection};
5654

57-
Renderer3D::Render(commandBuffer, projection);
58-
Renderer2D::Render(commandBuffer, global2DData);
55+
Renderer3D::Render(commandBuffers, projection);
56+
Renderer2D::Render(commandBuffers, global2DData);
5957
}
6058

6159
void Renderer::RecreateSwapChain()

engine/render/renderer/Renderer.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
#include "descriptor/DescriptorPool.h"
1515
#include "lights/PointLight.h"
16-
#include "material/Material.h"
1716
#include "model/Model.h"
18-
#include "pipeline/Pipeline.h"
1917
#include "render/renderer/platform/vulkan/CommandBuffer.h"
2018
#include "render/renderer/platform/vulkan/Context.h"
2119
#include "render/window/Window.h"
@@ -65,6 +63,11 @@ class Renderer
6563
return instance;
6664
}
6765

66+
static uint32_t GetCurrentFrameIndex()
67+
{
68+
return currentFrameIndex;
69+
}
70+
6871
private:
6972

7073
static Renderer* instance;

engine/render/renderer/Renderer3D.cpp

Lines changed: 0 additions & 8 deletions
This file was deleted.

engine/render/renderer/Renderer3D.h

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)