- 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>
36 lines
1.5 KiB
C++
36 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <SDL3/SDL_gpu.h>
|
|
|
|
// ============================================================================
|
|
// GpuPipeline — Creates and owns the graphics pipelines used by the engine.
|
|
//
|
|
// sprite_pipeline_ : textured quads, alpha blending.
|
|
// Vertex layout: GpuVertex (pos float2, uv float2, col float4).
|
|
// postfx_pipeline_ : full-screen triangle, no vertex buffer, no blend.
|
|
// Reads offscreen texture, writes to swapchain.
|
|
// ============================================================================
|
|
class GpuPipeline {
|
|
public:
|
|
// target_format: pass SDL_GetGPUSwapchainTextureFormat() result.
|
|
// offscreen_format: format of the offscreen render target.
|
|
bool init(SDL_GPUDevice* device,
|
|
SDL_GPUTextureFormat target_format,
|
|
SDL_GPUTextureFormat offscreen_format);
|
|
void destroy(SDL_GPUDevice* device);
|
|
|
|
SDL_GPUGraphicsPipeline* spritePipeline() const { return sprite_pipeline_; }
|
|
SDL_GPUGraphicsPipeline* postfxPipeline() const { return postfx_pipeline_; }
|
|
|
|
private:
|
|
SDL_GPUShader* createShader(SDL_GPUDevice* device,
|
|
const char* msl_source,
|
|
const char* entrypoint,
|
|
SDL_GPUShaderStage stage,
|
|
Uint32 num_samplers,
|
|
Uint32 num_uniform_buffers);
|
|
|
|
SDL_GPUGraphicsPipeline* sprite_pipeline_ = nullptr;
|
|
SDL_GPUGraphicsPipeline* postfx_pipeline_ = nullptr;
|
|
};
|