Skip to content

Commit 2839096

Browse files
committed
Change in Frame treatment
1 parent f2353a2 commit 2839096

36 files changed

+364
-376
lines changed

examples/resources/meshes/box.obj

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

include/engine/common.h

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@
9494
#define CUBEMAP_FACES 6
9595

9696
/// Simple exception class, which stores a human-readable error description
97-
class VKException : public std::runtime_error
97+
class VKFW_Exception : public std::runtime_error
9898
{
9999
public:
100100
template <typename... Args>
101-
VKException(const char* fmt, const Args&... args)
101+
VKFW_Exception(const char* fmt, const Args&... args)
102102
: std::runtime_error(fmt) {
103103
}
104104
};
@@ -141,8 +141,8 @@ typedef enum MaskType
141141

142142
typedef enum CullingMode
143143
{
144-
_FRONT = VK_CULL_MODE_FRONT_BIT,
145-
_BACK = VK_CULL_MODE_BACK_BIT,
144+
_FRONT = VK_CULL_MODE_FRONT_BIT,
145+
_BACK = VK_CULL_MODE_BACK_BIT,
146146
_NO_CULLING = VK_CULL_MODE_NONE,
147147
} CullingMode;
148148

@@ -350,7 +350,8 @@ enum ShaderStageType
350350
FRAGMENT = 1,
351351
GEOMETRY = 2,
352352
TESS_CONTROL = 3,
353-
TESS_EVALUATION = 4
353+
TESS_EVALUATION = 4,
354+
ALL_STAGES = 5
354355
};
355356

356357
enum UniformDataType
@@ -493,6 +494,67 @@ enum class BindingType
493494
RAYTRACING_BINDING = VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR
494495
};
495496

