Repository: godotengine/godot
File: servers/rendering/rendering_server_default.h (C/C++)

Code before:

#undef server_name
#undef ServerName
//from now on, calls forwarded to this singleton
#define ServerName RendererMaterialStorage
#define server_name RSG::material_storage

	FUNC3(global_shader_parameter_add, const StringName &, GlobalShaderParameterType, const Variant &)
	FUNC1(global_shader_parameter_remove, const StringName &)
	FUNC0RC(Vector<StringName>, global_shader_parameter_get_list)
	FUNC2(global_shader_parameter_set, const StringName &, const Variant &)
	FUNC2(global_shader_parameter_set_override, const StringName &, const Variant &)
	FUNC1RC(GlobalShaderParameterType, global_shader_parameter_get_type, const StringName &)
	FUNC1RC(Variant, global_shader_parameter_get, const StringName &)

	FUNC1(global_shader_parameters_load_settings, bool)
	FUNC0(global_shader_parameters_clear)

#undef server_name
#undef ServerName
#undef WRITE_ACTION
#undef SYNC_DEBUG

	/* FREE */

	virtual void free(RID p_rid) override {
		if (Thread::get_caller_id() == server_thread) {
			command_queue.flush_if_pending();
			_free(p_rid);
		} else {
			command_queue.push(this, &RenderingServerDefault::_free, p_rid);
		}
	}

	/* EVENT QUEUING */

	virtual void request_frame_drawn_callback(const Callable &p_callable) override;

	virtual void draw(bool p_swap_buffers, double frame_step) override;
	virtual void sync() override;
	virtual bool has_changed() const override;
	virtual void init() override;
	virtual void finish() override;

	/* STATUS INFORMATION */

	virtual uint64_t get_rendering_info(RenderingInfo p_info) override;
	virtual String get_video_adapter_name() const override;
	virtual String get_video_adapter_vendor() const override;
	virtual RenderingDevice::DeviceType get_video_adapter_type() const override;
	virtual String get_video_adapter_api_version() const override;

Review comment (performance):
This shouldn't be included here. ``FUNC0RC`` forces functions to be called on the command queue which adds unnecessary performance overhead to functions if they don't need to be called from the rendering thread.

``get_video_adapter_type`` should stay below with the other status information functions

Code after:

#undef server_name
#undef ServerName
//from now on, calls forwarded to this singleton
#define ServerName RendererMaterialStorage
#define server_name RSG::material_storage

	FUNC3(global_shader_parameter_add, const StringName &, GlobalShaderParameterType, const Variant &)
	FUNC1(global_shader_parameter_remove, const StringName &)
	FUNC0RC(Vector<StringName>, global_shader_parameter_get_list)
	FUNC2(global_shader_parameter_set, const StringName &, const Variant &)
	FUNC2(global_shader_parameter_set_override, const StringName &, const Variant &)
	FUNC1RC(GlobalShaderParameterType, global_shader_parameter_get_type, const StringName &)
	FUNC1RC(Variant, global_shader_parameter_get, const StringName &)

	FUNC1(global_shader_parameters_load_settings, bool)
	FUNC0(global_shader_parameters_clear)

#undef server_name
#undef ServerName
	/* STATUS INFORMATION */
#define ServerName RendererUtilities
#define server_name RSG::utilities
	FUNC0RC(String, get_video_adapter_name)
	FUNC0RC(String, get_video_adapter_vendor)
	FUNC0RC(String, get_video_adapter_api_version)
#undef server_name
#undef ServerName
#undef WRITE_ACTION
#undef SYNC_DEBUG

	virtual uint64_t get_rendering_info(RenderingInfo p_info) override;
	virtual RenderingDevice::DeviceType get_video_adapter_type() const override;

	virtual void set_frame_profiling_enabled(bool p_enable) override;
	virtual Vector<FrameProfileArea> get_frame_profile() override;
	virtual uint64_t get_frame_profile_frame() override;

	virtual RID get_test_cube() override;

	/* FREE */

	virtual void free(RID p_rid) override {
		if (Thread::get_caller_id() == server_thread) {
			command_queue.flush_if_pending();
			_free(p_rid);
		} else {
			command_queue.push(this, &RenderingServerDefault::_free, p_rid);
		}
	}