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

Cannot have more than GL_MAX_IMAGE_UNITS ShaderImage in a scene

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • 5.15.2, 6.2.4
    • Qt3D
    • None
    • Ubuntu 20.04
      NVIDIA GTX 1080, driver 470.129.06
    • 51aa6ab005e86c6a1c5d4c91671bd8c68dde0dea

    Description

      We have come across an issue with the OpenGL backend of Qt3D and usage of ShaderImage. It doesn't affect RHI because RHI doesn't support ShaderImage.
      If there are more than GL_MAX_IMAGE_UNITS ShaderImage s (in my case 8) used in the scene (cumulatively - you can remove Materials that have a ShaderImage and it won't free any up), then you get an error messages about not being able to find an available image unit, and "Unable to bind Image to Texture".

      We were able to deduce the issue was in ImageSubmissionContext and SubmissionContext. The root cause is that ImageSubmissionContext never "unpins" the active images, even when a different material is being rendered. While there is the function ImageSubmissionContext::deactivateImages() it is never called.

      It looks like ImageSubmissionContext is based upon TextureSubmissionContext so we looked at where and how that unpins the textures it has bound. The textures are unbound in SubmissionContext::setParameters. Based on the comment within that function, setParameters is called when the material changes. The other function, SubmissionContext::setActiveMaterial, is never called.

      So to fix ImageSubmissionContext never unpinning the image units, the fix is quite simple: add m_imageContext.deactivateImages(); in before activating the image units.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            seanharmer Sean Harmer
            samuelshaw Samuel Shaw
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes