1

I have a program which renders first to a texture, then pass the texture to the compute shader for processing, then renders the output result to the screen via a textured full screen quad.

I've read in the nVidia's programming guide for compute shaders that every time you dispatch a compute shader, it initiates a GPU device context switch, which should not be done quite often.

I'm very confused right now. The way I see it, in my rendering pipeline the GPU switches contexts twice. Right? Once during the first dispatch call, the next time when I render my full screen quad normally.

If this is correct, then I can avoid one switch by reorganizing my code like this. First, render to a texture. Second, do the processing on the compute shader. Then, IN THE NEXT FRAME, render the result, then (still in the next frame) render all updates to texture, do processing on compute shader... So basically every start of the frame I render the results of the last frame (the first frame will be an exception). Then there will only be one context switch, right?

But then the GPU will still have to do a context switch between the frames, right? So the two versions of my rendering pipeline all have two context switches. There would be no difference in performance. Am I correct?

Any help would be appreciated.

4

1 に答える 1

1

コンテキスト スイッチは小さなヒットをもたらしますが、あなたの場合はほとんど無視できるので、心配することなく、同じフレーム内でコンピューティング パイプラインとレンダリング パイプラインを何度も安全に切り替えることができます。

最新のゲームの多くでは、同じパイプライン (レンダリング用のグラフィックス パイプライン、ライト用の計算シェーダー、fxaa 用のピクセルシェーダーなど) に 2 つ以上のスイッチがありますが、それでも問題なく動作します。

于 2012-11-03T19:46:05.733 に答える