-
Notifications
You must be signed in to change notification settings - Fork 933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set the correct program link parameters #3110
Conversation
To me this looks like it increases coupling, although I agree the way things worked before was gross. Are there other approaches we could take here? IIRC, layout qualifiers might not be an option because of our GLSL version, but if they are, they'd at least let us restrict the coupling to the things already doomed to be coupled, and the shader manager wouldn't need to care about any of this. |
The |
In my opinion this PR reduces coupling. The shader manager no longer depends on a constant from another component. |
In that respect, it does, but now lots of other things directly interact with the shader manager and we've had to introduce the concept of program templates, which things are coupled with. Does OSG perhaps have something for sorting out binding by name? I know OpenGL lets you query the binding points for things by name, so I'd have thought Robert would have made OSG track that (whether it used the driver's defaults or came up with its own) and then implemented a mechanism to wire things up. This feels like a dumb idea, but we could also maybe alternatively do something with our shader preprocessor to make it strip out unsupported |
Program templates are weakly coupled at most. We default to
With this quiet complex approach we end up with nonstandard shader files incompatible with other engines. |
Osg's Vertex Attribute Aliasing can bind vertex attributes automatically that are referred by their fixed function name in the shader. We need to enable this functionality globally. If we do so, we may have unneeded tracking overhead when groundcover uses shaders while objects do not. Ubo can not be bound with this approach - there is no equivalent fixed function feature. |
Well that's a bit pants. It basically forces us to do something with lots of coupling, use a newer GLSL version with |
Is there any reason we did not merge this PR? |
I don't think anyone tested it. |
It wasn't merged because it looked to me like it massively increased coupling and I wanted a more experienced engineer to take a look. |
I've noticed we get a bunch of |
This message is thrown by OSG here, but it does not include any context unfortunately. It would be worth to investigate the particular programs that cause the message. Perhaps we have enabled some lighting calculations in programs that do not in fact use them. |
I'm unclear what you mean by lighting calculations that we don't use. What's happening now is that Edit: after looking over this implementation I see how this all works now with default program, the issue is something else entirely (see my comment below). |
Oh I see, OSG program copy does not copy uniform binding locations... https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/osg/Program.cpp#L102 Bug, maybe. You'll need to manually copy over the bindings, unless I've missed something obvious why these shouldn't be copied (though we definitely need them copied for our purpose). Copy in context here: And here |
Thank for you this great research. I will need to refactor this PR a little to work around this apparent bug outside of our control. |
This PR aims to solve `uniform block LightBufferBinding has no binding` messages @glassmancody has reportedly encountered since PR #3110 due to an apparent bug in OSG. While we do have to add a workaround here that adds a bit of clunkiness, #3216 should allow us to clean up these interactions a bit in the future.
Currently, Open MW's shader manager has to be aware of shader implementation details to set the associated linking parameters and sets unneeded linking parameters when unaware of the requirements. With these changes we pass an osg::Program template from the outside that specifies the required linking parameters.