Split vulkan_window.cpp by responsibility and render() into phases
VulkanWindow's 3000-line TU becomes sdl_window.cpp (window, events, cursor, screenshot BMP), vk_device.cpp (device, swapchain, MSAA, framebuffers), vk_pipelines.cpp (render passes, pipelines), vk_resources.cpp (buffers, render targets, geometry), vk_textures.cpp (textures, samplers, descriptors), vk_frame.cpp (render) and ui_batches.cpp; vulkan_window.cpp keeps construction and timing stats. Function bodies move verbatim. render() now reads fence/acquire -> prepare_draws -> prepare_ui -> write_draw_states -> record_passes -> record_readbacks -> submit -> finish_readbacks -> present, with FrameDraws / Readback carrying the locals that used to live across 500 lines. Verified: login-screen screenshot byte-identical to HEAD; game-world draw/vertex/index/UI counts identical; ctest, port_gate macos+android, Android build pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
eab5938072
commit
22d534c5eb
@@ -196,6 +196,44 @@ public:
|
||||
native_perf::RendererTotals perf_totals() const;
|
||||
|
||||
private:
|
||||
using TextureBytes = std::unordered_map<std::string, std::vector<std::uint8_t>>;
|
||||
|
||||
// render()'s phases, in call order (vk_frame.cpp).
|
||||
struct FrameDraws {
|
||||
std::vector<PreparedDraw> prepared_draws; // the back-buffer pass
|
||||
// Draws into offscreen render targets (the shadow map), in recorded order, drawn before the
|
||||
// back-buffer pass that samples them.
|
||||
std::vector<PreparedDraw> offscreen_draws;
|
||||
std::size_t vertex_count = 0, index_count = 0, skinned_draw_count = 0;
|
||||
};
|
||||
// Host copies of the swapchain image (--screenshot-out) and, with MT_DUMP_RT, of every render target.
|
||||
struct Readback {
|
||||
struct RtDump { VkBuffer buffer; VkDeviceMemory memory; std::uint32_t w, h; };
|
||||
bool screenshot = false;
|
||||
VkBuffer buffer = VK_NULL_HANDLE;
|
||||
VkDeviceMemory memory = VK_NULL_HANDLE;
|
||||
const char* dump_rt = nullptr;
|
||||
std::vector<RtDump> rt_dumps;
|
||||
};
|
||||
|
||||
// Geometry, pipeline and descriptors of each recorded draw; retires unused geometry.
|
||||
void prepare_draws(const std::vector<Render3DDraw>& draws, const TextureBytes& capture_textures, FrameDraws& frame);
|
||||
|
||||
// The UI batches, with the touch controls and FPS counter appended to the 40250 UI.
|
||||
void prepare_ui(std::uint32_t ui_width, std::uint32_t ui_height, const std::vector<UIRenderCommand>& ui_commands,
|
||||
const TextureBytes& capture_textures, std::vector<UiBatch>& ui_batches, std::size_t& ui_quad_count);
|
||||
|
||||
// Each draw's FixedFunctionState into the frame's dynamic-offset state buffer.
|
||||
void write_draw_states(FrameDraws& frame, std::vector<UiBatch>& ui_batches);
|
||||
|
||||
// Offscreen passes, then the back-buffer pass: UI behind 3D, 3D, UI.
|
||||
void record_passes(std::uint32_t image_index, const FrameDraws& frame, const std::vector<UiBatch>& ui_batches);
|
||||
|
||||
// Recorded after the passes; finish_readbacks() waits for the submit and writes the files.
|
||||
Readback record_readbacks(std::uint32_t image_index);
|
||||
|
||||
void finish_readbacks(Readback& readback);
|
||||
|
||||
void recreate_swapchain();
|
||||
|
||||
void collect_pending_gpu_timestamp(FrameSlot& slot);
|
||||
|
||||
Reference in New Issue
Block a user