aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2020-05-11 13:40:48 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-05-19 15:59:28 +0200
commit8ec0d9c00ab9473258f8053b7c563e8cda2f99e4 (patch)
tree3fa88c632e57f80f7db12243a83b669c954a9b49 /tests
parent21f2b604e7ff9bf845e22a252916048736923de2 (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 Change-Id: I61518dc1bf680d0d28dd0171c5dcf8b4a6b3695e Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit 1907265de25d3815cba24885c01fe4072b570e46)
Diffstat (limited to 'tests')
-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>