// WGPU render pipeline builder - reduces pipeline creation boilerplate #pragma once #include #include struct WGPUDeviceImpl; typedef struct WGPUDeviceImpl* WGPUDevice; struct WGPUBindGroupLayoutImpl; typedef struct WGPUBindGroupLayoutImpl* WGPUBindGroupLayout; struct WGPURenderPipelineImpl; typedef struct WGPURenderPipelineImpl* WGPURenderPipeline; struct WGPUShaderModuleImpl; typedef struct WGPUShaderModuleImpl* WGPUShaderModule; #include "gpu/shader_composer.h" #include "platform/platform.h" class RenderPipelineBuilder { WGPUDevice device_; WGPURenderPipelineDescriptor desc_{}; WGPUColorTargetState color_{}; WGPUBlendState blend_{}; WGPUDepthStencilState depth_{}; std::vector layouts_; std::string shader_text_; WGPUShaderModule shader_module_ = nullptr; bool has_blend_ = false; bool has_depth_ = false; public: explicit RenderPipelineBuilder(WGPUDevice device); RenderPipelineBuilder& shader(const char* wgsl, bool compose = true); RenderPipelineBuilder& bind_group_layout(WGPUBindGroupLayout layout); RenderPipelineBuilder& format(WGPUTextureFormat fmt); RenderPipelineBuilder& blend_alpha(); RenderPipelineBuilder& depth(WGPUTextureFormat depth_fmt = WGPUTextureFormat_Depth24Plus); RenderPipelineBuilder& cull_back(); WGPURenderPipeline build(); };