1 Reply Latest reply on Mar 18, 2015 11:39 PM by AGluk

    AGAL register accessors problem

    AGluk

      Hello.

       

      Could someone help me please?

      I've faced with a problem of incorrect behaviour while using register accessor in shader programs.

      I use AGALMiniAssembler for assemble code.

       

      Here is a sample code of fragment shader:

       

      mov ft0.xy, v0.xy

      mov ft0.z, fc.x

      mov ft0.w, fc.y

      mov ft0.zw, ft0.zw // the result of this command is incorrect

      mov oc, ft0

       

      Stage color in this case should be the following:

      correct.png

      but it is:

      incorrect.png

      If we change:

       

      "mov ft0.zw, ft0.zw" to "mov ft0.xw, ft0.xw", for example

       

      then the result will be the correct.

      There are several more accessors combinations which lead to incorrect result.

       

      The whole Main.as file you can find here: agluk.ru/files/Main.as.

       

      Thank you.

        • 1. Re: AGAL register accessors problem
          AGluk Level 1

          I've understood the reasons of such behaviour of my code. Misunderstanding was in lack of detailed information about AGAL. Detailed AGALMiniAssembler code analiz and AGAL OpCodes description led to the following:

          1.) If register uses as destination, then accessors sets write mask, for example:

           

          ft0.xy sets 1100b mask

           

          while

           

          ft0.yz sets 0110b mask.

           

          That means, that GPU will write only in that parts of register where the bit set to 1.

           

           

          2.) On other hand, when the register uses as source - accessors sets parts order of this register in the source. There are always for parts in source. And if you use less then four accessors, then the last one is used for remaining parts. For example:

           

          ft0.xy sets ft0.xyyy parts order

          It also means, that x-part will be writed to the first part of destination register if its mask bit set to 1.

          And three y-parts will be writed to the second, third and fourth parts of destination register if its mask bits set to 1.

           

          while

           

          ft0.yzw sets ft0.yzww pars order.

          In this case y-part of source register will be writed to the first part of destination register if its mask bit set to 1,

          z-part of source register will be writed to the second part of destination register if its mask bit set to 1

          and two w-parts of source register will be writed to the last couple parts of destination register if its mask bit set to 1 accordingly.

           

           

          Hope this will helpfully for someone else who tried to understand AGAL language.