microsoft / angle

ANGLE: OpenGL ES to DirectX translation
Other
615 stars 166 forks source link

Major design flaw with ms-holographic-experimental #76

Open mlfarrell opened 8 years ago

mlfarrell commented 8 years ago

I spent hours today debugging an issue that finally led to my discovery of this flaw:

glClear of the default framebuffer triggers a call to EGLint HolographicSwapChain11::updateHolographicRenderingParameters()

This method inspects the current shader and sets the uHolographicViewProjectionMatrix uniform for THAT shader at THAT time. This totally breaks down when using multiple shaders, since only the last bound shader receives the info, and clearing the framebuffer multiple times per frame isn't a valid solution. This mechanism is going to need to be rethought to ensure that multiple shaders can access the uHolographicViewProjectionMatrix state.

One solution would be to store the matrices in the GL state and allow a glGet(GL_HOLOGRAPHIC_VP_MATRICES_ANGLE, matrices); so I can set them for the shaders myself

mlfarrell commented 8 years ago

Potential solution

https://github.com/mlfarrell/angle/commit/7a858fce6ecda9e3964b34ac74c2f9b23da9ce0c

MikeRiches commented 8 years ago

@mlfarrell: I agree that you should be able to get the matrices and apply them to the shader pipeline yourself. This will be better for multi-pass rendering techniques. I will investigate a fix for this in the next update.

mlfarrell commented 8 years ago

Yea. I'm pretty forked from you guys at this point. Feel free to check my fork to see how I tackled this on my end. I'll try to update and sync up to your branch in the future as you guys continue to mature it.

https://github.com/mlfarrell/angle

bouviervj commented 7 years ago

Spend hours before seeing this issue ... @mlfarrell I have seen your patch, should we implement instead a trigger when calling glUseProgram ? It would be more transparent and less platform dependant.

mlfarrell commented 7 years ago

What I ended up doing was implementing a target I could call from angle to glGet to obtain the holo matrices myself instead of relying on automatic conversion. This allowed me to manage multiple shaders myself. I also have (in my engine) a flag I can check to see whether I'm targeting a stereo FBO or not and act accordingly.