summaryrefslogtreecommitdiff
path: root/servers/visual/rasterizer_rd
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2019-09-20 17:58:06 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-11 12:01:26 +0100
commit123ee5995c989d7c2f0bb320fe94ef1702a48c13 (patch)
tree97855b3218f56dcaaeb5e737bf1a919f28ac36db /servers/visual/rasterizer_rd
parentdc32083681a770e9d7e332c5beed30b52c793752 (diff)
Visual GPU profiler and related profiling support in Vulkan.
Diffstat (limited to 'servers/visual/rasterizer_rd')
-rw-r--r--servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp13
-rw-r--r--servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp25
-rw-r--r--servers/visual/rasterizer_rd/rasterizer_storage_rd.h8
3 files changed, 46 insertions, 0 deletions
diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp
index 82a5d8ba65..2ef331291a 100644
--- a/servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp
+++ b/servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp
@@ -1654,6 +1654,8 @@ void RasterizerSceneForwardRD::_render_scene(RenderBufferData *p_buffer_data, co
}
#endif
+ RENDER_TIMESTAMP("Setup 3D Scene");
+
bool using_shadows = true;
if (p_reflection_probe.is_valid()) {
@@ -2085,6 +2087,8 @@ void RasterizerSceneForwardRD::_render_scene(RenderBufferData *p_buffer_data, co
}
}
+ RENDER_TIMESTAMP("Render Opaque Pass");
+
_setup_render_base_uniform_set(RID(), RID(), RID(), RID(), radiance_cubemap, p_shadow_atlas, p_reflection_atlas);
render_list.sort_by_key(false);
@@ -2104,6 +2108,7 @@ void RasterizerSceneForwardRD::_render_scene(RenderBufferData *p_buffer_data, co
}
if (draw_sky) {
+ RENDER_TIMESTAMP("Render Sky");
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(opaque_framebuffer, RD::INITIAL_ACTION_CONTINUE, can_continue ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ_COLOR_AND_DEPTH);
_draw_sky(draw_list, RD::get_singleton()->framebuffer_get_format(opaque_framebuffer), p_environment, p_cam_projection, p_cam_transform, 1.0);
RD::get_singleton()->draw_list_end();
@@ -2201,6 +2206,9 @@ void RasterizerSceneForwardRD::_render_scene(RenderBufferData *p_buffer_data, co
glEnable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
#endif
+
+ RENDER_TIMESTAMP("Render Transparent Pass");
+
render_list.sort_by_reverse_depth_and_priority(true);
_fill_instances(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count);
@@ -2232,6 +2240,7 @@ void RasterizerSceneForwardRD::_render_scene(RenderBufferData *p_buffer_data, co
RasterizerEffectsRD *effects = storage->get_effects();
{
+ RENDER_TIMESTAMP("Tonemap");
//tonemap
RasterizerEffectsRD::TonemapSettings tonemap;
@@ -2326,6 +2335,8 @@ void RasterizerSceneForwardRD::_render_scene(RenderBufferData *p_buffer_data, co
}
void RasterizerSceneForwardRD::_render_shadow(RID p_framebuffer, InstanceBase **p_cull_result, int p_cull_count, const CameraMatrix &p_projection, const Transform &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip) {
+ RENDER_TIMESTAMP("Setup Rendering Shadow");
+
render_pass++;
scene_state.ubo.shadow_z_offset = p_bias;
@@ -2343,6 +2354,8 @@ void RasterizerSceneForwardRD::_render_shadow(RID p_framebuffer, InstanceBase **
_setup_render_base_uniform_set(RID(), RID(), RID(), RID(), RID(), RID(), RID());
+ RENDER_TIMESTAMP("Render Shadow");
+
render_list.sort_by_key(false);
_fill_instances(render_list.elements, render_list.element_count);
diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp
index e73efa1e12..639b78ec79 100644
--- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp
+++ b/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp
@@ -3656,6 +3656,31 @@ RasterizerEffectsRD *RasterizerStorageRD::get_effects() {
return &effects;
}
+void RasterizerStorageRD::capture_timestamps_begin() {
+ RD::get_singleton()->capture_timestamp("Frame Begin", false);
+}
+
+void RasterizerStorageRD::capture_timestamp(const String &p_name) {
+ RD::get_singleton()->capture_timestamp(p_name, true);
+}
+
+uint32_t RasterizerStorageRD::get_captured_timestamps_count() const {
+ return RD::get_singleton()->get_captured_timestamps_count();
+}
+uint64_t RasterizerStorageRD::get_captured_timestamps_frame() const {
+ return RD::get_singleton()->get_captured_timestamps_frame();
+}
+
+uint64_t RasterizerStorageRD::get_captured_timestamp_gpu_time(uint32_t p_index) const {
+ return RD::get_singleton()->get_captured_timestamp_gpu_time(p_index);
+}
+uint64_t RasterizerStorageRD::get_captured_timestamp_cpu_time(uint32_t p_index) const {
+ return RD::get_singleton()->get_captured_timestamp_cpu_time(p_index);
+}
+String RasterizerStorageRD::get_captured_timestamp_name(uint32_t p_index) const {
+ return RD::get_singleton()->get_captured_timestamp_name(p_index);
+}
+
RasterizerStorageRD::RasterizerStorageRD() {
for (int i = 0; i < SHADER_TYPE_MAX; i++) {
diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.h b/servers/visual/rasterizer_rd/rasterizer_storage_rd.h
index ef22a6689b..670c97a1c1 100644
--- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.h
+++ b/servers/visual/rasterizer_rd/rasterizer_storage_rd.h
@@ -1018,6 +1018,14 @@ public:
String get_video_adapter_name() const { return String(); }
String get_video_adapter_vendor() const { return String(); }
+ virtual void capture_timestamps_begin();
+ virtual void capture_timestamp(const String &p_name);
+ virtual uint32_t get_captured_timestamps_count() const;
+ virtual uint64_t get_captured_timestamps_frame() const;
+ virtual uint64_t get_captured_timestamp_gpu_time(uint32_t p_index) const;
+ virtual uint64_t get_captured_timestamp_cpu_time(uint32_t p_index) const;
+ virtual String get_captured_timestamp_name(uint32_t p_index) const;
+
static RasterizerStorage *base_singleton;
RasterizerEffectsRD *get_effects();