1    module draw
2    
3    def bind_descriptor_set (descriptor_set : DescriptorSet) (index : u32) =
4        let vulkan : Vulkan @auto
5    
6        let state = vulkan.gpu_state.draw_mut
7        let item = state.descriptor_set_states[ref index]
8        item.bound = false
9             descriptor_set = descriptor_set
10   
11       for image in descriptor_set.storage_images do
12           vulkan.raster_images.add image
13   
14   def bind_vertex_buffer (vertex_buffer : VertexBuffer) =
15       let vulkan : Vulkan @auto
16   
17       let state = vulkan.gpu_state.draw_mut
18       if state.vertex_buffer == vertex_buffer then
19           return
20   
21       state.vertex_buffer = vertex_buffer
22       vk/cmd_bind_vertex_buffers state.command_buffer 0 1
23                                  vertex_buffer.object@ptr
24                                  vertex_buffer.offset@ptr
25   
26   def bind_index_buffer (index_buffer : IndexBuffer
27                          offset : u32
28                          count : u32) =
29       let vulkan : Vulkan @auto
30   
31       let state = vulkan.gpu_state.draw_mut
32       if state.index_buffer == index_buffer then
33           return
34   
35       state.index_count = count
36             index_offset = offset
37             index_buffer = index_buffer
38   
39       vk/cmd_bind_index_buffer state.command_buffer index_buffer.object
40                                index_buffer.offset IndexType/Uint32
41   
42   def bind_pipeline (pipeline : Pipeline) =
43       let vulkan : Vulkan @auto
44   
45       let state = vulkan.gpu_state.draw_mut
46       if pipeline == state.pipeline then
47           return
48   
49       state.pipeline = pipeline
50             pipeline_push_constant_stages = pipeline.push_constant_stages
51   
52       vk/cmd_bind_pipeline state.command_buffer PipelineBindPoint/Graphics
53                            pipeline.object
54