質問

I am exploring the relatively new feature GL_ARB_separate_program_object.What I understand is I have to create a pipeline object which should contain shaders from stages which are mapped to there via glUseProgramStages

This make me think about 2 possibilites of using multiple shaders:

1.Creating Multiple pipelines with variant Vertex/Fragment shaders couples(not using other shader types for now) coming from one time mapping to each pipeline.

2.Creating single pipeline and in runtime switch the mapping to different shaders using

glUseProgramStages

I am mostly concerned with performance.Which option is more performance wise ?

役に立ちましたか?

解決

Your question cannot really be answered, as it would vary with driver implementations and such. However, the facts and history of the functionality should be informative.

EXT_separate_shader_objects was the first incarnation of this functionality. The biggest difference between them was this: you could not use user-defined varyings with the EXT version. You had to use the old compatibility input/outputs like gl_TexCoord.

Issue #2 in the EXT_separate_shader_objects specification attempts to justify this incomprehensible oversightexplains the reasoning for this as follows:

It is undesirable from a performance standpoint to attempt to support "rendezvous by name" for arbitrary separate shaders because the separate shaders won't be naturally compiled to match their varying inputs and outputs of the same name without a special link step. Such a special link would introduce an extra validation overhead to binding separate shaders. The link itself would have to be deferred until glBegin time since separate shaders won't match when transitioning from one set of consistent shaders to another. This special link would still create errors or undefined behavior when the names of input and output varyings matched but their types did not match.

This suggests that the reason not to rely on name matching, besides incompetence, was performance related (if you can't tell, I don't think very highly of EXT_SSO). The performance of "rendezvous by name" comes from having to do it at every draw call, rather than being able to do it once.

ARB_separate_shader_objects encapsulates the collection of programs in an object. Therefore, the object can store all of the "rendezvous" data. The first draw call may be slower, but subsequent uses of the same PPO will be fast, as long as you don't attach new programs to it.

So I would take that as evidence that PPOs should have programs set on them and then left alone. In general, modifying the attachments objects should be avoided whenever possible. That's why you're encouraged not to go adding or removing textures/renderbuffers from FBOs.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top