blob: 24b4e8b68a4eb989c41b5ab4f7d03a2932577042 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// WGPU render pipeline builder - reduces pipeline creation boilerplate
#pragma once
#include <string>
#include <vector>
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<WGPUBindGroupLayout> 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();
};
|