Skip to content

Commit

Permalink
-Dev: created PostProcessPass for more quick and flexible renderpasse…
Browse files Browse the repository at this point in the history
…s management
  • Loading branch information
AEspinosaDev committed Dec 3, 2024
1 parent b2c3f09 commit 724be6d
Show file tree
Hide file tree
Showing 31 changed files with 214 additions and 812 deletions.
3 changes: 2 additions & 1 deletion include/engine/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ typedef enum AccessFlagsBits
ACCESS_TRANSFER_WRITE = 0x00000006,
ACCESS_SHADER_READ = 0x00000007,
ACCESS_SHADER_WRITE = 0x00000008,
ACCESS_MAX = 0x00000009
ACCESS_MEMORY_READ = 0x00000009,
ACCESS_MAX = 0x00000010
} AccessFlags;
typedef enum AttachmentStoreOpFlagsBits
{
Expand Down
2 changes: 1 addition & 1 deletion include/engine/core/passes/composition_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CompositionPass : public GraphicPass
ColorFormatType colorFormat,
Mesh* vignette,
bool isDefault = true)
: BasePass(ctx, extent, framebufferCount, 1, isDefault)
: BasePass(ctx, extent, framebufferCount, 1, isDefault, "COMPOSITION")
, m_colorFormat(colorFormat)
, m_vignette(vignette) {
}
Expand Down
2 changes: 1 addition & 1 deletion include/engine/core/passes/forward_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ForwardPass : public GraphicPass
ColorFormatType depthFormat,
MSAASamples samples,
bool isDefault = true)
: BasePass(ctx, extent, framebufferCount, 1, isDefault)
: BasePass(ctx, extent, framebufferCount, 1, isDefault, "FORWARD")
, m_colorFormat(colorFormat)
, m_depthFormat(depthFormat)
, m_aa(samples) {
Expand Down
52 changes: 0 additions & 52 deletions include/engine/core/passes/fxaa_pass.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/engine/core/passes/geometry_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GeometryPass : public GraphicPass
ColorFormatType colorFormat,
ColorFormatType depthFormat,
bool isDefault = false)
: BasePass(ctx, extent, framebufferCount, 1, isDefault)
: BasePass(ctx, extent, framebufferCount, 1, isDefault, "GEOMETRY")
, m_colorFormat(colorFormat)
, m_depthFormat(depthFormat) {
}
Expand Down
8 changes: 6 additions & 2 deletions include/engine/core/passes/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class BasePass
std::vector<Graphics::Framebuffer> m_framebuffers;
uint32_t m_framebufferImageDepth; // The depth of the framebuffer image layers.

std::string m_name;

// Key: Renderpass ID
// Value: Framebuffer's image ID inside renderpass
std::unordered_map<uint32_t, std::vector<uint32_t>> m_imageDepedanceTable;
Expand All @@ -70,10 +72,12 @@ class BasePass
Extent2D extent,
uint32_t framebufferCount = 1,
uint32_t framebufferDepth = 1,
bool isDefault = false)
bool isDefault = false,
std::string name = "Graphic Pass")
: m_device(ctx)
, m_framebufferImageDepth(framebufferDepth)
, m_isDefault(isDefault) {
, m_isDefault(isDefault)
, m_name(name) {
m_framebuffers.resize(framebufferCount);
m_renderpass.extent = extent;
}
Expand Down
58 changes: 58 additions & 0 deletions include/engine/core/passes/postprocess_pass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
This file is part of Vulkan-Engine, a simple to use Vulkan based 3D library
MIT License
Copyright (c) 2023 Antonio Espinosa Garcia
*/
#ifndef POSTPROCESS_PASS_H
#define POSTPROCESS_PASS_H
#include <engine/core/passes/pass.h>

VULKAN_ENGINE_NAMESPACE_BEGIN

namespace Core {
/*
Generic Postprocess Pass. It recieves an image from a previous pass and performs a postptocess task defined by a shader
on it. Can be inherited.
*/
class PostProcessPass : public GraphicPass
{
protected:
ColorFormatType m_colorFormat;
Mesh* m_vignette;
Graphics::DescriptorSet m_imageDescriptorSet;
std::string m_shaderPath;

public:
PostProcessPass(Graphics::Device* ctx,
Extent2D extent,
uint32_t framebufferCount,
ColorFormatType colorFormat,
Mesh* vignette,
std::string shaderPath,
std::string name = "Post Process",
bool isDefault = true)
: BasePass(ctx, extent, framebufferCount, 1, isDefault, name)
, m_colorFormat(colorFormat)
, m_vignette(vignette)
, m_shaderPath(shaderPath) {
}

virtual void setup_attachments(std::vector<Graphics::Attachment>& attachments,
std::vector<Graphics::SubPassDependency>& dependencies);

virtual void setup_uniforms(std::vector<Graphics::Frame>& frames);

virtual void setup_shader_passes();

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

virtual void connect_to_previous_images(std::vector<Graphics::Image> images);
};

} // namespace Core
VULKAN_ENGINE_NAMESPACE_END

#endif
54 changes: 0 additions & 54 deletions include/engine/core/passes/ssao_blur_pass.h

This file was deleted.

58 changes: 0 additions & 58 deletions include/engine/core/passes/ssao_pass.h

This file was deleted.

52 changes: 0 additions & 52 deletions include/engine/core/passes/tonemapping_pass.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/engine/core/passes/variance_shadow_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class VarianceShadowPass : public GraphicPass
uint32_t framebufferCount,
uint32_t numLights,
ColorFormatType depthFormat)
: BasePass(ctx, extent, framebufferCount, numLights)
: BasePass(ctx, extent, framebufferCount, numLights, false, "SHADOWS")
, m_depthFormat(depthFormat) {
}

Expand Down
Loading

0 comments on commit 724be6d

Please sign in to comment.