From 8ec0d9c00ab9473258f8053b7c563e8cda2f99e4 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 11 May 2020 13:40:48 +0200 Subject: 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 (cherry picked from commit 1907265de25d3815cba24885c01fe4072b570e46) --- .../data/shaders/propertyanimation/property.qml | 30 +++++++++++++++++++++ .../shaders/propertyanimation/uniformanimator.qml | 21 +++++++++++++++ .../data/shared/shaders/+qsb/property.frag | Bin 0 -> 1197 bytes .../data/shared/shaders/compile.bat | 1 + .../data/shared/shaders/property.frag | 6 +++++ .../data/shared/shaders/property_rhi.frag | 14 ++++++++++ .../scenegraph_lancelot/data/shared/shared.qrc | 2 ++ 7 files changed, 74 insertions(+) create mode 100644 tests/manual/scenegraph_lancelot/data/shaders/propertyanimation/property.qml create mode 100644 tests/manual/scenegraph_lancelot/data/shaders/propertyanimation/uniformanimator.qml create mode 100644 tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/property.frag create mode 100644 tests/manual/scenegraph_lancelot/data/shared/shaders/property.frag create mode 100644 tests/manual/scenegraph_lancelot/data/shared/shaders/property_rhi.frag (limited to 'tests') 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 Binary files /dev/null and b/tests/manual/scenegraph_lancelot/data/shared/shaders/+qsb/property.frag 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 @@ shaders/gradient3.frag shaders/gradient4.frag shaders/gradient5.frag + shaders/property.frag shaders/shadow.frag shaders/stencil.frag shaders/wave.vert @@ -23,6 +24,7 @@ shaders/+qsb/gradient3.frag shaders/+qsb/gradient4.frag shaders/+qsb/gradient5.frag + shaders/+qsb/property.frag shaders/+qsb/shadow.frag shaders/+qsb/stencil.frag shaders/+qsb/wave.vert -- cgit v1.2.3