profile atlas recreation
This commit is contained in:
		| @@ -186,6 +186,8 @@ static void upload_texture_from_surface(GPUTexture texture, SDL_Surface *surface | ||||
|  | ||||
|  | ||||
| static void recreate_current_atlas_texture(TextureCache *cache) { | ||||
|     profile_start("atlas recreation"); | ||||
|  | ||||
|     /* TODO: should surfaces be freed after they cannot be referenced in atlas builing? */ | ||||
|     /*       for example, if full page of 64x64 tiles was already filled, there's no real reason to process them further */ | ||||
|     SDL_Surface *atlas_surface = cache->atlas_surfaces[cache->atlas_index]; | ||||
| @@ -216,6 +218,8 @@ static void recreate_current_atlas_texture(TextureCache *cache) { | ||||
|  | ||||
|     /* texturize it! */ | ||||
|     upload_texture_from_surface(cache->atlas_textures[cache->atlas_index], atlas_surface); | ||||
|  | ||||
|     profile_end("atlas recreation"); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -320,14 +320,15 @@ void profile_start(char profile[const static 1]) { | ||||
| void profile_end(char profile[const static 1]) { | ||||
|     struct ProfileItem *p = shgetp_null(profiles, profile); | ||||
|     if (!p) { | ||||
|         log_warn("profile %s wasn't started!", profile); | ||||
|         log_warn("Profile %s wasn't started!", profile); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     uint64_t took = SDL_GetPerformanceCounter() - p->value.tick_start; | ||||
|  | ||||
|     p->value.sample_count++; | ||||
|     p->value.tick_accum += took; | ||||
|     p->value.sample_count++; | ||||
|  | ||||
|     if (p->value.worst_tick < took) | ||||
|         p->value.worst_tick = took; | ||||
| } | ||||
| @@ -342,16 +343,16 @@ void profile_list_stats(void) { | ||||
|         else if (profiles[i].value.sample_count == 1) { | ||||
|             log_info("Profile '%s' took: %f seconds", | ||||
|                      profiles[i].key, | ||||
|                      (double)profiles[i].value.tick_accum / 1 / (double)(SDL_GetPerformanceFrequency())); | ||||
|                      (double)profiles[i].value.tick_accum / (double)(SDL_GetPerformanceFrequency())); | ||||
|         } | ||||
|  | ||||
|         else if (profiles[i].value.sample_count > 1) { | ||||
|             log_info("Profile '%s' on average took: %f seconds, worst case: %s, sample count: %llu", | ||||
|             log_info("Profile '%s' on average took: %f seconds, worst case: %f, sample count: %llu", | ||||
|                      profiles[i].key, | ||||
|                      (double)profiles[i].value.tick_accum / | ||||
|                         (double)profiles[i].value.sample_count / | ||||
|                         (double)(SDL_GetPerformanceFrequency()), | ||||
|                      (double)profiles[i].value.worst_tick / 1 / (double)(SDL_GetPerformanceFrequency()), | ||||
|                      (double)profiles[i].value.worst_tick / (double)(SDL_GetPerformanceFrequency()), | ||||
|                      profiles[i].value.sample_count); | ||||
|         } | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user