497+
typedef enum RenderResult
498+
{
499+
SUCCESS = VK_SUCCESS,
500+
NOT_READY = VK_NOT_READY,
501+
TIMEOUT = VK_TIMEOUT,
502+
EVENT_SET = VK_EVENT_SET,
503+
EVENT_RESET = VK_EVENT_RESET,
504+
INCOMPLETE = VK_INCOMPLETE,
505+
ERROR_OUT_OF_HOST_MEMORY = VK_ERROR_OUT_OF_HOST_MEMORY,
506+
ERROR_OUT_OF_DEVICE_MEMORY = VK_ERROR_OUT_OF_DEVICE_MEMORY,
507+
ERROR_INITIALIZATION_FAILED = VK_ERROR_INITIALIZATION_FAILED,
508+
ERROR_DEVICE_LOST = VK_ERROR_DEVICE_LOST,
509+
ERROR_MEMORY_MAP_FAILED = VK_ERROR_MEMORY_MAP_FAILED,
510+
ERROR_LAYER_NOT_PRESENT = VK_ERROR_LAYER_NOT_PRESENT,
511+
ERROR_EXTENSION_NOT_PRESENT = VK_ERROR_EXTENSION_NOT_PRESENT,
512+
ERROR_FEATURE_NOT_PRESENT = VK_ERROR_FEATURE_NOT_PRESENT,
513+
ERROR_INCOMPATIBLE_DRIVER = VK_ERROR_INCOMPATIBLE_DRIVER,
514+
ERROR_TOO_MANY_OBJECTS = VK_ERROR_TOO_MANY_OBJECTS,
515+
ERROR_FORMAT_NOT_SUPPORTED = VK_ERROR_FORMAT_NOT_SUPPORTED,
516+
ERROR_FRAGMENTED_POOL = VK_ERROR_FRAGMENTED_POOL,
517+
ERROR_UNKNOWN = VK_ERROR_UNKNOWN,
518+
ERROR_OUT_OF_POOL_MEMORY = VK_ERROR_OUT_OF_POOL_MEMORY,
519+
ERROR_INVALID_EXTERNAL_HANDLE = VK_ERROR_INVALID_EXTERNAL_HANDLE,
520+
ERROR_FRAGMENTATION = VK_ERROR_FRAGMENTATION,
521+
ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS = VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS,
522+
PIPELINE_COMPILE_REQUIRED = VK_PIPELINE_COMPILE_REQUIRED,
523+
ERROR_SURFACE_LOST_KHR = VK_ERROR_SURFACE_LOST_KHR,
524+
ERROR_NATIVE_WINDOW_IN_USE_KHR = VK_ERROR_NATIVE_WINDOW_IN_USE_KHR,
525+
SUBOPTIMAL_KHR = VK_SUBOPTIMAL_KHR,
526+
ERROR_OUT_OF_DATE_KHR = VK_ERROR_OUT_OF_DATE_KHR,
527+
ERROR_INCOMPATIBLE_DISPLAY_KHR = VK_ERROR_INCOMPATIBLE_DISPLAY_KHR,
528+
ERROR_VALIDATION_FAILED_EXT = VK_ERROR_VALIDATION_FAILED_EXT,
529+
ERROR_INVALID_SHADER_NV = VK_ERROR_INVALID_SHADER_NV,
530+
ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR = VK_ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR,
531+
ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR = VK_ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR,
532+
ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR = VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR,
533+
ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR = VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR,
534+
ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR = VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR,
535+
ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR = VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR,
536+
ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT = VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT,
537+
ERROR_NOT_PERMITTED_KHR = VK_ERROR_NOT_PERMITTED_KHR,
538+
ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT = VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT,
539+
THREAD_IDLE_KHR = VK_THREAD_IDLE_KHR,
540+
THREAD_DONE_KHR = VK_THREAD_DONE_KHR,
541+
OPERATION_DEFERRED_KHR = VK_OPERATION_DEFERRED_KHR,
542+
OPERATION_NOT_DEFERRED_KHR = VK_OPERATION_NOT_DEFERRED_KHR,
543+
ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR = VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR,
544+
ERROR_COMPRESSION_EXHAUSTED_EXT = VK_ERROR_COMPRESSION_EXHAUSTED_EXT,
545+
INCOMPATIBLE_SHADER_BINARY_EXT = VK_INCOMPATIBLE_SHADER_BINARY_EXT,
546+
ERROR_OUT_OF_POOL_MEMORY_KHR = VK_ERROR_OUT_OF_POOL_MEMORY_KHR,
547+
ERROR_INVALID_EXTERNAL_HANDLE_KHR = VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR,
548+
ERROR_FRAGMENTATION_EXT = VK_ERROR_FRAGMENTATION_EXT,
549+
ERROR_NOT_PERMITTED_EXT = VK_ERROR_NOT_PERMITTED_EXT,
550+
ERROR_INVALID_DEVICE_ADDRESS_EXT = VK_ERROR_INVALID_DEVICE_ADDRESS_EXT,
551+
ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR = VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR,
552+
PIPELINE_COMPILE_REQUIRED_EXT = VK_PIPELINE_COMPILE_REQUIRED_EXT,
553+
ERROR_PIPELINE_COMPILE_REQUIRED_EXT = VK_ERROR_PIPELINE_COMPILE_REQUIRED_EXT,
554+
ERROR_INCOMPATIBLE_SHADER_BINARY_EXT = VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT,
555+
RESULT_MAX_ENUM = VK_RESULT_MAX_ENUM
556+
} RenderResult;
557+
496558
VULKAN_ENGINE_NAMESPACE_END
497559

498560
#endif

include/engine/core/renderpasses/forward_pass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ class ForwardPass : public RenderPass
4848

4949
void setup_attachments();
5050

51-
void setup_uniforms();
51+
void setup_uniforms(std::vector<Graphics::Frame>& frames);
5252

5353
void setup_shader_passes();
5454

55-
void render(uint32_t frameIndex, Scene* const scene, uint32_t presentImageIndex = 0);
55+
void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0);
5656

5757
void update_uniforms(uint32_t frameIndex, Scene* const scene);
5858

include/engine/core/renderpasses/fxaa_pass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ class FXAAPass : public RenderPass
3636

3737
void setup_attachments();
3838

39-
void setup_uniforms();
39+
void setup_uniforms(std::vector<Graphics::Frame>& frames);
4040

4141
void setup_shader_passes();
4242

43-
void render(uint32_t frameIndex, Scene* const scene, uint32_t presentImageIndex = 0);
43+
void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0);
4444

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

include/engine/core/renderpasses/irradiance_compute_pass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ class IrrandianceComputePass : public RenderPass
2828

2929
void setup_attachments();
3030

31-
void setup_uniforms();
31+
void setup_uniforms(std::vector<Graphics::Frame>& frames);
3232

3333
void setup_shader_passes();
3434

35-
void render(uint32_t frameIndex, Scene* const scene, uint32_t presentImageIndex = 0);
35+
void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0);
3636

3737
void update_uniforms(uint32_t frameIndex, Scene* const scene);
3838

include/engine/core/renderpasses/panorama_conversion_pass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class PanoramaConverterPass : public RenderPass
3030

3131
void setup_attachments();
3232

33-
void setup_uniforms();
33+
void setup_uniforms(std::vector<Graphics::Frame>& frames);
3434

3535
void setup_shader_passes();
3636

37-
void render(uint32_t frameIndex, Scene* const scene, uint32_t presentImageIndex = 0);
37+
void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0);
3838

3939
void update_uniforms(uint32_t frameIndex, Scene* const scene);
4040

include/engine/core/renderpasses/renderpass.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ class RenderPass
5555
bool m_enabled{true};
5656
bool m_isDefault;
5757

58-
5958
public:
60-
static std::vector<Graphics::Frame> frames;
59+
// static std::vector<Graphics::Frame> frames;
6160

6261
RenderPass(Graphics::Device* ctx,
6362
Extent2D extent,
@@ -138,12 +137,12 @@ class RenderPass
138137
/*
139138
Setups de renderpass. Init, create framebuffers, pipelines and resources ...
140139
*/
141-
void setup();
140+
void setup(std::vector<Graphics::Frame>& frames);
142141

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

148147
virtual void update_uniforms(uint32_t frameIndex, Scene* const scene) {
149148
}

include/engine/core/renderpasses/shadow_pass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class ShadowPass : public RenderPass
3838

3939
void setup_attachments();
4040

41-
void setup_uniforms();
41+
void setup_uniforms(std::vector<Graphics::Frame>& frames);
4242

4343
void setup_shader_passes();
4444

45-
void render(uint32_t frameIndex, Scene* const scene, uint32_t presentImageIndex = 0);
45+
void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0);
4646
};
4747

4848
} // namespace Core

include/engine/core/renderpasses/variance_shadow_pass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ class VarianceShadowPass : public RenderPass
3939

4040
void setup_attachments();
4141

42-
void setup_uniforms();
42+
void setup_uniforms(std::vector<Graphics::Frame>& frames);
4343

4444
void setup_shader_passes();
4545

46-
void render(uint32_t frameIndex, Scene* const scene, uint32_t presentImageIndex = 0);
46+
void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0);
4747
};
4848

4949
} // namespace Core

include/engine/graphics/command_buffer.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <engine/graphics/shaderpass.h>
1616
#include <engine/graphics/utilities/initializers.h>
1717
#include <engine/graphics/vk_renderpass.h>
18+
#include <engine/graphics/semaphore.h>
1819

1920
VULKAN_ENGINE_NAMESPACE_BEGIN
2021

@@ -38,14 +39,14 @@ class CommandBuffer
3839

3940
void init(VkDevice device, CommandPool commandPool, VkCommandBufferLevel level = VK_COMMAND_BUFFER_LEVEL_PRIMARY);
4041

41-
void begin(VkFence& renderFence, VkCommandBufferUsageFlags flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
42+
void begin(VkCommandBufferUsageFlags flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
4243
void end();
4344
void reset();
4445

45-
void submit(VkQueue queue,
46-
VkSemaphore waitSemaphore = VK_NULL_HANDLE,
47-
VkSemaphore signalSemaphore = VK_NULL_HANDLE,
48-
VkFence fence = VK_NULL_HANDLE);
46+
void submit(VkQueue queue,
47+
Fence fence,
48+
std::vector<Semaphore> waitSemaphores = {},
49+
std::vector<Semaphore> signalSemaphores = {});
4950

5051
VkCommandBuffer get_handle() const {
5152
return m_handle;
@@ -92,7 +93,7 @@ class CommandPool
9293
return m_handle;
9394
}
9495

95-
void init(VkDevice& device,
96+
void init(VkDevice device,
9697
uint32_t queueFamilyIndex,
9798
VkCommandPoolCreateFlags flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
9899

0 commit comments

Comments
 (0)