Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. struct blendinfo {
  3.     Bool dst_alpha;
  4.     Bool src_alpha;
  5.     u32_t blend_cntl;
  6. };
  7.  
  8. static struct blendinfo RadeonBlendOp[] = {
  9.     /* 0 - Clear */
  10.     {0, 0, RADEON_SRC_BLEND_GL_ZERO                | RADEON_DST_BLEND_GL_ZERO},
  11.     /* 1 - Src */
  12.     {0, 0, RADEON_SRC_BLEND_GL_ONE                 | RADEON_DST_BLEND_GL_ZERO},
  13.     /* 2 - Dst */
  14.     {0, 0, RADEON_SRC_BLEND_GL_ZERO                | RADEON_DST_BLEND_GL_ONE},
  15.     /* 3 - Over */
  16.     {0, 1, RADEON_SRC_BLEND_GL_ONE                 | RADEON_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA},
  17.     /* 4 - OverReverse */
  18.     {1, 0, RADEON_SRC_BLEND_GL_ONE_MINUS_DST_ALPHA | RADEON_DST_BLEND_GL_ONE},
  19.     /* 5 - In */
  20.     {1, 0, RADEON_SRC_BLEND_GL_DST_ALPHA           | RADEON_DST_BLEND_GL_ZERO},
  21.     /* 6 - InReverse */
  22.     {0, 1, RADEON_SRC_BLEND_GL_ZERO                | RADEON_DST_BLEND_GL_SRC_ALPHA},
  23.     /* 7 - Out */
  24.     {1, 0, RADEON_SRC_BLEND_GL_ONE_MINUS_DST_ALPHA | RADEON_DST_BLEND_GL_ZERO},
  25.     /* 8 - OutReverse */
  26.     {0, 1, RADEON_SRC_BLEND_GL_ZERO                | RADEON_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA},
  27.     /* 9 - Atop */
  28.     {1, 1, RADEON_SRC_BLEND_GL_DST_ALPHA           | RADEON_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA},
  29.     /* 10- AtopReverse */
  30.     {1, 1, RADEON_SRC_BLEND_GL_ONE_MINUS_DST_ALPHA | RADEON_DST_BLEND_GL_SRC_ALPHA},
  31.     /* 11 - Xor */
  32.     {1, 1, RADEON_SRC_BLEND_GL_ONE_MINUS_DST_ALPHA | RADEON_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA},
  33.     /* 12 - Add */
  34.     {0, 0, RADEON_SRC_BLEND_GL_ONE                 | RADEON_DST_BLEND_GL_ONE},
  35. };
  36.  
  37.  
  38. static Bool R300TextureSetup(RHDPtr info,local_pixmap_t *srcpix, int w, int h, int unit)
  39. {
  40.     u32_t txfilter, txformat0, txformat1, txoffset, txpitch;
  41.  //   int w = pPict->pDrawable->width;
  42.  //   int h = pPict->pDrawable->height;
  43.     int i, pixel_shift;
  44.  
  45.  
  46.     txpitch = srcpix->pitch;
  47.     txoffset = (u32_t)srcpix->local;
  48.  
  49.     if ((txoffset & 0x1f) != 0)
  50.         dbgprintf("Bad texture offset 0x%x\n", (int)txoffset);
  51.     if ((txpitch & 0x1f) != 0)
  52.         dbgprintf("Bad texture pitch 0x%x\n", (int)txpitch);
  53.  
  54.     /* TXPITCH = pixels (texels) per line - 1 */
  55.     pixel_shift = 32 >> 4;
  56.     txpitch >>= pixel_shift;
  57.     txpitch -= 1;
  58.  
  59.   //  if (RADEONPixmapIsColortiled(pPix))
  60.   //      txoffset |= R300_MACRO_TILE;
  61.  
  62.  //   for (i = 0; i < sizeof(R300TexFormats) / sizeof(R300TexFormats[0]); i++)
  63.  //   {
  64.  //       if (R300TexFormats[i].fmt == pPict->format)
  65.  //           break;
  66.  //   }
  67.  
  68.     //txformat1 = R300TexFormats[i].card_fmt;
  69.  
  70.     txformat1 = R300_TX_FORMAT_A8R8G8B8;// R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
  71.  
  72.     txformat0 = ((((w - 1) & 0x7ff) << R300_TXWIDTH_SHIFT) |
  73.                  (((h - 1) & 0x7ff) << R300_TXHEIGHT_SHIFT));
  74.  
  75.     if (IS_R500_3D && ((w - 1) & 0x800))
  76.         txpitch |= R500_TXWIDTH_11;
  77.  
  78.     if (IS_R500_3D && ((h - 1) & 0x800))
  79.         txpitch |= R500_TXHEIGHT_11;
  80.  
  81.     /* Use TXPITCH instead of TXWIDTH for address computations: we could
  82.      * omit this if there is no padding, but there is no apparent advantage
  83.      * in doing so.
  84.      */
  85.     txformat0 |= R300_TXPITCH_EN;
  86.  
  87.   //  info->texW[unit] = w;
  88.   //  info->texH[unit] = h;
  89.  
  90.   //  if (pPict->repeat && !(unit == 0 && need_src_tile_x))
  91.   //    txfilter = R300_TX_CLAMP_S(R300_TX_CLAMP_WRAP);
  92.   //  else
  93.       txfilter = R300_TX_CLAMP_S(R300_TX_CLAMP_CLAMP_GL);
  94.  
  95.   //  if (pPict->repeat && !(unit == 0 && need_src_tile_y))
  96.   //    txfilter |= R300_TX_CLAMP_T(R300_TX_CLAMP_WRAP);
  97.   //  else
  98.       txfilter |= R300_TX_CLAMP_T(R300_TX_CLAMP_CLAMP_GL);
  99.  
  100.     txfilter |= (unit << R300_TX_ID_SHIFT);
  101.  
  102. //    switch (pPict->filter) {
  103. //    case PictFilterNearest:
  104.         txfilter |= (R300_TX_MAG_FILTER_NEAREST | R300_TX_MIN_FILTER_NEAREST);
  105. //        break;
  106. //    case PictFilterBilinear:
  107. //        txfilter |= (R300_TX_MAG_FILTER_LINEAR | R300_TX_MIN_FILTER_LINEAR);
  108. //        break;
  109. //    default:
  110. //        RADEON_FALLBACK(("Bad filter 0x%x\n", pPict->filter));
  111. //    }
  112.  
  113.     {
  114.         u32_t *ring;
  115.         u32_t ifl  = safe_cli();
  116.  
  117.         BEGIN_ACCEL(7);
  118.  
  119.         OUT_ACCEL_REG(R300_TX_FILTER0_0 + (unit * 4), txfilter);
  120.         OUT_ACCEL_REG(R300_TX_FILTER1_0 + (unit * 4), 0);
  121.         OUT_ACCEL_REG(R300_TX_FORMAT0_0 + (unit * 4), txformat0);
  122.         OUT_ACCEL_REG(R300_TX_FORMAT1_0 + (unit * 4), txformat1);
  123.         OUT_ACCEL_REG(R300_TX_FORMAT2_0 + (unit * 4), txpitch);
  124.         OUT_ACCEL_REG(R300_TX_OFFSET_0 + (unit * 4), txoffset);
  125. //    if (!pPict->repeat)
  126.         OUT_ACCEL_REG(R300_TX_BORDER_COLOR_0 + (unit * 4), 0);
  127.  
  128.         COMMIT_RING();
  129.         safe_sti(ifl);
  130.     }
  131. //    if (pPict->transform != 0) {
  132. //        is_transform[unit] = TRUE;
  133. //        transform[unit] = pPict->transform;
  134. //    } else {
  135. //        is_transform[unit] = FALSE;
  136. //    }
  137.  
  138.     return TRUE;
  139. }
  140.  
  141. static u32_t RADEONGetBlendCntl(int op, u32_t dst_format)
  142. {
  143.     u32_t sblend, dblend;
  144.  
  145.    // sblend = RadeonBlendOp[op].blend_cntl & RADEON_SRC_BLEND_MASK;
  146.    // dblend = RadeonBlendOp[op].blend_cntl & RADEON_DST_BLEND_MASK;
  147.  
  148.     /* If there's no dst alpha channel, adjust the blend op so that we'll treat
  149.      * it as always 1.
  150.      */
  151.   //  if ( RadeonBlendOp[op].dst_alpha) {
  152.   //      if (sblend == RADEON_SRC_BLEND_GL_DST_ALPHA)
  153.   //          sblend = RADEON_SRC_BLEND_GL_ONE;
  154.   //      else if (sblend == RADEON_SRC_BLEND_GL_ONE_MINUS_DST_ALPHA)
  155.   //          sblend = RADEON_SRC_BLEND_GL_ZERO;
  156.   //  }
  157.  
  158.     //return sblend | dblend;
  159.  
  160.     return RADEON_SRC_BLEND_GL_SRC_ALPHA | RADEON_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA;
  161. }
  162.  
  163.  
  164. Bool R300PrepareComposite(local_pixmap_t *dstpix, int dstX, int dstY,
  165.                           local_pixmap_t *srcpix, int srcX, int srcY,
  166.                           int w, int h, int op)
  167. {
  168.   //  RINFO_FROM_SCREEN(pDst->drawable.pScreen);
  169.     u32_t dst_format, dst_offset, dst_pitch;
  170.     u32_t txenable, colorpitch;
  171.     u32_t blendcntl;
  172.     int pixel_shift;
  173.     u32_t *ring;
  174.  
  175.     u32_t ifl;
  176.  
  177.     RHDPtr info = &rhd;
  178.  
  179.     dst_format = R300_COLORFORMAT_ARGB8888;
  180.  
  181.     dst_offset = (u32_t)dstpix->local;
  182.  
  183.     dst_pitch = dstpix->pitch;
  184.  
  185.     pixel_shift = 32 >> 4;
  186.  
  187.     colorpitch = dst_pitch >> pixel_shift;
  188.  
  189.   //  if (RADEONPixmapIsColortiled(pDst))
  190.   //      colorpitch |= R300_COLORTILE;
  191.  
  192.     colorpitch |= dst_format;
  193.  
  194.     if ((dst_offset & 0x0f) != 0)
  195.         dbgprintf("Bad destination offset 0x%x\n", (int)dst_offset);
  196.     if (((dst_pitch >> pixel_shift) & 0x7) != 0)
  197.         dbgprintf("Bad destination pitch 0x%x\n", (int)dst_pitch);
  198.  
  199.   //  if (!RADEONSetupSourceTile(pSrcPicture, pSrc, TRUE, FALSE))
  200.   //      return FALSE;
  201.  
  202.     if (!R300TextureSetup(&rhd, srcpix, w, h, 0))
  203.         return FALSE;
  204.  
  205.     txenable = R300_TEX_0_ENABLE;
  206.  
  207.   //  RADEON_SWITCH_TO_3D();
  208.  
  209.     /* setup the VAP */
  210.  
  211.     ifl = safe_cli();
  212.  
  213.     BEGIN_RING(32*2);
  214.  
  215.     OUT_ACCEL_REG(RADEON_WAIT_UNTIL, RADEON_WAIT_HOST_IDLECLEAN |
  216.                                      RADEON_WAIT_3D_IDLECLEAN);
  217.  
  218.     /* These registers define the number, type, and location of data submitted
  219.      * to the PVS unit of GA input (when PVS is disabled)
  220.      * DST_VEC_LOC is the slot in the PVS input vector memory when PVS/TCL is
  221.      * enabled.  This memory provides the imputs to the vertex shader program
  222.      * and ordering is not important.  When PVS/TCL is disabled, this field maps
  223.      * directly to the GA input memory and the order is signifigant.  In
  224.      * PVS_BYPASS mode the order is as follows:
  225.      * 0 Position
  226.      * 1 Point Size
  227.      * 2 Color 0
  228.      * 3 Color 1
  229.      * 4 Color 2
  230.      * 5 Color 3
  231.      * 6 Textures 0
  232.      * 7 Textures 1
  233.      * 8 Textures 2
  234.      * 9 Textures 3 - 7
  235.      * 14 Fog
  236.      */
  237.  
  238.      OUT_ACCEL_REG(R300_VAP_PROG_STREAM_CNTL_0,
  239.                    ((R300_DATA_TYPE_FLOAT_2 << R300_DATA_TYPE_0_SHIFT) |
  240.                     (0 << R300_SKIP_DWORDS_0_SHIFT) |
  241.                     (0 << R300_DST_VEC_LOC_0_SHIFT) |
  242.                      R300_SIGNED_0 |
  243.                     (R300_DATA_TYPE_FLOAT_2 << R300_DATA_TYPE_1_SHIFT) |
  244.                     (0 << R300_SKIP_DWORDS_1_SHIFT) |
  245.                     (6 << R300_DST_VEC_LOC_1_SHIFT) |
  246.                      R300_LAST_VEC_1 |
  247.                      R300_SIGNED_1));
  248.  
  249.     /* load the vertex shader
  250.      * We pre-load vertex programs in RADEONInit3DEngine():
  251.      * - exa no mask
  252.      * - exa mask
  253.      * - Xv
  254.      * Here we select the offset of the vertex program we want to use
  255.      */
  256.             OUT_ACCEL_REG(R300_VAP_PVS_CODE_CNTL_0,
  257.                           ((3 << R300_PVS_FIRST_INST_SHIFT) |
  258.                            (4 << R300_PVS_XYZW_VALID_INST_SHIFT) |
  259.                            (4 << R300_PVS_LAST_INST_SHIFT)));
  260.             OUT_ACCEL_REG(R300_VAP_PVS_CODE_CNTL_1,
  261.                           (4 << R300_PVS_LAST_VTX_SRC_INST_SHIFT));
  262.  
  263.     /* Position and one or two sets of 2 texture coordinates */
  264.     OUT_ACCEL_REG(R300_VAP_OUT_VTX_FMT_0, R300_VTX_POS_PRESENT);   //VTX_COLOR_0_PRESENT
  265.     OUT_ACCEL_REG(R300_VAP_OUT_VTX_FMT_1, (2 << R300_TEX_0_COMP_CNT_SHIFT));
  266.  
  267.     OUT_ACCEL_REG(R300_TX_INVALTAGS, 0x0);
  268.     OUT_ACCEL_REG(R300_TX_ENABLE, txenable);
  269.     FINISH_ACCEL();
  270.  
  271.     /* setup pixel shader */
  272.  
  273.  
  274.     /* setup pixel shader */
  275.     if (IS_R300_3D)
  276.     {
  277.     }
  278.     else
  279.     {
  280.         u32_t output_fmt;
  281.         u32_t src_color, src_alpha;
  282.         u32_t mask_color, mask_alpha;
  283.  
  284. //        if (PICT_FORMAT_RGB(PICT_a8r8g8b8) == 0)
  285. //            src_color = (R500_ALU_RGB_R_SWIZ_A_0 |
  286. //                         R500_ALU_RGB_G_SWIZ_A_0 |
  287. //                         R500_ALU_RGB_B_SWIZ_A_0);
  288. //        else
  289.             src_color = (R500_ALU_RGB_R_SWIZ_A_R |
  290.                          R500_ALU_RGB_G_SWIZ_A_G |
  291.                          R500_ALU_RGB_B_SWIZ_A_B);
  292.  
  293. //        if (PICT_FORMAT_A(PICT_a8r8g8b8) == 0)
  294. //            src_alpha = R500_ALPHA_SWIZ_A_1;
  295. //        else
  296.             src_alpha = R500_ALPHA_SWIZ_A_A;
  297.  
  298.         mask_color = (R500_ALU_RGB_R_SWIZ_B_1 |
  299.                       R500_ALU_RGB_G_SWIZ_B_1 |
  300.                       R500_ALU_RGB_B_SWIZ_B_1);
  301.         mask_alpha = R500_ALPHA_SWIZ_B_1;
  302.  
  303.         /* shader output swizzling */
  304.         output_fmt = (R300_OUT_FMT_C4_8         |
  305.                       R300_OUT_FMT_C0_SEL_BLUE  |
  306.                       R300_OUT_FMT_C1_SEL_GREEN |
  307.                       R300_OUT_FMT_C2_SEL_RED   |
  308.                       R300_OUT_FMT_C3_SEL_ALPHA);
  309.  
  310.         BEGIN_ACCEL(6);
  311.         OUT_ACCEL_REG(R300_RS_COUNT,
  312.                      ((2 << R300_RS_COUNT_IT_COUNT_SHIFT) |
  313.                        R300_RS_COUNT_HIRES_EN));
  314.  
  315.         OUT_ACCEL_REG(R300_RS_INST_COUNT, R300_INST_COUNT_RS(0) | R300_TX_OFFSET_RS(6));
  316.  
  317.         OUT_ACCEL_REG(R500_US_CODE_ADDR, (R500_US_CODE_START_ADDR(0) |
  318.                                           R500_US_CODE_END_ADDR(1)));
  319.         OUT_ACCEL_REG(R500_US_CODE_RANGE, (R500_US_CODE_RANGE_ADDR(0) |
  320.                                            R500_US_CODE_RANGE_SIZE(1)));
  321.         OUT_ACCEL_REG(R500_US_CODE_OFFSET, 0);
  322.  
  323.         OUT_ACCEL_REG(R300_US_OUT_FMT_0, output_fmt);
  324.         COMMIT_RING();
  325.  
  326.         BEGIN_ACCEL(13);
  327.         OUT_ACCEL_REG(R500_GA_US_VECTOR_INDEX, 0);
  328.             /* tex inst for src texture */
  329.         OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_INST_TYPE_TEX     |
  330.                                                R500_INST_TEX_SEM_WAIT |
  331.                                                R500_INST_RGB_WMASK_R  |
  332.                                                R500_INST_RGB_WMASK_G  |
  333.                                                R500_INST_RGB_WMASK_B  |
  334.                                                R500_INST_ALPHA_WMASK  |
  335.                                                R500_INST_RGB_CLAMP |
  336.                                                R500_INST_ALPHA_CLAMP));
  337.  
  338.        OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_TEX_ID(0) |
  339.                                                    R500_TEX_INST_LD |
  340.                                                    R500_TEX_SEM_ACQUIRE |
  341.                                                    R500_TEX_IGNORE_UNCOVERED));
  342.  
  343.             OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_TEX_SRC_ADDR(0) |
  344.                                                    R500_TEX_SRC_S_SWIZ_R |
  345.                                                    R500_TEX_SRC_T_SWIZ_G |
  346.                                                    R500_TEX_DST_ADDR(0) |
  347.                                                    R500_TEX_DST_R_SWIZ_R |
  348.                                                    R500_TEX_DST_G_SWIZ_G |
  349.                                                    R500_TEX_DST_B_SWIZ_B |
  350.                                                    R500_TEX_DST_A_SWIZ_A));
  351.             OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_DX_ADDR(0) |
  352.                                                    R500_DX_S_SWIZ_R |
  353.                                                    R500_DX_T_SWIZ_R |
  354.                                                    R500_DX_R_SWIZ_R |
  355.                                                    R500_DX_Q_SWIZ_R |
  356.                                                    R500_DY_ADDR(0) |
  357.                                                    R500_DY_S_SWIZ_R |
  358.                                                    R500_DY_T_SWIZ_R |
  359.                                                    R500_DY_R_SWIZ_R |
  360.                                                    R500_DY_Q_SWIZ_R));
  361.             OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, 0x00000000);
  362.             OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, 0x00000000);
  363.  
  364.         /* ALU inst */
  365.         /* *_OMASK* - output component write mask */
  366.         OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_INST_TYPE_OUT |
  367.                                                R500_INST_TEX_SEM_WAIT |
  368.                                                R500_INST_LAST |
  369.                                                R500_INST_RGB_OMASK_R |
  370.                                                R500_INST_RGB_OMASK_G |
  371.                                                R500_INST_RGB_OMASK_B |
  372.                                                R500_INST_ALPHA_OMASK |
  373.                                                R500_INST_RGB_CLAMP |
  374.                                                R500_INST_ALPHA_CLAMP));
  375.         /* ALU inst
  376.          * temp addresses for texture inputs
  377.          * RGB_ADDR0 is src tex (temp 0)
  378.          * RGB_ADDR1 is mask tex (temp 1)
  379.          */
  380.         OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_RGB_ADDR0(0) |
  381.                                                R500_RGB_ADDR1(1) |
  382.                                                R500_RGB_ADDR2(0)));
  383.         /* ALU inst
  384.          * temp addresses for texture inputs
  385.          * ALPHA_ADDR0 is src tex (temp 0)
  386.          * ALPHA_ADDR1 is mask tex (temp 1)
  387.          */
  388.         OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_ALPHA_ADDR0(0) |
  389.                                                R500_ALPHA_ADDR1(1) |
  390.                                                R500_ALPHA_ADDR2(0)));
  391.  
  392.         /* R500_ALU_RGB_TARGET - RGB render target */
  393.         OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_ALU_RGB_SEL_A_SRC0 |
  394.                                                src_color |
  395.                                                R500_ALU_RGB_SEL_B_SRC1 |
  396.                                                mask_color |
  397.                                                R500_ALU_RGB_TARGET(0)));
  398.  
  399.         /* R500_ALPHA_RGB_TARGET - alpha render target */
  400.         OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_ALPHA_OP_MAD |
  401.                                                R500_ALPHA_ADDRD(0) |
  402.                                                R500_ALPHA_SEL_A_SRC0 |
  403.                                                src_alpha |
  404.                                                R500_ALPHA_SEL_B_SRC1 |
  405.                                                mask_alpha |
  406.                                                R500_ALPHA_TARGET(0)));
  407.  
  408.         OUT_ACCEL_REG(R500_GA_US_VECTOR_DATA, (R500_ALU_RGBA_OP_MAD |
  409.                                                R500_ALU_RGBA_ADDRD(0) |
  410.                                                R500_ALU_RGBA_R_SWIZ_0 |
  411.                                                R500_ALU_RGBA_G_SWIZ_0 |
  412.                                                R500_ALU_RGBA_B_SWIZ_0 |
  413.                                                R500_ALU_RGBA_A_SWIZ_0));
  414.         FINISH_ACCEL();
  415.     }
  416.  
  417.     BEGIN_ACCEL(3);
  418.     OUT_ACCEL_REG(R300_RB3D_COLOROFFSET0, dst_offset);
  419.     OUT_ACCEL_REG(R300_RB3D_COLORPITCH0, colorpitch);
  420.  
  421.     blendcntl = RADEONGetBlendCntl(op, PICT_a8r8g8b8);
  422.     OUT_ACCEL_REG(R300_RB3D_BLENDCNTL, blendcntl | R300_ALPHA_BLEND_ENABLE |
  423.                                        R300_READ_ENABLE);
  424.  
  425.     FINISH_ACCEL();
  426.  
  427.     safe_sti(ifl);
  428.  
  429.     return TRUE;
  430. }
  431.  
  432.  
  433. #define VTX_COUNT 4
  434.  
  435. static __inline__ u32_t F_TO_DW(float val)
  436. {
  437.     union {
  438.         float f;
  439.         u32_t l;
  440.     } tmp;
  441.     tmp.f = val;
  442.     return tmp.l;
  443. }
  444.  
  445. #define OUT_RING_F(x) OUT_RING(F_TO_DW(x))
  446.  
  447. #define VTX_OUT(_dstX, _dstY, _srcX, _srcY)     \
  448. do {                                                            \
  449.     OUT_RING_F(_dstX);                                          \
  450.     OUT_RING_F(_dstY);                                          \
  451.     OUT_RING_F(_srcX);                                          \
  452.     OUT_RING_F(_srcY);                                          \
  453. } while (0)
  454.  
  455.  
  456.  
  457. static int RadeonCompositeTile(int srcX, int srcY,
  458.                                 int dstX, int dstY,
  459.                                 int w, int h)
  460. {
  461.   //  RINFO_FROM_SCREEN(pDst->drawable.pScreen);
  462.     int vtx_count;
  463.     xPointFixed srcTopLeft, srcTopRight, srcBottomLeft, srcBottomRight;
  464.     xPointFixed maskTopLeft, maskTopRight, maskBottomLeft, maskBottomRight;
  465.  
  466.     u32_t *ring;
  467.  
  468.     u32_t ifl;
  469.  
  470.  //   ACCEL_PREAMBLE();
  471.  
  472.  //   ENTER_DRAW(0);
  473.  
  474.     /* ErrorF("RadeonComposite (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n",
  475.        srcX, srcY, maskX, maskY,dstX, dstY, w, h); */
  476.  
  477.     srcTopLeft.x     = IntToxFixed(srcX);
  478.     srcTopLeft.y     = IntToxFixed(srcY);
  479.     srcTopRight.x    = IntToxFixed(srcX + w);
  480.     srcTopRight.y    = IntToxFixed(srcY);
  481.     srcBottomLeft.x  = IntToxFixed(srcX);
  482.     srcBottomLeft.y  = IntToxFixed(srcY + h);
  483.     srcBottomRight.x = IntToxFixed(srcX + w);
  484.     srcBottomRight.y = IntToxFixed(srcY + h);
  485.  
  486. /*
  487.     if (is_transform[0]) {
  488.         transformPoint(transform[0], &srcTopLeft);
  489.         transformPoint(transform[0], &srcTopRight);
  490.         transformPoint(transform[0], &srcBottomLeft);
  491.         transformPoint(transform[0], &srcBottomRight);
  492.     }
  493.     if (is_transform[1]) {
  494.         transformPoint(transform[1], &maskTopLeft);
  495.         transformPoint(transform[1], &maskTopRight);
  496.         transformPoint(transform[1], &maskBottomLeft);
  497.         transformPoint(transform[1], &maskBottomRight);
  498.     }
  499. */
  500.     vtx_count = VTX_COUNT;
  501.  
  502.  
  503.     ifl = safe_cli();
  504.  
  505.     BEGIN_RING(7 + 4 * vtx_count);
  506.  
  507.       OUT_ACCEL_REG(R300_VAP_VTX_SIZE, vtx_count);
  508.  
  509.       OUT_RING(CP_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2,
  510.                         4 * vtx_count));
  511.       OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
  512.               RADEON_CP_VC_CNTL_PRIM_WALK_RING |
  513.               (4 << RADEON_CP_VC_CNTL_NUM_SHIFT));
  514.  
  515.  
  516.       VTX_OUT((float)dstX, (float)dstY,
  517.               xFixedToFloat(srcTopLeft.x) / w,      // info->texW[0],
  518.               xFixedToFloat(srcTopLeft.y) / h);     // info->texH[0]);
  519.  
  520.       VTX_OUT((float)dstX, (float)(dstY + h),
  521.               xFixedToFloat(srcBottomLeft.x) / w,   // info->texW[0],
  522.               xFixedToFloat(srcBottomLeft.y) / h);  // info->texH[0]);
  523.  
  524.       VTX_OUT((float)(dstX + w), (float)(dstY + h),
  525.               xFixedToFloat(srcBottomRight.x) / w,  // info->texW[0],
  526.               xFixedToFloat(srcBottomRight.y) / h); // info->texH[0]);
  527.  
  528.       VTX_OUT((float)(dstX + w), (float)dstY,
  529.               xFixedToFloat(srcTopRight.x) / w,     // info->texW[0],
  530.               xFixedToFloat(srcTopRight.y) / h);    // info->texH[0]);
  531.  
  532.           /* flushing is pipelined, free/finish is not */
  533.       OUT_ACCEL_REG(R300_RB3D_DSTCACHE_CTLSTAT, R300_DC_FLUSH_3D);
  534.  
  535.       OUT_ACCEL_REG(RADEON_WAIT_UNTIL, RADEON_WAIT_3D_IDLECLEAN);
  536.  
  537.     COMMIT_RING();
  538.  
  539.     safe_sti(ifl);
  540.  
  541.  //   LEAVE_DRAW(0);
  542. }
  543. #undef VTX_OUT
  544. #undef VTX_OUT_MASK
  545.  
  546.  
  547. int RadeonComposite( io_blit_t *blit)
  548. {
  549.     int tileSrcY, tileMaskY, tileDstY;
  550.     int remainingHeight;
  551.  
  552.     local_pixmap_t *srcpixmap;
  553.     local_pixmap_t *dstpixmap;
  554.  
  555.     dbgprintf("Blit Alpha src: %x dst: %x\n",blit->srcpix, blit->dstpix);
  556.  
  557.     dstpixmap = (blit->dstpix == (void*)-1) ? &scr_pixmap : blit->dstpix ;
  558.     srcpixmap = (blit->srcpix == (void*)-1) ? &scr_pixmap : blit->srcpix ;
  559.  
  560.     {
  561.         u32_t *ring;
  562.         u32_t ifl = safe_cli();
  563.  
  564.         BEGIN_RING(2 + 6);
  565.  
  566.         CP_REG(R5XX_DP_WRITE_MASK, 0xFF000000);
  567.  
  568.         OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4));
  569.  
  570.         OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  571.                  RADEON_GMC_BRUSH_SOLID_COLOR      |
  572.                  RADEON_GMC_DST_32BPP              |
  573.                  RADEON_GMC_SRC_DATATYPE_COLOR     |
  574.                  R5XX_GMC_CLR_CMP_CNTL_DIS         |
  575.                  R5XX_ROP3_P
  576.                 );
  577.  
  578.         OUT_RING(srcpixmap->pitch_offset);
  579.         OUT_RING(blit->key);
  580.         OUT_RING( 0 );
  581.         OUT_RING((srcpixmap->width<<16)|srcpixmap->height);
  582.  
  583.         COMMIT_RING();
  584.  
  585.         safe_sti(ifl);
  586.     };
  587.  
  588.     R300PrepareComposite(dstpixmap, blit->dst_x, blit->dst_y,
  589.                          srcpixmap, blit->src_x, blit->src_y,
  590.                          blit->w, blit->h, 3);
  591.  
  592. //    if (!need_src_tile_x && !need_src_tile_y) {
  593.         RadeonCompositeTile( blit->src_x, blit->src_y,
  594.                              blit->dst_x, blit->dst_y,
  595.                              blit->w, blit->h);
  596.         return 0;
  597.   //  }
  598.  
  599.     /* Tiling logic borrowed from exaFillRegionTiled */
  600.  
  601. #if 0
  602.     modulus(srcY, src_tile_height, tileSrcY);
  603.     tileMaskY = maskY;
  604.     tileDstY = dstY;
  605.  
  606.     remainingHeight = height;
  607.     while (remainingHeight > 0) {
  608.         int remainingWidth = width;
  609.         int tileSrcX, tileMaskX, tileDstX;
  610.         int h = src_tile_height - tileSrcY;
  611.  
  612.         if (h > remainingHeight)
  613.             h = remainingHeight;
  614.         remainingHeight -= h;
  615.  
  616.         modulus(srcX, src_tile_width, tileSrcX);
  617.         tileMaskX = maskX;
  618.         tileDstX = dstX;
  619.  
  620.         while (remainingWidth > 0) {
  621.             int w = src_tile_width - tileSrcX;
  622.             if (w > remainingWidth)
  623.                 w = remainingWidth;
  624.             remainingWidth -= w;
  625.  
  626.             FUNC_NAME(RadeonCompositeTile)(pDst,
  627.                                            tileSrcX, tileSrcY,
  628.                                            tileMaskX, tileMaskY,
  629.                                            tileDstX, tileDstY,
  630.                                            w, h);
  631.  
  632.             tileSrcX = 0;
  633.             tileMaskX += w;
  634.             tileDstX += w;
  635.         }
  636.         tileSrcY = 0;
  637.         tileMaskY += h;
  638.         tileDstY += h;
  639.     }
  640. #endif
  641.  
  642. }
  643.