Adding standard derivatives extension leads to a compiled failure

This topic contains 7 replies, has 2 voices, and was last updated by  Joe Davis 2 years, 1 month ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #51781

    Chester
    Member

    Hi, guys.

    I’m having a problem now. When I added “#extension GL_OES_standard_derivatives : enable” to my fragment shader code for using dFdx/dFdy such derivative function, I had a compiler error message: Unexpected extension directive encountered after non-preprocessor tokens.

    However, if I remove the extension line, the derivative function can be used successfully. But if I want to run on the other non-powervr simulator (lower ES-SL version), I still need that extension line.

    What I don’t get it is, if the extension derivative function is already supported for ES-SL 3.0 with powervr, why would we have an compiled error while adding that extension line? Is there any possible way to make that extension line work without getting compiled error? Otherwise I have to write two shader code, one for PowerVR, one for the other…

    P.S The attachments is my OpenGL ES information by using PVRVFrame (from PowerVR SDK 3.5).

    temp

    Attachments:
    #51784

    Joe Davis
    Member

    Hi Chester,

    This sounds like a bug in our emulator. I’ll discuss the issue with the PVRVFrame lead.

    Is the issue only reproducible with PVRVFrame emulation or does it also occur on PowerVR devices?

    #51794

    Joe Davis
    Member

    Hi Chester,

    I’ve discussed the “Unexpected extension directive encountered after non-preprocessor tokens.” error with the PVRVFrame lead. He’s informed me that this is a requirement of the GLSL ES 1.00 spec. On page 15 of the GLSL ES 1.0.17 specification, it states.

    extension directives must occur before any non-preprocessor tokens.

    What this means is that it is illegal to define non-preprocessor tokens, such as variable and functions, before extension directives. If you move “#extension GL_OES_standard_derivatives : enable” to the start of your shader, it should compile correctly in PVRVFrame and all other GLSL ES compilers.

    #51809

    Chester
    Member

    Hi, Joe:

    Thanks for your quick response 🙂

    I did move that line to the start of my shader code before, however somehow it still didn’t work.

    #51817

    Joe Davis
    Member

    Hi Chester,

    Do you mean that, even with moving the declaration to the start of the shader, you are still encountering the issue?

    For reference this shader should generate an error according to the GLSL ES 1.00 specification:

    #version 100
    uniform mediump vec4 colour;
    #extension GL_OES_standard_derivatives : enable
    void main[] {
        gl_FragColor = colour;
    }

    This modified version should compile correctly with all conformant GLSL ES 1.00 compilers:

    #version 100
    #extension GL_OES_standard_derivatives : enable
    uniform mediump vec4 colour;
    void main[] {
        gl_FragColor = colour;
    }

    Our PVRShaderEditor tool gives as-you-type errors, warnings and performance estimates. If you are not using it already, I would recommend giving it a go. The shader verification code used by PVRShaderEditor is also used by PVRVFrame, so the errors should be the same in both tools.

    #51847

    Chester
    Member

    Here is first three lines from my fragment shader code:

    #version 100 // With or without this line doesn’t affect the error.
    #extension GL_OES_standard_derivatives : enable // Move this line above everything.
    precision mediump float;

    By using the PVRShaderEditor tool, it said ‘Compile succeeded’. However, when I run my program via visual studio 2010, the shader code can not be built successfully. The error I got is shown in following:

    Vertex shader failed to link, fragment shader failed to link.
    Vertex link error: INVALID_OPERATION.
    ERROR: error[#97] No program main found
    fragment link error: INVALID_OPERATION.
    ERROR: error[#97] No program main found
    ERROR: Failed to create OpenGL programs
    ERROR: Failed to init ResourceTracker

    I didn’t see this error on the other non-powervr simulator with the same code.

    #51848

    Joe Davis
    Member

    Hi Chester,

    I’m discussing the issue with the PVRVFrame lead now. If you can share a reproduction binary with us, it should help speed up our investigation. You can share packages with us confidentially through our ticketing system: https://pvrsupport.imgtec.com/new-ticket

    #51850

    Joe Davis
    Member

    Hi Chester,

    The PVRVFrame lead has told me that, from the errors alone, he can’t determine what’s causing the problem. If you can provide a reproduction binary we’ll continue our investigation.

Viewing 8 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic.