Browse Source

Mark pipeline compilation of ubershaders as high priority.

Dario 6 months ago
parent
commit
d0c29faa15

+ 1 - 1
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp

@@ -4427,7 +4427,7 @@ void RenderForwardClustered::_mesh_compile_pipeline_for_surface(SceneShaderForwa
 	r_pipeline_key.vertex_format_id = mesh_storage->mesh_surface_get_vertex_format(p_mesh_surface, input_mask, p_instanced_surface, pipeline_motion_vectors);
 	r_pipeline_key.vertex_format_id = mesh_storage->mesh_surface_get_vertex_format(p_mesh_surface, input_mask, p_instanced_surface, pipeline_motion_vectors);
 	r_pipeline_key.ubershader = p_ubershader;
 	r_pipeline_key.ubershader = p_ubershader;
 
 
-	p_shader->pipeline_hash_map.compile_pipeline(r_pipeline_key, r_pipeline_key.hash(), p_source);
+	p_shader->pipeline_hash_map.compile_pipeline(r_pipeline_key, r_pipeline_key.hash(), p_source, p_ubershader);
 
 
 	if (r_pipeline_pairs != nullptr) {
 	if (r_pipeline_pairs != nullptr) {
 		r_pipeline_pairs->push_back({ p_shader, r_pipeline_key });
 		r_pipeline_pairs->push_back({ p_shader, r_pipeline_key });

+ 1 - 1
servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp

@@ -2987,7 +2987,7 @@ void RenderForwardMobile::_mesh_compile_pipeline_for_surface(SceneShaderForwardM
 	uint64_t input_mask = p_shader->get_vertex_input_mask(r_pipeline_key.version, true);
 	uint64_t input_mask = p_shader->get_vertex_input_mask(r_pipeline_key.version, true);
 	r_pipeline_key.vertex_format_id = mesh_storage->mesh_surface_get_vertex_format(p_mesh_surface, input_mask, p_instanced_surface, false);
 	r_pipeline_key.vertex_format_id = mesh_storage->mesh_surface_get_vertex_format(p_mesh_surface, input_mask, p_instanced_surface, false);
 	r_pipeline_key.ubershader = true;
 	r_pipeline_key.ubershader = true;
-	p_shader->pipeline_hash_map.compile_pipeline(r_pipeline_key, r_pipeline_key.hash(), p_source);
+	p_shader->pipeline_hash_map.compile_pipeline(r_pipeline_key, r_pipeline_key.hash(), p_source, r_pipeline_key.ubershader);
 
 
 	if (r_pipeline_pairs != nullptr) {
 	if (r_pipeline_pairs != nullptr) {
 		r_pipeline_pairs->push_back({ p_shader, r_pipeline_key });
 		r_pipeline_pairs->push_back({ p_shader, r_pipeline_key });

+ 3 - 3
servers/rendering/renderer_rd/pipeline_hash_map_rd.h

@@ -92,7 +92,7 @@ public:
 	}
 	}
 
 
 	// Start compilation of a pipeline ahead of time in the background. Returns true if the compilation was started, false if it wasn't required. Source is only used for collecting statistics.
 	// Start compilation of a pipeline ahead of time in the background. Returns true if the compilation was started, false if it wasn't required. Source is only used for collecting statistics.
-	void compile_pipeline(const Key &p_key, uint32_t p_key_hash, RS::PipelineSource p_source) {
+	void compile_pipeline(const Key &p_key, uint32_t p_key_hash, RS::PipelineSource p_source, bool p_high_priority) {
 		DEV_ASSERT((creation_object != nullptr) && (creation_function != nullptr) && "Creation object and function was not set before attempting to compile a pipeline.");
 		DEV_ASSERT((creation_object != nullptr) && (creation_function != nullptr) && "Creation object and function was not set before attempting to compile a pipeline.");
 
 
 		MutexLock local_lock(local_mutex);
 		MutexLock local_lock(local_mutex);
@@ -133,7 +133,7 @@ public:
 #endif
 #endif
 
 
 		// Queue a background compilation task.
 		// Queue a background compilation task.
-		WorkerThreadPool::TaskID task_id = WorkerThreadPool::get_singleton()->add_template_task(creation_object, creation_function, p_key, false, "PipelineCompilation");
+		WorkerThreadPool::TaskID task_id = WorkerThreadPool::get_singleton()->add_template_task(creation_object, creation_function, p_key, p_high_priority, "PipelineCompilation");
 		compilation_tasks.insert(p_key_hash, task_id);
 		compilation_tasks.insert(p_key_hash, task_id);
 	}
 	}
 
 
@@ -165,7 +165,7 @@ public:
 
 
 		if (e == nullptr) {
 		if (e == nullptr) {
 			// Request compilation. The method will ignore the request if it's already being compiled.
 			// Request compilation. The method will ignore the request if it's already being compiled.
-			compile_pipeline(p_key, p_key_hash, p_source);
+			compile_pipeline(p_key, p_key_hash, p_source, p_wait_for_compilation);
 
 
 			if (p_wait_for_compilation) {
 			if (p_wait_for_compilation) {
 				wait_for_pipeline(p_key_hash);
 				wait_for_pipeline(p_key_hash);