Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright © <2010>, Intel Corporation.
  3.  *
  4.  * This program is licensed under the terms and conditions of the
  5.  * Eclipse Public License (EPL), version 1.0.  The full text of the EPL is at
  6.  * http://www.opensource.org/licenses/eclipse-1.0.php.
  7.  *
  8.  */
  9. //---------- Check dependency and spawn all MBs ----------
  10.  
  11. // Launch the 1st round of child threads for Vertical ILDB
  12. #if defined(_DEBUG)
  13.         mov             (1)             EntrySignature:w                        0x3333:w
  14. #endif
  15.  
  16. //=====================================================================
  17. // Jump Table 1
  18.         // 0 0 ---> Goto ALL_SPAWNED
  19.         // 0 1 ---> Goto ALL_SPAWNED
  20.         // 1 0 ---> Goto SLEEP_ENTRY
  21.         // 1 1 ---> Goto POST_SLEEP
  22.         mov (2)         JumpTable.0<1>:d        0:d                             { NoDDClr }
  23. #if defined(CHROMA_ROOT)               
  24.         mov (1)         JumpTable.2:d   SLEEP_ENTRY_UV_ILDB_FRAME_IP-ALL_SPAWNED_UV_ILDB_FRAME_IP:d             { NoDDClr, NoDDChk }
  25.         mov (1)         JumpTable.3:d   POST_SLEEP_UV_ILDB_FRAME_IP-ALL_SPAWNED_UV_ILDB_FRAME_IP:d              { NoDDChk }
  26. #else
  27.         mov (1)         JumpTable.2:d   SLEEP_ENTRY_Y_ILDB_FRAME_IP-ALL_SPAWNED_Y_ILDB_FRAME_IP:d               { NoDDClr, NoDDChk }
  28.         mov (1)         JumpTable.3:d   POST_SLEEP_Y_ILDB_FRAME_IP-ALL_SPAWNED_Y_ILDB_FRAME_IP:d                { NoDDChk }
  29. #endif
  30. //=====================================================================
  31.  
  32.         mov (2)         f0.0<1>:w               0:w
  33.  
  34.         // Get m0 most of fields ready for URB write
  35.         mov     (8)                     MRF0<1>:ud              MSGSRC.0<8;8,1>:ud
  36.  
  37.         // Add child kernel offset
  38.         add (1)         CT_R0Hdr.2:ud                   r0.2:ud                 CHILD_OFFSET:w
  39.  
  40.         // Init
  41.         mov (1)         Col_Boundary:w                  2:w
  42.         mov (1)         Row_Boundary:w                  LastRow:w
  43.         mov (1)         TopRowForScan:w                 0:w
  44.         mov (2)         OutstandingThreads<1>:w 0:w
  45.  
  46.         // Init Scoreboard  (idle = 0x00FF, busy = 0x0000)
  47.         // Low word is saved col.  High word is busy/idle status
  48.         mov     (16)            GatewayAperture(0)<1>   0x00FF00FF:ud           // Init r6-r7
  49.         mov     (16)            GatewayAperture(2)<1>   0x00FF00FF:ud           // Init r8-r9
  50.         mov     (16)            GatewayAperture(4)<1>   0x00FF00FF:ud           // Init r10-r11
  51.         mov     (16)            GatewayAperture(6)<1>   0x00FF00FF:ud           // Init r12-r13
  52.         mov     (16)            GatewayAperture(8)<1>   0x00FF00FF:ud           // Init r14-r15
  53.  
  54.         mul     (1)                     StatusAddr:w            CurRow:w                4:w             // dword to bytes offset conversion
  55.  
  56.         //=====================================================================
  57.  
  58. //SPAWN_LOOP:
  59.         //===== OutstandingThreads < ThreadLimit ? ============================
  60.         cmp.l.f0.1 (1)  null:w          OutstandingThreads:w    ThreadLimit:w           // Check the thread limit
  61. #if defined(CHROMA_ROOT)
  62.     (f0.1) jmpi         ILDB_LABEL(POST_SLEEP_UV)
  63. #else   // LUMA_ROOT
  64.     (f0.1) jmpi         ILDB_LABEL(POST_SLEEP_Y)
  65. #endif
  66.  
  67. #if defined(CHROMA_ROOT)
  68. ILDB_LABEL(SLEEP_ENTRY_UV):
  69. #else   // LUMA_ROOT
  70. ILDB_LABEL(SLEEP_ENTRY_Y):
  71. #endif
  72.     //===== Goto Sleep ====================================================
  73.     // Either reached max thread limit or no child thread can be spawned due to dependency.
  74.         add     (1)                     OutstandingThreads:w    OutstandingThreads:w    -1:w // Do this before wait is faster
  75.         wait                    n0.0:d                                                                                         
  76.  
  77. #if defined(CHROMA_ROOT)
  78. ILDB_LABEL(POST_SLEEP_UV):
  79. #else   // LUMA_ROOT
  80. ILDB_LABEL(POST_SLEEP_Y):
  81. #endif
  82.         //===== Luma Status[CurRow] == busy ? =====
  83.         cmp.z.f0.0 (1)  null:uw         r[StatusAddr, GatewayApertureB+ScoreBd_Idx]:uw          0:uw                    // Check west neighbor
  84.         cmp.g.f0.1 (1)  null:w          CurCol:w                LastCol:w               // Check if the curCol > LastCol
  85.  
  86. #if defined(CHROMA_ROOT)
  87.         mov     (16)            acc0.0<1>:w             URBOffsetUVBase<0;1,0>:w                        // Add offset to UV base (MBsCntY * URB_EBTRIES_PER_MB)
  88.         mac (1)                 URBOffset:w             CurRow:w                        4:w                             // 4 entries per row
  89. #else
  90.         mul     (1)                     URBOffset:w             CurRow:w                        4:w                             // 4 entries per row
  91. #endif
  92.  
  93. #if defined(CHROMA_ROOT)
  94.         (f0.0) jmpi             ILDB_LABEL(SLEEP_ENTRY_UV)                                                              // Current row has a child thread running, can not spawn a new child thread, go back to sleep
  95.         (f0.1) jmpi             ILDB_LABEL(NEXT_MB_UV)                                                                  // skip MB if the curCol > LastCol
  96. #else   // LUMA_ROOT
  97.         (f0.0) jmpi             ILDB_LABEL(SLEEP_ENTRY_Y)                                                               // Current row has a child thread running, can not spawn a new child thread, go back to sleep
  98.         (f0.1) jmpi             ILDB_LABEL(NEXT_MB_Y)                                                                   // skip MB if the curCol > LastCol
  99. #endif
  100.                
  101.         //========== Spwan a child thread ========================================
  102.         // Save cur col and set Status[CurRow] to busy
  103.         mov (2)                 r[StatusAddr, GatewayApertureB]<1>:uw           CurColB<2;2,1>:ub               // Store the new col
  104.                        
  105.         // Increase OutstandingThreads and ProcessedMBs by 1
  106.         add     (2)                     OutstandingThreads<1>:w         OutstandingThreads<2;2,1>:w             1:w  
  107.  
  108.         #include "AVC_ILDB_SpawnChild.asm"
  109.  
  110.         //===== Find next MB ===================================================
  111. #if defined(CHROMA_ROOT)
  112. ILDB_LABEL(NEXT_MB_UV):
  113. #else   // LUMA_ROOT
  114. ILDB_LABEL(NEXT_MB_Y):
  115. #endif
  116.         // Check pic boundary, results are in f0.0 bit0 and bit1
  117.         cmp.ge.f0.0     (2)     null<1>:w   CurCol<2;2,1>:w     Col_Boundary<2;2,1>:w
  118.  
  119.         // Update TopRowForScan if the curCol = LastCol
  120.         (f0.1) add (1)  TopRowForScan:w         CurRow:w                1:w    
  121.  
  122. //      cmp.l.f0.1 (1)  null<1>:w               ProcessedMBs:w          TotalBlocks:w           // Processed all blocks ?
  123.         // 2 sets compare
  124.         // ProcessedMBs:w < TotalBlocks:w               OutstandingThreads:w < ThreadLimit:wProcessedMBs:w
  125.         // 0 0 ---> Goto ALL_SPAWNED
  126.         // 0 1 ---> Goto ALL_SPAWNED
  127.         // 1 0 ---> Goto SLEEP_ENTRY
  128.         // 1 1 ---> Goto POST_SLEEP
  129.         cmp.l.f0.1 (2)  null<1>:w               OutstandingThreads<2;2,1>:w     ThreadLimit<2;2,1>:w
  130.  
  131.         // Just do it in stalled cycles
  132.         mov (1)         acc0.0:w                4:w
  133.         mac     (1)             StatusAddr:w            CurRow:w                4:w                                             // dword to bytes offset conversion    
  134.         add (2)         CurCol<1>:w             CurCol<2;2,1>:w         StepToNextMB<2;2,1>:b   // CurCol -= 2 and CurRow += 1
  135.                
  136.         // Set f0.0 if turning around is needed, assuming bit 15 - 2 are zeros for correct comparison.
  137.         cmp.nz.f0.0 (1) null<1>:w       f0.0:w          0x01:w
  138.                
  139.         mul (1)         JumpAddr:w              f0.1:w          4:w             // byte offet in dword count
  140.                
  141.         // The next MB is at the row TopRowForScan
  142.         (f0.0) mul (1)          StatusAddr:w    TopRowForScan:w         4:w                             // dword to bytes offset conversion
  143.         (f0.0) mov (1)          CurRow:w                TopRowForScan:w                                                         { NoDDClr }     // Restart from the top row that has MBs not deblocked yet.
  144.         (f0.0) add (1)          CurCol:w                r[StatusAddr, GatewayApertureB]:uw              1:w             { NoDDChk }
  145.        
  146.         //===== Processed all blocks ? =========================================
  147.         // (f0.1) jmpi          SPAWN_LOOP
  148.  
  149.         jmpi    r[JumpAddr, JUMPTABLE_BASE]:d
  150. //JUMP_BASE:
  151.  
  152.         //======================================================================
  153.  
  154.         // All MB are spawned at this point, check for outstanding thread count
  155. #if defined(CHROMA_ROOT)
  156. ILDB_LABEL(ALL_SPAWNED_UV):
  157. #else   // LUMA_ROOT
  158. ILDB_LABEL(ALL_SPAWNED_Y):
  159. #endif
  160.         cmp.e.f0.1 (1)  null:w          OutstandingThreads:w            0:w                     // Check before goto sleep
  161. #if defined(CHROMA_ROOT)
  162.         (f0.1) jmpi             ILDB_LABEL(ALL_DONE_UV)
  163. #else   // LUMA_ROOT
  164.         (f0.1) jmpi             ILDB_LABEL(ALL_DONE_Y)
  165. #endif
  166.        
  167.         wait                    n0.0:d                                                                                          // Wake up by a finished child thread
  168.         add     (1)                     OutstandingThreads:w    OutstandingThreads:w    -1:w
  169.  
  170. #if defined(CHROMA_ROOT)
  171.         // One thread is free and give it to luma thread limit --- Increase luma thread limit by one.
  172.         #include "AVC_ILDB_LumaThrdLimit.asm"
  173. #endif
  174.  
  175. #if defined(CHROMA_ROOT)
  176.     jmpi                        ILDB_LABEL(ALL_SPAWNED_UV)                                                      // Waked up and goto dependency check
  177. #else   // LUMA_ROOT
  178.     jmpi                        ILDB_LABEL(ALL_SPAWNED_Y)                                                       // Waked up and goto dependency check
  179. #endif
  180.  
  181.         // All child threads are finsihed at this point
  182. #if defined(CHROMA_ROOT)
  183. ILDB_LABEL(ALL_DONE_UV):
  184. #else   // LUMA_ROOT
  185. ILDB_LABEL(ALL_DONE_Y):
  186. #endif
  187.