Cogs.Core
PipelineStatesWebGPU.h
1#pragma once
2
3#include "CommonWebGPU.h"
4
5#include "../Base/ResourceMap.h"
6#include "../IPipelineStates.h"
7
8#include <unordered_map>
9
10namespace Cogs {
11 class GraphicsDeviceWebGPU;
12
14 {
15 size_t hash;
16 EffectHandle effect;
17 InputLayoutHandle inputLayoutHandle;
18 PrimitiveType primitiveType;
19 RasterizerStateHandle rasterizeStateHandle;
20 DepthStencilStateHandle depthStencilStateHandle;
21 BlendStateHandle blendStateHandle;
22 RenderTargetHandle renderTargetHandle;
23 DepthStencilHandle depthStencilHandle;
24
25 WGPURenderPipeline pipeline;
26 WGPUPipelineLayout pipeline_layout;
27 WGPUBindGroupLayout bind_group_layout;
28 };
30 {
31 size_t hash;
32 EffectHandle effect;
33
34 WGPUComputePipeline pipeline;
35 WGPUBindGroupLayout layout;
36 };
37
39
40 void initialize(GraphicsDeviceWebGPU *device);
41
42 size_t renderPipelineHash(EffectHandle effect,
43 InputLayoutHandle inputLayoutHandle,
44 PrimitiveType primitiveType,
45 RasterizerStateHandle rasterizeStateHandle,
46 DepthStencilStateHandle depthStencilStateHandle,
47 BlendStateHandle blendStateHandle,
48 RenderTargetHandle renderTargetHandle,
49 DepthStencilHandle depthStencilHandle,
50 WGPUIndexFormat stripIndexFormat = WGPUIndexFormat_Undefined);
51 RenderPipelineHandle loadRenderPipeline(EffectHandle effect,
52 InputLayoutHandle inputLayoutHandle,
53 PrimitiveType primitiveType,
54 RasterizerStateHandle rasterizeStateHandle,
55 DepthStencilStateHandle depthStencilStateHandle,
56 BlendStateHandle blendStateHandle,
57 RenderTargetHandle renderTargetHandle,
58 DepthStencilHandle depthStencilHandle,
59 WGPUIndexFormat stripIndexFormat = WGPUIndexFormat_Undefined);
60 ComputePipelineHandle loadComputePipeline(EffectHandle effect);
61
62 void releaseRenderPipeline(RenderPipelineHandle psoHandle) override;
63 void releaseComputePipeline(ComputePipelineHandle psoHandle) override;
64 void releaseResources() override;
65
66 GraphicsDeviceWebGPU *graphics_device = nullptr;
67
68 std::unordered_map<size_t, RenderPipelineHandle> renderPipelineHashMap;
70
71 std::unordered_map<size_t, ComputePipelineHandle> computePipelineHashMap;
73 };
74}
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
PrimitiveType
Primitive types for interpreting vertex data sent to the graphics pipeline.
Definition: Common.h:112