WIP: (micro) lignes 622-634 mise en plac des g_realloc() vertex & lines buffers

This commit is contained in:
Jean Sirmai 2023-10-25 16:31:46 +02:00
parent dbc54bd0f5
commit df54fc5751
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 34 additions and 11 deletions

View File

@ -47,6 +47,11 @@ static volatile int buffer_lines_size = 0;
static volatile int buffer_colors_size = 0; static volatile int buffer_colors_size = 0;
static volatile int buffer_plans_size = 0; static volatile int buffer_plans_size = 0;
static volatile int buffer_vertex_0_arrow = 0;
static volatile int buffer_lines_0_arrow = 0;
static volatile int buffer_colors_0_arrow = 0;
static volatile int buffer_plans_0_arrow = 0;
#define TEST 0 #define TEST 0
/* /*
@ -605,19 +610,28 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int
{ {
arrows_nb --; arrows_nb --;
if (1) arrows_ptr[address].load = arrows_ptr[arrows_nb].load;
{ arrows_ptr[address].site = arrows_ptr[arrows_nb].site;
arrows_ptr[address].load = arrows_ptr[arrows_nb].load; arrows_ptr[address].x = arrows_ptr[arrows_nb].x;
arrows_ptr[address].site = arrows_ptr[arrows_nb].site; arrows_ptr[address].y = arrows_ptr[arrows_nb].y;
arrows_ptr[address].x = arrows_ptr[arrows_nb].x; arrows_ptr[address].z = arrows_ptr[arrows_nb].z;
arrows_ptr[address].y = arrows_ptr[arrows_nb].y;
arrows_ptr[address].z = arrows_ptr[arrows_nb].z;
}
if (arrows_nb > 0) { if (arrows_nb > 0) {
void *newptr = g_realloc(arrows_ptr, arrows_nb * sizeof(struct arrow_t));
if (newptr) arrows_ptr = newptr; void *new_arrows_list_ptr = g_realloc(arrows_ptr, arrows_nb * sizeof(struct arrow_t));
else perror("In erase arrow, can't re_allocate for arrow list.\n"); if (new_arrows_list_ptr) arrows_ptr = new_arrows_list_ptr;
else perror("In erase arrow, can't re_allocate for arrow list.\n");
printf("buffer_vertex_0_arrow = %d arrows_nb * 3 = %d <<<<\n", buffer_vertex_0_arrow, arrows_nb * 3);
void *new_arrows_vertex_ptr = g_realloc(buffer_vertex_origin, buffer_vertex_0_arrow + 9 * 3 * sizeof(GLfloat));
if (new_arrows_vertex_ptr) buffer_vertex_origin = new_arrows_vertex_ptr;
else perror("In erase arrow, can't re_allocate for arrow vertex buffer.\n");
printf("buffer_lines_0_arrow = %d arrows_nb * 2 = %d <<<<\n", buffer_lines_0_arrow, arrows_nb * 2);
void *new_arrows_lines_ptr = g_realloc(buffer_lines_origin, buffer_lines_0_arrow + 9 * 2 * sizeof(GLfloat));
if (new_arrows_lines_ptr) buffer_lines_origin = new_arrows_lines_ptr;
else perror("In erase arrow, can't re_allocate for arrow lines buffer.\n");
} }
print_arrows_array (arrows_ptr, arrows_nb,0); print_arrows_array (arrows_ptr, arrows_nb,0);
@ -774,6 +788,15 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
write_grids_on_space_faces_lines (buffer_lines_size, space_X, space_Y, space_Z); write_grids_on_space_faces_lines (buffer_lines_size, space_X, space_Y, space_Z);
if (0) printf("buffer_lines_size after writing (n) space_faces_lines : %d (* 2 = %d)\n\n", buffer_lines_size / 2, buffer_lines_size); if (0) printf("buffer_lines_size after writing (n) space_faces_lines : %d (* 2 = %d)\n\n", buffer_lines_size / 2, buffer_lines_size);
/* Ce programme définit et crée séquentiellement les caractéristiques puis les images de l'espace puis celles des flèches
* Pour pouvoir effacer une flèche (n'importe laquelle),
* il est nécéssaire de connaître la taille des buffers au moment de la création de la première flèche */
buffer_vertex_0_arrow = buffer_vertex_size;
buffer_lines_0_arrow = buffer_lines_size;
printf("buffer_vertex_0_arrow = %d (%d points) buffer_lines_0_arrow = %d (%d lines)\n",\
buffer_vertex_0_arrow, buffer_vertex_0_arrow / 3, buffer_lines_0_arrow, buffer_lines_0_arrow / 2);
/* A R R O W S */ /* A R R O W S */
/* #pragma omp parallel */ /* #pragma omp parallel */