From c7383b55163675515c4245dc8f883d7b462db001 Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 11:44:15 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`pip?= =?UTF-8?q?iline`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @WSQS. * https://github.com/WSQS/sdl_test/pull/7#issuecomment-3527425652 The following files were modified: * `main.cpp` * `sdl_wrapper/sdl_wrapper.buffer.cpp` * `sdl_wrapper/sdl_wrapper.pipeline.cpp` --- main.cpp | 11 ++++------- sdl_wrapper/sdl_wrapper.buffer.cpp | 10 ++++------ sdl_wrapper/sdl_wrapper.pipeline.cpp | 24 ++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/main.cpp b/main.cpp index 8034d76..91169ef 100644 --- a/main.cpp +++ b/main.cpp @@ -226,14 +226,11 @@ void main() } /** - * @brief Advance the application by one frame: update UI state, handle vertex edits and live shader recompilation, - * and render. + * @brief Advance the application by one frame: update UI, apply vertex edits and live shader recompilation, render, and submit GPU work. * - * Processes ImGui frames, applies interactive vertex edits (uploading vertex data when changed), recompiles and - * replaces the vertex shader and graphics pipeline on edits, acquires a GPU command buffer and swapchain texture, - * records a render pass that draws the triangle and ImGui draw lists, and submits the command buffer. + * Processes ImGui frames, uploads vertex data when edited, recompiles and replaces the vertex shader and graphics pipeline on shader edits, records a render pass that draws the triangle and ImGui draw lists, and submits the GPU command buffer for presentation. * - * @return SDL_AppResult SDL_APP_CONTINUE to continue the main loop. + * @return `SDL_APP_CONTINUE` to continue the main loop. */ virtual SDL_AppResult iterate() override { @@ -400,4 +397,4 @@ void main() } }; -sopho::App* create_app() { return new UserApp(); } +sopho::App* create_app() { return new UserApp(); } \ No newline at end of file diff --git a/sdl_wrapper/sdl_wrapper.buffer.cpp b/sdl_wrapper/sdl_wrapper.buffer.cpp index 907cfd2..e94078f 100644 --- a/sdl_wrapper/sdl_wrapper.buffer.cpp +++ b/sdl_wrapper/sdl_wrapper.buffer.cpp @@ -34,12 +34,10 @@ namespace sopho } /** - * @brief Uploads a block of data into the wrapped GPU vertex buffer at the specified offset. + * @brief Uploads a block of data into the wrapped GPU vertex buffer at the specified byte offset. * - * If the internal transfer (staging) buffer is smaller than `p_size`, it will be reallocated - * to accommodate the upload. The function copies `p_size` bytes from `p_data` into the transfer - * buffer and enqueues a GPU copy pass that transfers those bytes into the vertex buffer at - * `p_offset`. + * If the internal staging transfer buffer is smaller than p_size it is reallocated to fit. + * Copies p_size bytes from p_data into the transfer buffer and enqueues a GPU copy pass to transfer them into the vertex buffer at p_offset. * * @param p_data Pointer to the source data to upload. * @param p_size Size in bytes of the data to upload. @@ -80,4 +78,4 @@ namespace sopho SDL_EndGPUCopyPass(copy_pass); SDL_SubmitGPUCommandBuffer(command_buffer); } -} // namespace sopho +} // namespace sopho \ No newline at end of file diff --git a/sdl_wrapper/sdl_wrapper.pipeline.cpp b/sdl_wrapper/sdl_wrapper.pipeline.cpp index 5f981f5..d926577 100644 --- a/sdl_wrapper/sdl_wrapper.pipeline.cpp +++ b/sdl_wrapper/sdl_wrapper.pipeline.cpp @@ -9,7 +9,19 @@ import :pipeline; namespace sopho { - PipelineWrapper::PipelineWrapper(std::shared_ptr p_device) : m_device(p_device) {} + /** + * @brief Initializes the PipelineWrapper with the given GPU device wrapper. + * + * @param p_device Shared pointer to a GpuWrapper representing the target GPU device; the wrapper retains this reference for its lifetime. + */ +PipelineWrapper::PipelineWrapper(std::shared_ptr p_device) : m_device(p_device) {} + /** + * @brief Releases any GPU graphics pipeline owned by this wrapper. + * + * If a graphics pipeline is currently held, it is released using the associated + * device and the stored pipeline handle is cleared so the wrapper no longer + * references the pipeline. + */ PipelineWrapper::~PipelineWrapper() { if (m_graphics_pipeline) @@ -18,6 +30,14 @@ namespace sopho m_graphics_pipeline = nullptr; } } + /** + * @brief Rebuilds the GPU graphics pipeline when the wrapper is marked modified. + * + * If the wrapper's modified flag is set, this clears the flag, attempts to create a new + * graphics pipeline from the stored pipeline info and device, and on success replaces the + * current pipeline (releasing the previous pipeline first). If creation fails, an error + * is logged. + */ auto PipelineWrapper::submit() { if (modified) @@ -38,4 +58,4 @@ namespace sopho } } } -} // namespace sopho +} // namespace sopho \ No newline at end of file From 04ec4b22f66d7995873a7224d08d8b137922c31a Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 11:44:28 +0000 Subject: [PATCH 2/2] style: format code with ClangFormat This commit fixes the style issues introduced in c7383b5 according to the output from ClangFormat. Details: https://github.com/WSQS/sdl_test/pull/17 --- main.cpp | 9 ++++++--- sdl_wrapper/sdl_wrapper.buffer.cpp | 5 +++-- sdl_wrapper/sdl_wrapper.pipeline.cpp | 13 +++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/main.cpp b/main.cpp index 91169ef..4ab014f 100644 --- a/main.cpp +++ b/main.cpp @@ -226,9 +226,12 @@ void main() } /** - * @brief Advance the application by one frame: update UI, apply vertex edits and live shader recompilation, render, and submit GPU work. + * @brief Advance the application by one frame: update UI, apply vertex edits and live shader recompilation, render, + * and submit GPU work. * - * Processes ImGui frames, uploads vertex data when edited, recompiles and replaces the vertex shader and graphics pipeline on shader edits, records a render pass that draws the triangle and ImGui draw lists, and submits the GPU command buffer for presentation. + * Processes ImGui frames, uploads vertex data when edited, recompiles and replaces the vertex shader and graphics + * pipeline on shader edits, records a render pass that draws the triangle and ImGui draw lists, and submits the GPU + * command buffer for presentation. * * @return `SDL_APP_CONTINUE` to continue the main loop. */ @@ -397,4 +400,4 @@ void main() } }; -sopho::App* create_app() { return new UserApp(); } \ No newline at end of file +sopho::App* create_app() { return new UserApp(); } diff --git a/sdl_wrapper/sdl_wrapper.buffer.cpp b/sdl_wrapper/sdl_wrapper.buffer.cpp index e94078f..3249bb7 100644 --- a/sdl_wrapper/sdl_wrapper.buffer.cpp +++ b/sdl_wrapper/sdl_wrapper.buffer.cpp @@ -37,7 +37,8 @@ namespace sopho * @brief Uploads a block of data into the wrapped GPU vertex buffer at the specified byte offset. * * If the internal staging transfer buffer is smaller than p_size it is reallocated to fit. - * Copies p_size bytes from p_data into the transfer buffer and enqueues a GPU copy pass to transfer them into the vertex buffer at p_offset. + * Copies p_size bytes from p_data into the transfer buffer and enqueues a GPU copy pass to transfer them into the + * vertex buffer at p_offset. * * @param p_data Pointer to the source data to upload. * @param p_size Size in bytes of the data to upload. @@ -78,4 +79,4 @@ namespace sopho SDL_EndGPUCopyPass(copy_pass); SDL_SubmitGPUCommandBuffer(command_buffer); } -} // namespace sopho \ No newline at end of file +} // namespace sopho diff --git a/sdl_wrapper/sdl_wrapper.pipeline.cpp b/sdl_wrapper/sdl_wrapper.pipeline.cpp index d926577..5136955 100644 --- a/sdl_wrapper/sdl_wrapper.pipeline.cpp +++ b/sdl_wrapper/sdl_wrapper.pipeline.cpp @@ -10,11 +10,12 @@ import :pipeline; namespace sopho { /** - * @brief Initializes the PipelineWrapper with the given GPU device wrapper. - * - * @param p_device Shared pointer to a GpuWrapper representing the target GPU device; the wrapper retains this reference for its lifetime. - */ -PipelineWrapper::PipelineWrapper(std::shared_ptr p_device) : m_device(p_device) {} + * @brief Initializes the PipelineWrapper with the given GPU device wrapper. + * + * @param p_device Shared pointer to a GpuWrapper representing the target GPU device; the wrapper retains this + * reference for its lifetime. + */ + PipelineWrapper::PipelineWrapper(std::shared_ptr p_device) : m_device(p_device) {} /** * @brief Releases any GPU graphics pipeline owned by this wrapper. * @@ -58,4 +59,4 @@ PipelineWrapper::PipelineWrapper(std::shared_ptr p_device) : m_devic } } } -} // namespace sopho \ No newline at end of file +} // namespace sopho