Several GI related optimizations and fixes

-SDFGI direct light is done over many frames
-SDFGI Changed settings for rays/frame
-SDFGI Misc optimizations
-SDFGI Bug fix on probe scroll

-GIProbe was not working, got it to work again
-GIProbe dynamic objects were not working, fixed

-Added a half size GI option.
This commit is contained in:
reduz 2021-01-22 20:50:24 -03:00
parent 6ddfc8e718
commit 6fe342478b
21 changed files with 490 additions and 263 deletions

View file

@ -162,6 +162,51 @@ void RenderingServerDefault::draw(bool p_swap_buffers, double frame_step) {
}
frame_profile_frame = RSG::storage->get_captured_timestamps_frame();
if (print_gpu_profile) {
if (print_frame_profile_ticks_from == 0) {
print_frame_profile_ticks_from = OS::get_singleton()->get_ticks_usec();
}
float total_time = 0.0;
for (int i = 0; i < frame_profile.size() - 1; i++) {
String name = frame_profile[i].name;
if (name[0] == '<' || name[0] == '>') {
continue;
}
float time = frame_profile[i + 1].gpu_msec - frame_profile[i].gpu_msec;
if (name[0] != '<' && name[0] != '>') {
if (print_gpu_profile_task_time.has(name)) {
print_gpu_profile_task_time[name] += time;
} else {
print_gpu_profile_task_time[name] = time;
}
}
}
if (frame_profile.size()) {
total_time = frame_profile[frame_profile.size() - 1].gpu_msec;
}
uint64_t ticks_elapsed = OS::get_singleton()->get_ticks_usec() - print_frame_profile_ticks_from;
print_frame_profile_frame_count++;
if (ticks_elapsed > 1000000) {
print_line("GPU PROFILE (total " + rtos(total_time) + "ms): ");
float print_threshold = 0.01;
for (OrderedHashMap<String, float>::Element E = print_gpu_profile_task_time.front(); E; E = E.next()) {
float time = E.value() / float(print_frame_profile_frame_count);
if (time > print_threshold) {
print_line("\t-" + E.key() + ": " + rtos(time) + "ms");
}
}
print_gpu_profile_task_time.clear();
print_frame_profile_ticks_from = OS::get_singleton()->get_ticks_usec();
print_frame_profile_frame_count = 0;
}
}
}
float RenderingServerDefault::get_frame_setup_time_cpu() const {
@ -232,6 +277,11 @@ void RenderingServerDefault::sdfgi_set_debug_probe_select(const Vector3 &p_posit
RSG::scene->sdfgi_set_debug_probe_select(p_position, p_dir);
}
void RenderingServerDefault::set_print_gpu_profile(bool p_enable) {
RSG::storage->capturing_timestamps = p_enable;
print_gpu_profile = p_enable;
}
RID RenderingServerDefault::get_test_cube() {
if (!test_cube.is_valid()) {
test_cube = _make_test_cube();