Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-112969

[Reg 5.15.11 -> 5.15.12] Crash when updating shader variable in CustomMaterial

    XMLWordPrintable

Details

    • 5720c0da7 (tqtc/lts-5.15)

    Description

      Code
      shader.frag

      in vec2 uvs;
      out vec4 fragColor;
      
      void main()
      {
          fragColor = vec4(0, exampleProperty, 0, 1);
      }
      

      MyCustomMaterial.qml

      import QtQuick 2.15
      import QtQuick3D 1.15
      import QtQuick3D.Materials 1.15
      
      CustomMaterial {
          property real exampleProperty: 0.5
      
          shaderInfo: ShaderInfo {
              version: "330"
              type: "GLSL"
          }
      
          Shader {
              id: vertShader
              stage: Shader.Vertex
              shader: "shader.vert"
          }
      
          Shader {
              id: fragShader
              stage: Shader.Fragment
              shader: "shader.frag" // shader.frag uses the value of exampleProperty
          }
      
          passes: [
              Pass {
                  shaders: [
                      vertShader, fragShader
                  ]
              }
          ]
      }
      

      main.qml

      import QtQuick 2.15
      import QtQuick3D 1.15
      import QtQuick.Window 2.15
      
      Window {
          id: window
          width: 1280
          height: 720
          visible: true
          color: "navy"
          title: "Qt Quick 3D 5.15 Assertion"
      
          View3D {
              anchors.fill: parent
              camera: camera
      
              PerspectiveCamera {
                  id: camera
                  position: Qt.vector3d(0, 100, 150)
                  eulerRotation.x: -30
              }
              Model {
                  source: "#Sphere"
                  scale: Qt.vector3d(1, 1, 1)
                  materials: [
                      MyCustomMaterial { id: myMaterial }
                  ]
              }
          }
      
          Timer {
              repeat: true
              interval: 250
              running: true
              onTriggered: myMaterial.exampleProperty = Math.random() // This causes a crash
          }
      }
      
      

       

      Expected outcome (Qt 5.15.11)
      The green circle on screen periodically changes "luminosity"

       

      Actual outcome (Qt 5.15.12/5.15.13)
      We get an assertion in QSSGMaterialSystem::doRenderCustomMaterial for falling into the default switch() case:
      https://github.com/qt/qtquick3d/blob/v5.15.9-lts-lgpl/src/runtimerender/qssgrendercustommaterialsystem.cpp#L1557 Ignoring the assertion leads to a crash.

      Attachments

        For Gerrit Dashboard: QTBUG-112969
        # Subject Branch Project Status CR V

        Activity

          People

            tokorpip Tomi Korpipää
            skoh-qt Sze Howe Koh
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes