test_s3dut_utils.h (1618B)
1 /* Copyright (C) 2016, 2017, 2020, 2021, 2023 |Méso|Star> (contact@meso-star.com) 2 * 3 * This program is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, either version 3 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 16 #ifndef TEST_S3DUT_UTILS_H 17 #define TEST_S3DUT_UTILS_H 18 19 #include "s3dut.h" 20 21 #include <rsys/mem_allocator.h> 22 #include <stdio.h> 23 24 static INLINE void 25 dump_mesh_data(FILE* stream, const struct s3dut_mesh_data* data) 26 { 27 size_t i; 28 CHK(data != NULL); 29 30 FOR_EACH(i, 0, data->nvertices) { 31 fprintf(stream, "v %g %g %g\n", SPLIT3(data->positions + i*3)); 32 } 33 FOR_EACH(i, 0, data->nprimitives) { 34 fprintf(stream, "f %lu %lu %lu\n", 35 (unsigned long)(data->indices[i*3+0] + 1), 36 (unsigned long)(data->indices[i*3+1] + 1), 37 (unsigned long)(data->indices[i*3+2] + 1)); 38 } 39 } 40 41 static INLINE void 42 check_memory_allocator(struct mem_allocator* allocator) 43 { 44 if(MEM_ALLOCATED_SIZE(allocator)) { 45 char dump[512]; 46 MEM_DUMP(allocator, dump, sizeof(dump)/sizeof(char)); 47 fprintf(stderr, "%s\n", dump); 48 FATAL("Memory leaks\n"); 49 } 50 } 51 52 #endif /* TEST_S3DUT_UTILS_H */ 53