Path SDL3 GPU amb PostFX passthrough; Screen amb init/shutdown explicit (v0.4.0)
This commit is contained in:
1 parent
0348acb0eb
commit
6c8ef9ff44
18 files changed
+14213
-38
No files matched your search
@@ -3,8 +3,11 @@
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "core/rendering/shader_backend.hpp"
|
||||
#include "utils/defaults.hpp"
|
||||
|
||||
class Screen {
|
||||
@@ -17,12 +20,15 @@ class Screen {
|
||||
bool vsync{Defaults::Video::VSYNC};
|
||||
Defaults::ScalingMode scaling_mode{Defaults::Video::SCALING_MODE};
|
||||
Defaults::TextureFilter texture_filter{Defaults::Video::TEXTURE_FILTER};
|
||||
bool gpu_acceleration{Defaults::Video::GPU_ACCELERATION};
|
||||
std::string preferred_driver{Defaults::Video::GPU_PREFERRED_DRIVER};
|
||||
};
|
||||
|
||||
// Meyers singleton: la destrucció ocorre durant la termianció estàtica
|
||||
// (LIFO respecte a Resource::Cache). El SDL_Quit s'ha de registrar via
|
||||
// std::atexit ABANS de la primera crida a get(); així Screen::~Screen
|
||||
// (que crida SDL_Destroy*/SDL_QuitSubSystem) s'executa amb SDL encara viu.
|
||||
// Meyers singleton només per a l'accés (get()). El cicle de vida de SDL
|
||||
// el porta el Director: configure() i shutdown() s'han de cridar
|
||||
// explícitament, NO el destructor estàtic. El patró atexit + destructor
|
||||
// estàtic provoca segfaults a vkDestroyInstance en Wayland/Vulkan perquè
|
||||
// alguns recursos de SDL ja són inconsistents quan corre el destructor.
|
||||
static auto get() -> Screen&;
|
||||
|
||||
Screen(const Screen&) = delete;
|
||||
@@ -30,10 +36,14 @@ class Screen {
|
||||
auto operator=(const Screen&) -> Screen& = delete;
|
||||
auto operator=(Screen&&) -> Screen& = delete;
|
||||
|
||||
// Crea (o recrea) finestra, renderer i textura a partir de la config.
|
||||
// Imprescindible cridar-lo abans de qualsevol clear()/present().
|
||||
// Inicialitza SDL_VIDEO i crea finestra + renderer o shader backend GPU
|
||||
// segons la config. Cal cridar-lo una vegada abans de qualsevol clear()/present().
|
||||
void configure(const Config& config);
|
||||
|
||||
// Destrueix tots els recursos SDL (finestra, GPU device, renderer, textura)
|
||||
// i tanca el subsistema de vídeo. El Director el crida ABANS de SDL_Quit.
|
||||
void shutdown();
|
||||
|
||||
void clear(std::uint8_t r = 0, std::uint8_t g = 0, std::uint8_t b = 0);
|
||||
void present();
|
||||
|
||||
@@ -43,17 +53,22 @@ class Screen {
|
||||
[[nodiscard]] auto getCanvasHeight() const -> int { return canvas_height_; }
|
||||
|
||||
private:
|
||||
Screen();
|
||||
~Screen();
|
||||
Screen() = default;
|
||||
~Screen() = default;
|
||||
|
||||
void destroySdl();
|
||||
void createSdl();
|
||||
|
||||
bool subsystem_initialized_{false};
|
||||
|
||||
Config config_{};
|
||||
|
||||
SDL_Window* window_{nullptr};
|
||||
// Camí SDL_Renderer (fallback quan gpu_acceleration = false).
|
||||
SDL_Renderer* renderer_{nullptr};
|
||||
SDL_Texture* game_texture_{nullptr};
|
||||
// Camí SDL3 GPU (prioritari quan gpu_acceleration = true).
|
||||
std::unique_ptr<Rendering::ShaderBackend> shader_backend_;
|
||||
|
||||
int canvas_width_{0};
|
||||
int canvas_height_{0};
|
||||
|
||||
Reference in new issue
Block a user