add apotential fix to the issue with viewInverse for Legacy transform path support

This commit is contained in:
Sam Gateau 2015-06-08 06:46:45 -07:00
parent c47cee3f3b
commit b7d88e2642
3 changed files with 34 additions and 0 deletions

View file

@ -87,6 +87,11 @@ public:
GLuint _transformCameraSlot = -1;
GLuint _transformObjectSlot = -1;
#if (GPU_TRANSFORM_PROFILE == GPU_CORE)
#else
GLuint _transformCamera_viewInverse = -1;
#endif
GLShader();
~GLShader();
};
@ -311,6 +316,11 @@ protected:
GLuint _program;
bool _invalidProgram;
#if (GPU_TRANSFORM_PROFILE == GPU_CORE)
#else
GLuint _program_transformCamera_viewInverse = -1;
#endif
State::Data _stateCache;
State::Signature _stateSignatureCache;

View file

@ -71,6 +71,11 @@ void GLBackend::do_setPipeline(Batch& batch, uint32 paramOffset) {
_pipeline._program = 0;
_pipeline._invalidProgram = true;
#if (GPU_TRANSFORM_PROFILE == GPU_CORE)
#else
_pipeline._program_transformCamera_viewInverse = -1
#endif
_pipeline._state = nullptr;
_pipeline._invalidState = true;
} else {
@ -83,6 +88,11 @@ void GLBackend::do_setPipeline(Batch& batch, uint32 paramOffset) {
if (_pipeline._program != pipelineObject->_program->_program) {
_pipeline._program = pipelineObject->_program->_program;
_pipeline._invalidProgram = true;
#if (GPU_TRANSFORM_PROFILE == GPU_CORE)
#else
_pipeline._program_transformCamera_viewInverse = pipelineObject->_program->_transformCamera_viewInverse;
#endif
}
// Now for the state
@ -130,6 +140,15 @@ void GLBackend::updatePipeline() {
}
_pipeline._invalidState = false;
}
#if (GPU_TRANSFORM_PROFILE == GPU_CORE)
#else
// If shader program needs the inverseView we need to provide it
// YES InverseView in the shade is called View on the Batch interface
if (_pipeline._program_transformCamera_viewInverse >= 0) {
glUniformMatrix4fv(_pipeline._program_transformCamera_viewInverse, 1, false, &_transform._view);
}
#endif
}
void GLBackend::do_setUniformBuffer(Batch& batch, uint32 paramOffset) {

View file

@ -106,6 +106,11 @@ void makeBindings(GLBackend::GLShader* shader) {
glUniformBlockBinding(glprogram, loc, gpu::TRANSFORM_CAMERA_SLOT);
shader->_transformCameraSlot = gpu::TRANSFORM_CAMERA_SLOT;
}
#else
loc = glGetUniformLocation(glprogram, "transformCamera_viewInverse");
if (loc >= 0) {
shader->_transformCamera_viewInverse = loc;
}
#endif
}