aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/scenegraph_lancelot
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2020-05-11 13:40:48 +0200
committerPaul Olav Tvete <paul.tvete@qt.io>2020-05-15 09:35:29 +0200
commit1907265de25d3815cba24885c01fe4072b570e46 (patch)
tree8e274261409a8791d0f6e335d5b8c9cdef3bd0db /tests/manual/scenegraph_lancelot
parented8413f7f3b1f0a165c25cbcb9c162b8b12e7864 (diff)
Lancelot tests for ShaderEffect uniform bindings
Test that properties are bound to shader uniforms. Three ways of setting the property: initial value, PropertyAnimation, and UniformAnimator. Task-number: QTBUG-83975 Pick-to: 5.15 Change-Id: I61518dc1bf680d0d28dd0171c5dcf8b4a6b3695e Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests/manual/scenegraph_lancelot')
-rw-r--r--tests/manual/scenegraph_lancelot/data/shaders/propertyanimation/property.qml30
-rw-r--r--tests/manual/scenegraph_lancelot/data/shaders/propertyanimation/uniformanimator.qml21
-rw-r--r--tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/property.fragbin0 -> 1197 bytes
-rw-r--r--tests/manual/scenegraph_lancelot/data/shared/shaders/compile.bat1
-rw-r--r--tests/manual/scenegraph_lancelot/data/shared/shaders/property.frag6
-rw-r--r--tests/manual/scenegraph_lancelot/data/shared/shaders/property_rhi.frag14
-rw-r--r--tests/manual/scenegraph_lancelot/data/shared/shared.qrc2
7 files changed, 74 insertions, 0 deletions
diff --git a/tests/manual/scenegraph_lancelot/data/shaders/propertyanimation/property.qml b/tests/manual/scenegraph_lancelot/data/shaders/propertyanimation/property.qml
new file mode 100644
index 0000000000..c58380aca8
--- /dev/null
+++ b/tests/manual/scenegraph_lancelot/data/shaders/propertyanimation/property.qml
@@ -0,0 +1,30 @@
+import QtQuick 2.0
+
+Item {
+ width: 320
+ height: 480
+
+ ShaderEffect {
+ x: 10
+ y: 10
+ width: 300
+ height: 200
+ property real colorProperty: 0.5
+ fragmentShader: "qrc:shaders/property.frag"
+ }
+
+ ShaderEffect {
+ x: 10
+ y: 250
+ width: 300
+ height: 200
+ property real colorProperty: 0.0
+ fragmentShader: "qrc:shaders/property.frag"
+
+ NumberAnimation on colorProperty {
+ duration: 200
+ from: 0.0
+ to: 1.0
+ }
+ }
+}
diff --git a/tests/manual/scenegraph_lancelot/data/shaders/propertyanimation/uniformanimator.qml b/tests/manual/scenegraph_lancelot/data/shaders/propertyanimation/uniformanimator.qml
new file mode 100644
index 0000000000..22691652b0
--- /dev/null
+++ b/tests/manual/scenegraph_lancelot/data/shaders/propertyanimation/uniformanimator.qml
@@ -0,0 +1,21 @@
+import QtQuick 2.15
+
+Item {
+ width: 320
+ height: 480
+
+ ShaderEffect {
+ x: 10
+ y: 250
+ width: 300
+ height: 200
+ property real colorProperty: 0.0
+ fragmentShader: "qrc:shaders/property.frag"
+
+ UniformAnimator on colorProperty {
+ duration: 200
+ from: 0.0
+ to: 1.0
+ }
+ }
+}
diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/property.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/property.frag
new file mode 100644
index 0000000000..078252cad4
--- /dev/null
+++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/property.frag
Binary files differ
diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/compile.bat b/tests/manual/scenegraph_lancelot/data/shared/shaders/compile.bat
index 85b762cebd..8a7f56174c 100644
--- a/tests/manual/scenegraph_lancelot/data/shared/shaders/compile.bat
+++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/compile.bat
@@ -10,5 +10,6 @@ qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o +qsb/gradient2.frag gradient2_
qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o +qsb/gradient3.frag gradient3_rhi.frag
qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o +qsb/gradient4.frag gradient4_rhi.frag
qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o +qsb/gradient5.frag gradient5_rhi.frag
+qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o +qsb/property.frag property_rhi.frag
qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o +qsb/shadow.frag shadow_rhi.frag
qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o +qsb/stencil.frag stencil_rhi.frag
diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/property.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/property.frag
new file mode 100644
index 0000000000..0d28bff43b
--- /dev/null
+++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/property.frag
@@ -0,0 +1,6 @@
+varying highp vec2 qt_TexCoord0;
+uniform lowp float qt_Opacity;
+uniform lowp float colorProperty;
+void main() {
+ gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, colorProperty, 1);
+}
diff --git a/tests/manual/scenegraph_lancelot/data/shared/shaders/property_rhi.frag b/tests/manual/scenegraph_lancelot/data/shared/shaders/property_rhi.frag
new file mode 100644
index 0000000000..2ffa707fb1
--- /dev/null
+++ b/tests/manual/scenegraph_lancelot/data/shared/shaders/property_rhi.frag
@@ -0,0 +1,14 @@
+#version 440
+
+layout(location = 0) in vec2 qt_TexCoord0;
+layout(location = 0) out vec4 fragColor;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 qt_Matrix;
+ float qt_Opacity;
+ float colorProperty;
+} ubuf;
+
+void main() {
+ fragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, ubuf.colorProperty, 1);
+}
diff --git a/tests/manual/scenegraph_lancelot/data/shared/shared.qrc b/tests/manual/scenegraph_lancelot/data/shared/shared.qrc
index a8bd6e9ea8..10883211aa 100644
--- a/tests/manual/scenegraph_lancelot/data/shared/shared.qrc
+++ b/tests/manual/scenegraph_lancelot/data/shared/shared.qrc
@@ -10,6 +10,7 @@
<file>shaders/gradient3.frag</file>
<file>shaders/gradient4.frag</file>
<file>shaders/gradient5.frag</file>
+ <file>shaders/property.frag</file>
<file>shaders/shadow.frag</file>
<file>shaders/stencil.frag</file>
<file>shaders/wave.vert</file>
@@ -23,6 +24,7 @@
<file>shaders/+qsb/gradient3.frag</file>
<file>shaders/+qsb/gradient4.frag</file>
<file>shaders/+qsb/gradient5.frag</file>
+ <file>shaders/+qsb/property.frag</file>
<file>shaders/+qsb/shadow.frag</file>
<file>shaders/+qsb/stencil.frag</file>
<file>shaders/+qsb/wave.vert</file>