Kaydet (Commit) db9fe1ea authored tarafından Emmanuel Gil Peyrot's avatar Emmanuel Gil Peyrot Kaydeden (comit) Tomaž Vajngerl

slideshow: Add an ugly workaround for Intel’s matrix multiplication

When more than three multiplications are chained, Intel’s Windows
driver returns a mat4 containing only zeroes, likely due to a
misbehaving optimisation.  This patch prevents it from doing any
optimisation by doing each multiplication in its own uniform block.

Change-Id: I0b435d3a5444afd47f78c379f0d2e442d2c2cfc0
Reviewed-on: https://gerrit.libreoffice.org/22470Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 06404309
...@@ -25,10 +25,21 @@ uniform float shadow; ...@@ -25,10 +25,21 @@ uniform float shadow;
uniform mat4 orthoProjectionMatrix; uniform mat4 orthoProjectionMatrix;
uniform mat4 orthoViewMatrix; uniform mat4 orthoViewMatrix;
// Workaround for Intel's Windows driver, to prevent optimisation breakage.
uniform float zero;
out mat4 projectionMatrix; out mat4 projectionMatrix;
out mat4 modelViewMatrix; out mat4 modelViewMatrix;
out mat4 shadowMatrix; out mat4 shadowMatrix;
mat4 identityMatrix(void)
{
return mat4(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
}
mat4 translationMatrix(vec3 axis) mat4 translationMatrix(vec3 axis)
{ {
return mat4(1.0, 0.0, 0.0, 0.0, return mat4(1.0, 0.0, 0.0, 0.0,
...@@ -61,25 +72,35 @@ mat4 rotationMatrix(vec3 axis, float angle) ...@@ -61,25 +72,35 @@ mat4 rotationMatrix(vec3 axis, float angle)
void main( void ) void main( void )
{ {
mat4 nmodelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix; mat4 nmodelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
mat4 transformMatrix; mat4 transformMatrix = identityMatrix();
// TODO: use the aspect ratio of the slide instead. // TODO: use the aspect ratio of the slide instead.
mat4 slideScaleMatrix = scaleMatrix(vec3(0.75, 1, 1)); mat4 slideScaleMatrix = scaleMatrix(vec3(0.75, 1, 1));
mat4 invertSlideScaleMatrix = scaleMatrix(1.0 / vec3(0.75, 1, 1)); mat4 invertSlideScaleMatrix = scaleMatrix(1.0 / vec3(0.75, 1, 1));
// These ugly zero comparisons are a workaround for Intel's Windows driver optimisation bug.
if (selectedTexture > 0.5) { if (selectedTexture > 0.5) {
// Leaving texture // Leaving texture
transformMatrix = translationMatrix(vec3(0, 0, 6 * time)) if (zero < 1.0)
* scaleMatrix(vec3(1 + pow(2 * time, 2.1), 1 + pow(2 * time, 2.1), 0)) transformMatrix = invertSlideScaleMatrix * transformMatrix;
* slideScaleMatrix if (zero < 2.0)
* rotationMatrix(vec3(0.0, 0.0, 1.0), -pow(time, 3) * M_PI) transformMatrix = rotationMatrix(vec3(0.0, 0.0, 1.0), -pow(time, 3) * M_PI) * transformMatrix;
* invertSlideScaleMatrix; if (zero < 3.0)
transformMatrix = slideScaleMatrix * transformMatrix;
if (zero < 4.0)
transformMatrix = scaleMatrix(vec3(1 + pow(2 * time, 2.1), 1 + pow(2 * time, 2.1), 0)) * transformMatrix;
if (zero < 5.0)
transformMatrix = translationMatrix(vec3(0, 0, 6 * time)) * transformMatrix;
} else { } else {
// Entering texture // Entering texture
transformMatrix = translationMatrix(vec3(0, 0, 28 * (sqrt(time) - 1))) if (zero < 1.0)
* slideScaleMatrix transformMatrix = invertSlideScaleMatrix * transformMatrix;
* rotationMatrix(vec3(0.0, 0.0, 1.0), pow(0.8 * (time - 1.0), 2.0) * M_PI) if (zero < 2.0)
* invertSlideScaleMatrix; transformMatrix = rotationMatrix(vec3(0.0, 0.0, 1.0), pow(0.8 * (time - 1.0), 2.0) * M_PI) * transformMatrix;
if (zero < 3.0)
transformMatrix = slideScaleMatrix * transformMatrix;
if (zero < 4.0)
transformMatrix = translationMatrix(vec3(0, 0, 28 * (sqrt(time) - 1))) * transformMatrix;
} }
if (shadow < 0.5) { if (shadow < 0.5) {
......
...@@ -26,6 +26,9 @@ uniform ivec2 numTiles; ...@@ -26,6 +26,9 @@ uniform ivec2 numTiles;
uniform sampler2D permTexture; uniform sampler2D permTexture;
uniform float slide; uniform float slide;
// Workaround for Intel's Windows driver, to prevent optimisation breakage.
uniform float zero;
out vec2 g_texturePosition; out vec2 g_texturePosition;
out vec3 g_normal; out vec3 g_normal;
out mat4 modelViewMatrix; out mat4 modelViewMatrix;
...@@ -130,10 +133,14 @@ void main( void ) ...@@ -130,10 +133,14 @@ void main( void )
vec3 translationVector = vec3(rotationFuzz, 0.0, 0.0); vec3 translationVector = vec3(rotationFuzz, 0.0, 0.0);
// Compute the actual rotation matrix. // Compute the actual rotation matrix.
transform = translationMatrix(translationVector)
* rotationMatrix(vec3(0.0, 1.0, 0.0), clamp(rotation, -1.0, 1.0) * M_PI) // Intel's Windows driver gives a wrong matrix when all operations are done at once.
* translationMatrix(-translationVector) if (zero < 1.0)
* transform; transform = translationMatrix(translationVector) * transform;
if (zero < 2.0)
transform = rotationMatrix(vec3(0.0, 1.0, 0.0), clamp(rotation, -1.0, 1.0) * M_PI) * transform;
if (zero < 3.0)
transform = translationMatrix(-translationVector) * transform;
} }
modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix; modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment