Jackalope / jen (public) (License: GPLv3 or later version) (since 2018-10-24) (hash sha1)
----> ABOUT:

3D rendering and computing framework based on Vulkan API.

Libraries:
- simdcpp submodule (see my simdcpp repo)
- jmath submodule (see my jmath repo)
- mesh (constexpr generation of cubes, spheres, icosahedrons subdivisions)
- atlas (1D lines and 2D rectangles cutting)
- jlib submodule (see my jlib repo)
- jrf submodule (see my jrf repo)
- vkw (Vulkan API C++ wrapper)
Modules:
- compute (run compute shaders on gpu)
- graphics (draw models with clustered forward rendering and onscreen text)
- resource manager (load meshes, models, textures, scene data from
files and create related objects in graphics module)

----> INSTALLING:

To download all the parts of this framework it's enough to launch
git clone with recursive flag:

$ git clone —recursive ssh://rocketgit@ssh.rocketgit.com/user/Jackalope/jen

After this look at git tags:

$ git tag

It is recommended to use a tagged version instead of the latest commit,
because the first commit after the tagged one mostly includes incompatible
parts of future changes for the next version.

$ git checkout v0.1.0

----> DEPENDENCIES:

To use JEN as CMake subdirectory and successfully build programs with it
you need to make sure you have all of its dependencies:
- compiler: Clang or GCC, support for C++17. Clang 10+ or GCC 9+ is recommended,
compiling on Windows OS is tricky and requires something like MinGW with MSYS,
there are also some complications to go through to make dependencies work;
- GLFW3 library, supported version is 3.2.1;
- FreeType library, if graphics module will be used;
- Vulkan API headers, and optional validation layers to debug sneaky problems,
you also need Vulkan support in your graphics driver to run compiled programs;
- LibZip can be necessary, if JRF is used to read zip files;
- CMake, for obvious reasons;
- glslangValidator to compile shader for the graphics module.

CMake must be able to find GLFW3, Vulkan and FreeType (for graphics)
with find_package().

----> HOW TO USE IT:

To use JEN, you need to add it as a subdirectory:

add_subdirecroty(${PATH_TO_JEN})

There are several configuration options:
- JEN_MODULE_COMPUTE - turn compute module on for compiling and including;
- JEN_MODULE_GRAPHICS - turn graphics module on ...;
- JEN_MULTITHREADED_DRAW_FRAME - draw_frame function will use thread pool queue
instead of linear executing;
- JEN_MODULE_RESOURCE_MANAGER - resource manager module ON, if graphics is ON;
- JEN_VLK_VALIDATION - enable Vulkan Validation Layers to debug some errors
related to JEN. This will often produce false-positive,
as well as true-positive errors.

Look in CMakeLists.txt at JenExamples repo for details on how to use and
configure JEN automatically:

$ git clone ssh://rocketgit@ssh.rocketgit.com/user/Jackalope/JenExamples

Also I recommend to compile and run examples to make sure it works correctly.

----> SUPPORTED HARDWARE:

JEN has not been tested well, because it requires running it on large amount of
different hardware to do so. It must work with mesa driver and modern
Intel i965 GPUs as well as AMD GPUs.


----> DOCUMENTATION:

You can generate Doxygen documentation, to do so
turn on any of JEN_DOXYGEN_* options and run documentation target in cmake:

$ cmake -G %1 -DJEN_DOXYGEN_HTML=ON -DJEN_DOXYGEN_LATEX=ON
$ cmake —build —target documentation

Resource manager is not documented because it still requires large enhancements.
List of commits:
Subject Hash Author Date (UTC)
Remove debug overlay from framework settings, instead load on request. 33c0b44a748570c1c8dcce58794fdac21d517156 Jackalope 2020-06-01 12:24:31
Shaders shading bug fix. Shader shared code moved for including with extention. 7de6429997bda227a175db8fba81e8f960b1a340 Jackalope 2020-06-01 12:23:05
Window laggy input fixes. 1d136d616277dde9262a3093c802f3d24ca8aa5d Jackalope 2020-06-01 12:21:00
New shading type SHADOW_MAPPING is added to remove experimental shadow mapping from DEFAULT. d4651206b1798ddec7e3275352f48445b8a184d2 Jackalope 2020-06-01 04:01:29
Debug pipelines crash fix. 9b0a75d94e30eb7fd45360f7fe10429bf05c243e Jackalope 2020-06-01 04:00:24
Window improvements. scroll_diff and cursor_diff members. Update noclip screen. 8d659590a0fb52e1e24683305a7ee8699bdff6da Jackalope 2020-06-01 01:30:50
Update jlib 0.4.1 Update jrf 0.2.2 d36e5263523a9b0443476b2db8d856e86086af81 Jackalope 2020-05-31 23:58:41
Update jmath 0.1.2. 8d3566336ef87f73318e84cde87bdf841240dcdc Jackalope 2020-05-31 23:57:25
Use scanf instead of fgets for interactive device selection. fd7ff8b61ef1e21852d6c0a15ab0d17d09c5cccc Jackalope 2020-05-31 23:56:34
Include FreeType as system library to prevent warnings. dc92c7f8acdaa90b25cf272f1730d338111780fc Jackalope 2020-05-31 23:54:37
Add glfw required version. 3.3.1 is not working. ee727d7efda88af1e8a227b542f5b79d0ba6f301 Jackalope 2020-05-31 23:53:33
GCC Compatibility. c828a38456627d0383d431165b802f97fd303349 Jackalope 2020-05-29 16:48:24
Solved clang compiler warnings from compute module. b9416237761f8648bbddb7e7ba59e833a7879528 Jackalope 2020-05-28 11:09:55
CMake: two shaders targets, instead of single target per shader. a708650319e44c7b98056f3bc85a896dd65d96f3 Jackalope 2020-05-28 11:06:13
Reduced amount of warnings. 18bf33ca4e0e7f0369f6b5fdc59b81a8420dde8e Jackalope 2020-05-27 15:11:37
Replace jl::rarray with generic structure in shader header file. 1cedb5886becc0f70c19d1c649e96f7eac5e0037 Jackalope 2020-05-27 13:07:31
Embedding shaders in obj library. e877e7a688ee4a899480c12acba55c340622f993 Jackalope 2020-05-27 12:40:34
Update jlib 0.3.0 (refactoring of threads, new thread pool). 1c713a320ced91d0ad5f1606c39f1187871d28e5 Jackalope 2020-05-26 14:44:35
Update graphics after change of "wait for monitor" flag. 29d9b749c803646006b9b0071b54256bd3c08ca8 Jackalope 2020-05-26 14:40:34
reduced number of -Wno* warnings bf3ec94ce3020715e246107a47efc9a8772db382 Jackalope 2020-05-25 01:48:40
Commit 33c0b44a748570c1c8dcce58794fdac21d517156 - Remove debug overlay from framework settings, instead load on request.
Author: Jackalope
Author date (UTC): 2020-06-01 12:24
Committer name: Jackalope
Committer date (UTC): 2020-06-01 12:24
Parent(s): 7de6429997bda227a175db8fba81e8f960b1a340
Signing key:
Tree: 791ad62b5482114fa1c319c5675ad7f589f3d12b
File Lines added Lines deleted
include/jen/graphics.h 60 15
include/jen/settings.h 0 18
libs/vkw/include/vkw/result.h 1 0
libs/vkw/src/vkw.cpp 1 0
src/graphics/debug_overlay.cpp 15 3
src/graphics/debug_overlay.h 22 19
src/graphics/graphics.cpp 2 13
src/graphics/graphics_interface.cpp 27 19
File include/jen/graphics.h changed (mode: 100644) (index cdd29e4..4c9f25f)
34 34 namespace jen { namespace jen {
35 35 struct ModuleGraphics; struct ModuleGraphics;
36 36 struct DrawFrameLoop; struct DrawFrameLoop;
37 /// @brief Options for DebugOverlay (display some information on screen).
38 struct DebugOverlaySettings {
39 /// @brief Initialize with default values.
40 constexpr void set_default() {
41 is_visible = false;
42 toggle_key = Key::Board::f1;
43 p_font_path = "fonts/IBMPlexMono.ttf";
44 }
45 /// Is enabled by default
46 bool is_visible;
47 /// Keyboard code to toggle overlay.
48 Key::Board toggle_key;
49 /// Path to font for displayed text, must not be nullptr.
50 const char *p_font_path;
51 };
37 52 } }
38 53 /// @brief 3D Graphics renderer /// @brief 3D Graphics renderer
39 54 /// ModuleGraphics can only be created and destroyed by the Framework. /// ModuleGraphics can only be created and destroyed by the Framework.
 
... ... struct jen::ModuleGraphics
49 64 /// @param settings GraphicsSettings with valid values /// @param settings GraphicsSettings with valid values
50 65 /// @return User optionally can check for VK_ERROR_OUT_OF_HOST_MEMORY or /// @return User optionally can check for VK_ERROR_OUT_OF_HOST_MEMORY or
51 66 /// VK_ERROR_OUT_OF_DEVICE_MEMORY to free up some memory. /// VK_ERROR_OUT_OF_DEVICE_MEMORY to free up some memory.
52 Result apply_settings(const GraphicsSettings &settings);
67 Result
68 apply_settings(const GraphicsSettings &settings);
69
70
71 /// @brief Load overlay -- on-screen debug info.
72 /// @param settings DebugOverlaySettings
73 /// @return Possible values are: VK_ERROR_OUT_OF_HOST_MEMORY,
74 /// vkw::ERROR_EXIST (overlay is already loaded), ERROR_FILE_OPENING.
75 Result
76 overlay_load(const DebugOverlaySettings &settings);
77 /// @brief Destroy overlay.
78 /// If overlay is not loaded, nothing will be changed.
79 void
80 overlay_unload();
81
82
53 83 /// @brief Update camera and frustum parameters /// @brief Update camera and frustum parameters
54 void apply_camera(const Camera&, const Frustum&);
84 void
85 apply_camera(const Camera&, const Frustum&);
55 86 /// @brief Update shadow-casting light. /// @brief Update shadow-casting light.
56 87 /// @param l light for shadow mapping /// @param l light for shadow mapping
57 void apply_light_shadow(const Light &l);
88 void
89 apply_light_shadow(const Light &l);
58 90 /// @brief Provide pointer to light information. /// @brief Provide pointer to light information.
59 91 /// Light data must not change simultaneously with function draw_frame /// Light data must not change simultaneously with function draw_frame
60 92 /// (data pointed to by array LightsDraw.lights). /// (data pointed to by array LightsDraw.lights).
 
... ... struct jen::ModuleGraphics
63 95 /// checked in draw_frame function and will be set to false. /// checked in draw_frame function and will be set to false.
64 96 /// @param p_lights pointer to LightsDraw, must be valid pointer until /// @param p_lights pointer to LightsDraw, must be valid pointer until
65 97 /// new pointer is provided or ModuleGraphics is destroyed /// new pointer is provided or ModuleGraphics is destroyed
66 void apply_lights(LightsDraw *p_lights);
98 void
99 apply_lights(LightsDraw *p_lights);
67 100 /// @brief Run data to GPU writing process and acquire GpuData memory handle. /// @brief Run data to GPU writing process and acquire GpuData memory handle.
68 101 /// User memory under WriteData.p ptr must be valid when the writing process /// User memory under WriteData.p ptr must be valid when the writing process
69 102 /// is occurs. To check writtings process status, use is_resource_ready. /// is occurs. To check writtings process status, use is_resource_ready.
 
... ... struct jen::ModuleGraphics
76 109 /// @param free_src If this flag is set to true, WriteData.p memory will /// @param free_src If this flag is set to true, WriteData.p memory will
77 110 /// be deallocated in the end of the writing proccess /// be deallocated in the end of the writing proccess
78 111 /// @return If not VK_SUCCESS then nothing is done /// @return If not VK_SUCCESS then nothing is done
112
113
79 114 [[nodiscard]] Result [[nodiscard]] Result
80 115 create(const WriteData &w, GpuData **pp_dst, bool free_src); create(const WriteData &w, GpuData **pp_dst, bool free_src);
81 116 /// @brief Run data to GPU writing process and write GpuData to user memory. /// @brief Run data to GPU writing process and write GpuData to user memory.
 
... ... struct jen::ModuleGraphics
87 122 /// @see create(const WriteData&, GpuData**, bool) /// @see create(const WriteData&, GpuData**, bool)
88 123 [[nodiscard]] Result [[nodiscard]] Result
89 124 create(const WriteData& w, GpuData *p_allocated, bool free_src); create(const WriteData& w, GpuData *p_allocated, bool free_src);
125 /// @brief Free memory and GpuData handle.
126 /// GpuData handle becomes invalid after freeing
127 /// @param p Valid GpuData handle, acquired from ModuleGraphics::create
128 /// @param free_src If set to true, specified in ModuleGraphics::create
129 /// WriteData.p memory will be deallocated
130 /// (no effect if it is already deallocated after create)
131 void
132 destroy(GpuData *p, bool free_src);
133
134
90 135 /// @brief Run gpu texture creation process and acquire GpuTexture handle. /// @brief Run gpu texture creation process and acquire GpuTexture handle.
91 136 /// User memory under jrf::Image.p_pixels pointer must be valid when the /// User memory under jrf::Image.p_pixels pointer must be valid when the
92 137 /// texture creation process occurs. To check process status, /// texture creation process occurs. To check process status,
 
... ... struct jen::ModuleGraphics
101 146 /// be destroyed in the end if the writing proccess /// be destroyed in the end if the writing proccess
102 147 [[nodiscard]] Result [[nodiscard]] Result
103 148 create(const jrf::Image &texture, GpuTexture **pp_dst, bool free_src); create(const jrf::Image &texture, GpuTexture **pp_dst, bool free_src);
104 /// @brief Free memory and GpuData handle.
105 /// GpuData handle becomes invalid after freeing
106 /// @param p Valid GpuData handle, acquired from ModuleGraphics::create
107 /// @param free_src If set to true, specified in ModuleGraphics::create
108 /// WriteData.p memory will be deallocated
109 /// (no effect if it is already deallocated after create)
110 void destroy(GpuData *p, bool free_src);
111 149 /// @brief Free memory and GpuTexture handle. /// @brief Free memory and GpuTexture handle.
112 150 /// GpuTexture handle becomes invalid after freeing /// GpuTexture handle becomes invalid after freeing
113 151 /// @param p Valid GpuTexture handle, acquired from ModuleGraphics::create /// @param p Valid GpuTexture handle, acquired from ModuleGraphics::create
114 152 /// @param free_src If set to true, specified in ModuleGraphics::create /// @param free_src If set to true, specified in ModuleGraphics::create
115 153 /// jrf::Image will be destroyed /// jrf::Image will be destroyed
116 154 /// (no effect if it is already destroyed after create) /// (no effect if it is already destroyed after create)
117 void destroy(GpuTexture *p, bool free_src);
155 void
156 destroy(GpuTexture *p, bool free_src);
157
118 158
119 159 /// @brief Create GlyphManager handle with font from file. /// @brief Create GlyphManager handle with font from file.
120 160 /// @param font_path path to font file with /// @param font_path path to font file with
 
... ... struct jen::ModuleGraphics
123 163 /// @return true if success, else nothing is created /// @return true if success, else nothing is created
124 164 [[nodiscard]] bool [[nodiscard]] bool
125 165 create(const char* font_path, GlyphManager **pp_dst); create(const char* font_path, GlyphManager **pp_dst);
126
127 166 /// @brief Create or update text on the gpu. /// @brief Create or update text on the gpu.
128 167 /// After this function call this text will be drawn every frame untill /// After this function call this text will be drawn every frame untill
129 168 /// ModuleGraphics::destroy(GpuText*) is called with this GpuText handle. /// ModuleGraphics::destroy(GpuText*) is called with this GpuText handle.
 
... ... struct jen::ModuleGraphics
145 184 /// @brief Stop gpu text drawing and free GpuText handle. /// @brief Stop gpu text drawing and free GpuText handle.
146 185 /// After this call, GpuText handle cant be used again for text_update /// After this call, GpuText handle cant be used again for text_update
147 186 /// @param p_text Text to free /// @param p_text Text to free
148 void destroy(GpuText *p_text);
187 void
188 destroy(GpuText *p_text);
149 189 /// @brief Destroy GlyphManager handle and font data. /// @brief Destroy GlyphManager handle and font data.
150 190 /// GlyphManager handle is freed and invalid after this function. /// GlyphManager handle is freed and invalid after this function.
151 191 /// @param p_font Valid GlyphManager handle, all GpuText handles created /// @param p_font Valid GlyphManager handle, all GpuText handles created
152 192 /// with this GlyphManager handle must be destroyed before. /// with this GlyphManager handle must be destroyed before.
153 void destroy(GlyphManager *p_font);
193 void
194 destroy(GlyphManager *p_font);
195
196
154 197 /// @brief Acquire swapchain image, draw on it and present to window's surface /// @brief Acquire swapchain image, draw on it and present to window's surface
155 198 /// @param models Constant array of models to use in rendering operation /// @param models Constant array of models to use in rendering operation
156 199 /// @return If not VK_SUCCESS then frame is not presented /// @return If not VK_SUCCESS then frame is not presented
157 200 [[nodiscard]] Result [[nodiscard]] Result
158 201 draw_frame(const jl::rarray<const Model> &models); draw_frame(const jl::rarray<const Model> &models);
202
203
159 204 struct Data; struct Data;
160 205 /// @brief Pointer to hidden data of ModuleGraphics. /// @brief Pointer to hidden data of ModuleGraphics.
161 206 /// Because of this pointer, ModuleGraphics can be shared by value. /// Because of this pointer, ModuleGraphics can be shared by value.
File include/jen/settings.h changed (mode: 100644) (index be2dfd1..98acc7a)
... ... struct jen::GraphicsSettings
192 192 wait_for_monitor = true; wait_for_monitor = true;
193 193 is_debug_normals_visible = false; is_debug_normals_visible = false;
194 194 is_debug_depth_cube_visible = false; is_debug_depth_cube_visible = false;
195
196 debug_overlay.is_enabled = true;
197 debug_overlay.is_visible = false;
198 debug_overlay.toggle_key = Key::Board::f1;
199 debug_overlay.font_path = "fonts//IBMPlexMono.ttf";
200 195 } }
201 196 /// @brief Get default settings. /// @brief Get default settings.
202 197 /// @see GraphicsSettings::set_default /// @see GraphicsSettings::set_default
 
... ... struct jen::GraphicsSettings
218 213 /// A 2D-cube texture represented by 6 layers: extent*extent*6. /// A 2D-cube texture represented by 6 layers: extent*extent*6.
219 214 uint32_t extent; uint32_t extent;
220 215 }; };
221 /// @brief Options for DebugOverlay (display some information on screen).
222 struct DebugOverlay {
223 /// If not enabled, it is impossible to enable later
224 bool is_enabled;
225 /// Overlay will hide if it is not visible
226 bool is_visible;
227 /// Keyboard code to toggle visibility
228 Key::Board toggle_key;
229 /// Valid path to font for displayed text
230 const char *font_path;
231 };
232 216 /// @see GraphicsSettings::Shading /// @see GraphicsSettings::Shading
233 217 Shading shading; Shading shading;
234 218 /// @see GraphicsSettings::Shadow /// @see GraphicsSettings::Shadow
 
