Skip navigation
Currently Being Moderated

crash occurs when division in material kernel

Jun 14, 2011 11:29 PM

Error: Error #3625: AGAL validation failed: Bad AGAL source operands. Both are constants (this must be precomputed) at token 24 of fragment program.

 

The code scrap that causes the crash is as follows

interpolated float4 d;

d.x = //a float

float density = .05;

float f = exp( - density * density /  d.x / d.x);

 

if it is"float f = exp( - d.x * d.x * density * density);", the app will be all right.

 

Pls help me! Or my shader will become an opposite one...

 

 

What's more, I find that interpolated variables in material kernel must be float4, otherwise it will crash in the runtime. Is it true? It's not written in the reference.

 
Replies
  • Currently Being Moderated
    Jun 17, 2011 2:33 PM   in reply to Jin-Huang

    Thanks for posting ypur questions.

    --With regards to the AGAL validation error, its not valid to use two constant operands in a single instruction. Please copy over one of the constants to a temporary and use it for now. We ll fix it on our side to make this automatic under the covers if ppl use it in the language.

     

    --Also, I am not sure if its an AGAL restriction that interpolateds must be float-4. But, please use float-4 for now. If its an AGAL restriction, the language would still allow you to use float3s, but we ll take care of putting it into the right format while translating to AGAL.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 2, 2011 11:30 PM   in reply to aifBharani

    To Mr. Bharani with apologies to Mr. Jin-Huang,

    I am not attempting to hijack this thread; I am trying to understand it and turn it from a "Possibly Answered" one to a "Correctly Answered" one.

     

    I have spent ten hours trying to do something about:


    Error: Error #3625: AGAL validation failed: Bad AGAL source operands. Both are constants (this must be precomputed) at token 9 of vertex program.

     

    and have made no headway.

     

    Now, admittedly, I am a complete newbie, and quite evidently Mssrs. Jin-Hunag and Bharani are not.  Since I am exposing my ignorance for what I believe will be the benefit of a few other folks who are unable to understand what is wrong, and unable to understand how to correct it, let's define where I am.

     

    01.  I am trying to run what should be the simplest example from Mr. Santander's  minimole project. --  Segments Demo.  I think it is the simplest in terms of the amount of infrastructure required to make it work, and am I talking about the infrastructure both in the Actionscript API from the latest incubator download that is available [051211], as well as the infrastructure of the latest pixelbender3d toolkit [042711].

     

    02.  Now, unfortunately, that leaves us a little unsure as to whether or not minimole examples will work under those conditions.  Mr. Santander left us with some beautifully working examples at the end of April, but then announced that he was not going to be able to devote time to maintaining those sources.  The main reason, therefore, for my using this as the 'Hello World' example is that:

     

        a.  Adobe Labs does not provide a 'Hello World" example; and

        b.  At the end of June, Mr. Santander completed the migration of his project from SVN to GIT AND made a minor bug fix to his library.  Preseumably, his examples are working as of that date.

     

    So, that's the state of affairs -- I am sure that advanced users of these tools could get the Segments Demo running in a couple of minutes, but this is a request for the rest of us.

     

    03.  Where is there a list documenting Error Code #3625?  It is not to be found in the 051211 PRERELEASE DOCUMENTATION asdocs..

     

    04.  Given the three-way split of output from the compilation of two source files -- a vertexKernel.pbvk and a materialKernel.pbmk -- all of which have been black-box-welded by the time that this error occurs, in which source file should I look for "token 9"?

     

    Error: Error #3625: AGAL validation failed: Bad AGAL source operands. Both are constants (this must be precomputed) at token 9 of vertex program.
        at flash.display3D::Program3D/upload()
        at com.li.minimole.materials::MaterialBase/initPB3D()[G:\Flash_AS\lib\co m\li\minimole\materials\MaterialBase.as:85]
        at com.li.minimole.materials::LineMaterial/buildProgram3d()[G:\Flash_AS\ lib\com\li\minimole\materials\LineMaterial.as:46]
        at com.li.minimole.materials::MaterialBase/set context3d()[G:\Flash_AS\lib\com\li\minimole\materials\MaterialBase.as :45]
        at com.li.minimole.core::Mesh/set context3d()[G:\Flash_AS\lib\com\li\minimole\core\Mesh.as:109]
        at com.li.minimole.core::Scene3D/set context3d()[G:\Flash_AS\lib\com\li\minimole\core\Scene3D.as:31]
        at com.li.minimole.core::View3D/context3dCreatedHandler()[G:\Flash_AS\li b\com\li\minimole\core\View3D.as:87]

     

    05.  Or, since Mr. Santander obviously spent a lot of time looking at these kinds of errors, in which of the three .pbasm files should I look for "token 9"?  Is it to be found anywhere in this diagnostic output?

     

    PB3D Version - major: 0, minor: 2
    ---------------------------------------------------------------------- --
    - AgalProgramPair -
    ---------------------------------------------------------------------- --
      vertexProgram:
        - AgalProgram -
          name: >>>LineVertexKernel<<<
          temp. register count: 4
          byteCode:   ¡    ää     ä ä     ä ä     ä ä      ää      ä ä      ä ä      ä ä      ª              ä ä      ä  ä
        U      U  ä      ä  ä
        U      U  ä     ä     U      U  ª      ª  U      ª  U      ª          ª      U  ÿ        U      U        ÿ       ª     U     ÿ     U      ä  ä
        U      U  ä      ä      ä       ä     U          ä         U  U   ä         ª  ª   ä       ä    ä
          registers:
            - RegisterMap -
              numericalConstants:
              - NumericalConstantsInfo -
                startRegister: 0
                values:
              vertexRegisters: 3
              - VertexRegisterInfo -
                globalId:
                  - GlobalID -
                    name: offsetDirection
                    format: float4
                    semantics: PB3D_OFF_DIRECTION
                mapIndex: 0
              - VertexRegisterInfo -
                globalId:
                  - GlobalID -
                    name: oppositeVertexPosition
                    format: float4
                    semantics: PB3D_OP_POSITION
                mapIndex: 1
              - VertexRegisterInfo -
                globalId:
                  - GlobalID -
                    name: vertexPosition
                    format: float4
                    semantics: PB3D_POSITION
                mapIndex: 2
              parameterRegisters: 3
              - ParameterRegisterInfo -
                globalId:
                  - GlobalID -
                    name: objectToClipSpaceTransform
                    format: float_4X4
                    semantics: null
                elementGroup:
                  - RegisterElementGroup -
                    contiguous: true
                    nElements: 16
                    elements:
                      - RegisterElement -
                        elementIndex: 0
                        registerIndex: 0
                        isValid: true
                      - RegisterElement -
                        elementIndex: 1
                        registerIndex: 0
                        isValid: true
                      - RegisterElement -
                        elementIndex: 2
                        registerIndex: 0
                        isValid: true
                      - RegisterElement -
                        elementIndex: 3
                        registerIndex: 0
                        isValid: true
                      - RegisterElement -
                        elementIndex: 0
                        registerIndex: 1
                        isValid: true
                      - RegisterElement -
                        elementIndex: 1
                        registerIndex: 1
                        isValid: true
                      - RegisterElement -
                        elementIndex: 2
                        registerIndex: 1
                        isValid: true
                      - RegisterElement -
                        elementIndex: 3
                        registerIndex: 1
                        isValid: true
                      - RegisterElement -
                        elementIndex: 0
                        registerIndex: 2
                        isValid: true
                      - RegisterElement -
                        elementIndex: 1
                        registerIndex: 2
                        isValid: true
                      - RegisterElement -
                        elementIndex: 2
                        registerIndex: 2
                        isValid: true
                      - RegisterElement -
                        elementIndex: 3
                        registerIndex: 2
                        isValid: true
                      - RegisterElement -
                        elementIndex: 0
                        registerIndex: 3
                        isValid: true
                      - RegisterElement -
                        elementIndex: 1
                        registerIndex: 3
                        isValid: true
                      - RegisterElement -
                        elementIndex: 2
                        registerIndex: 3
                        isValid: true
                      - RegisterElement -
                        elementIndex: 3
                        registerIndex: 3
                        isValid: true
              - ParameterRegisterInfo -
                globalId:
                  - GlobalID -
                    name: props
                    format: float4
                    semantics: null
                elementGroup:
                  - RegisterElementGroup -
                    contiguous: true
                    nElements: 4
                    elements:
                      - RegisterElement -
                        elementIndex: 0
                        registerIndex: 4
                        isValid: true
                      - RegisterElement -
                        elementIndex: 1
                        registerIndex: 4
                        isValid: true
                      - RegisterElement -
                        elementIndex: 2
                        registerIndex: 4
                        isValid: true
                      - RegisterElement -
                        elementIndex: 3
                        registerIndex: 4
                        isValid: true
              - ParameterRegisterInfo -
                globalId:
                  - GlobalID -
                    name: colorParam
                    format: float4
                    semantics: null
                elementGroup:
                  - RegisterElementGroup -
                    contiguous: true
                    nElements: 4
                    elements:
                      - RegisterElement -
                        elementIndex: 0
                        registerIndex: 5
                        isValid: true
                      - RegisterElement -
                        elementIndex: 1
                        registerIndex: 5
                        isValid: true
                      - RegisterElement -
                        elementIndex: 2
                        registerIndex: 5
                        isValid: true
                      - RegisterElement -
                        elementIndex: 3
                        registerIndex: 5
                        isValid: true
              textureRegisters: 0
      fragmentProgram:
        - AgalProgram -
          name: >>>SolidColorMaterialKernel<<<
          temp. register count: 0
          byteCode:   ¡   ä
          registers:
            - RegisterMap -
              numericalConstants:
              - NumericalConstantsInfo -
                startRegister: 0
                values:
              vertexRegisters: 0
              parameterRegisters: 1
              - ParameterRegisterInfo -
                globalId:
                  - GlobalID -
                    name: colorParam
                    format: float4
                    semantics: null
                elementGroup:
                  - RegisterElementGroup -
                    contiguous: true
                    nElements: 4
                    elements:
                      - RegisterElement -
                        elementIndex: 0
                        registerIndex: 0
                        isValid: true
                      - RegisterElement -
                        elementIndex: 1
                        registerIndex: 0
                        isValid: true
                      - RegisterElement -
                        elementIndex: 2
                        registerIndex: 0
                        isValid: true
                      - RegisterElement -
                        elementIndex: 3
                        registerIndex: 0
                        isValid: true
              textureRegisters: 0

     

    Is there any helpful guide to understanding that diagnostic output?

     

    06.  Assuming that that message is pointing somewhere in here, where, exactly, and how, exactly, are we to write the code so is to avoid the compilers coming up with some operator that has two operands which are constants?

     

    module_vertex_program LineVertexKernel

     

        metadata
            namespace const(string, "com.li.minimole")
            vendor const(string, "Li")
            version const(int, 1)
            description const(string, "Projects vertices from object space to clip/screen space with an offset for line rendering.")
        end_metadata
       
        transformations
            SCF INTOSSA OPT(DCE* {APR DCE*}*)
        end_transformations
       
        globals
            global parameter float-4-4 objectToClipSpaceTransform
            global parameter float-4 props
            input vertex float-4 offsetDirection
                metadata
                    id const(string, "PB3D_OFF_DIRECTION")
                end_metadata
            input vertex float-4 oppositeVertexPosition
                metadata
                    id const(string, "PB3D_OP_POSITION")
                end_metadata
            input vertex float-4 vertexPosition
                metadata
                    id const(string, "PB3D_POSITION")
                end_metadata
            output clipcoord float-4 vertexClipPosition
        end_globals
       
        functions
            external_function void evaluateVertex()
                body
                    basic_block entry%A !! outlets(basic%A)
                        position-0 = allocNonSSA type(float-4) : float-4
                        opPosition-0 = allocNonSSA type(float-4) : float-4
                        thickness-0 = allocNonSSA type(float) : float
                        L-0 = allocNonSSA type(float-4) : float-4
                        D-0 = allocNonSSA type(float-4) : float-4
                        P-0 = allocNonSSA type(float-4) : float-4
                        jump block(basic%A) : void
                    end_basic_block
                    basic_block basic%A !! inlets(entry%A) outlets(exit%A)
                        _LD_position-1 = mul vertexPosition, objectToClipSpaceTransform : float-4
                        _LD_opPosition-1 = mul oppositeVertexPosition, objectToClipSpaceTransform : float-4
                        propsElem%A-0 = extractVE props, const(int, 0) : float
                        propsElem%B-0 = extractVE props, const(int, 2) : float
                        _LD_thickness-1 = div propsElem%A-0, propsElem%B-0 : float
                        _LD_L-1 = sub _LD_opPosition-1, _LD_position-1 : float-4
                        _LD_L-2 = normalize _LD_L-1 : float-4
                        _LD_D-1 = normalize _LD_opPosition-1 : float-4
                        propsElem%C-0 = extractVE props, const(int, 1) : float
                        _LD_D-2 = insertVE propsElem%C-0, _LD_D-1, const(int, 3) : float-4
                        _LD_LElem%A-0 = extractVE _LD_L-2, const(int, 1) : float
                        _LD_DElem%A-0 = extractVE _LD_D-2, const(int, 2) : float
                        _mulResult%C-0 = mul _LD_LElem%A-0, _LD_DElem%A-0 : float
                        _LD_LElem%B-0 = extractVE _LD_L-2, const(int, 2) : float
                        _LD_DElem%B-0 = extractVE _LD_D-2, const(int, 1) : float
                        _mulResult%D-0 = mul _LD_LElem%B-0, _LD_DElem%B-0 : float
                        _subResult%B-0 = sub _mulResult%C-0, _mulResult%D-0 : float
                        _LD_LElem%C-0 = extractVE _LD_L-2, const(int, 2) : float
                        _LD_DElem%C-0 = extractVE _LD_D-2, const(int, 0) : float
                        _mulResult%E-0 = mul _LD_LElem%C-0, _LD_DElem%C-0 : float
                        _LD_LElem%D-0 = extractVE _LD_L-2, const(int, 0) : float
                        _LD_DElem%D-0 = extractVE _LD_D-2, const(int, 2) : float
                        _mulResult%F-0 = mul _LD_LElem%D-0, _LD_DElem%D-0 : float
                        _subResult%C-0 = sub _mulResult%E-0, _mulResult%F-0 : float
                        _LD_LElem%E-0 = extractVE _LD_L-2, const(int, 0) : float
                        _LD_DElem%E-0 = extractVE _LD_D-2, const(int, 1) : float
                        _mulResult%G-0 = mul _LD_LElem%E-0, _LD_DElem%E-0 : float
                        _LD_LElem%F-0 = extractVE _LD_L-2, const(int, 1) : float
                        _LD_DElem%F-0 = extractVE _LD_D-2, const(int, 0) : float
                        _mulResult%H-0 = mul _LD_LElem%F-0, _LD_DElem%F-0 : float
                        _subResult%D-0 = sub _mulResult%G-0, _mulResult%H-0 : float
                        propsElem%D-0 = extractVE props, const(int, 1) : float
                        _LD_P-1 = makeFloatVector _subResult%B-0, _subResult%C-0, _subResult%D-0, propsElem%D-0 : float-4
                        _LD_P-2 = normalize _LD_P-1 : float-4
                        offsetDirectionElem%A-0 = extractVE offsetDirection, const(int, 0) : float
                        _mulResult%I-0 = mul _LD_P-2, offsetDirectionElem%A-0 : float-4
                        _LD_P-3 = mul _mulResult%I-0, _LD_thickness-1 : float-4
                        propsElem%E-0 = extractVE props, const(int, 1) : float
                        _LD_P-4 = insertVE propsElem%E-0, _LD_P-3, const(int, 3) : float-4
                        _LD_positionElem%A-0 = extractVE _LD_position-1, const(int, 0) : float
                        _LD_PElem%A-0 = extractVE _LD_P-4, const(int, 0) : float
                        _addResult%A-0 = add _LD_positionElem%A-0, _LD_PElem%A-0 : float
                        _LD_position-2 = insertVE _addResult%A-0, _LD_position-1, const(int, 0) : float-4
                        _LD_positionElem%B-0 = extractVE _LD_position-2, const(int, 1) : float
                        _LD_PElem%B-0 = extractVE _LD_P-4, const(int, 1) : float
                        _addResult%B-0 = add _LD_positionElem%B-0, _LD_PElem%B-0 : float
                        _LD_position-3 = insertVE _addResult%B-0, _LD_position-2, const(int, 1) : float-4
                        _LD_positionElem%C-0 = extractVE _LD_position-3, const(int, 2) : float
                        _LD_PElem%C-0 = extractVE _LD_P-4, const(int, 2) : float
                        _addResult%C-0 = add _LD_positionElem%C-0, _LD_PElem%C-0 : float
                        _LD_vertexClipPosition-1 = insertVE _addResult%C-0, _LD_position-3, const(int, 2) : float-4
                        jump block(exit%A) : void
                    end_basic_block
                    basic_block exit%A !! inlets(basic%A)
                        moveToNonSSA _LD_vertexClipPosition-1, vertexClipPosition : void
                        ret : void
                    end_basic_block
                end_body
            end_external_function
        end_functions
       
    end_module_vertex_program

     

    I hope I have found the right "stuff" and correctly laid out what I think is the 'pipeline", so that you can reply with some nice, clear, interspersed comments using big, bold, red text to help us learn how to use these tools.

     

    Thank you.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 6, 2011 10:28 AM   in reply to tcorbet

    This error:

     

    Error: Error #3625: AGAL validation failed: Bad AGAL source operands. Both are constants (this must be precomputed) at token 9 of vertex program.

     

    is caused by doing a computation with two values that are parameters. Take this kernel for example:

     

    <languageVersion : 1.0;>
    vertex kernel Bulge
    <
        namespace : "AIF Test";
        vendor : "Adobe";
        version : 1;
    >
    {   
        parameter float scale;
        parameter float scale2;
        parameter float4x4 objectToClipSpaceTransform;

        input vertex float4 vertexPosition
        <
            id : "PB3D_POSITION";
        >;
        input vertex float4 vertexNormal;

        output vertex float4 vertexClipPosition;

        void evaluateVertex()
        {
            float4 t = vertexPosition;
            t += vertexNormal * ( scale + scale2);
           
            vertexClipPosition = t * objectToClipSpaceTransform;
        }
    }

    Because scale and scale2 are both parameters (and therefore constant for every vertex), the value scale + scale2 isn't going to change and could actually be precomputed. The low level hardware doesn't allow you to do a computation with two parameters like this. We are fixing the compiler to allow this (although it's still not a great idea - it puts in extra instructions that aren't necessary and will slow down the computation). In the meantime, there are two workarounds:

     

    1. Do the computation outside the kernel. In the example shown oprecalculate scale + scale2 and pass in the result of that computation as the parameter.

     

    2. Copy one of the values to a temporary and use the temporary in the computation:

     

        void evaluateVertex()
        {
            float4 t = vertexPosition;

            float temp = scale2;
            t += vertexNormal * ( scale + temp);
           
            vertexClipPosition = t * objectToClipSpaceTransform;
        }

    Bob

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 6, 2011 11:28 AM   in reply to AIF Bob

    Bob,

     

    Thank you for a clearer statement of the problem.

     

    I also understand and appreciate the fact that performing some operation on two constants on the 'Actionscript side of the interface' will result in a more efficient pipeline.

     

    So, part of my objective has been met.  For the benefit of the community I wonder if I can entice you to going the second mile?  I understand the roles played by the various members of a software development organization, so I am pretty sure that you don't get up every day looking for a chance to do quality assurance on the technical writing team.  Can we be assured that as an 'Employee' moinitoring and providing helpful assistance for the forum, as you have here, that the issues being raised are finding their way back to product management for the allocation of the necessary resources?

     

    You have ignored the question/quandry that the user has in attempting to get from the cryptic diagnostic error message to where s/he can fix the problem.

     

    A.  Where is the cross-reference of error codes to nice descriptions of their meaning?

     

    B.  How would the user know whether to look for the problem in the vertex kernel or the material kernel source?

     

    C. You know that a parameter data type is a constant, but how does the new user come to learn that?

     

    D.  What is the heuristic for getting from a Token # to a line of code?

     

    My hope is that working on these matters will result in a better product for Adobe and for those of us who imagine using your facilities to deliver superior rich application experiences.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 6, 2011 11:53 AM   in reply to tcorbet
    function(){return A.apply(null,[this].concat($A(arguments)))}

    Can we be assured that as an 'Employee' moinitoring and providing helpful assistance for the forum, as you have here, that the issues being raised are finding their way back to product management for the allocation of the necessary resources?

     

    I can certainly give you that assurance. We're a small team, and most of the Adobe people responsing to posts on this forum are part of that small team. We do feed the information on here back to our management, and we do take it into account when planning.

     

    function(){return A.apply(null,[this].concat($A(arguments)))}

    A.  Where is the cross-reference of error codes to nice descriptions of their meaning?

     

    Pixel Bender 3D is built on top of the Molehill API that is part of Flash. That's handled by a separate team. There's a bunch of information on the Molehill APIs here:

     

    http://labs.adobe.com/technologies/flashplatformruntimes/incubator/fea tures/molehill.html

     

    I had a quick look and couldn't find a listing of error codes.

     

    Our goal with the Pixel Bender 3D components is never to hand anything in to Molehill that will give errors. We are obviously not there yet but we're working on it.

     

    function(){return A.apply(null,[this].concat($A(arguments)))}

    B.  How would the user know whether to look for the problem in the vertex kernel or the material kernel source?


    Once we have all of the error checking into the compiler stages properly, the compiler will tell you. If there is a problem in the Molehill API you'll probably need to swap out a vertex program for a known good vertex program and see if that fixes the problem. Relating that back to the original source code can be tricky though, the compiler does a lot of optimization work which means that the final output is often very different from the source input.

     

    function(){return A.apply(null,[this].concat($A(arguments)))}

    C. You know that a parameter data type is a constant, but how does the new user come to learn that?

     

    Through what will be improved documentation by the time we ship, through better error checking in the compiler so that error messages relate more closely to the original source code and through discussions like this on the forum.

     

    function(){return A.apply(null,[this].concat($A(arguments)))}

    D.  What is the heuristic for getting from a Token # to a line of code?

     

    There isn't one I'm afraid. It's like trying to get from a line of assembler to the original line of C++ or Java or ActionScript.

     

    The bottom line is that we know that what we're shipping now isn't production quality - it's a beta release. We're taking the feedback we get to fix bugs, improve the documentation and make the system more robust so that when we do the full release we'll be putting out a much higher quality system.

     

    I know that it's frustrating working with prerelease software and documentation, but this is exactly the sort of feedback we need to improve things.

     

    Thanks for your questions.

     

    Bob

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 17, 2011 11:28 PM   in reply to Jin-Huang

    Hi Jin,

     

    Can  you please upload the kernel you're trying to put through the compiler and the command line you were using and i will try to look into it.

     

     

    __________________________________

    Add url free or submit your articles

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 26, 2011 11:54 AM   in reply to karendanes

    This problem has been fixed in preview 3 of Pixel Bender 3D

     

    Bob

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points