MCPcopy Create free account
hub / github.com/TheRealMJP/SHforHLSL / encodeVertexBlock

Function encodeVertexBlock

SHTest/Externals/meshoptimizer/vertexcodec.cpp:264–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264static unsigned char* encodeVertexBlock(unsigned char* data, unsigned char* data_end, const unsigned char* vertex_data, size_t vertex_count, size_t vertex_size, unsigned char last_vertex[256])
265{
266 assert(vertex_count > 0 && vertex_count <= kVertexBlockMaxSize);
267
268 unsigned char buffer[kVertexBlockMaxSize];
269 assert(sizeof(buffer) % kByteGroupSize == 0);
270
271 // we sometimes encode elements we didn't fill when rounding to kByteGroupSize
272 memset(buffer, 0, sizeof(buffer));
273
274 for (size_t k = 0; k < vertex_size; ++k)
275 {
276 size_t vertex_offset = k;
277
278 unsigned char p = last_vertex[k];
279
280 for (size_t i = 0; i < vertex_count; ++i)
281 {
282 buffer[i] = zigzag8(vertex_data[vertex_offset] - p);
283
284 p = vertex_data[vertex_offset];
285
286 vertex_offset += vertex_size;
287 }
288
289 data = encodeBytes(data, data_end, buffer, (vertex_count + kByteGroupSize - 1) & ~(kByteGroupSize - 1));
290 if (!data)
291 return NULL;
292 }
293
294 memcpy(last_vertex, &vertex_data[vertex_size * (vertex_count - 1)], vertex_size);
295
296 return data;
297}
298
299#if defined(SIMD_FALLBACK) || (!defined(SIMD_SSE) && !defined(SIMD_NEON) && !defined(SIMD_AVX) && !defined(SIMD_WASM))
300static const unsigned char* decodeBytesGroup(const unsigned char* data, unsigned char* buffer, int bitslog2)

Callers 1

Calls 2

zigzag8Function · 0.85
encodeBytesFunction · 0.85

Tested by

no test coverage detected