Skip to content

Commit e964e03

Browse files
committed
All vulkan obj creation to Device class
1 parent f35471f commit e964e03

Some content is hidden

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

59 files changed

+1108
-1322
lines changed

include/engine/core/geometries/geometry.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Geometry;
2222

2323
struct GeometricData {
2424
std::vector<uint32_t> vertexIndex;
25-
std::vector<Graphics::Utils::Vertex> vertexData;
25+
std::vector<Graphics::Vertex> vertexData;
2626

2727
// Stats
2828
Vec3 maxCoords;
@@ -74,8 +74,8 @@ class Geometry
7474
~Geometry() {
7575
}
7676

77-
void fill(std::vector<Graphics::Utils::Vertex> vertexInfo);
78-
void fill(std::vector<Graphics::Utils::Vertex> vertexInfo, std::vector<uint32_t> vertexIndex);
77+
void fill(std::vector<Graphics::Vertex> vertexInfo);
78+
void fill(std::vector<Graphics::Vertex> vertexInfo, std::vector<uint32_t> vertexIndex);
7979
void fill(Vec3* pos, Vec3* normal, Vec2* uv, Vec3* tangent, uint32_t vertNumber);
8080
static Geometry* create_quad();
8181
static Geometry* create_cube();

include/engine/core/renderpasses/forward_pass.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class ForwardPass : public RenderPass
4646
, m_aa(samples) {
4747
}
4848

49-
void setup_attachments();
49+
void setup_attachments(std::vector<Graphics::Attachment>& attachments,
50+
std::vector<Graphics::SubPassDependency>& dependencies);
5051

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

include/engine/core/renderpasses/fxaa_pass.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class FXAAPass : public RenderPass
3434
, m_vignette(vignette) {
3535
}
3636

37-
void setup_attachments();
37+
void setup_attachments(std::vector<Graphics::Attachment>& attachments,
38+
std::vector<Graphics::SubPassDependency>& dependencies);
3839

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

include/engine/core/renderpasses/irradiance_compute_pass.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class IrrandianceComputePass : public RenderPass
2626
, m_format(format) {
2727
}
2828

29-
void setup_attachments();
29+
void setup_attachments(std::vector<Graphics::Attachment>& attachments,
30+
std::vector<Graphics::SubPassDependency>& dependencies);
3031

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

include/engine/core/renderpasses/panorama_conversion_pass.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class PanoramaConverterPass : public RenderPass
2828
, m_format(format) {
2929
}
3030

31-
void setup_attachments();
31+
void setup_attachments(std::vector<Graphics::Attachment>& attachments,
32+
std::vector<Graphics::SubPassDependency>& dependencies);
3233

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

include/engine/core/renderpasses/renderpass.h

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,27 @@ It can be inherited for full user control over the render pipeline.
3535
class RenderPass
3636
{
3737
protected:
38-
Graphics::VulkanRenderPass m_handle;
3938
Graphics::Device* m_device{nullptr};
4039
Graphics::DescriptorPool m_descriptorPool{};
41-
std::vector<Graphics::Attachment> m_attachments;
42-
std::vector<Graphics::SubPassDependency> m_dependencies;
40+
Graphics::VulkanRenderPass m_handle;
4341
std::vector<Graphics::Framebuffer> m_framebuffers;
4442
std::unordered_map<std::string, Graphics::ShaderPass*> m_shaderPasses;
4543

46-
Extent2D m_extent;
4744
uint32_t m_framebufferImageDepth; // The depth of the framebuffer image layers.
4845

4946
// Key: Renderpass ID
5047
// Value: Framebuffer's image ID inside renderpass
5148
std::unordered_map<uint32_t, std::vector<uint32_t>> m_imageDepedanceTable;
5249

53-
bool m_initiatized{false};
54-
bool m_isResizeable{true};
55-
bool m_enabled{true};
56-
bool m_isDefault;
50+
bool m_initiatized = false;
51+
bool m_isResizeable = true;
52+
bool m_enabled = true;
53+
bool m_isDefault = false;
54+
55+
virtual void setup_attachments(std::vector<Graphics::Attachment>& attachments,
56+
std::vector<Graphics::SubPassDependency>& dependencies) = 0;
57+
virtual void setup_uniforms(std::vector<Graphics::Frame>& frames) = 0;
58+
virtual void setup_shader_passes() = 0;
5759

5860
public:
5961
// static std::vector<Graphics::Frame> frames;
@@ -64,10 +66,10 @@ class RenderPass
6466
uint32_t framebufferDepth = 1,
6567
bool isDefault = false)
6668
: m_device(ctx)
67-
, m_extent(extent)
6869
, m_framebufferImageDepth(framebufferDepth)
6970
, m_isDefault(isDefault) {
7071
m_framebuffers.resize(framebufferCount);
72+
m_handle.extent = extent;
7173
}
7274

7375
#pragma region Getters & Setters
@@ -80,10 +82,10 @@ class RenderPass
8082
}
8183

8284
inline Extent2D get_extent() const {
83-
return m_extent;
85+
return m_handle.extent;
8486
}
8587
inline void set_extent(Extent2D extent) {
86-
m_extent = extent;
88+
m_handle.extent = extent;
8789
}
8890

8991
inline Graphics::VulkanRenderPass get_handle() const {
@@ -94,10 +96,10 @@ class RenderPass
9496
}
9597

