Skip to content

WebGL does not work in Webrender #10376

Closed

Description

@cbrewster

Running ./mach run -d tests/html/test_webgl_triangle.html displays a colored triangle.

If you run again with the -w flag: ./mach run -d -w tests/html/test_webgl_triangle.html, nothing is rendered and the following errors are printed to the console:

ERROR:script::dom::webglrenderingcontext: Couldn't create WebGLRenderingContext: CGLCreateContext
ERROR:script::dom::webglrenderingcontext: Couldn't create WebGLRenderingContext: CGLCreateContext
ERROR:js::rust: Error at .../servo/tests/html/test_webgl_triangle.html:17:7: gl is null

Activity

  1. cbrewster commented on Apr 2, 2016

    @cbrewster
    ContributorAuthor

    This issue only applies to cgl on Mac.

  2. cbrewster commented on Apr 3, 2016

    @cbrewster
    ContributorAuthor

    @emilio After doing some more digging I found that when creating a context from a shared context, they should both share the same attributes. (CGLCreateContext discussion section). I tried this and there is now a new crash, seems to be related to shader compilation; however, I used apitrace and found that the new contexts that are created from the shared context no longer return the invalid share context error.

  3. cbrewster commented on Apr 3, 2016

    @cbrewster
    ContributorAuthor

    The crash occurs when compiling shaders. The non-webrender version uses Legacy OpenGL and webrender uses OpenGL 3.2. Are there any differences in shaders between the two?

  4. cbrewster commented on Apr 3, 2016

    @cbrewster
    ContributorAuthor

    @emilio I setup GetProgramInfoLog and GetShaderInfoLog. After using the pixel_format from the main context it creates the new context that uses OpenGL 3.2. The shaders no longer compile because they don't have a #version. When manually setting the new context to legacy OpenGL( < 3.2) it crashes because it can't share the context created by webrender which is OpenGL 3.2. I am not too familiar with angle, but is that supposed to translate the WebGL shader into a shader that OpenGL 3.2 can compile?

    I have tried setting the shader output in webglshader.rs to Output::Glsl150Core for Mac; however, when the shader is compiled it does not know what webgl_FragColor is. I assume the translator was supposed to add a out vec4 webgl_FragColor; but for some reason, did not.

  5. emilio commented on Apr 3, 2016

    @emilio
    Member

    Oh, if that's the problem, that's a really easy problem to solve! :)

    I forgot WR changed the requirements from OpenGL 3.0 to OpenGL 3.2. Let's just tweak the values of the shader compiler output, to something tha tworks in OpenGL 3.2 core.

    https://github.com/emilio/angle/blob/servo/src/hl.rs#L50

    Probably the best for compat will be Glsl130 or Glsl150Core, let me know if any of those work for you.

  6. added
    P-mac
    A-content/webgl
    on Apr 3, 2016
  7. cbrewster commented on Apr 3, 2016

    @cbrewster
    ContributorAuthor

    @emilio When using Glsl130, it says version 130 is not supported. Glsl150Core is supported, but the shader gets translated incorrectly:

    Original Shader:

    precision mediump float;
    varying vec4 aVertexColor;
    
    void main() {
        gl_FragColor = aVertexColor;
    }
    

    Translated Shader:

    #version 150
    in vec4 aVertexColor;
    void main(){
    (webgl_FragColor = aVertexColor);
    }
    

    During shader compilation, OpenGL errors with Use of undeclared identifier 'webgl_FragColor'. From looking at other examples of translated shaders for angle, it looks like it is missing out vec4 webgl_FragColor;.

  8. cbrewster commented on Apr 4, 2016

    @cbrewster
    ContributorAuthor

    @emilio Almost to the bottom of this. It looks like SH_VARIABLES option is required to print out out vec4 webgl_FragColor;. Now it looks like both shaders compile successfully, but there is now another crash. Here is the relevant apitrace dump:

    674 glCompileShader(shader = 32)
    677 glGetShaderiv(shader = 32, pname = GL_COMPILE_STATUS, params = &1)
    680 glCreateProgram() = 33
    683 glAttachShader(program = 33, shader = 31)
    686 glAttachShader(program = 33, shader = 32)
    689 glBindAttribLocation(program = 33, index = 0, name = "aTextureCoord")
    690 glBindAttribLocation(program = 33, index = 1, name = "aVertexPosition")
    691 glLinkProgram(program = 33)
    694 glGetProgramiv(program = 33, pname = GL_LINK_STATUS, params = &1)
    697 glUseProgram(program = 33)
    700 glGetAttribLocation(program = 33, name = "aVertexPosition") = 1
    703 glEnableVertexAttribArray(index = 1)
    704 glGetError() = GL_INVALID_OPERATION
    
  9. cbrewster commented on May 12, 2016

    @cbrewster
    ContributorAuthor

    Dupe of #11138. Closing this one as the new issue is clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/webglA-webrenderP-mac

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions