Skip to content

Commit 779ecdf

Browse files
committed
-Dev: GraphicPass class implemented as base
1 parent 2f9f553 commit 779ecdf

28 files changed

+279
-354
lines changed

include/engine/core/passes/bloom_pass.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef BLOOM_PASS_H
1010
#define BLOOM_PASS_H
1111

12-
#include <engine/core/passes/pass.h>
12+
#include <engine/core/passes/graphic_pass.h>
1313

1414
VULKAN_ENGINE_NAMESPACE_BEGIN
1515

@@ -29,7 +29,7 @@ both X and Y axes.
2929
A (first downsampled image).
3030
- Finally, we mix the overall bloom contribution into the HDR source image, with a strong bias towards the HDR source.
3131
*/
32-
class BloomPass : public BasePass
32+
class BloomPass : public GraphicPass
3333
{
3434
protected:
3535
ColorFormatType m_colorFormat = SRGBA_32F;
@@ -50,7 +50,7 @@ class BloomPass : public BasePass
5050

5151
public:
5252
BloomPass(Graphics::Device* ctx, Extent2D extent, bool isDefault = false)
53-
: BasePass(ctx, extent, 1, 1, isDefault, "BLOOM") {
53+
: GraphicPass(ctx, extent, 1, 1, isDefault, "BLOOM") {
5454
}
5555

5656
inline float get_bloom_strength() const {
@@ -71,7 +71,7 @@ class BloomPass : public BasePass
7171

7272
void link_previous_images(std::vector<Graphics::Image> images);
7373

74-
void update_framebuffer();
74+
void resize_attachments();
7575

7676
void cleanup();
7777
};

include/engine/core/passes/composition_pass.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
#ifndef COMPOSITION_PASS_H
1010
#define COMPOSITION_PASS_H
11-
#include <engine/core/passes/pass.h>
11+
#include <engine/core/passes/graphic_pass.h>
1212
#include <engine/core/resource_manager.h>
1313

1414
VULKAN_ENGINE_NAMESPACE_BEGIN
@@ -74,7 +74,7 @@ class CompositionPass : public GraphicPass
7474

7575
public:
7676
CompositionPass(Graphics::Device* ctx, VkExtent2D extent, ColorFormatType colorFormat, bool isDefault = true)
77-
: BasePass(ctx, extent, 1, 1, isDefault, "COMPOSITION")
77+
: GraphicPass(ctx, extent, 1, 1, isDefault, "COMPOSITION")
7878
, m_colorFormat(colorFormat) {
7979
}
8080

@@ -122,7 +122,7 @@ class CompositionPass : public GraphicPass
122122

123123
void update_uniforms(uint32_t frameIndex, Scene* const scene);
124124

125-
void update_framebuffer();
125+
void resize_attachments();
126126

127127
void cleanup();
128128
};

include/engine/core/passes/enviroment_pass.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
#ifndef ENVIROMENT_PASS_H
1010
#define ENVIROMENT_PASS_H
11-
#include <engine/core/passes/pass.h>
11+
#include <engine/core/passes/graphic_pass.h>
1212
#include <engine/core/textures/textureHDR.h>
1313

1414
VULKAN_ENGINE_NAMESPACE_BEGIN
@@ -30,7 +30,7 @@ class EnviromentPass : public GraphicPass
3030

3131
public:
3232
EnviromentPass(Graphics::Device* ctx)
33-
: BasePass(ctx, {1, 1}, 2, CUBEMAP_FACES, false)
33+
: GraphicPass(ctx, {1, 1}, 2, CUBEMAP_FACES, false)
3434
, m_format(SRGBA_32F)
3535
, m_irradianceResolution({1, 1}) {
3636
}
@@ -53,7 +53,7 @@ class EnviromentPass : public GraphicPass
5353

5454
void update_uniforms(uint32_t frameIndex, Scene* const scene);
5555

56-
void update_framebuffer();
56+
void resize_attachments();
5757

5858
void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0);
5959

include/engine/core/passes/forward_pass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
#ifndef FORWARD_PASS_H
1010
#define FORWARD_PASS_H
11-
#include <engine/core/passes/pass.h>
11+
#include <engine/core/passes/graphic_pass.h>
1212
#include <engine/core/resource_manager.h>
1313
#include <engine/core/textures/texture.h>
1414
#include <engine/core/textures/textureLDR.h>
@@ -43,7 +43,7 @@ class ForwardPass : public GraphicPass
4343
ColorFormatType depthFormat,
4444
MSAASamples samples,
4545
bool isDefault = true)
46-
: BasePass(ctx, extent, 1,1, isDefault, "FORWARD")
46+
: GraphicPass(ctx, extent, 1,1, isDefault, "FORWARD")
4747
, m_colorFormat(colorFormat)
4848
, m_depthFormat(depthFormat)
4949
, m_aa(samples) {

include/engine/core/passes/geometry_pass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
#ifndef GEOMETRY_PASS_H
1010
#define GEOMETRY_PASS_H
11-
#include <engine/core/passes/pass.h>
11+
#include <engine/core/passes/graphic_pass.h>
1212
#include <engine/core/resource_manager.h>
1313

1414
VULKAN_ENGINE_NAMESPACE_BEGIN
@@ -39,7 +39,7 @@ class GeometryPass : public GraphicPass
3939
ColorFormatType colorFormat,
4040
ColorFormatType depthFormat,
4141
bool isDefault = false)
42-
: BasePass(ctx, extent, 1, 1, isDefault, "GEOMETRY")
42+
: GraphicPass(ctx, extent, 1, 1, isDefault, "GEOMETRY")
4343
, m_colorFormat(colorFormat)
4444
, m_depthFormat(depthFormat) {
4545
}

include/engine/core/passes/graphic_pass.h

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,13 @@
2020
#include <engine/graphics/renderpass.h>
2121
#include <engine/graphics/swapchain.h>
2222

23+
#include <engine/core/passes/pass.h>
2324
#include <engine/core/scene/scene.h>
2425

2526
VULKAN_ENGINE_NAMESPACE_BEGIN
2627

2728
namespace Core {
2829

29-
/*
30-
Data containing a dependicy image's location belonging to a previows pass
31-
*/
32-
struct ImageDependency;
33-
3430
/*
3531
Core abstract GRAPHIC class needed for a renderer to work. It draws polygon primitives and rasterized them onto
3632
framebuffers. It controls the flow of the renderer state, what information and how it is being rendered. It also gives
@@ -44,47 +40,37 @@ class GraphicPass : public BasePass
4440
std::vector<Graphics::Framebuffer> m_framebuffers;
4541
uint32_t m_framebufferImageDepth; // In case if multilayered rendering.
4642

47-
virtual void
48-
setup_attachments(std::vector<Graphics::AttachmentInfo>& attachments,
49-
std::vector<Graphics::SubPassDependency>& dependencies) = 0;
43+
virtual void setup_attachments(std::vector<Graphics::AttachmentInfo>& attachments,
44+
std::vector<Graphics::SubPassDependency>& dependencies) = 0;
5045

5146
public:
52-
GraphicPass(Graphics::Device* ctx,
53-
Extent2D extent,
54-
uint32_t framebufferCount = 1,
55-
uint32_t framebufferDepth = 1,
56-
bool isDefault = false,
57-
std::string name = "UNNAMED PASS")
58-
: m_device(ctx)
59-
, m_framebufferImageDepth(framebufferDepth)
60-
, m_isDefault(isDefault)
61-
, m_name(name) {
47+
GraphicPass(Graphics::Device* ctx,
48+
Extent2D extent,
49+
uint32_t framebufferCount = 1,
50+
uint32_t framebufferDepth = 1,
51+
bool isDefault = false,
52+
std::string name = "VIRTUAL GRAPHIC PASS")
53+
54+
: BasePass(ctx, extent, isDefault, name)
55+
, m_framebufferImageDepth(framebufferDepth) {
6256
!isDefault ? m_framebuffers.resize(framebufferCount)
6357
: m_framebuffers.resize(m_device->get_swapchain().get_present_images().size());
64-
m_imageExtent = extent;
6558
}
6659
virtual ~GraphicPass() {
6760
}
6861

6962
#pragma region Getters & Setters
7063

71-
72-
7364
inline Graphics::RenderPass get_renderpass() const {
7465
return m_renderpass;
7566
}
7667
inline std::vector<Graphics::Framebuffer> const get_framebuffers() const {
7768
return m_framebuffers;
7869
}
79-
inline std::vector<Graphics::Image> const get_resource_images() const {
80-
return m_resourceImages;
81-
}
8270
inline void set_attachment_clear_value(VkClearValue value, size_t attachmentLayout = 0) {
8371
m_renderpass.attachmentsInfo[attachmentLayout].clearValue = value;
8472
}
8573

86-
87-
8874
#pragma endregion
8975
#pragma region Core Functions
9076
/*
@@ -93,11 +79,6 @@ class GraphicPass : public BasePass
9379
void setup(std::vector<Graphics::Frame>& frames);
9480

9581
virtual void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0) = 0;
96-
97-
virtual void update_uniforms(uint32_t frameIndex, Scene* const scene) {
98-
}
99-
virtual void link_previous_images(std::vector<Graphics::Image> images) {
100-
}
10182
/**
10283
* Create framebuffers and images attached to them necessary for the
10384
* renderpass to work. It also sets the extent of the renderpass.
@@ -115,7 +96,7 @@ class GraphicPass : public BasePass
11596
* regeneration
11697
*
11798
*/
118-
virtual void update_framebuffer();
99+
virtual void resize_attachments();
119100
/**
120101
* Destroy the renderpass and its shaderpasses. Framebuffers are managed in a
121102
* sepparate function for felxibilty matters
@@ -129,27 +110,6 @@ class GraphicPass : public BasePass
129110
static Core::Geometry* vignette;
130111
};
131112

132-
#pragma region IMAGE DEP
133-
134-
struct ImageDependency {
135-
uint32_t passID = 0; // The pass that produces this image
136-
uint32_t fboID = 0; // The FBO within the pass that produces this image
137-
bool isFBO = true; // If set to false, It will take the attachments from the pass resourceImages (Useful if not a
138-
// graphical pass).
139-
std::vector<uint32_t> attachmentIDs; // The attachment indeces within the FBO
140-
141-
ImageDependency(uint32_t passId, u_int fboId, std::vector<uint32_t> attachmentIds)
142-
: passID(passId)
143-
, fboID(fboId)
144-
, attachmentIDs(attachmentIds) {
145-
}
146-
ImageDependency(uint32_t passId, std::vector<uint32_t> attachmentIds)
147-
: passID(passId)
148-
, attachmentIDs(attachmentIds)
149-
, isFBO(false) {
150-
}
151-
};
152-
153113
#pragma endregion
154114
} // namespace Core
155115

include/engine/core/passes/pass.h

Lines changed: 12 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,18 @@ struct ImageDependency;
3434
/*
3535
Core abstract class needed for a renderer to work.
3636
It controls the flow of the renderer state, what information and how it is being
37-
rendered/computed. It also gives access to the framebuffers containing the rendered data.
37+
rendered/computed.
3838
It can be inherited for full user control over the render/compute pipeline.
3939
*/
4040
class BasePass;
41-
typedef BasePass GraphicPass; // Sintax for graphic passes that draw primitives and rasterized them onto framebuffers
42-
typedef BasePass ComputePass; // Sintax for passes focused on GPGPU
43-
typedef BasePass RaytracedPass; // Sintax for passes that only use the raytracing mode.
41+
typedef BasePass ComputePass; // Sintax for passes focused on GPGPU
4442
class BasePass
4543
{
4644
protected:
4745
// Graphic Objects
4846
Graphics::Device* m_device = nullptr;
4947
Graphics::DescriptorPool m_descriptorPool = {};
5048
std::unordered_map<std::string, Graphics::BaseShaderPass*> m_shaderPasses;
51-
// In case it is a graphical pass ... which is the most usual
52-
Graphics::RenderPass m_renderpass = {};
53-
std::vector<Graphics::Framebuffer> m_framebuffers;
54-
uint32_t m_framebufferImageDepth; // In case if multilayered rendering.
5549
// In case is not graphical or need auxiliar data, other graphic data can be stored onto these images
5650
std::vector<Graphics::Image> m_resourceImages;
5751

@@ -66,28 +60,17 @@ class BasePass
6660
bool m_isDefault = false;
6761
bool m_isGraphical = true;
6862

69-
virtual void
70-
setup_attachments(std::vector<Graphics::AttachmentInfo>& attachments,
71-
std::vector<Graphics::SubPassDependency>& dependencies) = 0; // Only for graphical renderpasses
7263
virtual void setup_uniforms(std::vector<Graphics::Frame>& frames) = 0;
7364
virtual void setup_shader_passes() = 0;
7465

7566
public:
76-
BasePass(Graphics::Device* ctx,
77-
Extent2D extent,
78-
uint32_t framebufferCount = 1,
79-
uint32_t framebufferDepth = 1,
80-
bool isDefault = false,
81-
std::string name = "UNNAMED PASS")
67+
BasePass(Graphics::Device* ctx, Extent2D extent, bool isDefault = false, std::string name = "UNNAMED PASS")
8268
: m_device(ctx)
83-
, m_framebufferImageDepth(framebufferDepth)
8469
, m_isDefault(isDefault)
85-
, m_name(name) {
86-
!isDefault ? m_framebuffers.resize(framebufferCount)
87-
: m_framebuffers.resize(m_device->get_swapchain().get_present_images().size());
88-
m_imageExtent = extent;
70+
, m_name(name)
71+
, m_imageExtent(extent) {
8972
}
90-
virtual ~BasePass(){
73+
virtual ~BasePass() {
9174
}
9275

9376
#pragma region Getters & Setters
@@ -106,19 +89,6 @@ class BasePass
10689
m_imageExtent = extent;
10790
}
10891

109-
inline Graphics::RenderPass get_renderpass() const {
110-
return m_renderpass;
111-
}
112-
inline std::vector<Graphics::Framebuffer> const get_framebuffers() const {
113-
return m_framebuffers;
114-
}
115-
inline std::vector<Graphics::Image> const get_resource_images() const {
116-
return m_resourceImages;
117-
}
118-
inline void set_attachment_clear_value(VkClearValue value, size_t attachmentLayout = 0) {
119-
m_renderpass.attachmentsInfo[attachmentLayout].clearValue = value;
120-
}
121-
12292
inline bool resizeable() const {
12393
return m_isResizeable;
12494
}
@@ -151,49 +121,27 @@ class BasePass
151121
inline std::vector<ImageDependency> get_image_dependencies() const {
152122
return m_imageDependencies;
153123
}
124+
inline std::vector<Graphics::Image> const get_resource_images() const {
125+
return m_resourceImages;
126+
}
154127

155128
#pragma endregion
156129
#pragma region Core Functions
157130
/*
158131
Setups de renderpass. Init, create framebuffers, pipelines and resources ...
159132
*/
160-
void setup(std::vector<Graphics::Frame>& frames);
133+
virtual void setup(std::vector<Graphics::Frame>& frames);
161134

162135
virtual void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0) = 0;
163136

164137
virtual void update_uniforms(uint32_t frameIndex, Scene* const scene) {
165138
}
139+
virtual void resize_attachments() {
140+
}
166141
virtual void link_previous_images(std::vector<Graphics::Image> images) {
167142
}
168-
/**
169-
* Create framebuffers and images attached to them necessary for the
170-
* renderpass to work. It also sets the extent of the renderpass.
171-
*/
172-
virtual void create_framebuffer();
173-
/**
174-
* Destroy framebuffers and images attached to them necessary for the
175-
* renderpass to work. If images have a sampler attached to them, contol the
176-
* destruction of it too.
177-
*/
178-
virtual void clean_framebuffer();
179-
/**
180-
* Recreates the renderpass with new parameters. Useful for example, when
181-
* resizing the screen. It automatically manages framebuffer cleanup and
182-
* regeneration
183-
*
184-
*/
185-
virtual void update_framebuffer();
186-
/**
187-
* Destroy the renderpass and its shaderpasses. Framebuffers are managed in a
188-
* sepparate function for felxibilty matters
189-
*/
190143
virtual void cleanup();
191144
#pragma endregion
192-
193-
/*
194-
Public static member.
195-
Vignette for rendering textures onto screen.*/
196-
static Core::Geometry* vignette;
197145
};
198146

199147
#pragma region IMAGE DEP

0 commit comments

Comments
 (0)