feat(gpu): migrar a SDL3_GPU amb 2-pass rendering i post-processat
- Infraestructura GPU: GpuContext, GpuPipeline, GpuSpriteBatch, GpuTexture - Engine::render() migrat a 2-pass: sprites → offscreen R8G8B8A8 → swapchain + vignette - UI/text via software renderer (SDL3_ttf) + upload com a textura overlay GPU - CMakeLists.txt actualitzat per incloure subsistema gpu/ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
33
source/gpu/gpu_context.hpp
Normal file
33
source/gpu/gpu_context.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL_gpu.h>
|
||||
#include <SDL3/SDL_video.h>
|
||||
|
||||
// ============================================================================
|
||||
// GpuContext — SDL_GPU device + swapchain wrapper
|
||||
// Replaces SDL_Renderer as the main rendering backend.
|
||||
// ============================================================================
|
||||
class GpuContext {
|
||||
public:
|
||||
bool init(SDL_Window* window);
|
||||
void destroy();
|
||||
|
||||
SDL_GPUDevice* device() const { return device_; }
|
||||
SDL_Window* window() const { return window_; }
|
||||
SDL_GPUTextureFormat swapchainFormat() const { return swapchain_format_; }
|
||||
|
||||
// Per-frame helpers
|
||||
SDL_GPUCommandBuffer* acquireCommandBuffer();
|
||||
// Returns nullptr if window is minimized (swapchain not available).
|
||||
SDL_GPUTexture* acquireSwapchainTexture(SDL_GPUCommandBuffer* cmd_buf,
|
||||
Uint32* out_w, Uint32* out_h);
|
||||
void submit(SDL_GPUCommandBuffer* cmd_buf);
|
||||
|
||||
// VSync control (call after init)
|
||||
bool setVSync(bool enabled);
|
||||
|
||||
private:
|
||||
SDL_GPUDevice* device_ = nullptr;
|
||||
SDL_Window* window_ = nullptr;
|
||||
SDL_GPUTextureFormat swapchain_format_ = SDL_GPU_TEXTUREFORMAT_INVALID;
|
||||
};
|
||||
Reference in New Issue
Block a user