Tessellation QShader Support
-
Hi,
[quote author="Michael Goddard" date="1300234191"]Perhaps it's included in Qt/3d?
http://qt.gitorious.org/qt-labs/qt3d
[/quote]
We don't have support for TC or TE shaders in Qt3D. We do have a lot of plans for future development but we have to look at things that have broad support on platforms.
[quote author="Hornsj2" date="1300273855"]It looks to be implied that there may be some plan to merge Qt/3D with Qt. I base that only on the language they use when describing Qt/3D, so that may be totally bogus.[/quote]
QGLShaderProgram originally came from Qt3D and was brought over with some other classes into Qt proper. There should be a few more classes like this - our so called "Enablers". But at present, despite our earlier plans, it looks doubtful that we will merge large parts of Qt3D into Qt. Mostly this is because of the "modularisation effort in Qt":http://labs.qt.nokia.com/2011/01/21/status-of-qt-modularization/
Qt's QGLShader* classes now support geometry shaders, but in reality they don't get much use - I don't think anything in Qt uses them, and I don't see any examples or demos there. We mostly focus on OpenGL 2 and ES 2 as the lowest common denominator - and of course OpenGL ES 1.x is still popular and supported.
Qt3D does help you out a lot with VBO's and also with the resolving of extensions. We do support calling gl functions as well. Check "the documentation":http://doc.qt.nokia.com/qt3d-snapshot/ for details.
If TE and TC shader support was going to be added, it probably really ought to be done in Qt rather than Qt3D. Then Qt3D would really need to have some changes to its VBO support to make it easier to work with the control data and so on. Its not a big thing to do. You could request it as a suggestion on "the bug system":http://bugreports.qt.nokia.com.
-
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.
-
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?
-
@
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 intAs you can see there is something very wrong with whatever the third extension is resolving to.
This worked on your build?
-
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.
-
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.