@@ -85,42 +85,6 @@ static void le_mesh_clear( le_mesh_o* self ) {
8585}
8686
8787// ----------------------------------------------------------------------
88- // write contents of our internal data out to gpu memory - or to other kind
89- // of memory, really.
90-
91- // Now, this method can get quite complicated
92- // because we cannot assume that our source data is continuous.
93- //
94- // how about we create something like an iterator for each attribute
95- // if our source data is not continuous?
96- //
97- // we also need to take into account that the output data might
98- // be interleaved, but in a different way.
99- //
100- // we want this to be fast, but it should not be optimized to the point
101- // where it becomes unreadable -- data is usually only written out
102- // rarely.
103- //
104- // but because the data can be quite substantial, we want this to be
105- // as contiguous as possible.
106- //
107- // in case we want to interleave our output, we want to
108- // change the signature for this function so that it supports
109- // requesting interleaved data via a vector of `attribute_info`
110- //
111- // if the attribute info array that we get perfectly aligns
112- // with the attribute info array for an existing buffer, we can
113- // copy out the buffer in one go -- that's the fast path.
114- //
115- // if the out attribute info array does not match the current attribute info array
116- // we need to build some iterators, i think; perhaps we can use an output_iterator
117- // and hope that the compiler does the work for us?
118- //
119- //
120- // Another thing that we might want to have is a reformat() function for mesh
121- // which allows us to re-arrange our data and make it interleave or do some other
122- // things with it. there's also zeux' meshopt that could come in handy.
123- //
12488
12589static void le_mesh_read_vertex_data_into_buffer ( le_mesh_o const * self, void * target, size_t target_capacity_num_bytes,
12690 le_mesh_attribute_info_t const * dst_attribute_info,
@@ -215,13 +179,12 @@ static void le_mesh_read_vertex_data_into_buffer( le_mesh_o const* self, void* t
215179 }
216180 }
217181
218- // Optimization:
219- // If all iterators use the same input buffer, and the
220- // input buffer is tightly packed, and in the same order
221- // as the output, then we can copy everything in bulk.
222- // we can copy
223-
224182 {
183+ // OPTIMIZATION:
184+ //
185+ // If all iterators use the same input buffer, and the
186+ // input buffer is tightly packed, and in the same order
187+ // as the output, then we can copy everything in bulk.
225188
226189 // Conditions:
227190 // - src_stride needs to match dst_stride, which is unique, and pre-calculated above.
@@ -231,7 +194,7 @@ static void le_mesh_read_vertex_data_into_buffer( le_mesh_o const* self, void* t
231194 // - .src and .dst need to start at 0, relative to start value
232195 // - both last .src and last .dst + n_bytes needs to match dst_stride
233196
234- uint8_t const * prev_p = self->data .front ().cpu_data .data (); // source data pointer (these may be into different source data buffers)
197+ uint8_t const * prev_p = self->data .front ().cpu_data .data ();
235198 ptrdiff_t next_diff = 0 ;
236199 size_t total_stride = dst_stride;
237200
@@ -240,7 +203,7 @@ static void le_mesh_read_vertex_data_into_buffer( le_mesh_o const* self, void* t
240203 ptrdiff_t diff = it.src - prev_p;
241204
242205 if ( next_diff != diff || it.src_stride != dst_stride ) {
243- // inconsistency detected.
206+ // inconsistency detected
244207 break ;
245208 }
246209
@@ -259,8 +222,9 @@ static void le_mesh_read_vertex_data_into_buffer( le_mesh_o const* self, void* t
259222
260223 // ---------| Invariant: Vertices are not tightly packed in src and dst.
261224
262- // Process one iterator at a time.
263- // The hope is that this will lead to greater cache locality.
225+ // Process one iterator at a time, because we hope
226+ // that this will lead to better cache locality as
227+ // it means less hopping between buffers.
264228 for ( it_t & it : iterators ) {
265229 it.src += it.src_stride * first_vertex;
266230 for ( size_t i = first_vertex; i != num_max_iterations; i++ ) {
0 commit comments