slideshow/opengl/honeycombFragmentShader.glsl | 6 +-- slideshow/opengl/honeycombGeometryShader.glsl | 2 - slideshow/opengl/honeycombVertexShader.glsl | 41 +++++++++++++++++++------- slideshow/opengl/vortexFragmentShader.glsl | 6 +-- slideshow/opengl/vortexVertexShader.glsl | 17 +++++++--- 5 files changed, 50 insertions(+), 22 deletions(-)
New commits: commit bbf28c9bc0c335646f610bf535fba5c125dcd65f Author: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com> Date: Wed Feb 24 20:21:10 2016 +0000 slideshow: Only use texture() in GLSL 1.50, fixes Intel on Windows texture2D() is still available, but not in the geometry stage, so better be consistent everywhere. Change-Id: I86bf1921713bcbf32946190525401bfcc633a69f diff --git a/slideshow/opengl/honeycombFragmentShader.glsl b/slideshow/opengl/honeycombFragmentShader.glsl index 41b6738..c207203 100644 --- a/slideshow/opengl/honeycombFragmentShader.glsl +++ b/slideshow/opengl/honeycombFragmentShader.glsl @@ -29,7 +29,7 @@ bool isBorder(vec2 point) void main() { - vec4 fragment = vec4(texture2D(slideTexture, texturePosition).rgb, 1.0); + vec4 fragment = vec4(texture(slideTexture, texturePosition).rgb, 1.0); vec3 lightVector = vec3(0.0, 0.0, 1.0); float light = max(dot(lightVector, normal), 0.0); if (hexagonSize > 1.0) { @@ -75,8 +75,8 @@ void main() } float visibility = 1.0; const float epsilon = 0.0001; - if (texture2D(depthShadowTexture, shadowCoordinate.xy).r < shadowCoordinate.z - epsilon) - visibility *= 0.7 + 0.3 * (1.0 - texture2D(colorShadowTexture, shadowCoordinate.xy).a); + if (texture(depthShadowTexture, shadowCoordinate.xy).r < shadowCoordinate.z - epsilon) + visibility *= 0.7 + 0.3 * (1.0 - texture(colorShadowTexture, shadowCoordinate.xy).a); vec4 black = vec4(0.0, 0.0, 0.0, fragment.a); if (fragment.a < 0.001) discard; diff --git a/slideshow/opengl/honeycombGeometryShader.glsl b/slideshow/opengl/honeycombGeometryShader.glsl index 5269fad..5afaa7b 100644 --- a/slideshow/opengl/honeycombGeometryShader.glsl +++ b/slideshow/opengl/honeycombGeometryShader.glsl @@ -29,7 +29,7 @@ const float expandFactor = 0.0318; float snoise(vec2 p) { - return texture2D(permTexture, p).r; + return texture(permTexture, p).r; } mat4 identityMatrix(void) diff --git a/slideshow/opengl/vortexFragmentShader.glsl b/slideshow/opengl/vortexFragmentShader.glsl index 3212ebe..a3f8191 100644 --- a/slideshow/opengl/vortexFragmentShader.glsl +++ b/slideshow/opengl/vortexFragmentShader.glsl @@ -20,12 +20,12 @@ in vec4 shadowCoordinate; void main() { vec3 lightVector = vec3(0.0, 0.0, 1.0); float light = max(dot(lightVector, v_normal), 0.0); - vec4 fragment = texture2D(slideTexture, v_texturePosition); + vec4 fragment = texture(slideTexture, v_texturePosition); float visibility = 1.0; const float epsilon = 0.0001; - if (texture2D(leavingShadowTexture, shadowCoordinate.xy).r < shadowCoordinate.z - epsilon) + if (texture(leavingShadowTexture, shadowCoordinate.xy).r < shadowCoordinate.z - epsilon) visibility *= 0.7; - if (texture2D(enteringShadowTexture, shadowCoordinate.xy).r < shadowCoordinate.z - epsilon) + if (texture(enteringShadowTexture, shadowCoordinate.xy).r < shadowCoordinate.z - epsilon) visibility *= 0.7; vec4 black = vec4(0.0, 0.0, 0.0, fragment.a); gl_FragColor = mix(black, fragment, visibility * light); diff --git a/slideshow/opengl/vortexVertexShader.glsl b/slideshow/opengl/vortexVertexShader.glsl index 5c6fe23..8d1a67d 100755 --- a/slideshow/opengl/vortexVertexShader.glsl +++ b/slideshow/opengl/vortexVertexShader.glsl @@ -39,7 +39,7 @@ out float endTime; float snoise(vec2 p) { - return texture2D(permTexture, p).r; + return texture(permTexture, p).r; } mat4 identityMatrix(void) commit 92958290631112e65fb1dade7d4c7c91cc8ece17 Author: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com> Date: Wed Feb 24 20:21:12 2016 +0000 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 diff --git a/slideshow/opengl/honeycombVertexShader.glsl b/slideshow/opengl/honeycombVertexShader.glsl index 32fdece..c3484d3 100644 --- a/slideshow/opengl/honeycombVertexShader.glsl +++ b/slideshow/opengl/honeycombVertexShader.glsl @@ -25,10 +25,21 @@ uniform float shadow; uniform mat4 orthoProjectionMatrix; uniform mat4 orthoViewMatrix; +// Workaround for Intel's Windows driver, to prevent optimisation breakage. +uniform float zero; + out mat4 projectionMatrix; out mat4 modelViewMatrix; 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) { return mat4(1.0, 0.0, 0.0, 0.0, @@ -61,25 +72,35 @@ mat4 rotationMatrix(vec3 axis, float angle) void main( void ) { mat4 nmodelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix; - mat4 transformMatrix; + mat4 transformMatrix = identityMatrix(); // TODO: use the aspect ratio of the slide instead. mat4 slideScaleMatrix = scaleMatrix(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) { // Leaving texture - transformMatrix = translationMatrix(vec3(0, 0, 6 * time)) - * scaleMatrix(vec3(1 + pow(2 * time, 2.1), 1 + pow(2 * time, 2.1), 0)) - * slideScaleMatrix - * rotationMatrix(vec3(0.0, 0.0, 1.0), -pow(time, 3) * M_PI) - * invertSlideScaleMatrix; + if (zero < 1.0) + transformMatrix = invertSlideScaleMatrix * transformMatrix; + if (zero < 2.0) + transformMatrix = rotationMatrix(vec3(0.0, 0.0, 1.0), -pow(time, 3) * M_PI) * transformMatrix; + 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 { // Entering texture - transformMatrix = translationMatrix(vec3(0, 0, 28 * (sqrt(time) - 1))) - * slideScaleMatrix - * rotationMatrix(vec3(0.0, 0.0, 1.0), pow(0.8 * (time - 1.0), 2.0) * M_PI) - * invertSlideScaleMatrix; + if (zero < 1.0) + transformMatrix = invertSlideScaleMatrix * transformMatrix; + if (zero < 2.0) + 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) { diff --git a/slideshow/opengl/vortexVertexShader.glsl b/slideshow/opengl/vortexVertexShader.glsl index 3d5838e..5c6fe23 100755 --- a/slideshow/opengl/vortexVertexShader.glsl +++ b/slideshow/opengl/vortexVertexShader.glsl @@ -26,6 +26,9 @@ uniform ivec2 numTiles; uniform sampler2D permTexture; uniform float slide; +// Workaround for Intel's Windows driver, to prevent optimisation breakage. +uniform float zero; + out vec2 g_texturePosition; out vec3 g_normal; out mat4 modelViewMatrix; @@ -130,10 +133,14 @@ void main( void ) vec3 translationVector = vec3(rotationFuzz, 0.0, 0.0); // Compute the actual rotation matrix. - transform = translationMatrix(translationVector) - * rotationMatrix(vec3(0.0, 1.0, 0.0), clamp(rotation, -1.0, 1.0) * M_PI) - * translationMatrix(-translationVector) - * transform; + + // Intel's Windows driver gives a wrong matrix when all operations are done at once. + if (zero < 1.0) + 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;
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits