| … | 75 unchanged lines hidden | ||
| 76 | 76 | attributes: [MAX_VERTEX_ATTRIBS]Vertex_Attribute, | |
| 77 | 77 | attr_count: int, | |
| 78 | 78 | ) { | |
| 79 | + | return vertex_layout_to_pipeline_attrs_for_binding(layout, 0, .Vertex, 0) | |
| 80 | + | } | |
| 81 | + | ||
| 82 | + | vertex_layout_to_pipeline_attrs_for_binding :: proc( | |
| 83 | + | layout: ^Vertex_Layout, | |
| 84 | + | binding_index: u32, | |
| 85 | + | input_rate: Vertex_Input_Rate, | |
| 86 | + | first_location: u32, | |
| 87 | + | ) -> ( | |
| 88 | + | binding: Vertex_Binding, | |
| 89 | + | attributes: [MAX_VERTEX_ATTRIBS]Vertex_Attribute, | |
| 90 | + | attr_count: int, | |
| 91 | + | ) { | |
| 79 | 92 | binding = Vertex_Binding { | |
| 80 | - | binding = 0, | |
| 93 | + | binding = binding_index, | |
| 81 | 94 | stride = layout.stride, | |
| 95 | + | input_rate = input_rate, | |
| 82 | 96 | } | |
| 83 | 97 | for i in 0 ..< int(layout.count) { | |
| 84 | 98 | e := &layout.entries[i] | |
| 85 | 99 | attributes[i] = Vertex_Attribute { | |
| 86 | - | location = u32(i), | |
| 100 | + | location = first_location + u32(i), | |
| 101 | + | binding = binding_index, | |
| 87 | 102 | offset = e.offset, | |
| 88 | 103 | format = e.format, | |
| 89 | 104 | } | |
| … | 109 unchanged lines hidden | ||
Diff hidden because this file has more than 800 lines.
Diff hidden because this file has more than 800 lines.
Diff hidden because this file has more than 800 lines.
| … | 52 unchanged lines hidden | ||
| 53 | 53 | } | |
| 54 | 54 | ||
| 55 | 55 | @(test) | |
| 56 | + | test_vertex_layout_can_emit_instance_binding_metadata :: proc(t: ^testing.T) { | |
| 57 | + | layout := bk.vertex_layout_build(.Position, .Color) | |
| 58 | + | binding, attrs, attr_count := bk.vertex_layout_to_pipeline_attrs_for_binding( | |
| 59 | + | &layout, | |
| 60 | + | 1, | |
| 61 | + | .Instance, | |
| 62 | + | 3, | |
| 63 | + | ) | |
| 64 | + | testing.expect_value(t, binding.binding, u32(1)) | |
| 65 | + | testing.expect_value(t, binding.input_rate, bk.Vertex_Input_Rate.Instance) | |
| 66 | + | testing.expect_value(t, binding.stride, u32(28)) | |
| 67 | + | testing.expect_value(t, attr_count, 2) | |
| 68 | + | testing.expect_value(t, attrs[0].location, u32(3)) | |
| 69 | + | testing.expect_value(t, attrs[0].binding, u32(1)) | |
| 70 | + | testing.expect_value(t, attrs[0].offset, u32(0)) | |
| 71 | + | testing.expect_value(t, attrs[1].location, u32(4)) | |
| 72 | + | testing.expect_value(t, attrs[1].binding, u32(1)) | |
| 73 | + | testing.expect_value(t, attrs[1].offset, u32(12)) | |
| 74 | + | } | |
| 75 | + | ||
| 76 | + | @(test) | |
| 56 | 77 | test_backend_handle_index_rejects_null_and_out_of_range :: proc(t: ^testing.T) { | |
| 57 | 78 | _, null_ok := bk.handle_index(bk.NULL_BUFFER, 8) | |
| 58 | 79 | testing.expect(t, !null_ok) | |
| … | 39 unchanged lines hidden | ||