9698
inline std::vector<Graphics::Attachment> get_attachments() {
97-
return m_attachments;
99+
return m_handle.attachments;
98100
}
99101
inline void set_attachment_clear_value(VkClearValue value, size_t attachmentLayout = 0) {
100-
m_attachments[attachmentLayout].clearValue = value;
102+
m_handle.attachments[attachmentLayout].clearValue = value;
101103
}
102104

103105
inline bool resizeable() const {
@@ -139,9 +141,6 @@ class RenderPass
139141
*/
140142
void setup(std::vector<Graphics::Frame>& frames);
141143

142-
virtual void setup_attachments() = 0;
143-
virtual void setup_uniforms(std::vector<Graphics::Frame>& frames) = 0;
144-
virtual void setup_shader_passes() = 0;
145144
virtual void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0) = 0;
146145

147146
virtual void update_uniforms(uint32_t frameIndex, Scene* const scene) {

include/engine/core/renderpasses/shadow_pass.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class ShadowPass : public RenderPass
3636
, m_depthFormat(depthFormat) {
3737
}
3838

39-
void setup_attachments();
39+
void setup_attachments(std::vector<Graphics::Attachment>& attachments,
40+
std::vector<Graphics::SubPassDependency>& dependencies);
4041

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

include/engine/core/renderpasses/variance_shadow_pass.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class VarianceShadowPass : public RenderPass
3737
, m_depthFormat(depthFormat) {
3838
}
3939

40-
void setup_attachments();
40+
void setup_attachments(std::vector<Graphics::Attachment>& attachments,
41+
std::vector<Graphics::SubPassDependency>& dependencies);
4142

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

include/engine/core/textures/texture.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ VULKAN_ENGINE_NAMESPACE_BEGIN
1717
namespace Core {
1818

1919
struct TextureSettings {
20-
ColorFormatType format = SRGBA_8;
21-
TextureFilterType filter = LINEAR;
22-
TextureAdressModeType adressMode = REPEAT;
23-
bool useMipmaps = true;
24-
bool anisotropicFilter = true;
25-
int minMipLevel = 0;
26-
int maxMipLevel = -1;
20+
ColorFormatType format = SRGBA_8;
21+
TextureFilterType filter = LINEAR;
22+
TextureAdressModeType adressMode = REPEAT;
23+
bool useMipmaps = true;
24+
bool anisotropicFilter = true;
25+
int anisotropicFilterPower = 16;
26+
int minMipLevel = 1;
27+
int maxMipLevel = 1;
2728
};
2829

2930
/*

include/engine/core/textures/textureLDR.h

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
VULKAN_ENGINE_NAMESPACE_BEGIN
1515

16-
namespace Core
17-
{
16+
namespace Core {
1817
class TextureLDR;
1918
typedef TextureLDR Texture;
2019
/*
@@ -23,37 +22,35 @@ Standard texture that supports LDR color data from standard image files (jpg,png
2322
class TextureLDR : public ITexture
2423
{
2524
private:
26-
unsigned char *m_tmpCache{nullptr};
25+
unsigned char* m_tmpCache{nullptr};
2726

2827
public:
29-
static Texture *FALLBACK_TEX;
30-
static Texture *BLUE_NOISE_TEXT;
28+
static Texture* FALLBACK_TEX;
29+
static Texture* BLUE_NOISE_TEXT;
3130

32-
TextureLDR() : ITexture()
33-
{
31+
TextureLDR()
32+
: ITexture() {
3433
}
35-
TextureLDR(TextureSettings settings) : ITexture(settings)
36-
{
34+
TextureLDR(TextureSettings settings)
35+
: ITexture(settings) {
3736
}
38-
TextureLDR(unsigned char *data, Extent3D size, uint16_t channels, TextureSettings settings = {})
39-
: ITexture(size, channels, settings), m_tmpCache(data)
40-
{
37+
TextureLDR(unsigned char* data, Extent3D size, uint16_t channels, TextureSettings settings = {})
38+
: ITexture(size, channels, settings)
39+
, m_tmpCache(data) {
40+
m_image.loadedOnCPU = true;
4141
}
4242

43-
inline void set_image_cache(void *cache, Extent3D extent, uint16_t channels)
44-
{
45-
m_tmpCache = static_cast<unsigned char *>(cache);
46-
m_channels = channels; // Set the number of channels
47-
m_image.extent = extent; // Set the image extent
48-
m_image.loadedOnCPU = true; // Mark the image as loaded on CPU
49-
m_isDirty = true; // Mark as dirty
43+
inline void set_image_cache(void* cache, Extent3D extent, uint16_t channels) {
44+
m_tmpCache = static_cast<unsigned char*>(cache);
45+
m_channels = channels; // Set the number of channels
46+
m_image.extent = extent; // Set the image extent
47+
m_image.loadedOnCPU = true; // Mark the image as loaded on CPU
48+
m_isDirty = true; // Mark as dirty
5049
}
51-
inline void get_image_cache(void *&cache) const
52-
{
53-
cache = static_cast<void *>(m_tmpCache);
50+
inline void get_image_cache(void*& cache) const {
51+
cache = static_cast<void*>(m_tmpCache);
5452
}
55-
inline size_t get_bytes_per_pixel() const
56-
{
53+
inline size_t get_bytes_per_pixel() const {
5754
return static_cast<size_t>(m_channels) * sizeof(unsigned char);
5855
}
5956
};

0 commit comments

Comments
 (0)