Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Tessellation QShader Support
Forum Updated to NodeBB v4.3 + New Features

Tessellation QShader Support

Scheduled Pinned Locked Moved General and Desktop
30 Posts 5 Posters 15.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hornsj2
    wrote on last edited by
    #21

    I added it in Qt. I'm pretty confident it works because the shaders compile and link. However, I haven't had time to get a test harness working. I haven't touched OpenGL since before 3 so I'm learning the shader only model & writing the harness.

    Like I say above, I can post the source files with the changes somewhere if someone wants to build them into their QtOpengl project and write a harness.

    I will hopefully have tested it by this weekend.

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #22

      You could make a clone of Qt on gitorious and push your changes to a branch there.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hornsj2
        wrote on last edited by
        #23

        I've not been there but I just made an account. Perhaps tonight I'll do that.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          Hornsj2
          wrote on last edited by
          #24

          Update: Merged my changes into a clone of Qt Master. I have done a quick test of a compile/link of a shaderprogram with tesscontrol and tesseval shaders and will begin writing a full test.

          1 Reply Last reply
          0
          • H Offline
            H Offline
            Hornsj2
            wrote on last edited by
            #25

            Well, the master code works for compatibility profile. When I attempt to use Core profile the call stack goes as follows:

            QtOpenGLd4.dll!QGLExtensionMatcher::QGLExtensionMatcher() Line 5388 C++
            QtOpenGLd4.dll!QGLExtensions::currentContextExtensions() Line 5425 C++

            QtOpenGLd4.dll!QGLExtensions::glExtensions() Line 5530 + 0x9 bytes C++
            QtOpenGLd4.dll!QGLEngineSelector::preferredPaintEngine() Line 200 + 0x1a bytes C++

            @
            QPaintEngine::Type preferredPaintEngine() {
            #ifdef Q_WS_MAC
            // The ATI X1600 driver for Mac OS X does not support return
            // values from functions in GLSL. Since working around this in
            // the GL2 engine would require a big, ugly rewrite, we're
            // falling back to the GL 1 engine..
            static bool mac_x1600_check_done = false;
            if (!mac_x1600_check_done) {
            QGLTemporaryContext *tmp = 0;
            if (!QGLContext::currentContext())
            tmp = new QGLTemporaryContext();
            if (strstr((char *) glGetString(GL_RENDERER), "X1600"))
            engineType = QPaintEngine::OpenGL;
            if (tmp)
            delete tmp;
            mac_x1600_check_done = true;
            }
            #endif
            if (engineType == QPaintEngine::MaxUser) {
            // No user-set engine - use the defaults
            #if defined(QT_OPENGL_ES_2)
            engineType = QPaintEngine::OpenGL2;
            #else
            // We can't do this in the constructor for this object because it
            // needs to be called before the QApplication constructor.
            // Also check for the FragmentShader extension in conjunction with
            // the 2.0 version flag, to cover the case where we export the display
            // from an old GL 1.1 server to a GL 2.x client. In that case we can't
            // use GL 2.0.
            if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)
            && (QGLExtensions::glExtensions() & QGLExtensions::FragmentShader)
            && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty())
            engineType = QPaintEngine::OpenGL2;
            else
            engineType = QPaintEngine::OpenGL;
            #endif
            }
            @

            During that function you can see it tries to instantiate the following:

            QGLExtensionMatcher extensions, called in QGLExtensions::Extensions();

            In that instantiation it attempts to resolve extensions. 221 Extensions are recognized but when it gets to extension 3 the index i and numExtensions variables overflow. This is done in the call to reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, i));

            @
            QGLExtensionMatcher::QGLExtensionMatcher()
            {
            const char *extensionStr = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));

            if (extensionStr) {
                init(extensionStr);
            } else {
                // clear error state
                while (glGetError()) {}
            
                const QGLContext *ctx = QGLContext::currentContext();
                if (ctx) {
                    qt_glGetStringi glGetStringi = (qt_glGetStringi)ctx->getProcAddress(QLatin1String("glGetStringi"));
            
                    GLint numExtensions;
                    glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
            
                    for (int i = 0; i < numExtensions; ++i) {
                        const char *str = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i));
            
                        m_offsets << m_extensions.size();
            
                        while (*str != 0)
                            m_extensions.append(*str++);
                        m_extensions.append(' ');
                    }
                }
            }
            

            }
            @

            Why is the code attempting to resolve extensions in the core profile?

            1 Reply Last reply
            0
            • H Offline
              H Offline
              Hornsj2
              wrote on last edited by
              #26

              OK nevermind the question why.. I know why. The problem is with m_extensions. For some reason it overflows numExtensions during the third iteration through the for loop. I am investigating.

              1 Reply Last reply
              0
              • H Offline
                H Offline
                Hornsj2
                wrote on last edited by
                #27

                @
                m_offsets << m_extensions.size();
                @

                That is the offending line.
                Here's the contents of m_offsets after the third iteration through the loop.

                [0] 0 int
                [1] 27 int
                [2] 1766445569 int

                As you can see there is something very wrong with whatever the third extension is resolving to.

                This worked on your build?

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  Hornsj2
                  wrote on last edited by
                  #28

                  On a complete whim I tried lowering my core profile to 3.0 and it worked fine.

                  I know for a fact (I have 2 GTX 480s with updated drivers) that I should be able to support 4.0.

                  The question now becomes, should I open another thread to address this, as it is an obvious bug.

                  By the way I have a real application I want to write (which is what started me down this path). I am going to probably put this on the back burner because Qt support for OpenGL seems so spotty. I'll just use native calls.

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    Hornsj2
                    wrote on last edited by
                    #29

                    For what it's worth, here's the repo.

                    git://gitorious.org/~hornsj2/qt/hornsj2s-qt.git

                    Untested for now.

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      ZapB
                      wrote on last edited by
                      #30

                      Thanks. I'll take a look at it when I get a chance (probably be the weekend). From what you have said, it looks like Qt could do with an overhaul when it comes to support for newer versions of OpenGL.

                      Your machine must generate a lot of heat with 2 x 480's in it ;-)

                      I only have a lowly 8800GTS at the moment but I want to build myself a new machine sometime later this year.

                      Nokia Certified Qt Specialist
                      Interested in hearing about Qt related work

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved