Bug 38528 - [Qt] WebGL viewport does not show up on N900
Summary: [Qt] WebGL viewport does not show up on N900
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other Linux
: P2 Normal
Assignee: Jarkko Sakkinen
URL:
Keywords: Qt, QtTriaged
Depends on:
Blocks:
 
Reported: 2010-05-04 10:17 PDT by Jarkko Sakkinen
Modified: 2010-06-17 01:20 PDT (History)
5 users (show)

See Also:


Attachments
Fixes shader issues with OGLES2, improves drawTexture usage a bit. (3.60 KB, patch)
2010-05-20 07:01 PDT, Jarkko Sakkinen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jarkko Sakkinen 2010-05-04 10:17:10 PDT
WebGL viewport does not show up anymore on N900 when tested with QtLauncher.
Comment 1 Jarkko Sakkinen 2010-05-05 00:20:53 PDT
Issue here is simple. Higher-level WebGL code does not handle precision arguments yet (I suppose) and WebGL applications do not usually define precisions.
Comment 2 Jarkko Sakkinen 2010-05-05 00:27:55 PDT
Verified that there is no code that handles shader precisions.
Comment 3 Jarkko Sakkinen 2010-05-05 00:31:47 PDT
https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html#4.4

Issue here is that most of the WebGL pages do not respect that at all :) Shaders are not ES GLSL compatible. They don't define precision arguments.
Comment 4 Jarkko Sakkinen 2010-05-05 00:33:41 PDT
QGLContext::drawTexture functions do not work in Maemo version. Tweaked qgl.cpp a little bit:

diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 644a737..da61e61 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -2706,7 +2706,7 @@ void QGLContext::drawTexture(const QRectF &target, QMacCompatGLuint textureId, Q
 void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget)
 {
     // this would be ok on OpenGL ES 2.0, but currently we don't have a define for that
-#ifdef QT_OPENGL_ES
+#if !defined(QT_OPENGL_ES_2) && defined(QT_OPENGL_ES)
     Q_UNUSED(point);
     Q_UNUSED(textureId);
     Q_UNUSED(textureTarget);


Let's how that helps.
Comment 5 Jarkko Sakkinen 2010-05-05 00:51:20 PDT
Kenneth, Simon says that you have some ideas on handling the precision argument in shader code. Can you elaborate a bit what you have in mind? :)

I think I'll add the following work-around to Qt backend:
- QtWebKit is compiled for a desktop system: define precision arguments as empty macros so that shaders still compile (similar idea as in http://doc.qt.nokia.com/4.6-snapshot/qglshaderprogram.html)
- QtWebKit is compiled for a mobile device: define default precisions and append to the beginning of shader code.

When something more higher-level comes out this workaround can be dropped. Simon, I don't find that too hackish, what do you think?
Comment 6 Jarkko Sakkinen 2010-05-05 03:43:19 PDT
Added new bugreport to Qt Jira: http://bugreports.qt.nokia.com/browse/QTBUG-10420
Comment 7 Jarkko Sakkinen 2010-05-05 09:04:53 PDT
See my comment on Qt Jira. I think point version of drawTexture() is really impossible to make work ES 2.0 but I don't actually can't figure out why rect version is only available for ES versions less than 2.0.
Comment 8 Jarkko Sakkinen 2010-05-05 09:27:39 PDT
Ok that first "patch snippet" was completely crap but now I have patch candidate for rect version, let's see if it works :)
Comment 9 Kenneth Russell 2010-05-05 09:31:29 PDT
(In reply to comment #5)
> Kenneth, Simon says that you have some ideas on handling the precision argument
> in shader code. Can you elaborate a bit what you have in mind? :)

In the context of the ANGLE project ( http://code.google.com/p/angleproject/ ) a GLSL ES -> GLSL translator is being developed. Once this is complete, we hope to work with all browser vendors developing WebGL on the desktop to integrate it simultaneously, because as you've discovered, none of the shaders in the WebGL content currently on the web are GLSL ES compliant.

> I think I'll add the following work-around to Qt backend:
> - QtWebKit is compiled for a desktop system: define precision arguments as
> empty macros so that shaders still compile (similar idea as in
> http://doc.qt.nokia.com/4.6-snapshot/qglshaderprogram.html)
> - QtWebKit is compiled for a mobile device: define default precisions and
> append to the beginning of shader code.
> 
> When something more higher-level comes out this workaround can be dropped.
> Simon, I don't find that too hackish, what do you think?

This sounds like the best short-term workaround.
Comment 10 Jarkko Sakkinen 2010-05-11 00:24:32 PDT
drawTexture() issue is now fixed by Qt people: http://bugreports.qt.nokia.com/browse/QTBUG-10420. Great :) I'm submitting soon patch with workaround for shaders.
Comment 11 Jesus Sanchez-Palencia 2010-05-12 06:57:42 PDT
Please remember to block the 2.0 release meta-bug if you want this to be cherry-picked when the patch is ready.
Comment 12 Jarkko Sakkinen 2010-05-14 02:00:47 PDT
Still waiting for the drawTexture() fix to arrive to Qt public repositories.
Comment 13 Simon Hausmann 2010-05-14 03:42:10 PDT
(In reply to comment #12)
> Still waiting for the drawTexture() fix to arrive to Qt public repositories.

Sounds like we should also make WebGL only available when compiling against Qt 4.7?
Comment 14 Jarkko Sakkinen 2010-05-14 03:59:54 PDT
Depends. If we want to keep readPixels as a fallback for 4.6 then we can support both. I don't really have an opinnion on this, I'll let others to decide this :) 

Simon, have you already created bug for dropping readPixels? We already discussed about readPixels support but does everyone else share the opinnion that WebGL should be only supported with GL viewport? 

drawTexture() can be used for both cases (AC enabled/disabled) when GL viewport is active. I have already fix for this in my gitorious repository and I'm planning to add that change to this patch.
Comment 15 Jarkko Sakkinen 2010-05-20 07:01:49 PDT
Created attachment 56592 [details]
Fixes shader issues with OGLES2, improves drawTexture usage a bit.
Comment 16 WebKit Commit Bot 2010-06-16 19:55:20 PDT
Comment on attachment 56592 [details]
Fixes shader issues with OGLES2, improves drawTexture usage a bit.

Clearing flags on attachment: 56592

Committed r61301: <http://trac.webkit.org/changeset/61301>
Comment 17 WebKit Commit Bot 2010-06-16 19:55:26 PDT
All reviewed patches have been landed.  Closing bug.
Comment 18 Simon Hausmann 2010-06-17 01:20:15 PDT
WebGL is not part of the QtWebKit 2.0 release, so removing from the blocker bug.