RESOLVED FIXED 175425
[TexMap] Remove GraphicsContext3D usage from TextureMapperShaderProgram
https://bugs.webkit.org/show_bug.cgi?id=175425
Summary [TexMap] Remove GraphicsContext3D usage from TextureMapperShaderProgram
Zan Dobersek
Reported 2017-08-10 04:28:51 PDT
[TexMap] Remove GraphicsContext3D usage from TextureMapperShaderProgram
Attachments
WIP (15.46 KB, patch)
2017-08-10 04:30 PDT, Zan Dobersek
no flags
Patch (16.31 KB, patch)
2017-08-10 05:09 PDT, Zan Dobersek
no flags
ANGLE translation of TexMap shaders on OpenGL ES 2.0 (23.77 KB, text/plain)
2017-08-10 23:30 PDT, Zan Dobersek
no flags
ANGLE translation of TexMap shaders on OpenGL 3.0 (23.30 KB, text/plain)
2017-08-10 23:32 PDT, Zan Dobersek
no flags
ANGLE translation of TexMap shaders on OpenGL 4.3 (23.28 KB, text/plain)
2017-08-10 23:32 PDT, Zan Dobersek
no flags
Patch (22.41 KB, patch)
2017-10-20 07:42 PDT, Miguel Gomez
no flags
Patch (22.41 KB, patch)
2017-10-23 01:14 PDT, Miguel Gomez
no flags
Zan Dobersek
Comment 1 2017-08-10 04:30:21 PDT
Miguel Gomez
Comment 2 2017-08-10 05:03:00 PDT
(In reply to Zan Dobersek from comment #1) > Created attachment 317803 [details] > WIP Zan, we can't just replace m_context->compileShader() with glCompileShader(), cause m_context->compileShader() uses ANGLE to translate the shader source to the appropriate GLSL version before actually calling glCompileShader(). Before doing this change we need to refactor TextureMapperShaderProgram to provide the appropriate shader code for each possible gl version: GLES2, OpenGL < 3.2 and OpenGL >= 3.2.
Zan Dobersek
Comment 3 2017-08-10 05:09:39 PDT
Build Bot
Comment 4 2017-08-10 05:10:57 PDT
Attachment 317804 [details] did not pass style-queue: ERROR: Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:161: More than one command on the same line [whitespace/newline] [4] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Zan Dobersek
Comment 5 2017-08-10 06:21:01 PDT
(In reply to Miguel Gomez from comment #2) > (In reply to Zan Dobersek from comment #1) > > Created attachment 317803 [details] > > WIP > > Zan, we can't just replace m_context->compileShader() with > glCompileShader(), cause m_context->compileShader() uses ANGLE to translate > the shader source to the appropriate GLSL version before actually calling > glCompileShader(). > Before doing this change we need to refactor TextureMapperShaderProgram to > provide the appropriate shader code for each possible gl version: GLES2, > OpenGL < 3.2 and OpenGL >= 3.2. Why can't we target specific GLSL and GLSL ES versions? The shaders seem to compile fine with all the options enabled for both OpenGL and OpenGL ES. The only problem is the Rect option, which depends on the GL_ARB_texture_rectangle extension, and that doesn't compile for GLSL ES 1.00 out-of-the-box. But on the other hand, this program option never gets set upstream or downstream, so program with that option never gets compiled.
Miguel Gomez
Comment 6 2017-08-10 06:44:52 PDT
(In reply to Zan Dobersek from comment #5) > (In reply to Miguel Gomez from comment #2) > > (In reply to Zan Dobersek from comment #1) > > > Created attachment 317803 [details] > > > WIP > > > > Zan, we can't just replace m_context->compileShader() with > > glCompileShader(), cause m_context->compileShader() uses ANGLE to translate > > the shader source to the appropriate GLSL version before actually calling > > glCompileShader(). > > Before doing this change we need to refactor TextureMapperShaderProgram to > > provide the appropriate shader code for each possible gl version: GLES2, > > OpenGL < 3.2 and OpenGL >= 3.2. > > Why can't we target specific GLSL and GLSL ES versions? > > The shaders seem to compile fine with all the options enabled for both > OpenGL and OpenGL ES. Yes, we can target specific versions. We need GLSL 1.50 for OpenGL >= 3.2, GLSL ES for GLES and for OpenGL < 3.2 ANGLE uses the compatibility mode, which I guess is 1.10 (not sure). For the case of OpenGL >= 3.2, we want to use a core profile, which I think also has implications in the shader code. > The only problem is the Rect option, which depends on the > GL_ARB_texture_rectangle extension, and that doesn't compile for GLSL ES > 1.00 out-of-the-box. But on the other hand, this program option never gets > set upstream or downstream, so program with that option never gets compiled. I think there are more problems than just that. First, the shaders need to have a line with the GLSL version they are using (which is added by ANGLE). Then, in GLSL 1.50 the variables need to have the in/out qualifiers (added by ANGLE as well) while that's not needed in older versions. And I'm sure there are more differences. Bear in mind that the current code used for the shaders is like a pseudocode that gets properly translated by ANGLE. What I was planning to do to find the differences we need to check between versions was to check the ouput of the ANGLE translation for the 3 targeted GLSL versions with all the options enabled, and then refactor TextureMapperShaderProgram somehow to generate that code depending on the OpenGL version available.
Zan Dobersek
Comment 7 2017-08-10 23:30:11 PDT
Created attachment 317917 [details] ANGLE translation of TexMap shaders on OpenGL ES 2.0
Zan Dobersek
Comment 8 2017-08-10 23:32:07 PDT
Created attachment 317918 [details] ANGLE translation of TexMap shaders on OpenGL 3.0
Zan Dobersek
Comment 9 2017-08-10 23:32:53 PDT
Created attachment 317919 [details] ANGLE translation of TexMap shaders on OpenGL 4.3
Zan Dobersek
Comment 10 2017-08-11 00:00:05 PDT
(In reply to Zan Dobersek from comment #9) > Created attachment 317919 [details] > ANGLE translation of TexMap shaders on OpenGL 4.3 Forcing through GLSL 1.10 shaders on a core OpenGL profile works on Mesa drivers. But the spec doesn't guarantee that to be supported.
Zan Dobersek
Comment 11 2017-09-11 11:18:09 PDT
Using the glslangValidator program[1], The vertex and fragment shader sources pass the validation when enforcing the 1.50 version through the '#version' directive. Only a few warnings are thrown about deprecated stuff used in the shaders: > shaders/gl150.vert > WARNING: 0:40: attribute deprecated in version 130; may be removed in future release > WARNING: 0:40: varying deprecated in version 130; may be removed in future release > WARNING: 0:40: varying deprecated in version 130; may be removed in future release > WARNING: 0:40: varying deprecated in version 130; may be removed in future release > shaders/gl150.frag > WARNING: 0:54: varying deprecated in version 130; may be removed in future release > WARNING: 0:54: varying deprecated in version 130; may be removed in future release > WARNING: 0:54: varying deprecated in version 130; may be removed in future release [1] https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/
Miguel Gomez
Comment 12 2017-10-20 07:42:59 PDT
Build Bot
Comment 13 2017-10-20 07:44:37 PDT
Attachment 324397 [details] did not pass style-queue: ERROR: Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:161: More than one command on the same line [whitespace/newline] [4] Total errors found: 1 in 6 files If any of these errors are false positives, please file a bug against check-webkit-style.
Miguel Gomez
Comment 14 2017-10-20 07:50:14 PDT
(In reply to Miguel Gomez from comment #12) > Created attachment 324397 [details] > Patch In the end the changes needed to the shaders code were: - add the "version 150" directive when using OpenGL >= 3.2 - use in/out for input/output parameters definition with OpenGL >= 3.2 - use the default precision just on GLES2 I've tested the generated code with these changes using OpenGL versions higher and lower than 3.2 and everything seems to work. I also tested GLES2 with the rpi2 and a broadcom box. Seems to work fine as well. But I was only able to test OpenGL with Mesa. I hope we don't have problems with other OpenGL implementations. Also, when removing the GraphicsContext3D from VideoTextureCopierGStreamer, I had to add a VAO, as the one that was being used was provided by the GC3D. We will need to that as well when removing the GC3D from TextureMaperGL.
Zan Dobersek
Comment 15 2017-10-22 22:19:42 PDT
Comment on attachment 324397 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=324397&action=review > Source/WebCore/platform/graphics/gstreamer/VideoTextureCopierGStreamer.cpp:200 > + if (GLContext::current()->version() >= 320) This should check for m_vao being non-zero.
Miguel Gomez
Comment 16 2017-10-23 01:14:16 PDT
Build Bot
Comment 17 2017-10-23 01:15:09 PDT
Attachment 324548 [details] did not pass style-queue: ERROR: Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:161: More than one command on the same line [whitespace/newline] [4] Total errors found: 1 in 6 files If any of these errors are false positives, please file a bug against check-webkit-style.
Miguel Gomez
Comment 18 2017-10-23 01:33:00 PDT
Don, Fuji, I'm adding you to the CC as this could potentially trigger some rendering issues. Please feel free to blame me if you find any problem that could be related to this change :)
WebKit Commit Bot
Comment 19 2017-10-23 03:11:15 PDT
Comment on attachment 324548 [details] Patch Clearing flags on attachment: 324548 Committed r223833: <https://trac.webkit.org/changeset/223833>
WebKit Commit Bot
Comment 20 2017-10-23 03:11:17 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.