... ... struct jen::GraphicsSettings
254 238 bool is_debug_normals_visible; bool is_debug_normals_visible;
255 239 /// Draw shadow map depth cube faces onscreen for debug purposes. /// Draw shadow map depth cube faces onscreen for debug purposes.
256 240 bool is_debug_depth_cube_visible; bool is_debug_depth_cube_visible;
257 /// @see GraphicsSettings::DebugOverlay
258 DebugOverlay debug_overlay;
259 241 }; };
260 242 #endif #endif
261 243 /// @brief All settings for framework components. /// @brief All settings for framework components.
File libs/vkw/include/vkw/result.h changed (mode: 100644) (index 9a0302a..743eeb4)
... ... namespace vkw {
33 33 ERROR_FILE_CORRUPTED, ERROR_FILE_CORRUPTED,
34 34 ERROR_NO_OBJECTS_LEFT, ERROR_NO_OBJECTS_LEFT,
35 35 ERROR_WINDOW_INITIALIZATION, ERROR_WINDOW_INITIALIZATION,
36 ERROR_EXIST
36 37 }; };
37 38 using Result = detail::EnumInheritance<Error, VkResult>; using Result = detail::EnumInheritance<Error, VkResult>;
38 39 const char* to_string(VkResult result); const char* to_string(VkResult result);
File libs/vkw/src/vkw.cpp changed (mode: 100644) (index 5a2241a..7cd3dfa)
... ... const char* vkw::to_string(Result result) {
79 79 STR(ERROR_WRONG_RESOURCE_FORMAT); STR(ERROR_WRONG_RESOURCE_FORMAT);
80 80 STR(ERROR_NO_OBJECTS_LEFT); STR(ERROR_NO_OBJECTS_LEFT);
81 81 STR(ERROR_WINDOW_INITIALIZATION); STR(ERROR_WINDOW_INITIALIZATION);
82 STR(ERROR_EXIST);
82 83 #undef STR #undef STR
83 84 } }
84 85 return to_string(result.operator VkResult()); return to_string(result.operator VkResult());
File src/graphics/debug_overlay.cpp changed (mode: 100644) (index 09a40fc..87d810c)
... ... fill_fps(DebugOverlay *p_do, uint32_t *p_color = nullptr)
122 122
123 123
124 124 [[nodiscard]] Result DebugOverlay:: [[nodiscard]] Result DebugOverlay::
125 init(ModuleGraphics mg, const char *p_font_path) {
126 if (not mg.create(p_font_path, &p_font))
125 init(ModuleGraphics mg, const DebugOverlaySettings &settings) {
126 is_disabled = not settings.is_visible;
127 toggle_key = settings.toggle_key;
128 if (not mg.create(settings.p_font_path, &p_font))
127 129 return vkw::Error::ERROR_FILE_OPENING; return vkw::Error::ERROR_FILE_OPENING;
128 130 for (auto &p : p_texts) for (auto &p : p_texts)
129 131 p = nullptr; p = nullptr;
132 period_elapsed = {};
133 frames_per_period = 0;
130 134 return VK_SUCCESS; return VK_SUCCESS;
131 135 } }
132 136 [[nodiscard]] Result DebugOverlay:: [[nodiscard]] Result DebugOverlay::
133 update(ModuleGraphics mg, jl::time elapsed) {
137 update(ModuleGraphics mg, jl::time elapsed, const Window &window) {
138 if (button.is_fired(toggle_key, window)) {
139 if (is_disabled) {
140 disable(mg);
141 return VK_SUCCESS;
142 }
143 }
144 is_disabled = false;
134 145 uint32_t color; uint32_t color;
135 146 color = 0xFFFFFFFF; color = 0xFFFFFFFF;
136 147
 
... ... disable(ModuleGraphics mg) {
174 185 mg.destroy(p); mg.destroy(p);
175 186 p = nullptr; p = nullptr;
176 187 } }
188 is_disabled = true;
177 189 } }
File src/graphics/debug_overlay.h changed (mode: 100644) (index bfa9a8f..7f2791e)
20 20 #include <jlib/time.h> #include <jlib/time.h>
21 21 #include "draw_data/text_data/glyphs.h" #include "draw_data/text_data/glyphs.h"
22 22 #include <jen/graphics.h> #include <jen/graphics.h>
23 #include <jen/window.h>
23 24
24 namespace jen
25 {
26 struct DebugOverlay
27 {
28 constexpr static const uint32_t BUFFER_SIZE = 1000;
29 constexpr static const uint32_t ELAPSED_BUFFER_SIZE = 25;
25 namespace jen { struct DebugOverlay; }
26 struct jen::DebugOverlay {
27 constexpr static const uint32_t BUFFER_SIZE = 1000;
28 constexpr static const uint32_t ELAPSED_BUFFER_SIZE = 25;
30 29
30 [[nodiscard]] Result
31 init(ModuleGraphics mg, const DebugOverlaySettings &settings);
32 void
33 destroy(ModuleGraphics mg);
31 34
32 [[nodiscard]] Result init(ModuleGraphics mg, const char *font_path);
33 void destroy(ModuleGraphics mg);
35 [[nodiscard]] Result
36 update(ModuleGraphics mg, jl::time elapsed, const Window &window);
37 void
38 disable(ModuleGraphics mg);
34 39
35 [[nodiscard]] Result update(ModuleGraphics mg, jl::time elapsed);
36 void disable(ModuleGraphics mg);
37
38 GlyphManager *p_font;
39 GpuText *p_texts[1];
40
41 jl::time period_elapsed = {};
42 uint64_t frames_per_period = 0;
43 uint32_t buffer[BUFFER_SIZE];
44 };
45 }
40 bool is_disabled;
41 Key::Board toggle_key;
42 Button button;
43 GlyphManager *p_font;
44 GpuText *p_texts[1];
45 jl::time period_elapsed;
46 uint64_t frames_per_period;
47 uint32_t buffer[BUFFER_SIZE];
48 };
File src/graphics/graphics.cpp changed (mode: 100644) (index d750a0e..1fe8415)
... ... EXIT:
822 822 jl::time elapsed = p->last_draw_time.elapsed(current_time); jl::time elapsed = p->last_draw_time.elapsed(current_time);
823 823 p->last_draw_time = current_time; p->last_draw_time = current_time;
824 824
825 if (p->p_debug_overlay != nullptr) {
826 static Button button = {};
827 if (button.is_fired(p->settings.debug_overlay.toggle_key,
828 p->p_instance->window))
829 p->settings.debug_overlay.is_visible =
830 not p->settings.debug_overlay.is_visible;
831 if (p->settings.debug_overlay.is_visible) {
832 res = p->p_debug_overlay->update({p}, elapsed);
833 if (res != VK_SUCCESS)
834 return res;
835 }
836 else p->p_debug_overlay->disable({p});
837 }
825 if (p->p_debug_overlay != nullptr)
826 (void)p->p_debug_overlay->update(*this, elapsed, p->p_instance->window);
838 827 p->p_instance->window.is_damaged = false; p->p_instance->window.is_damaged = false;
839 828 } }
840 829 return res; return res;
File src/graphics/graphics_interface.cpp changed (mode: 100644) (index 513494c..b84e5f1)
... ... init(Instance *p_inst, Device *p_dev, const GraphicsSettings &setts)
74 74 goto EXIT; goto EXIT;
75 75 } }
76 76
77 if (settings.debug_overlay.is_enabled) {
78 if (not jl::allocate(&p_debug_overlay)) {
79 destroy(6);
80 goto EXIT;
81 }
82 res = p_debug_overlay->init({this}, settings.debug_overlay.font_path);
83 if (res != VK_SUCCESS) {
84 destroy(7);
85 goto EXIT;
86 }
87 }
88 else p_debug_overlay = nullptr;
77 p_debug_overlay = nullptr;
89 78 EXIT: EXIT:
90 79 if (res != VK_SUCCESS) if (res != VK_SUCCESS)
91 80 fprintf(stderr, "Graphics module loading failed %s\n", vkw::to_string(res)); fprintf(stderr, "Graphics module loading failed %s\n", vkw::to_string(res));
 
... ... void ModuleGraphics::Data::
100 89 destroy(int code) destroy(int code)
101 90 { {
102 91 (void)p_device->device.wait_idle(); (void)p_device->device.wait_idle();
92 ModuleGraphics{this}.overlay_unload();
103 93
104 94 switch(code) switch(code)
105 95 { {
106 96 default: default:
107 [[fallthrough]]; case 8: if (p_debug_overlay != nullptr)
108 p_debug_overlay->destroy({this});
109 [[fallthrough]]; case 7: if (p_debug_overlay != nullptr)
110 jl::deallocate(&p_debug_overlay);
111 97 [[fallthrough]]; case 6: draw_data.destroy(); [[fallthrough]]; case 6: draw_data.destroy();
112 98 [[fallthrough]]; case 5: destroyer.destroy(); [[fallthrough]]; case 5: destroyer.destroy();
113 99 [[fallthrough]]; case 4: gpu_transfer.join(); [[fallthrough]]; case 4: gpu_transfer.join();
 
... ... apply_settings(const GraphicsSettings &settings) {
214 200 return VK_SUCCESS; return VK_SUCCESS;
215 201 } }
216 202
203
204 [[nodiscard]] Result ModuleGraphics::
205 overlay_load(const DebugOverlaySettings &settings) {
206 if (p->p_debug_overlay != nullptr)
207 return vkw::ERROR_EXIST;
208 if (not jl::allocate(&p->p_debug_overlay))
209 return VK_ERROR_OUT_OF_HOST_MEMORY;
210 Result res;
211 res = p->p_debug_overlay->init(*this, settings);
212 if (res != VK_SUCCESS) {
213 jl::deallocate(&p->p_debug_overlay);
214 return res;
215 }
216 return VK_SUCCESS;
217 }
218 void ModuleGraphics::
219 overlay_unload() {
220 if (p->p_debug_overlay == nullptr)
221 return;
222 p->p_debug_overlay->destroy(*this);
223 jl::deallocate(&p->p_debug_overlay);
224 }
225
226
217 227 jen::ResourceState jen::resource_state(const jen::GpuData * const p) { jen::ResourceState jen::resource_state(const jen::GpuData * const p) {
218 228 return p->state; return p->state;
219 229 } }
 
... ... run(ModuleGraphics mg, void *p_update_arg, void(*pf_update)(void*))
363 373 elapsed_after_update = last_update_time.elapsed(update_time); elapsed_after_update = last_update_time.elapsed(update_time);
364 374 last_update_time = update_time; last_update_time = update_time;
365 375
366 if (window.is_damaged || (not pause)) {
376 if (not pause or window.is_damaged) {
367 377 pf_update(p_update_arg); pf_update(p_update_arg);
368 378 if (break_loop) if (break_loop)
369 379 break; break;
370
371 380 if (not draw) if (not draw)
372 381 continue; continue;
373
374 382 result = mg.draw_frame(models); result = mg.draw_frame(models);
375 383 is_drawn = result == VK_SUCCESS; is_drawn = result == VK_SUCCESS;
376 384 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/Jackalope/jen

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/Jackalope/jen

Clone this repository using git:
git clone git://git.rocketgit.com/user/Jackalope/jen

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main