将渲染和物理分离为游戏引擎的独立线程是否有效

将渲染和物理分离为游戏引擎的独立线程是否有效

本文介绍了将渲染和物理分离为游戏引擎的独立线程是否有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在开发一些3D游戏的实验性游戏引擎(通过XNA),我正在考虑将物理和渲染过程分成C#中的单独线程。



所以,我在StackOverflow的一篇文章中读到多线程并不总是有效甚至可能损害整体性能。



我认为它没关系,因为渲染对物理或游戏逻辑同步没什么关键,这可能导致程序在运行时崩溃。所以我想把物理学留在主线程中并将渲染过程交给另一个线程,然后它会影响物理和AI的计算。



我想这个想法很棒,因为无论游戏中的逻辑如何,渲染都可能会变慢,因此无论渲染是否延迟,都应计算下一个逻辑步骤。总体而言,渲染过程与其他所有逻辑过程一样繁重。



问题:

1)所以,它是好的想要在这里执行多线程吗?

2)如果渲染比逻辑计算慢,是否会导致鼠标滞后?

3)拆分是个好主意许多线程的游戏逻辑?像AI,Physics,Sound等?

Hello , I am developing now some experimental game engine for 3D games (via XNA) and i was thinking of splitting the physics and rendering processes to separate threads in C# .

So , i was reading in some article at StackOverflow that Multi-Threading isn''t always effective and may even hurt the overall performance .

I thought it would be OK because rendering have nothing critical to sync with the physics or game logic which may cause the program to crash at running time . So i wanted to leave the physics in the main thread and give the rendering process to another thread and then it will affect less the physics and the AI calculations .

I think this idea is great at all , because the Rendering may be slower regardless the logic in the game so the next logical step should be calculated whatever if the rendering is delays or not . And in overall the rendering is so heavy process as all the other logical processes together .

Questions :
1) So , is it good idea to perform here multithreading at all ?
2) If the rendering is slower than the logic calculation , Will it cause mouse lags ?
3) Is it good idea to split the game logic to many threads ? like AI , Physics , Sound etc ?

推荐答案


这篇关于将渲染和物理分离为游戏引擎的独立线程是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 23:44