1    type Vulkan
2        def pipeline_cache (settings : PipelineSettings) =
3            if not shader_pipeline_caches.contains settings then
4                let is_depth = settings.fragment_shader.output_mask == 0
5                let depth_stencil = DepthStencil
6                    enable_depth_write = is_depth
7                    f@ DepthStencil.default
8    
9                let color_blend = if is_depth then
10                   ColorBlend.disabled 0
11               else
12                   let attachment = Attachment
13                       enable_blend = true
14                       alpha_blend_op = BlendOp/Add
15                       color_blend_op = BlendOp/Add
16                       src_color_blend_factor = BlendFactor/SrcAlpha
17                       dst_color_blend_factor = BlendFactor/OneMinusSrcAlpha
18                       src_alpha_blend_factor = BlendFactor/One
19                       dst_alpha_blend_factor = BlendFactor/OneMinusSrcAlpha
20                       f@ Attachment.default
21   
22                   ColorBlend
23                       enable_logic_op = false
24                       logic_op = LogicOp/Clear
25                       attachments = [attachment]
26                       blend_constant = Vector4.new
27   
28               let pipeline_layout =
29                   PipelineLayout.raster settings.vertex_shader
30                                         settings.fragment_shader
31   
32               let pipeline_cache = PipelineCache
33                   vertex_shader = settings.vertex_shader
34                   fragment_shader = settings.fragment_shader
35                   rasterization = Rasterization
36                       cull_mode = settings.cull_mode
37                       f@ Rasterization.default
38   
39                   multisample = Multisample.default
40                   =depth_stencil =color_blend =pipeline_layout
41   
42               shader_pipeline_caches.add settings pipeline_cache
43   
44           shader_pipeline_caches[settings]
45