Rev 4359 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4359 | Rev 4501 | ||
---|---|---|---|
Line 1457... | Line 1457... | ||
1457 | DBG(("%s: discarding full vbo\n", __FUNCTION__)); |
1457 | DBG(("%s: discarding full vbo\n", __FUNCTION__)); |
1458 | sna->render.vbo = NULL; |
1458 | sna->render.vbo = NULL; |
1459 | sna->render.vertices = sna->render.vertex_data; |
1459 | sna->render.vertices = sna->render.vertex_data; |
1460 | sna->render.vertex_size = ARRAY_SIZE(sna->render.vertex_data); |
1460 | sna->render.vertex_size = ARRAY_SIZE(sna->render.vertex_data); |
1461 | free_bo = bo; |
1461 | free_bo = bo; |
1462 | } else if (IS_CPU_MAP(bo->map)) { |
1462 | } else if (sna->render.vertices == MAP(bo->map__cpu)) { |
1463 | DBG(("%s: converting CPU map to GTT\n", __FUNCTION__)); |
1463 | DBG(("%s: converting CPU map to GTT\n", __FUNCTION__)); |
1464 | sna->render.vertices = kgem_bo_map__gtt(&sna->kgem, bo); |
1464 | sna->render.vertices = kgem_bo_map__gtt(&sna->kgem, bo); |
1465 | if (sna->render.vertices == NULL) { |
1465 | if (sna->render.vertices == NULL) { |
1466 | DBG(("%s: discarding non-mappable vertices\n",__FUNCTION__)); |
1466 | DBG(("%s: discarding non-mappable vertices\n",__FUNCTION__)); |
1467 | sna->render.vbo = NULL; |
1467 | sna->render.vbo = NULL; |
Line 1655... | Line 1655... | ||
1655 | gen3_get_rectangles(sna, op, 1); |
1655 | gen3_get_rectangles(sna, op, 1); |
Line 1656... | Line 1656... | ||
1656 | 1656 | ||
1657 | op->prim_emit(sna, op, r); |
1657 | op->prim_emit(sna, op, r); |
Line -... | Line 1658... | ||
- | 1658 | } |
|
- | 1659 | ||
- | 1660 | #if 0 |
|
- | 1661 | fastcall static void |
|
- | 1662 | gen3_render_composite_box(struct sna *sna, |
|
- | 1663 | const struct sna_composite_op *op, |
|
- | 1664 | const BoxRec *box) |
|
- | 1665 | { |
|
- | 1666 | struct sna_composite_rectangles r; |
|
- | 1667 | ||
- | 1668 | DBG(("%s: src=+(%d, %d), mask=+(%d, %d), dst=+(%d, %d)\n", |
|
- | 1669 | __FUNCTION__, |
|
- | 1670 | op->src.offset[0], op->src.offset[1], |
|
- | 1671 | op->mask.offset[0], op->mask.offset[1], |
|
- | 1672 | op->dst.x, op->dst.y)); |
|
- | 1673 | ||
- | 1674 | gen3_get_rectangles(sna, op, 1); |
|
- | 1675 | ||
- | 1676 | r.dst.x = box->x1; |
|
- | 1677 | r.dst.y = box->y1; |
|
- | 1678 | r.width = box->x2 - box->x1; |
|
- | 1679 | r.height = box->y2 - box->y1; |
|
- | 1680 | r.src = r.mask = r.dst; |
|
- | 1681 | ||
- | 1682 | op->prim_emit(sna, op, &r); |
|
- | 1683 | } |
|
- | 1684 | ||
- | 1685 | static void |
|
- | 1686 | gen3_render_composite_boxes__blt(struct sna *sna, |
|
- | 1687 | const struct sna_composite_op *op, |
|
- | 1688 | const BoxRec *box, int nbox) |
|
- | 1689 | { |
|
- | 1690 | DBG(("%s: nbox=%d, src=+(%d, %d), mask=+(%d, %d), dst=+(%d, %d)\n", |
|
- | 1691 | __FUNCTION__, nbox, |
|
- | 1692 | op->src.offset[0], op->src.offset[1], |
|
- | 1693 | op->mask.offset[0], op->mask.offset[1], |
|
- | 1694 | op->dst.x, op->dst.y)); |
|
- | 1695 | ||
- | 1696 | do { |
|
- | 1697 | int nbox_this_time; |
|
- | 1698 | ||
- | 1699 | nbox_this_time = gen3_get_rectangles(sna, op, nbox); |
|
- | 1700 | nbox -= nbox_this_time; |
|
- | 1701 | ||
- | 1702 | do { |
|
- | 1703 | struct sna_composite_rectangles r; |
|
- | 1704 | ||
- | 1705 | DBG((" %s: (%d, %d) x (%d, %d)\n", __FUNCTION__, |
|
- | 1706 | box->x1, box->y1, |
|
- | 1707 | box->x2 - box->x1, |
|
- | 1708 | box->y2 - box->y1)); |
|
- | 1709 | ||
- | 1710 | r.dst.x = box->x1; r.dst.y = box->y1; |
|
- | 1711 | r.width = box->x2 - box->x1; |
|
- | 1712 | r.height = box->y2 - box->y1; |
|
- | 1713 | r.src = r.mask = r.dst; |
|
- | 1714 | ||
- | 1715 | op->prim_emit(sna, op, &r); |
|
- | 1716 | box++; |
|
- | 1717 | } while (--nbox_this_time); |
|
- | 1718 | } while (nbox); |
|
- | 1719 | } |
|
- | 1720 | ||
- | 1721 | static void |
|
- | 1722 | gen3_render_composite_boxes(struct sna *sna, |
|
- | 1723 | const struct sna_composite_op *op, |
|
- | 1724 | const BoxRec *box, int nbox) |
|
- | 1725 | { |
|
- | 1726 | DBG(("%s: nbox=%d\n", __FUNCTION__, nbox)); |
|
- | 1727 | ||
- | 1728 | do { |
|
- | 1729 | int nbox_this_time; |
|
- | 1730 | float *v; |
|
- | 1731 | ||
- | 1732 | nbox_this_time = gen3_get_rectangles(sna, op, nbox); |
|
- | 1733 | assert(nbox_this_time); |
|
- | 1734 | nbox -= nbox_this_time; |
|
- | 1735 | ||
- | 1736 | v = sna->render.vertices + sna->render.vertex_used; |
|
- | 1737 | sna->render.vertex_used += nbox_this_time * op->floats_per_rect; |
|
- | 1738 | ||
- | 1739 | op->emit_boxes(op, box, nbox_this_time, v); |
|
- | 1740 | box += nbox_this_time; |
|
- | 1741 | } while (nbox); |
|
- | 1742 | } |
|
- | 1743 | ||
- | 1744 | static void |
|
- | 1745 | gen3_render_composite_boxes__thread(struct sna *sna, |
|
- | 1746 | const struct sna_composite_op *op, |
|
- | 1747 | const BoxRec *box, int nbox) |
|
- | 1748 | { |
|
- | 1749 | DBG(("%s: nbox=%d\n", __FUNCTION__, nbox)); |
|
- | 1750 | ||
- | 1751 | sna_vertex_lock(&sna->render); |
|
- | 1752 | do { |
|
- | 1753 | int nbox_this_time; |
|
- | 1754 | float *v; |
|
- | 1755 | ||
- | 1756 | nbox_this_time = gen3_get_rectangles(sna, op, nbox); |
|
- | 1757 | assert(nbox_this_time); |
|
- | 1758 | nbox -= nbox_this_time; |
|
- | 1759 | ||
- | 1760 | v = sna->render.vertices + sna->render.vertex_used; |
|
- | 1761 | sna->render.vertex_used += nbox_this_time * op->floats_per_rect; |
|
- | 1762 | ||
- | 1763 | sna_vertex_acquire__locked(&sna->render); |
|
- | 1764 | sna_vertex_unlock(&sna->render); |
|
- | 1765 | ||
- | 1766 | op->emit_boxes(op, box, nbox_this_time, v); |
|
- | 1767 | box += nbox_this_time; |
|
- | 1768 | ||
- | 1769 | sna_vertex_lock(&sna->render); |
|
- | 1770 | sna_vertex_release__locked(&sna->render); |
|
- | 1771 | } while (nbox); |
|
- | 1772 | sna_vertex_unlock(&sna->render); |
|
- | 1773 | } |
|
1658 | } |
1774 | #endif |
1659 | 1775 | ||
1660 | static void |
1776 | static void |
1661 | gen3_render_composite_done(struct sna *sna, |
1777 | gen3_render_composite_done(struct sna *sna, |
1662 | const struct sna_composite_op *op) |
1778 | const struct sna_composite_op *op) |
Line 1700... | Line 1816... | ||
1700 | 1816 | ||
1701 | state->floats_per_vertex = 0; |
1817 | state->floats_per_vertex = 0; |
1702 | state->last_floats_per_vertex = 0; |
1818 | state->last_floats_per_vertex = 0; |
Line 1703... | Line -... | ||
1703 | state->last_vertex_offset = 0; |
- | |
1704 | 1819 | state->last_vertex_offset = 0; |
|
1705 | if (sna->render.vbo != NULL && |
1820 | |
1706 | !kgem_bo_is_mappable(&sna->kgem, sna->render.vbo)) { |
1821 | if (sna->render.vbo && !kgem_bo_can_map(&sna->kgem, sna->render.vbo)) { |
1707 | DBG(("%s: discarding vbo as next access will stall: %d\n", |
1822 | DBG(("%s: discarding vbo as next access will stall: %d\n", |
1708 | __FUNCTION__, sna->render.vbo->presumed_offset)); |
1823 | __FUNCTION__, sna->render.vbo->presumed_offset)); |
Line 1753... | Line 1868... | ||
1753 | } |
1868 | } |
1754 | return false; |
1869 | return false; |
1755 | } |
1870 | } |
Line 1756... | Line 1871... | ||
1756 | 1871 | ||
- | 1872 | #if 0 |
|
- | 1873 | static bool source_is_covered(PicturePtr picture, |
|
- | 1874 | int x, int y, |
|
- | 1875 | int width, int height) |
|
- | 1876 | { |
|
- | 1877 | int x1, y1, x2, y2; |
|
- | 1878 | ||
- | 1879 | if (picture->repeat && picture->repeatType != RepeatNone) |
|
- | 1880 | return true; |
|
- | 1881 | ||
- | 1882 | if (picture->pDrawable == NULL) |
|
- | 1883 | return false; |
|
- | 1884 | ||
- | 1885 | if (picture->transform) { |
|
- | 1886 | pixman_box16_t sample; |
|
- | 1887 | ||
- | 1888 | sample.x1 = x; |
|
- | 1889 | sample.y1 = y; |
|
- | 1890 | sample.x2 = x + width; |
|
- | 1891 | sample.y2 = y + height; |
|
- | 1892 | ||
- | 1893 | pixman_transform_bounds(picture->transform, &sample); |
|
- | 1894 | ||
- | 1895 | x1 = sample.x1; |
|
- | 1896 | x2 = sample.x2; |
|
- | 1897 | y1 = sample.y1; |
|
- | 1898 | y2 = sample.y2; |
|
- | 1899 | } else { |
|
- | 1900 | x1 = x; |
|
- | 1901 | y1 = y; |
|
- | 1902 | x2 = x + width; |
|
- | 1903 | y2 = y + height; |
|
- | 1904 | } |
|
- | 1905 | ||
- | 1906 | return |
|
- | 1907 | x1 >= 0 && y1 >= 0 && |
|
- | 1908 | x2 <= picture->pDrawable->width && |
|
- | 1909 | y2 <= picture->pDrawable->height; |
|
- | 1910 | } |
|
- | 1911 | ||
- | 1912 | static bool gen3_composite_channel_set_xformat(PicturePtr picture, |
|
- | 1913 | struct sna_composite_channel *channel, |
|
- | 1914 | int x, int y, |
|
- | 1915 | int width, int height) |
|
- | 1916 | { |
|
- | 1917 | unsigned int i; |
|
- | 1918 | ||
- | 1919 | if (PICT_FORMAT_A(picture->format) != 0) |
|
- | 1920 | return false; |
|
- | 1921 | ||
- | 1922 | if (width == 0 || height == 0) |
|
- | 1923 | return false; |
|
- | 1924 | ||
- | 1925 | if (!source_is_covered(picture, x, y, width, height)) |
|
- | 1926 | return false; |
|
- | 1927 | ||
- | 1928 | for (i = 0; i < ARRAY_SIZE(gen3_tex_formats); i++) { |
|
- | 1929 | if (gen3_tex_formats[i].xfmt == picture->format) { |
|
- | 1930 | channel->card_format = gen3_tex_formats[i].card_fmt; |
|
- | 1931 | channel->rb_reversed = gen3_tex_formats[i].rb_reversed; |
|
- | 1932 | channel->alpha_fixup = true; |
|
- | 1933 | return true; |
|
- | 1934 | } |
|
- | 1935 | } |
|
- | 1936 | ||
- | 1937 | return false; |
|
- | 1938 | } |
|
- | 1939 | ||
- | 1940 | static int |
|
- | 1941 | gen3_init_solid(struct sna_composite_channel *channel, uint32_t color) |
|
- | 1942 | { |
|
- | 1943 | channel->u.gen3.mode = color; |
|
- | 1944 | channel->u.gen3.type = SHADER_CONSTANT; |
|
- | 1945 | if (color == 0) |
|
- | 1946 | channel->u.gen3.type = SHADER_ZERO; |
|
- | 1947 | else if (color == 0xff000000) |
|
- | 1948 | channel->u.gen3.type = SHADER_BLACK; |
|
- | 1949 | else if (color == 0xffffffff) |
|
- | 1950 | channel->u.gen3.type = SHADER_WHITE; |
|
- | 1951 | ||
- | 1952 | channel->bo = NULL; |
|
- | 1953 | channel->is_opaque = (color >> 24) == 0xff; |
|
- | 1954 | channel->is_affine = 1; |
|
- | 1955 | channel->alpha_fixup = 0; |
|
- | 1956 | channel->rb_reversed = 0; |
|
- | 1957 | ||
- | 1958 | DBG(("%s: color=%08x, is_opaque=%d, type=%d\n", |
|
- | 1959 | __FUNCTION__, color, channel->is_opaque, channel->u.gen3.type)); |
|
- | 1960 | ||
- | 1961 | /* for consistency */ |
|
- | 1962 | channel->repeat = RepeatNormal; |
|
- | 1963 | channel->filter = PictFilterNearest; |
|
- | 1964 | channel->pict_format = PICT_a8r8g8b8; |
|
- | 1965 | channel->card_format = MAPSURF_32BIT | MT_32BIT_ARGB8888; |
|
- | 1966 | ||
- | 1967 | return 1; |
|
- | 1968 | } |
|
- | 1969 | ||
- | 1970 | static void gen3_composite_channel_convert(struct sna_composite_channel *channel) |
|
- | 1971 | { |
|
- | 1972 | if (channel->u.gen3.type == SHADER_TEXTURE) |
|
- | 1973 | channel->repeat = gen3_texture_repeat(channel->repeat); |
|
- | 1974 | else |
|
- | 1975 | channel->repeat = gen3_gradient_repeat(channel->repeat); |
|
- | 1976 | ||
- | 1977 | channel->filter = gen3_filter(channel->filter); |
|
- | 1978 | if (channel->card_format == 0) |
|
- | 1979 | gen3_composite_channel_set_format(channel, channel->pict_format); |
|
- | 1980 | assert(channel->card_format); |
|
- | 1981 | } |
|
- | 1982 | ||
- | 1983 | static bool gen3_gradient_setup(struct sna *sna, |
|
- | 1984 | PicturePtr picture, |
|
- | 1985 | struct sna_composite_channel *channel, |
|
- | 1986 | int16_t ox, int16_t oy) |
|
- | 1987 | { |
|
- | 1988 | int16_t dx, dy; |
|
- | 1989 | ||
- | 1990 | if (picture->repeat == 0) { |
|
- | 1991 | channel->repeat = RepeatNone; |
|
- | 1992 | } else switch (picture->repeatType) { |
|
- | 1993 | case RepeatNone: |
|
- | 1994 | case RepeatNormal: |
|
- | 1995 | case RepeatPad: |
|
- | 1996 | case RepeatReflect: |
|
- | 1997 | channel->repeat = picture->repeatType; |
|
- | 1998 | break; |
|
- | 1999 | default: |
|
- | 2000 | return false; |
|
- | 2001 | } |
|
- | 2002 | ||
- | 2003 | channel->bo = |
|
- | 2004 | sna_render_get_gradient(sna, |
|
- | 2005 | (PictGradient *)picture->pSourcePict); |
|
- | 2006 | if (channel->bo == NULL) |
|
- | 2007 | return false; |
|
- | 2008 | ||
- | 2009 | channel->pict_format = PICT_a8r8g8b8; |
|
- | 2010 | channel->card_format = MAPSURF_32BIT | MT_32BIT_ARGB8888; |
|
- | 2011 | channel->filter = PictFilterNearest; |
|
- | 2012 | channel->is_affine = sna_transform_is_affine(picture->transform); |
|
- | 2013 | if (sna_transform_is_integer_translation(picture->transform, &dx, &dy)) { |
|
- | 2014 | DBG(("%s: integer translation (%d, %d), removing\n", |
|
- | 2015 | __FUNCTION__, dx, dy)); |
|
- | 2016 | ox += dx; |
|
- | 2017 | oy += dy; |
|
- | 2018 | channel->transform = NULL; |
|
- | 2019 | } else |
|
- | 2020 | channel->transform = picture->transform; |
|
- | 2021 | channel->width = channel->bo->pitch / 4; |
|
- | 2022 | channel->height = 1; |
|
- | 2023 | channel->offset[0] = ox; |
|
- | 2024 | channel->offset[1] = oy; |
|
- | 2025 | channel->scale[0] = channel->scale[1] = 1; |
|
- | 2026 | return true; |
|
- | 2027 | } |
|
- | 2028 | ||
- | 2029 | static int |
|
- | 2030 | gen3_init_linear(struct sna *sna, |
|
- | 2031 | PicturePtr picture, |
|
- | 2032 | struct sna_composite_op *op, |
|
- | 2033 | struct sna_composite_channel *channel, |
|
- | 2034 | int ox, int oy) |
|
- | 2035 | { |
|
- | 2036 | PictLinearGradient *linear = |
|
- | 2037 | (PictLinearGradient *)picture->pSourcePict; |
|
- | 2038 | float x0, y0, sf; |
|
- | 2039 | float dx, dy, offset; |
|
- | 2040 | int n; |
|
- | 2041 | ||
- | 2042 | DBG(("%s: p1=(%f, %f), p2=(%f, %f)\n", |
|
- | 2043 | __FUNCTION__, |
|
- | 2044 | xFixedToDouble(linear->p1.x), xFixedToDouble(linear->p1.y), |
|
- | 2045 | xFixedToDouble(linear->p2.x), xFixedToDouble(linear->p2.y))); |
|
- | 2046 | ||
- | 2047 | if (linear->p2.x == linear->p1.x && linear->p2.y == linear->p1.y) |
|
- | 2048 | return 0; |
|
- | 2049 | ||
- | 2050 | dx = xFixedToDouble(linear->p2.x - linear->p1.x); |
|
- | 2051 | dy = xFixedToDouble(linear->p2.y - linear->p1.y); |
|
- | 2052 | sf = dx*dx + dy*dy; |
|
- | 2053 | dx /= sf; |
|
- | 2054 | dy /= sf; |
|
- | 2055 | ||
- | 2056 | x0 = xFixedToDouble(linear->p1.x); |
|
- | 2057 | y0 = xFixedToDouble(linear->p1.y); |
|
- | 2058 | offset = dx*x0 + dy*y0; |
|
- | 2059 | ||
- | 2060 | n = op->u.gen3.num_constants; |
|
- | 2061 | channel->u.gen3.constants = FS_C0 + n / 4; |
|
- | 2062 | op->u.gen3.constants[n++] = dx; |
|
- | 2063 | op->u.gen3.constants[n++] = dy; |
|
- | 2064 | op->u.gen3.constants[n++] = -offset; |
|
- | 2065 | op->u.gen3.constants[n++] = 0; |
|
- | 2066 | ||
- | 2067 | if (!gen3_gradient_setup(sna, picture, channel, ox, oy)) |
|
- | 2068 | return -1; |
|
- | 2069 | ||
- | 2070 | channel->u.gen3.type = SHADER_LINEAR; |
|
- | 2071 | op->u.gen3.num_constants = n; |
|
- | 2072 | ||
- | 2073 | DBG(("%s: dx=%f, dy=%f, offset=%f, constants=%d\n", |
|
- | 2074 | __FUNCTION__, dx, dy, -offset, channel->u.gen3.constants - FS_C0)); |
|
- | 2075 | return 1; |
|
- | 2076 | } |
|
- | 2077 | ||
- | 2078 | static int |
|
- | 2079 | gen3_init_radial(struct sna *sna, |
|
- | 2080 | PicturePtr picture, |
|
- | 2081 | struct sna_composite_op *op, |
|
- | 2082 | struct sna_composite_channel *channel, |
|
- | 2083 | int ox, int oy) |
|
- | 2084 | { |
|
- | 2085 | PictRadialGradient *radial = (PictRadialGradient *)picture->pSourcePict; |
|
- | 2086 | double dx, dy, dr, r1; |
|
- | 2087 | int n; |
|
- | 2088 | ||
- | 2089 | dx = xFixedToDouble(radial->c2.x - radial->c1.x); |
|
- | 2090 | dy = xFixedToDouble(radial->c2.y - radial->c1.y); |
|
- | 2091 | dr = xFixedToDouble(radial->c2.radius - radial->c1.radius); |
|
- | 2092 | ||
- | 2093 | r1 = xFixedToDouble(radial->c1.radius); |
|
- | 2094 | ||
- | 2095 | n = op->u.gen3.num_constants; |
|
- | 2096 | channel->u.gen3.constants = FS_C0 + n / 4; |
|
- | 2097 | if (radial->c2.x == radial->c1.x && radial->c2.y == radial->c1.y) { |
|
- | 2098 | if (radial->c2.radius == radial->c1.radius) { |
|
- | 2099 | channel->u.gen3.type = SHADER_ZERO; |
|
- | 2100 | return 1; |
|
- | 2101 | } |
|
- | 2102 | ||
- | 2103 | op->u.gen3.constants[n++] = xFixedToDouble(radial->c1.x) / dr; |
|
- | 2104 | op->u.gen3.constants[n++] = xFixedToDouble(radial->c1.y) / dr; |
|
- | 2105 | op->u.gen3.constants[n++] = 1. / dr; |
|
- | 2106 | op->u.gen3.constants[n++] = -r1 / dr; |
|
- | 2107 | ||
- | 2108 | channel->u.gen3.mode = RADIAL_ONE; |
|
- | 2109 | } else { |
|
- | 2110 | op->u.gen3.constants[n++] = -xFixedToDouble(radial->c1.x); |
|
- | 2111 | op->u.gen3.constants[n++] = -xFixedToDouble(radial->c1.y); |
|
- | 2112 | op->u.gen3.constants[n++] = r1; |
|
- | 2113 | op->u.gen3.constants[n++] = -4 * (dx*dx + dy*dy - dr*dr); |
|
- | 2114 | ||
- | 2115 | op->u.gen3.constants[n++] = -2 * dx; |
|
- | 2116 | op->u.gen3.constants[n++] = -2 * dy; |
|
- | 2117 | op->u.gen3.constants[n++] = -2 * r1 * dr; |
|
- | 2118 | op->u.gen3.constants[n++] = 1 / (2 * (dx*dx + dy*dy - dr*dr)); |
|
- | 2119 | ||
- | 2120 | channel->u.gen3.mode = RADIAL_TWO; |
|
- | 2121 | } |
|
- | 2122 | ||
- | 2123 | if (!gen3_gradient_setup(sna, picture, channel, ox, oy)) |
|
- | 2124 | return -1; |
|
- | 2125 | ||
- | 2126 | channel->u.gen3.type = SHADER_RADIAL; |
|
- | 2127 | op->u.gen3.num_constants = n; |
|
- | 2128 | return 1; |
|
- | 2129 | } |
|
- | 2130 | ||
- | 2131 | static bool |
|
- | 2132 | sna_picture_is_clear(PicturePtr picture, |
|
- | 2133 | int x, int y, int w, int h, |
|
- | 2134 | uint32_t *color) |
|
- | 2135 | { |
|
- | 2136 | struct sna_pixmap *priv; |
|
- | 2137 | ||
- | 2138 | if (!picture->pDrawable) |
|
- | 2139 | return false; |
|
- | 2140 | ||
- | 2141 | priv = sna_pixmap(get_drawable_pixmap(picture->pDrawable)); |
|
- | 2142 | if (priv == NULL || !priv->clear) |
|
- | 2143 | return false; |
|
- | 2144 | ||
- | 2145 | if (!source_is_covered(picture, x, y, w, h)) |
|
- | 2146 | return false; |
|
- | 2147 | ||
- | 2148 | *color = priv->clear_color; |
|
- | 2149 | return true; |
|
- | 2150 | } |
|
1757 | #if 0 |
2151 | |
1758 | static int |
2152 | static int |
1759 | gen3_composite_picture(struct sna *sna, |
2153 | gen3_composite_picture(struct sna *sna, |
1760 | PicturePtr picture, |
2154 | PicturePtr picture, |
1761 | struct sna_composite_op *op, |
2155 | struct sna_composite_op *op, |
Line 1872... | Line 2266... | ||
1872 | } |
2266 | } |
Line 1873... | Line 2267... | ||
1873 | 2267 | ||
1874 | return sna_render_pixmap_bo(sna, channel, pixmap, |
2268 | return sna_render_pixmap_bo(sna, channel, pixmap, |
1875 | x, y, w, h, dst_x, dst_y); |
2269 | x, y, w, h, dst_x, dst_y); |
1876 | } |
- | |
1877 | - | ||
1878 | static inline bool |
- | |
1879 | source_use_blt(struct sna *sna, PicturePtr picture) |
- | |
1880 | { |
- | |
1881 | /* If it is a solid, try to use the BLT paths */ |
- | |
1882 | if (!picture->pDrawable) |
- | |
1883 | return picture->pSourcePict->type == SourcePictTypeSolidFill; |
- | |
1884 | - | ||
1885 | if (picture->pDrawable->width == 1 && |
- | |
1886 | picture->pDrawable->height == 1 && |
- | |
1887 | picture->repeat) |
- | |
1888 | return true; |
- | |
1889 | - | ||
1890 | if (too_large(picture->pDrawable->width, picture->pDrawable->height)) |
- | |
1891 | return true; |
- | |
1892 | - | ||
1893 | return !is_gpu(sna, picture->pDrawable, PREFER_GPU_RENDER); |
- | |
1894 | } |
- | |
1895 | - | ||
1896 | static bool |
- | |
1897 | try_blt(struct sna *sna, |
- | |
1898 | PicturePtr dst, |
- | |
1899 | PicturePtr src, |
- | |
1900 | int width, int height) |
- | |
1901 | { |
- | |
1902 | if (sna->kgem.mode != KGEM_RENDER) { |
- | |
1903 | DBG(("%s: already performing BLT\n", __FUNCTION__)); |
- | |
1904 | return true; |
- | |
1905 | } |
- | |
1906 | - | ||
1907 | if (too_large(width, height)) { |
- | |
1908 | DBG(("%s: operation too large for 3D pipe (%d, %d)\n", |
- | |
1909 | __FUNCTION__, width, height)); |
- | |
1910 | return true; |
- | |
1911 | } |
- | |
1912 | - | ||
1913 | if (too_large(dst->pDrawable->width, dst->pDrawable->height)) { |
- | |
1914 | DBG(("%s: target too large for 3D pipe (%d, %d)\n", |
- | |
1915 | __FUNCTION__, |
- | |
1916 | dst->pDrawable->width, dst->pDrawable->height)); |
- | |
1917 | return true; |
- | |
1918 | } |
- | |
1919 | - | ||
1920 | /* is the source picture only in cpu memory e.g. a shm pixmap? */ |
- | |
1921 | return source_use_blt(sna, src); |
- | |
1922 | } |
2270 | } |
Line 1923... | Line 2271... | ||
1923 | #endif |
2271 | #endif |
1924 | 2272 | ||
1925 | static void |
2273 | static void |
1926 | gen3_align_vertex(struct sna *sna, |
2274 | gen3_align_vertex(struct sna *sna, |
1927 | const struct sna_composite_op *op) |
- | |
1928 | { |
- | |
1929 | if (op->floats_per_vertex != sna->render_state.gen3.last_floats_per_vertex) { |
2275 | const struct sna_composite_op *op) |
Line -... | Line 2276... | ||
- | 2276 | { |
|
- | 2277 | int vertex_index; |
|
- | 2278 | ||
1930 | if (sna->render.vertex_size - sna->render.vertex_used < 2*op->floats_per_rect) |
2279 | if (op->floats_per_vertex == sna->render_state.gen3.last_floats_per_vertex) |
1931 | gen3_vertex_finish(sna); |
2280 | return; |
1932 | 2281 | ||
- | 2282 | DBG(("aligning vertex: was %d, now %d floats per vertex\n", |
|
1933 | DBG(("aligning vertex: was %d, now %d floats per vertex, %d->%d\n", |
2283 | sna->render_state.gen3.last_floats_per_vertex, |
- | 2284 | op->floats_per_vertex)); |
|
1934 | sna->render_state.gen3.last_floats_per_vertex, |
2285 | |
1935 | op->floats_per_vertex, |
2286 | assert(op->floats_per_rect == 3*op->floats_per_vertex); |
- | 2287 | ||
1936 | sna->render.vertex_index, |
2288 | vertex_index = (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex; |
1937 | (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex)); |
2289 | if ((int)sna->render.vertex_size - vertex_index * op->floats_per_vertex < 2*op->floats_per_rect) { |
- | 2290 | DBG(("%s: flushing vertex buffer: new index=%d, max=%d\n", |
|
- | 2291 | __FUNCTION__, vertex_index, sna->render.vertex_size / op->floats_per_vertex)); |
|
1938 | sna->render.vertex_index = (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex; |
2292 | if (gen3_vertex_finish(sna) < op->floats_per_vertex) |
1939 | sna->render.vertex_used = sna->render.vertex_index * op->floats_per_vertex; |
2293 | kgem_submit(&sna->kgem); |
- | 2294 | ||
- | 2295 | vertex_index = (sna->render.vertex_used + op->floats_per_vertex - 1) / op->floats_per_vertex; |
|
- | 2296 | } |
|
1940 | assert(sna->render.vertex_used < sna->render.vertex_size - op->floats_per_rect); |
2297 | |
Line 1941... | Line 2298... | ||
1941 | sna->render_state.gen3.last_floats_per_vertex = op->floats_per_vertex; |
2298 | sna->render.vertex_index = vertex_index; |
1942 | } |
2299 | sna->render.vertex_used = vertex_index * op->floats_per_vertex; |
1943 | } |
2300 | } |
Line 2057... | Line 2414... | ||
2057 | DBG(("%s: dst is not on the GPU and the operation should not fallback: use-cpu? %d\n", |
2414 | DBG(("%s: dst is not on the GPU and the operation should not fallback: use-cpu? %d\n", |
2058 | __FUNCTION__, dst_use_cpu(dst_pixmap))); |
2415 | __FUNCTION__, dst_use_cpu(dst_pixmap))); |
2059 | return dst_use_cpu(dst_pixmap); |
2416 | return dst_use_cpu(dst_pixmap); |
2060 | } |
2417 | } |
Line -... | Line 2418... | ||
- | 2418 | ||
- | 2419 | static int |
|
- | 2420 | reuse_source(struct sna *sna, |
|
- | 2421 | PicturePtr src, struct sna_composite_channel *sc, int src_x, int src_y, |
|
- | 2422 | PicturePtr mask, struct sna_composite_channel *mc, int msk_x, int msk_y) |
|
- | 2423 | { |
|
- | 2424 | if (src_x != msk_x || src_y != msk_y) |
|
- | 2425 | return false; |
|
- | 2426 | ||
- | 2427 | if (mask == src) { |
|
- | 2428 | *mc = *sc; |
|
- | 2429 | if (mc->bo) |
|
- | 2430 | kgem_bo_reference(mc->bo); |
|
- | 2431 | return true; |
|
- | 2432 | } |
|
- | 2433 | ||
- | 2434 | if ((src->pDrawable == NULL || mask->pDrawable != src->pDrawable)) |
|
- | 2435 | return false; |
|
- | 2436 | ||
- | 2437 | if (sc->is_solid) |
|
- | 2438 | return false; |
|
- | 2439 | ||
- | 2440 | DBG(("%s: mask reuses source drawable\n", __FUNCTION__)); |
|
- | 2441 | ||
- | 2442 | if (!sna_transform_equal(src->transform, mask->transform)) |
|
- | 2443 | return false; |
|
- | 2444 | ||
- | 2445 | if (!sna_picture_alphamap_equal(src, mask)) |
|
- | 2446 | return false; |
|
- | 2447 | ||
- | 2448 | if (!gen3_check_repeat(mask)) |
|
- | 2449 | return false; |
|
- | 2450 | ||
- | 2451 | if (!gen3_check_filter(mask)) |
|
- | 2452 | return false; |
|
- | 2453 | ||
- | 2454 | if (!gen3_check_format(mask)) |
|
- | 2455 | return false; |
|
- | 2456 | ||
- | 2457 | DBG(("%s: reusing source channel for mask with a twist\n", |
|
- | 2458 | __FUNCTION__)); |
|
- | 2459 | ||
- | 2460 | *mc = *sc; |
|
- | 2461 | mc->repeat = gen3_texture_repeat(mask->repeat ? mask->repeatType : RepeatNone); |
|
- | 2462 | mc->filter = gen3_filter(mask->filter); |
|
- | 2463 | mc->pict_format = mask->format; |
|
- | 2464 | gen3_composite_channel_set_format(mc, mask->format); |
|
- | 2465 | assert(mc->card_format); |
|
- | 2466 | if (mc->bo) |
|
- | 2467 | kgem_bo_reference(mc->bo); |
|
- | 2468 | return true; |
|
- | 2469 | } |
|
2061 | 2470 | ||
2062 | static bool |
2471 | static bool |
2063 | gen3_render_composite(struct sna *sna, |
2472 | gen3_render_composite(struct sna *sna, |
2064 | uint8_t op, |
2473 | uint8_t op, |
2065 | PicturePtr src, |
2474 | PicturePtr src, |
Line 2081... | Line 2490... | ||
2081 | 2490 | ||
2082 | /* Try to use the BLT engine unless it implies a |
2491 | /* Try to use the BLT engine unless it implies a |
2083 | * 3D -> 2D context switch. |
2492 | * 3D -> 2D context switch. |
2084 | */ |
2493 | */ |
2085 | if (mask == NULL && |
- | |
2086 | try_blt(sna, dst, src, width, height) && |
2494 | if (mask == NULL && |
2087 | sna_blt_composite(sna, |
2495 | sna_blt_composite(sna, |
2088 | op, src, dst, |
2496 | op, src, dst, |
2089 | src_x, src_y, |
2497 | src_x, src_y, |
2090 | dst_x, dst_y, |
2498 | dst_x, dst_y, |
2091 | width, height, |
2499 | width, height, |
2092 | tmp, false)) |
2500 | tmp, false)) |
Line 2093... | Line 2501... | ||
2093 | return true; |
2501 | return true; |
2094 | 2502 | ||
Line 2095... | Line 2503... | ||
2095 | if (gen3_composite_fallback(sna, op, src, mask, dst)) |
2503 | if (gen3_composite_fallback(sna, op, src, mask, dst)) |
2096 | return false; |
2504 | goto fallback; |
2097 | 2505 | ||
2098 | if (need_tiling(sna, width, height)) |
2506 | if (need_tiling(sna, width, height)) |
Line 2115... | Line 2523... | ||
2115 | if (too_large(tmp->dst.width, tmp->dst.height) || |
2523 | if (too_large(tmp->dst.width, tmp->dst.height) || |
2116 | !gen3_check_pitch_3d(tmp->dst.bo)) { |
2524 | !gen3_check_pitch_3d(tmp->dst.bo)) { |
2117 | if (!sna_render_composite_redirect(sna, tmp, |
2525 | if (!sna_render_composite_redirect(sna, tmp, |
2118 | dst_x, dst_y, width, height, |
2526 | dst_x, dst_y, width, height, |
2119 | op > PictOpSrc || dst->pCompositeClip->data)) |
2527 | op > PictOpSrc || dst->pCompositeClip->data)) |
2120 | return false; |
2528 | goto fallback; |
2121 | } |
2529 | } |
Line 2122... | Line 2530... | ||
2122 | 2530 | ||
2123 | tmp->u.gen3.num_constants = 0; |
2531 | tmp->u.gen3.num_constants = 0; |
2124 | tmp->src.u.gen3.type = SHADER_TEXTURE; |
2532 | tmp->src.u.gen3.type = SHADER_TEXTURE; |
Line 2404... | Line 2812... | ||
2404 | tmp->dst.bo, tmp->src.bo, tmp->mask.bo, |
2812 | tmp->dst.bo, tmp->src.bo, tmp->mask.bo, |
2405 | NULL)) |
2813 | NULL)) |
2406 | goto cleanup_mask; |
2814 | goto cleanup_mask; |
2407 | } |
2815 | } |
Line 2408... | Line -... | ||
2408 | - | ||
2409 | gen3_emit_composite_state(sna, tmp); |
2816 | |
- | 2817 | gen3_align_vertex(sna, tmp); |
|
2410 | gen3_align_vertex(sna, tmp); |
2818 | gen3_emit_composite_state(sna, tmp); |
Line 2411... | Line 2819... | ||
2411 | return true; |
2819 | return true; |
2412 | 2820 | ||
2413 | cleanup_mask: |
2821 | cleanup_mask: |
Line 2417... | Line 2825... | ||
2417 | if (tmp->src.bo) |
2825 | if (tmp->src.bo) |
2418 | kgem_bo_destroy(&sna->kgem, tmp->src.bo); |
2826 | kgem_bo_destroy(&sna->kgem, tmp->src.bo); |
2419 | cleanup_dst: |
2827 | cleanup_dst: |
2420 | if (tmp->redirect.real_bo) |
2828 | if (tmp->redirect.real_bo) |
2421 | kgem_bo_destroy(&sna->kgem, tmp->dst.bo); |
2829 | kgem_bo_destroy(&sna->kgem, tmp->dst.bo); |
- | 2830 | fallback: |
|
2422 | return false; |
2831 | return (mask == NULL && |
- | 2832 | sna_blt_composite(sna, |
|
- | 2833 | op, src, dst, |
|
- | 2834 | src_x, src_y, |
|
- | 2835 | dst_x, dst_y, |
|
- | 2836 | width, height, |
|
- | 2837 | tmp, true)); |
|
2423 | } |
2838 | } |
2424 | #endif |
- | |
2425 | - | ||
2426 | - | ||
2427 | - | ||
2428 | - | ||
2429 | - | ||
2430 | - | ||
2431 | - | ||
2432 | - | ||
2433 | - | ||
2434 | - | ||
2435 | - | ||
2436 | - | ||
2437 | - | ||
2438 | - | ||
2439 | - | ||
2440 | - | ||
2441 | - | ||
2442 | - | ||
2443 | - | ||
2444 | - | ||
2445 | - | ||
2446 | - | ||
2447 | - | ||
2448 | - | ||
2449 | - | ||
2450 | - | ||
2451 | - | ||
2452 | - | ||
2453 | - | ||
2454 | - | ||
2455 | - | ||
2456 | - | ||
2457 | - | ||
2458 | - | ||
2459 | - | ||
2460 | - | ||
2461 | - | ||
2462 | - | ||
2463 | - | ||
2464 | - | ||
2465 | - | ||
2466 | - | ||
2467 | - | ||
2468 | - | ||
2469 | - | ||
2470 | - | ||
2471 | - | ||
2472 | - | ||
2473 | - | ||
2474 | - | ||
2475 | - | ||
2476 | - | ||
2477 | - | ||
2478 | - | ||
2479 | - | ||
2480 | - | ||
2481 | - | ||
2482 | - | ||
2483 | - | ||
2484 | - | ||
2485 | - | ||
Line -... | Line 2839... | ||
- | 2839 | ||
- | 2840 | static void |
|
- | 2841 | gen3_emit_composite_spans_vertex(struct sna *sna, |
|
- | 2842 | const struct sna_composite_spans_op *op, |
|
- | 2843 | int16_t x, int16_t y, |
|
- | 2844 | float opacity) |
|
- | 2845 | { |
|
- | 2846 | gen3_emit_composite_dstcoord(sna, x + op->base.dst.x, y + op->base.dst.y); |
|
- | 2847 | gen3_emit_composite_texcoord(sna, &op->base.src, x, y); |
|
- | 2848 | OUT_VERTEX(opacity); |
|
Line -... | Line 2849... | ||
- | 2849 | } |
|
- | 2850 | ||
- | 2851 | fastcall static void |
|
- | 2852 | gen3_emit_composite_spans_primitive_zero(struct sna *sna, |
|
- | 2853 | const struct sna_composite_spans_op *op, |
|
- | 2854 | const BoxRec *box, |
|
- | 2855 | float opacity) |
|
- | 2856 | { |
|
Line -... | Line 2857... | ||
- | 2857 | float *v = sna->render.vertices + sna->render.vertex_used; |
|
- | 2858 | sna->render.vertex_used += 6; |
|
Line -... | Line 2859... | ||
- | 2859 | ||
- | 2860 | v[0] = op->base.dst.x + box->x2; |
|
Line -... | Line 2861... | ||
- | 2861 | v[1] = op->base.dst.y + box->y2; |
|
- | 2862 | ||
- | 2863 | v[2] = op->base.dst.x + box->x1; |
|
Line -... | Line 2864... | ||
- | 2864 | v[3] = v[1]; |
|
- | 2865 | ||
- | 2866 | v[4] = v[2]; |
|
- | 2867 | v[5] = op->base.dst.x + box->y1; |
|
- | 2868 | } |
|
- | 2869 | ||
- | 2870 | fastcall static void |
|
- | 2871 | gen3_emit_composite_spans_primitive_zero__boxes(const struct sna_composite_spans_op *op, |
|
- | 2872 | const struct sna_opacity_box *b, |
|
- | 2873 | int nbox, float *v) |
|
- | 2874 | { |
|
- | 2875 | do { |
|
- | 2876 | v[0] = op->base.dst.x + b->box.x2; |
|
- | 2877 | v[1] = op->base.dst.y + b->box.y2; |
|
- | 2878 | ||
- | 2879 | v[2] = op->base.dst.x + b->box.x1; |
|
- | 2880 | v[3] = v[1]; |
|
- | 2881 | ||
- | 2882 | v[4] = v[2]; |
|
Line -... | Line 2883... | ||
- | 2883 | v[5] = op->base.dst.x + b->box.y1; |
|
- | 2884 | ||
- | 2885 | v += 6; |
|
- | 2886 | b++; |
|
- | 2887 | } while (--nbox); |
|
- | 2888 | } |
|
- | 2889 | ||
- | 2890 | fastcall static void |
|
- | 2891 | gen3_emit_composite_spans_primitive_zero_no_offset(struct sna *sna, |
|
- | 2892 | const struct sna_composite_spans_op *op, |
|
- | 2893 | const BoxRec *box, |
|
- | 2894 | float opacity) |
|
- | 2895 | { |
|
- | 2896 | float *v = sna->render.vertices + sna->render.vertex_used; |
|
Line -... | Line 2897... | ||
- | 2897 | sna->render.vertex_used += 6; |
|
- | 2898 | ||
- | 2899 | v[0] = box->x2; |
|
- | 2900 | v[3] = v[1] = box->y2; |
|
- | 2901 | v[4] = v[2] = box->x1; |
|
- | 2902 | v[5] = box->y1; |
|
- | 2903 | } |
|
- | 2904 | ||
- | 2905 | fastcall static void |
|
- | 2906 | gen3_emit_composite_spans_primitive_zero_no_offset__boxes(const struct sna_composite_spans_op *op, |
|
- | 2907 | const struct sna_opacity_box *b, |
|
- | 2908 | int nbox, float *v) |
|
- | 2909 | { |
|
- | 2910 | do { |
|
- | 2911 | v[0] = b->box.x2; |
|
Line -... | Line 2912... | ||
- | 2912 | v[3] = v[1] = b->box.y2; |
|
- | 2913 | v[4] = v[2] = b->box.x1; |
|
- | 2914 | v[5] = b->box.y1; |
|
- | 2915 | ||
- | 2916 | b++; |
|
- | 2917 | v += 6; |
|
- | 2918 | } while (--nbox); |
|
- | 2919 | } |
|
- | 2920 | ||
- | 2921 | fastcall static void |
|
- | 2922 | gen3_emit_composite_spans_primitive_constant(struct sna *sna, |
|
- | 2923 | const struct sna_composite_spans_op *op, |
|
- | 2924 | const BoxRec *box, |
|
- | 2925 | float opacity) |
|
- | 2926 | { |
|
Line -... | Line 2927... | ||
- | 2927 | float *v = sna->render.vertices + sna->render.vertex_used; |
|
- | 2928 | sna->render.vertex_used += 9; |
|
- | 2929 | ||
- | 2930 | v[0] = op->base.dst.x + box->x2; |
|
- | 2931 | v[6] = v[3] = op->base.dst.x + box->x1; |
|
- | 2932 | v[4] = v[1] = op->base.dst.y + box->y2; |
|
- | 2933 | v[7] = op->base.dst.y + box->y1; |
|
- | 2934 | v[8] = v[5] = v[2] = opacity; |
|
- | 2935 | } |
|
- | 2936 | ||
- | 2937 | fastcall static void |
|
- | 2938 | gen3_emit_composite_spans_primitive_constant__boxes(const struct sna_composite_spans_op *op, |
|
- | 2939 | const struct sna_opacity_box *b, |
|
- | 2940 | int nbox, |
|
- | 2941 | float *v) |
|
- | 2942 | { |
|
- | 2943 | do { |
|
Line -... | Line 2944... | ||
- | 2944 | v[0] = op->base.dst.x + b->box.x2; |
|
- | 2945 | v[6] = v[3] = op->base.dst.x + b->box.x1; |
|
- | 2946 | v[4] = v[1] = op->base.dst.y + b->box.y2; |
|
- | 2947 | v[7] = op->base.dst.y + b->box.y1; |
|
- | 2948 | v[8] = v[5] = v[2] = b->alpha; |
|
- | 2949 | ||
- | 2950 | v += 9; |
|
- | 2951 | b++; |
|
- | 2952 | } while (--nbox); |
|
- | 2953 | } |
|
- | 2954 | ||
- | 2955 | fastcall static void |
|
- | 2956 | gen3_emit_composite_spans_primitive_constant_no_offset(struct sna *sna, |
|
- | 2957 | const struct sna_composite_spans_op *op, |
|
- | 2958 | const BoxRec *box, |
|
Line -... | Line 2959... | ||
- | 2959 | float opacity) |
|
- | 2960 | { |
|
- | 2961 | float *v = sna->render.vertices + sna->render.vertex_used; |
|
- | 2962 | sna->render.vertex_used += 9; |
|
- | 2963 | ||
- | 2964 | v[0] = box->x2; |
|
- | 2965 | v[6] = v[3] = box->x1; |
|
- | 2966 | v[4] = v[1] = box->y2; |
|
- | 2967 | v[7] = box->y1; |
|
- | 2968 | v[8] = v[5] = v[2] = opacity; |
|
- | 2969 | } |
|
- | 2970 | ||
- | 2971 | fastcall static void |
|
- | 2972 | gen3_emit_composite_spans_primitive_constant_no_offset__boxes(const struct sna_composite_spans_op *op, |
|
- | 2973 | const struct sna_opacity_box *b, |
|
- | 2974 | int nbox, float *v) |
|
Line -... | Line 2975... | ||
- | 2975 | { |
|
- | 2976 | do { |
|
- | 2977 | v[0] = b->box.x2; |
|
- | 2978 | v[6] = v[3] = b->box.x1; |
|
- | 2979 | v[4] = v[1] = b->box.y2; |
|
- | 2980 | v[7] = b->box.y1; |
|
- | 2981 | v[8] = v[5] = v[2] = b->alpha; |
|
- | 2982 | ||
- | 2983 | v += 9; |
|
- | 2984 | b++; |
|
- | 2985 | } while (--nbox); |
|
- | 2986 | } |
|
- | 2987 | ||
- | 2988 | fastcall static void |
|
- | 2989 | gen3_emit_composite_spans_primitive_identity_source(struct sna *sna, |
|
- | 2990 | const struct sna_composite_spans_op *op, |
|
- | 2991 | const BoxRec *box, |
|
- | 2992 | float opacity) |
|
- | 2993 | { |
|
- | 2994 | float *v = sna->render.vertices + sna->render.vertex_used; |
|
- | 2995 | sna->render.vertex_used += 15; |
|
- | 2996 | ||
- | 2997 | v[0] = op->base.dst.x + box->x2; |
|
- | 2998 | v[1] = op->base.dst.y + box->y2; |
|
- | 2999 | v[2] = (op->base.src.offset[0] + box->x2) * op->base.src.scale[0]; |
|
- | 3000 | v[3] = (op->base.src.offset[1] + box->y2) * op->base.src.scale[1]; |
|
- | 3001 | v[4] = opacity; |
|
Line -... | Line 3002... | ||
- | 3002 | ||
- | 3003 | v[5] = op->base.dst.x + box->x1; |
|
- | 3004 | v[6] = v[1]; |
|
- | 3005 | v[7] = (op->base.src.offset[0] + box->x1) * op->base.src.scale[0]; |
|
- | 3006 | v[8] = v[3]; |
|
- | 3007 | v[9] = opacity; |
|
- | 3008 | ||
- | 3009 | v[10] = v[5]; |
|
- | 3010 | v[11] = op->base.dst.y + box->y1; |
|
- | 3011 | v[12] = v[7]; |
|
- | 3012 | v[13] = (op->base.src.offset[1] + box->y1) * op->base.src.scale[1]; |
|
- | 3013 | v[14] = opacity; |
|
- | 3014 | } |
|
- | 3015 | ||
- | 3016 | fastcall static void |
|
- | 3017 | gen3_emit_composite_spans_primitive_identity_source__boxes(const struct sna_composite_spans_op *op, |
|
- | 3018 | const struct sna_opacity_box *b, |
|
- | 3019 | int nbox, |
|
- | 3020 | float *v) |
|
- | 3021 | { |
|
- | 3022 | do { |
|
- | 3023 | v[0] = op->base.dst.x + b->box.x2; |
|
- | 3024 | v[1] = op->base.dst.y + b->box.y2; |
|
- | 3025 | v[2] = (op->base.src.offset[0] + b->box.x2) * op->base.src.scale[0]; |
|
- | 3026 | v[3] = (op->base.src.offset[1] + b->box.y2) * op->base.src.scale[1]; |
|
- | 3027 | v[4] = b->alpha; |
|
- | 3028 | ||
- | 3029 | v[5] = op->base.dst.x + b->box.x1; |
|
- | 3030 | v[6] = v[1]; |
|
Line -... | Line 3031... | ||
- | 3031 | v[7] = (op->base.src.offset[0] + b->box.x1) * op->base.src.scale[0]; |
|
- | 3032 | v[8] = v[3]; |
|
- | 3033 | v[9] = b->alpha; |
|
- | 3034 | ||
- | 3035 | v[10] = v[5]; |
|
- | 3036 | v[11] = op->base.dst.y + b->box.y1; |
|
- | 3037 | v[12] = v[7]; |
|
- | 3038 | v[13] = (op->base.src.offset[1] + b->box.y1) * op->base.src.scale[1]; |
|
- | 3039 | v[14] = b->alpha; |
|
- | 3040 | ||
- | 3041 | v += 15; |
|
- | 3042 | b++; |
|
- | 3043 | } while (--nbox); |
|
- | 3044 | } |
|
- | 3045 | ||
- | 3046 | fastcall static void |
|
- | 3047 | gen3_emit_composite_spans_primitive_affine_source(struct sna *sna, |
|
- | 3048 | const struct sna_composite_spans_op *op, |
|
- | 3049 | const BoxRec *box, |
|
- | 3050 | float opacity) |
|
- | 3051 | { |
|
- | 3052 | PictTransform *transform = op->base.src.transform; |
|
- | 3053 | float *v; |
|
- | 3054 | ||
- | 3055 | v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3056 | sna->render.vertex_used += 15; |
|
- | 3057 | ||
- | 3058 | v[0] = op->base.dst.x + box->x2; |
|
- | 3059 | v[6] = v[1] = op->base.dst.y + box->y2; |
|
- | 3060 | v[10] = v[5] = op->base.dst.x + box->x1; |
|
- | 3061 | v[11] = op->base.dst.y + box->y1; |
|
- | 3062 | v[14] = v[9] = v[4] = opacity; |
|
- | 3063 | ||
Line -... | Line 3064... | ||
- | 3064 | _sna_get_transformed_scaled((int)op->base.src.offset[0] + box->x2, |
|
- | 3065 | (int)op->base.src.offset[1] + box->y2, |
|
- | 3066 | transform, op->base.src.scale, |
|
- | 3067 | &v[2], &v[3]); |
|
- | 3068 | ||
- | 3069 | _sna_get_transformed_scaled((int)op->base.src.offset[0] + box->x1, |
|
- | 3070 | (int)op->base.src.offset[1] + box->y2, |
|
- | 3071 | transform, op->base.src.scale, |
|
- | 3072 | &v[7], &v[8]); |
|
- | 3073 | ||
- | 3074 | _sna_get_transformed_scaled((int)op->base.src.offset[0] + box->x1, |
|
- | 3075 | (int)op->base.src.offset[1] + box->y1, |
|
- | 3076 | transform, op->base.src.scale, |
|
- | 3077 | &v[12], &v[13]); |
|
- | 3078 | } |
|
- | 3079 | ||
- | 3080 | fastcall static void |
|
- | 3081 | gen3_emit_composite_spans_primitive_affine_source__boxes(const struct sna_composite_spans_op *op, |
|
- | 3082 | const struct sna_opacity_box *b, |
|
- | 3083 | int nbox, |
|
- | 3084 | float *v) |
|
- | 3085 | { |
|
- | 3086 | PictTransform *transform = op->base.src.transform; |
|
- | 3087 | ||
- | 3088 | do { |
|
- | 3089 | v[0] = op->base.dst.x + b->box.x2; |
|
- | 3090 | v[6] = v[1] = op->base.dst.y + b->box.y2; |
|
- | 3091 | v[10] = v[5] = op->base.dst.x + b->box.x1; |
|
- | 3092 | v[11] = op->base.dst.y + b->box.y1; |
|
- | 3093 | v[14] = v[9] = v[4] = b->alpha; |
|
- | 3094 | ||
- | 3095 | _sna_get_transformed_scaled((int)op->base.src.offset[0] + b->box.x2, |
|
- | 3096 | (int)op->base.src.offset[1] + b->box.y2, |
|
Line -... | Line 3097... | ||
- | 3097 | transform, op->base.src.scale, |
|
- | 3098 | &v[2], &v[3]); |
|
- | 3099 | ||
- | 3100 | _sna_get_transformed_scaled((int)op->base.src.offset[0] + b->box.x1, |
|
- | 3101 | (int)op->base.src.offset[1] + b->box.y2, |
|
- | 3102 | transform, op->base.src.scale, |
|
- | 3103 | &v[7], &v[8]); |
|
- | 3104 | ||
- | 3105 | _sna_get_transformed_scaled((int)op->base.src.offset[0] + b->box.x1, |
|
- | 3106 | (int)op->base.src.offset[1] + b->box.y1, |
|
- | 3107 | transform, op->base.src.scale, |
|
- | 3108 | &v[12], &v[13]); |
|
- | 3109 | v += 15; |
|
- | 3110 | b++; |
|
- | 3111 | } while (--nbox); |
|
- | 3112 | } |
|
- | 3113 | ||
- | 3114 | fastcall static void |
|
- | 3115 | gen3_emit_composite_spans_primitive_identity_gradient(struct sna *sna, |
|
- | 3116 | const struct sna_composite_spans_op *op, |
|
- | 3117 | const BoxRec *box, |
|
- | 3118 | float opacity) |
|
- | 3119 | { |
|
- | 3120 | float *v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3121 | sna->render.vertex_used += 15; |
|
- | 3122 | ||
- | 3123 | v[0] = op->base.dst.x + box->x2; |
|
Line -... | Line 3124... | ||
- | 3124 | v[1] = op->base.dst.y + box->y2; |
|
- | 3125 | v[2] = op->base.src.offset[0] + box->x2; |
|
- | 3126 | v[3] = op->base.src.offset[1] + box->y2; |
|
- | 3127 | v[4] = opacity; |
|
- | 3128 | ||
- | 3129 | v[5] = op->base.dst.x + box->x1; |
|
- | 3130 | v[6] = v[1]; |
|
- | 3131 | v[7] = op->base.src.offset[0] + box->x1; |
|
- | 3132 | v[8] = v[3]; |
|
- | 3133 | v[9] = opacity; |
|
- | 3134 | ||
- | 3135 | v[10] = v[5]; |
|
- | 3136 | v[11] = op->base.dst.y + box->y1; |
|
- | 3137 | v[12] = v[7]; |
|
- | 3138 | v[13] = op->base.src.offset[1] + box->y1; |
|
- | 3139 | v[14] = opacity; |
|
- | 3140 | } |
|
- | 3141 | ||
- | 3142 | fastcall static void |
|
- | 3143 | gen3_emit_composite_spans_primitive_identity_gradient__boxes(const struct sna_composite_spans_op *op, |
|
- | 3144 | const struct sna_opacity_box *b, |
|
- | 3145 | int nbox, |
|
- | 3146 | float *v) |
|
- | 3147 | { |
|
- | 3148 | do { |
|
- | 3149 | v[0] = op->base.dst.x + b->box.x2; |
|
- | 3150 | v[1] = op->base.dst.y + b->box.y2; |
|
- | 3151 | v[2] = op->base.src.offset[0] + b->box.x2; |
|
- | 3152 | v[3] = op->base.src.offset[1] + b->box.y2; |
|
Line -... | Line 3153... | ||
- | 3153 | v[4] = b->alpha; |
|
- | 3154 | ||
- | 3155 | v[5] = op->base.dst.x + b->box.x1; |
|
- | 3156 | v[6] = v[1]; |
|
- | 3157 | v[7] = op->base.src.offset[0] + b->box.x1; |
|
- | 3158 | v[8] = v[3]; |
|
- | 3159 | v[9] = b->alpha; |
|
- | 3160 | ||
- | 3161 | v[10] = v[5]; |
|
- | 3162 | v[11] = op->base.dst.y + b->box.y1; |
|
- | 3163 | v[12] = v[7]; |
|
- | 3164 | v[13] = op->base.src.offset[1] + b->box.y1; |
|
- | 3165 | v[14] = b->alpha; |
|
- | 3166 | ||
- | 3167 | v += 15; |
|
- | 3168 | b++; |
|
- | 3169 | } while (--nbox); |
|
- | 3170 | } |
|
- | 3171 | ||
- | 3172 | #if defined(sse2) && !defined(__x86_64__) |
|
- | 3173 | sse2 fastcall static void |
|
- | 3174 | gen3_emit_composite_spans_primitive_constant__sse2(struct sna *sna, |
|
- | 3175 | const struct sna_composite_spans_op *op, |
|
- | 3176 | const BoxRec *box, |
|
- | 3177 | float opacity) |
|
- | 3178 | { |
|
- | 3179 | float *v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3180 | sna->render.vertex_used += 9; |
|
- | 3181 | ||
- | 3182 | v[0] = op->base.dst.x + box->x2; |
|
- | 3183 | v[6] = v[3] = op->base.dst.x + box->x1; |
|
- | 3184 | v[4] = v[1] = op->base.dst.y + box->y2; |
|
- | 3185 | v[7] = op->base.dst.y + box->y1; |
|
- | 3186 | v[8] = v[5] = v[2] = opacity; |
|
- | 3187 | } |
|
- | 3188 | ||
- | 3189 | sse2 fastcall static void |
|
- | 3190 | gen3_emit_composite_spans_primitive_constant__sse2__boxes(const struct sna_composite_spans_op *op, |
|
- | 3191 | const struct sna_opacity_box *b, |
|
- | 3192 | int nbox, |
|
- | 3193 | float *v) |
|
- | 3194 | { |
|
- | 3195 | do { |
|
- | 3196 | v[0] = op->base.dst.x + b->box.x2; |
|
- | 3197 | v[6] = v[3] = op->base.dst.x + b->box.x1; |
|
- | 3198 | v[4] = v[1] = op->base.dst.y + b->box.y2; |
|
- | 3199 | v[7] = op->base.dst.y + b->box.y1; |
|
- | 3200 | v[8] = v[5] = v[2] = b->alpha; |
|
- | 3201 | ||
- | 3202 | v += 9; |
|
- | 3203 | b++; |
|
- | 3204 | } while (--nbox); |
|
- | 3205 | } |
|
- | 3206 | ||
- | 3207 | sse2 fastcall static void |
|
- | 3208 | gen3_render_composite_spans_constant_box__sse2(struct sna *sna, |
|
- | 3209 | const struct sna_composite_spans_op *op, |
|
- | 3210 | const BoxRec *box, float opacity) |
|
- | 3211 | { |
|
- | 3212 | float *v; |
|
- | 3213 | DBG(("%s: src=+(%d, %d), opacity=%f, dst=+(%d, %d), box=(%d, %d) x (%d, %d)\n", |
|
- | 3214 | __FUNCTION__, |
|
- | 3215 | op->base.src.offset[0], op->base.src.offset[1], |
|
- | 3216 | opacity, |
|
- | 3217 | op->base.dst.x, op->base.dst.y, |
|
- | 3218 | box->x1, box->y1, |
|
- | 3219 | box->x2 - box->x1, |
|
- | 3220 | box->y2 - box->y1)); |
|
- | 3221 | ||
- | 3222 | gen3_get_rectangles(sna, &op->base, 1); |
|
- | 3223 | ||
- | 3224 | v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3225 | sna->render.vertex_used += 9; |
|
- | 3226 | ||
- | 3227 | v[0] = box->x2; |
|
- | 3228 | v[6] = v[3] = box->x1; |
|
- | 3229 | v[4] = v[1] = box->y2; |
|
- | 3230 | v[7] = box->y1; |
|
- | 3231 | v[8] = v[5] = v[2] = opacity; |
|
- | 3232 | } |
|
- | 3233 | ||
- | 3234 | sse2 fastcall static void |
|
- | 3235 | gen3_render_composite_spans_constant_thread__sse2__boxes(struct sna *sna, |
|
- | 3236 | const struct sna_composite_spans_op *op, |
|
- | 3237 | const struct sna_opacity_box *box, |
|
- | 3238 | int nbox) |
|
- | 3239 | { |
|
- | 3240 | DBG(("%s: nbox=%d, src=+(%d, %d), dst=+(%d, %d)\n", |
|
- | 3241 | __FUNCTION__, nbox, |
|
- | 3242 | op->base.src.offset[0], op->base.src.offset[1], |
|
- | 3243 | op->base.dst.x, op->base.dst.y)); |
|
- | 3244 | ||
- | 3245 | sna_vertex_lock(&sna->render); |
|
- | 3246 | do { |
|
- | 3247 | int nbox_this_time; |
|
- | 3248 | float *v; |
|
- | 3249 | ||
- | 3250 | nbox_this_time = gen3_get_rectangles(sna, &op->base, nbox); |
|
- | 3251 | assert(nbox_this_time); |
|
- | 3252 | nbox -= nbox_this_time; |
|
- | 3253 | ||
- | 3254 | v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3255 | sna->render.vertex_used += nbox_this_time * 9; |
|
- | 3256 | ||
- | 3257 | sna_vertex_acquire__locked(&sna->render); |
|
- | 3258 | sna_vertex_unlock(&sna->render); |
|
- | 3259 | ||
- | 3260 | do { |
|
- | 3261 | v[0] = box->box.x2; |
|
- | 3262 | v[6] = v[3] = box->box.x1; |
|
- | 3263 | v[4] = v[1] = box->box.y2; |
|
- | 3264 | v[7] = box->box.y1; |
|
- | 3265 | v[8] = v[5] = v[2] = box->alpha; |
|
- | 3266 | v += 9; |
|
- | 3267 | box++; |
|
- | 3268 | } while (--nbox_this_time); |
|
- | 3269 | ||
- | 3270 | sna_vertex_lock(&sna->render); |
|
- | 3271 | sna_vertex_release__locked(&sna->render); |
|
- | 3272 | } while (nbox); |
|
- | 3273 | sna_vertex_unlock(&sna->render); |
|
- | 3274 | } |
|
- | 3275 | ||
- | 3276 | sse2 fastcall static void |
|
- | 3277 | gen3_emit_composite_spans_primitive_constant__sse2__no_offset(struct sna *sna, |
|
- | 3278 | const struct sna_composite_spans_op *op, |
|
- | 3279 | const BoxRec *box, |
|
- | 3280 | float opacity) |
|
- | 3281 | { |
|
- | 3282 | float *v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3283 | sna->render.vertex_used += 9; |
|
- | 3284 | ||
- | 3285 | v[0] = box->x2; |
|
- | 3286 | v[6] = v[3] = box->x1; |
|
- | 3287 | v[4] = v[1] = box->y2; |
|
- | 3288 | v[7] = box->y1; |
|
- | 3289 | v[8] = v[5] = v[2] = opacity; |
|
- | 3290 | } |
|
- | 3291 | ||
- | 3292 | sse2 fastcall static void |
|
- | 3293 | gen3_emit_composite_spans_primitive_constant__sse2__no_offset__boxes(const struct sna_composite_spans_op *op, |
|
- | 3294 | const struct sna_opacity_box *b, |
|
- | 3295 | int nbox, float *v) |
|
- | 3296 | { |
|
- | 3297 | do { |
|
- | 3298 | v[0] = b->box.x2; |
|
- | 3299 | v[6] = v[3] = b->box.x1; |
|
- | 3300 | v[4] = v[1] = b->box.y2; |
|
- | 3301 | v[7] = b->box.y1; |
|
- | 3302 | v[8] = v[5] = v[2] = b->alpha; |
|
- | 3303 | ||
- | 3304 | v += 9; |
|
- | 3305 | b++; |
|
- | 3306 | } while (--nbox); |
|
- | 3307 | } |
|
- | 3308 | ||
- | 3309 | sse2 fastcall static void |
|
- | 3310 | gen3_emit_composite_spans_primitive_identity_source__sse2(struct sna *sna, |
|
- | 3311 | const struct sna_composite_spans_op *op, |
|
- | 3312 | const BoxRec *box, |
|
- | 3313 | float opacity) |
|
- | 3314 | { |
|
- | 3315 | float *v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3316 | sna->render.vertex_used += 15; |
|
- | 3317 | ||
- | 3318 | v[0] = op->base.dst.x + box->x2; |
|
- | 3319 | v[1] = op->base.dst.y + box->y2; |
|
- | 3320 | v[2] = (op->base.src.offset[0] + box->x2) * op->base.src.scale[0]; |
|
- | 3321 | v[3] = (op->base.src.offset[1] + box->y2) * op->base.src.scale[1]; |
|
- | 3322 | v[4] = opacity; |
|
- | 3323 | ||
- | 3324 | v[5] = op->base.dst.x + box->x1; |
|
- | 3325 | v[6] = v[1]; |
|
- | 3326 | v[7] = (op->base.src.offset[0] + box->x1) * op->base.src.scale[0]; |
|
- | 3327 | v[8] = v[3]; |
|
- | 3328 | v[9] = opacity; |
|
- | 3329 | ||
- | 3330 | v[10] = v[5]; |
|
- | 3331 | v[11] = op->base.dst.y + box->y1; |
|
- | 3332 | v[12] = v[7]; |
|
- | 3333 | v[13] = (op->base.src.offset[1] + box->y1) * op->base.src.scale[1]; |
|
- | 3334 | v[14] = opacity; |
|
- | 3335 | } |
|
- | 3336 | ||
- | 3337 | sse2 fastcall static void |
|
- | 3338 | gen3_emit_composite_spans_primitive_identity_source__sse2__boxes(const struct sna_composite_spans_op *op, |
|
- | 3339 | const struct sna_opacity_box *b, |
|
- | 3340 | int nbox, |
|
- | 3341 | float *v) |
|
- | 3342 | { |
|
- | 3343 | do { |
|
- | 3344 | v[0] = op->base.dst.x + b->box.x2; |
|
- | 3345 | v[1] = op->base.dst.y + b->box.y2; |
|
- | 3346 | v[2] = (op->base.src.offset[0] + b->box.x2) * op->base.src.scale[0]; |
|
- | 3347 | v[3] = (op->base.src.offset[1] + b->box.y2) * op->base.src.scale[1]; |
|
- | 3348 | v[4] = b->alpha; |
|
- | 3349 | ||
- | 3350 | v[5] = op->base.dst.x + b->box.x1; |
|
- | 3351 | v[6] = v[1]; |
|
- | 3352 | v[7] = (op->base.src.offset[0] + b->box.x1) * op->base.src.scale[0]; |
|
- | 3353 | v[8] = v[3]; |
|
- | 3354 | v[9] = b->alpha; |
|
- | 3355 | ||
- | 3356 | v[10] = v[5]; |
|
- | 3357 | v[11] = op->base.dst.y + b->box.y1; |
|
- | 3358 | v[12] = v[7]; |
|
- | 3359 | v[13] = (op->base.src.offset[1] + b->box.y1) * op->base.src.scale[1]; |
|
- | 3360 | v[14] = b->alpha; |
|
- | 3361 | ||
- | 3362 | v += 15; |
|
- | 3363 | b++; |
|
- | 3364 | } while (--nbox); |
|
- | 3365 | } |
|
- | 3366 | sse2 fastcall static void |
|
- | 3367 | gen3_emit_composite_spans_primitive_affine_source__sse2(struct sna *sna, |
|
- | 3368 | const struct sna_composite_spans_op *op, |
|
- | 3369 | const BoxRec *box, |
|
- | 3370 | float opacity) |
|
- | 3371 | { |
|
- | 3372 | PictTransform *transform = op->base.src.transform; |
|
- | 3373 | float *v; |
|
- | 3374 | ||
- | 3375 | v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3376 | sna->render.vertex_used += 15; |
|
- | 3377 | ||
- | 3378 | v[0] = op->base.dst.x + box->x2; |
|
- | 3379 | v[6] = v[1] = op->base.dst.y + box->y2; |
|
- | 3380 | v[10] = v[5] = op->base.dst.x + box->x1; |
|
- | 3381 | v[11] = op->base.dst.y + box->y1; |
|
- | 3382 | v[14] = v[9] = v[4] = opacity; |
|
- | 3383 | ||
- | 3384 | _sna_get_transformed_scaled((int)op->base.src.offset[0] + box->x2, |
|
- | 3385 | (int)op->base.src.offset[1] + box->y2, |
|
- | 3386 | transform, op->base.src.scale, |
|
- | 3387 | &v[2], &v[3]); |
|
- | 3388 | ||
- | 3389 | _sna_get_transformed_scaled((int)op->base.src.offset[0] + box->x1, |
|
- | 3390 | (int)op->base.src.offset[1] + box->y2, |
|
- | 3391 | transform, op->base.src.scale, |
|
- | 3392 | &v[7], &v[8]); |
|
- | 3393 | ||
- | 3394 | _sna_get_transformed_scaled((int)op->base.src.offset[0] + box->x1, |
|
- | 3395 | (int)op->base.src.offset[1] + box->y1, |
|
- | 3396 | transform, op->base.src.scale, |
|
- | 3397 | &v[12], &v[13]); |
|
- | 3398 | } |
|
- | 3399 | ||
- | 3400 | sse2 fastcall static void |
|
- | 3401 | gen3_emit_composite_spans_primitive_affine_source__sse2__boxes(const struct sna_composite_spans_op *op, |
|
- | 3402 | const struct sna_opacity_box *b, |
|
- | 3403 | int nbox, |
|
- | 3404 | float *v) |
|
- | 3405 | { |
|
- | 3406 | PictTransform *transform = op->base.src.transform; |
|
- | 3407 | ||
- | 3408 | do { |
|
- | 3409 | v[0] = op->base.dst.x + b->box.x2; |
|
- | 3410 | v[6] = v[1] = op->base.dst.y + b->box.y2; |
|
- | 3411 | v[10] = v[5] = op->base.dst.x + b->box.x1; |
|
- | 3412 | v[11] = op->base.dst.y + b->box.y1; |
|
- | 3413 | v[14] = v[9] = v[4] = b->alpha; |
|
- | 3414 | ||
- | 3415 | _sna_get_transformed_scaled((int)op->base.src.offset[0] + b->box.x2, |
|
- | 3416 | (int)op->base.src.offset[1] + b->box.y2, |
|
- | 3417 | transform, op->base.src.scale, |
|
- | 3418 | &v[2], &v[3]); |
|
- | 3419 | ||
- | 3420 | _sna_get_transformed_scaled((int)op->base.src.offset[0] + b->box.x1, |
|
- | 3421 | (int)op->base.src.offset[1] + b->box.y2, |
|
- | 3422 | transform, op->base.src.scale, |
|
- | 3423 | &v[7], &v[8]); |
|
- | 3424 | ||
- | 3425 | _sna_get_transformed_scaled((int)op->base.src.offset[0] + b->box.x1, |
|
- | 3426 | (int)op->base.src.offset[1] + b->box.y1, |
|
- | 3427 | transform, op->base.src.scale, |
|
- | 3428 | &v[12], &v[13]); |
|
- | 3429 | v += 15; |
|
- | 3430 | b++; |
|
- | 3431 | } while (--nbox); |
|
- | 3432 | } |
|
- | 3433 | ||
- | 3434 | sse2 fastcall static void |
|
- | 3435 | gen3_emit_composite_spans_primitive_identity_gradient__sse2(struct sna *sna, |
|
- | 3436 | const struct sna_composite_spans_op *op, |
|
- | 3437 | const BoxRec *box, |
|
- | 3438 | float opacity) |
|
- | 3439 | { |
|
- | 3440 | float *v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3441 | sna->render.vertex_used += 15; |
|
- | 3442 | ||
- | 3443 | v[0] = op->base.dst.x + box->x2; |
|
- | 3444 | v[1] = op->base.dst.y + box->y2; |
|
- | 3445 | v[2] = op->base.src.offset[0] + box->x2; |
|
- | 3446 | v[3] = op->base.src.offset[1] + box->y2; |
|
- | 3447 | v[4] = opacity; |
|
- | 3448 | ||
- | 3449 | v[5] = op->base.dst.x + box->x1; |
|
- | 3450 | v[6] = v[1]; |
|
- | 3451 | v[7] = op->base.src.offset[0] + box->x1; |
|
- | 3452 | v[8] = v[3]; |
|
- | 3453 | v[9] = opacity; |
|
- | 3454 | ||
- | 3455 | v[10] = v[5]; |
|
- | 3456 | v[11] = op->base.dst.y + box->y1; |
|
- | 3457 | v[12] = v[7]; |
|
- | 3458 | v[13] = op->base.src.offset[1] + box->y1; |
|
- | 3459 | v[14] = opacity; |
|
- | 3460 | } |
|
- | 3461 | ||
- | 3462 | sse2 fastcall static void |
|
- | 3463 | gen3_emit_composite_spans_primitive_identity_gradient__sse2__boxes(const struct sna_composite_spans_op *op, |
|
- | 3464 | const struct sna_opacity_box *b, |
|
- | 3465 | int nbox, |
|
- | 3466 | float *v) |
|
- | 3467 | { |
|
- | 3468 | do { |
|
- | 3469 | v[0] = op->base.dst.x + b->box.x2; |
|
- | 3470 | v[1] = op->base.dst.y + b->box.y2; |
|
- | 3471 | v[2] = op->base.src.offset[0] + b->box.x2; |
|
- | 3472 | v[3] = op->base.src.offset[1] + b->box.y2; |
|
- | 3473 | v[4] = b->alpha; |
|
- | 3474 | ||
- | 3475 | v[5] = op->base.dst.x + b->box.x1; |
|
- | 3476 | v[6] = v[1]; |
|
- | 3477 | v[7] = op->base.src.offset[0] + b->box.x1; |
|
- | 3478 | v[8] = v[3]; |
|
- | 3479 | v[9] = b->alpha; |
|
- | 3480 | ||
- | 3481 | v[10] = v[5]; |
|
- | 3482 | v[11] = op->base.dst.y + b->box.y1; |
|
- | 3483 | v[12] = v[7]; |
|
- | 3484 | v[13] = op->base.src.offset[1] + b->box.y1; |
|
- | 3485 | v[14] = b->alpha; |
|
- | 3486 | ||
- | 3487 | v += 15; |
|
- | 3488 | b++; |
|
- | 3489 | } while (--nbox); |
|
- | 3490 | } |
|
- | 3491 | ||
- | 3492 | sse2 fastcall static void |
|
- | 3493 | gen3_emit_composite_spans_primitive_affine_gradient__sse2(struct sna *sna, |
|
- | 3494 | const struct sna_composite_spans_op *op, |
|
- | 3495 | const BoxRec *box, |
|
- | 3496 | float opacity) |
|
- | 3497 | { |
|
- | 3498 | PictTransform *transform = op->base.src.transform; |
|
- | 3499 | float *v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3500 | sna->render.vertex_used += 15; |
|
- | 3501 | ||
- | 3502 | v[0] = op->base.dst.x + box->x2; |
|
- | 3503 | v[1] = op->base.dst.y + box->y2; |
|
- | 3504 | _sna_get_transformed_scaled(op->base.src.offset[0] + box->x2, |
|
- | 3505 | op->base.src.offset[1] + box->y2, |
|
- | 3506 | transform, op->base.src.scale, |
|
- | 3507 | &v[2], &v[3]); |
|
- | 3508 | v[4] = opacity; |
|
- | 3509 | ||
- | 3510 | v[5] = op->base.dst.x + box->x1; |
|
- | 3511 | v[6] = v[1]; |
|
- | 3512 | _sna_get_transformed_scaled(op->base.src.offset[0] + box->x1, |
|
- | 3513 | op->base.src.offset[1] + box->y2, |
|
- | 3514 | transform, op->base.src.scale, |
|
- | 3515 | &v[7], &v[8]); |
|
- | 3516 | v[9] = opacity; |
|
- | 3517 | ||
- | 3518 | v[10] = v[5]; |
|
- | 3519 | v[11] = op->base.dst.y + box->y1; |
|
- | 3520 | _sna_get_transformed_scaled(op->base.src.offset[0] + box->x1, |
|
- | 3521 | op->base.src.offset[1] + box->y1, |
|
- | 3522 | transform, op->base.src.scale, |
|
- | 3523 | &v[12], &v[13]); |
|
- | 3524 | v[14] = opacity; |
|
- | 3525 | } |
|
- | 3526 | ||
- | 3527 | sse2 fastcall static void |
|
- | 3528 | gen3_emit_composite_spans_primitive_affine_gradient__sse2__boxes(const struct sna_composite_spans_op *op, |
|
- | 3529 | const struct sna_opacity_box *b, |
|
- | 3530 | int nbox, |
|
- | 3531 | float *v) |
|
- | 3532 | { |
|
- | 3533 | PictTransform *transform = op->base.src.transform; |
|
- | 3534 | ||
- | 3535 | do { |
|
- | 3536 | v[0] = op->base.dst.x + b->box.x2; |
|
- | 3537 | v[1] = op->base.dst.y + b->box.y2; |
|
- | 3538 | _sna_get_transformed_scaled(op->base.src.offset[0] + b->box.x2, |
|
- | 3539 | op->base.src.offset[1] + b->box.y2, |
|
- | 3540 | transform, op->base.src.scale, |
|
- | 3541 | &v[2], &v[3]); |
|
- | 3542 | v[4] = b->alpha; |
|
- | 3543 | ||
- | 3544 | v[5] = op->base.dst.x + b->box.x1; |
|
Line -... | Line 3545... | ||
- | 3545 | v[6] = v[1]; |
|
- | 3546 | _sna_get_transformed_scaled(op->base.src.offset[0] + b->box.x1, |
|
- | 3547 | op->base.src.offset[1] + b->box.y2, |
|
- | 3548 | transform, op->base.src.scale, |
|
- | 3549 | &v[7], &v[8]); |
|
- | 3550 | v[9] = b->alpha; |
|
- | 3551 | ||
- | 3552 | v[10] = v[5]; |
|
- | 3553 | v[11] = op->base.dst.y + b->box.y1; |
|
- | 3554 | _sna_get_transformed_scaled(op->base.src.offset[0] + b->box.x1, |
|
- | 3555 | op->base.src.offset[1] + b->box.y1, |
|
- | 3556 | transform, op->base.src.scale, |
|
- | 3557 | &v[12], &v[13]); |
|
- | 3558 | v[14] = b->alpha; |
|
- | 3559 | v += 15; |
|
- | 3560 | b++; |
|
- | 3561 | } while (--nbox); |
|
- | 3562 | } |
|
- | 3563 | #endif |
|
- | 3564 | ||
- | 3565 | fastcall static void |
|
- | 3566 | gen3_emit_composite_spans_primitive_affine_gradient(struct sna *sna, |
|
- | 3567 | const struct sna_composite_spans_op *op, |
|
- | 3568 | const BoxRec *box, |
|
- | 3569 | float opacity) |
|
- | 3570 | { |
|
- | 3571 | PictTransform *transform = op->base.src.transform; |
|
- | 3572 | float *v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3573 | sna->render.vertex_used += 15; |
|
- | 3574 | ||
- | 3575 | v[0] = op->base.dst.x + box->x2; |
|
- | 3576 | v[1] = op->base.dst.y + box->y2; |
|
- | 3577 | _sna_get_transformed_scaled(op->base.src.offset[0] + box->x2, |
|
- | 3578 | op->base.src.offset[1] + box->y2, |
|
Line -... | Line 3579... | ||
- | 3579 | transform, op->base.src.scale, |
|
- | 3580 | &v[2], &v[3]); |
|
- | 3581 | v[4] = opacity; |
|
- | 3582 | ||
- | 3583 | v[5] = op->base.dst.x + box->x1; |
|
- | 3584 | v[6] = v[1]; |
|
- | 3585 | _sna_get_transformed_scaled(op->base.src.offset[0] + box->x1, |
|
- | 3586 | op->base.src.offset[1] + box->y2, |
|
- | 3587 | transform, op->base.src.scale, |
|
- | 3588 | &v[7], &v[8]); |
|
- | 3589 | v[9] = opacity; |
|
- | 3590 | ||
- | 3591 | v[10] = v[5]; |
|
- | 3592 | v[11] = op->base.dst.y + box->y1; |
|
- | 3593 | _sna_get_transformed_scaled(op->base.src.offset[0] + box->x1, |
|
- | 3594 | op->base.src.offset[1] + box->y1, |
|
- | 3595 | transform, op->base.src.scale, |
|
- | 3596 | &v[12], &v[13]); |
|
- | 3597 | v[14] = opacity; |
|
- | 3598 | } |
|
- | 3599 | ||
- | 3600 | fastcall static void |
|
- | 3601 | gen3_emit_composite_spans_primitive_affine_gradient__boxes(const struct sna_composite_spans_op *op, |
|
- | 3602 | const struct sna_opacity_box *b, |
|
- | 3603 | int nbox, |
|
- | 3604 | float *v) |
|
- | 3605 | { |
|
- | 3606 | PictTransform *transform = op->base.src.transform; |
|
- | 3607 | ||
- | 3608 | do { |
|
- | 3609 | v[0] = op->base.dst.x + b->box.x2; |
|
- | 3610 | v[1] = op->base.dst.y + b->box.y2; |
|
- | 3611 | _sna_get_transformed_scaled(op->base.src.offset[0] + b->box.x2, |
|
- | 3612 | op->base.src.offset[1] + b->box.y2, |
|
- | 3613 | transform, op->base.src.scale, |
|
- | 3614 | &v[2], &v[3]); |
|
Line -... | Line 3615... | ||
- | 3615 | v[4] = b->alpha; |
|
- | 3616 | ||
- | 3617 | v[5] = op->base.dst.x + b->box.x1; |
|
- | 3618 | v[6] = v[1]; |
|
- | 3619 | _sna_get_transformed_scaled(op->base.src.offset[0] + b->box.x1, |
|
- | 3620 | op->base.src.offset[1] + b->box.y2, |
|
- | 3621 | transform, op->base.src.scale, |
|
- | 3622 | &v[7], &v[8]); |
|
- | 3623 | v[9] = b->alpha; |
|
- | 3624 | ||
- | 3625 | v[10] = v[5]; |
|
- | 3626 | v[11] = op->base.dst.y + b->box.y1; |
|
- | 3627 | _sna_get_transformed_scaled(op->base.src.offset[0] + b->box.x1, |
|
- | 3628 | op->base.src.offset[1] + b->box.y1, |
|
- | 3629 | transform, op->base.src.scale, |
|
- | 3630 | &v[12], &v[13]); |
|
Line -... | Line 3631... | ||
- | 3631 | v[14] = b->alpha; |
|
- | 3632 | v += 15; |
|
- | 3633 | b++; |
|
- | 3634 | } while (--nbox); |
|
- | 3635 | } |
|
- | 3636 | ||
- | 3637 | fastcall static void |
|
- | 3638 | gen3_emit_composite_spans_primitive(struct sna *sna, |
|
- | 3639 | const struct sna_composite_spans_op *op, |
|
- | 3640 | const BoxRec *box, |
|
- | 3641 | float opacity) |
|
- | 3642 | { |
|
- | 3643 | gen3_emit_composite_spans_vertex(sna, op, |
|
- | 3644 | box->x2, box->y2, |
|
- | 3645 | opacity); |
|
- | 3646 | gen3_emit_composite_spans_vertex(sna, op, |
|
- | 3647 | box->x1, box->y2, |
|
- | 3648 | opacity); |
|
- | 3649 | gen3_emit_composite_spans_vertex(sna, op, |
|
- | 3650 | box->x1, box->y1, |
|
- | 3651 | opacity); |
|
- | 3652 | } |
|
- | 3653 | ||
- | 3654 | fastcall static void |
|
- | 3655 | gen3_render_composite_spans_constant_box(struct sna *sna, |
|
- | 3656 | const struct sna_composite_spans_op *op, |
|
Line -... | Line 3657... | ||
- | 3657 | const BoxRec *box, float opacity) |
|
- | 3658 | { |
|
- | 3659 | float *v; |
|
- | 3660 | DBG(("%s: src=+(%d, %d), opacity=%f, dst=+(%d, %d), box=(%d, %d) x (%d, %d)\n", |
|
- | 3661 | __FUNCTION__, |
|
- | 3662 | op->base.src.offset[0], op->base.src.offset[1], |
|
- | 3663 | opacity, |
|
- | 3664 | op->base.dst.x, op->base.dst.y, |
|
- | 3665 | box->x1, box->y1, |
|
- | 3666 | box->x2 - box->x1, |
|
- | 3667 | box->y2 - box->y1)); |
|
- | 3668 | ||
- | 3669 | gen3_get_rectangles(sna, &op->base, 1); |
|
- | 3670 | ||
- | 3671 | v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3672 | sna->render.vertex_used += 9; |
|
- | 3673 | ||
- | 3674 | v[0] = box->x2; |
|
- | 3675 | v[6] = v[3] = box->x1; |
|
- | 3676 | v[4] = v[1] = box->y2; |
|
- | 3677 | v[7] = box->y1; |
|
- | 3678 | v[8] = v[5] = v[2] = opacity; |
|
- | 3679 | } |
|
- | 3680 | ||
- | 3681 | fastcall static void |
|
- | 3682 | gen3_render_composite_spans_constant_thread_boxes(struct sna *sna, |
|
- | 3683 | const struct sna_composite_spans_op *op, |
|
- | 3684 | const struct sna_opacity_box *box, |
|
- | 3685 | int nbox) |
|
- | 3686 | { |
|
- | 3687 | DBG(("%s: nbox=%d, src=+(%d, %d), dst=+(%d, %d)\n", |
|
- | 3688 | __FUNCTION__, nbox, |
|
- | 3689 | op->base.src.offset[0], op->base.src.offset[1], |
|
- | 3690 | op->base.dst.x, op->base.dst.y)); |
|
- | 3691 | ||
- | 3692 | sna_vertex_lock(&sna->render); |
|
- | 3693 | do { |
|
- | 3694 | int nbox_this_time; |
|
- | 3695 | float *v; |
|
- | 3696 | ||
- | 3697 | nbox_this_time = gen3_get_rectangles(sna, &op->base, nbox); |
|
Line -... | Line 3698... | ||
- | 3698 | assert(nbox_this_time); |
|
- | 3699 | nbox -= nbox_this_time; |
|
- | 3700 | ||
- | 3701 | v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3702 | sna->render.vertex_used += nbox_this_time * 9; |
|
- | 3703 | ||
- | 3704 | sna_vertex_acquire__locked(&sna->render); |
|
- | 3705 | sna_vertex_unlock(&sna->render); |
|
- | 3706 | ||
- | 3707 | do { |
|
- | 3708 | v[0] = box->box.x2; |
|
- | 3709 | v[6] = v[3] = box->box.x1; |
|
- | 3710 | v[4] = v[1] = box->box.y2; |
|
Line -... | Line 3711... | ||
- | 3711 | v[7] = box->box.y1; |
|
- | 3712 | v[8] = v[5] = v[2] = box->alpha; |
|
- | 3713 | v += 9; |
|
Line -... | Line 3714... | ||
- | 3714 | box++; |
|
- | 3715 | } while (--nbox_this_time); |
|
- | 3716 | ||
- | 3717 | sna_vertex_lock(&sna->render); |
|
- | 3718 | sna_vertex_release__locked(&sna->render); |
|
- | 3719 | } while (nbox); |
|
- | 3720 | sna_vertex_unlock(&sna->render); |
|
- | 3721 | } |
|
- | 3722 | ||
- | 3723 | fastcall static void |
|
- | 3724 | gen3_render_composite_spans_box(struct sna *sna, |
|
- | 3725 | const struct sna_composite_spans_op *op, |
|
- | 3726 | const BoxRec *box, float opacity) |
|
- | 3727 | { |
|
- | 3728 | DBG(("%s: src=+(%d, %d), opacity=%f, dst=+(%d, %d), box=(%d, %d) x (%d, %d)\n", |
|
- | 3729 | __FUNCTION__, |
|
- | 3730 | op->base.src.offset[0], op->base.src.offset[1], |
|
- | 3731 | opacity, |
|
- | 3732 | op->base.dst.x, op->base.dst.y, |
|
- | 3733 | box->x1, box->y1, |
|
- | 3734 | box->x2 - box->x1, |
|
- | 3735 | box->y2 - box->y1)); |
|
- | 3736 | ||
- | 3737 | gen3_get_rectangles(sna, &op->base, 1); |
|
- | 3738 | op->prim_emit(sna, op, box, opacity); |
|
- | 3739 | } |
|
- | 3740 | ||
- | 3741 | static void |
|
Line -... | Line 3742... | ||
- | 3742 | gen3_render_composite_spans_boxes(struct sna *sna, |
|
- | 3743 | const struct sna_composite_spans_op *op, |
|
- | 3744 | const BoxRec *box, int nbox, |
|
- | 3745 | float opacity) |
|
- | 3746 | { |
|
- | 3747 | DBG(("%s: nbox=%d, src=+(%d, %d), opacity=%f, dst=+(%d, %d)\n", |
|
- | 3748 | __FUNCTION__, nbox, |
|
- | 3749 | op->base.src.offset[0], op->base.src.offset[1], |
|
- | 3750 | opacity, |
|
- | 3751 | op->base.dst.x, op->base.dst.y)); |
|
- | 3752 | ||
- | 3753 | do { |
|
- | 3754 | int nbox_this_time; |
|
- | 3755 | ||
- | 3756 | nbox_this_time = gen3_get_rectangles(sna, &op->base, nbox); |
|
- | 3757 | nbox -= nbox_this_time; |
|
- | 3758 | ||
- | 3759 | do { |
|
- | 3760 | DBG((" %s: (%d, %d) x (%d, %d)\n", __FUNCTION__, |
|
- | 3761 | box->x1, box->y1, |
|
- | 3762 | box->x2 - box->x1, |
|
- | 3763 | box->y2 - box->y1)); |
|
- | 3764 | ||
- | 3765 | op->prim_emit(sna, op, box++, opacity); |
|
- | 3766 | } while (--nbox_this_time); |
|
- | 3767 | } while (nbox); |
|
- | 3768 | } |
|
- | 3769 | ||
- | 3770 | fastcall static void |
|
- | 3771 | gen3_render_composite_spans_boxes__thread(struct sna *sna, |
|
- | 3772 | const struct sna_composite_spans_op *op, |
|
- | 3773 | const struct sna_opacity_box *box, |
|
- | 3774 | int nbox) |
|
- | 3775 | { |
|
Line -... | Line 3776... | ||
- | 3776 | DBG(("%s: nbox=%d, src=+(%d, %d), dst=+(%d, %d)\n", |
|
- | 3777 | __FUNCTION__, nbox, |
|
- | 3778 | op->base.src.offset[0], op->base.src.offset[1], |
|
- | 3779 | op->base.dst.x, op->base.dst.y)); |
|
- | 3780 | ||
- | 3781 | sna_vertex_lock(&sna->render); |
|
Line -... | Line 3782... | ||
- | 3782 | do { |
|
Line -... | Line 3783... | ||
- | 3783 | int nbox_this_time; |
|
- | 3784 | float *v; |
|
Line -... | Line 3785... | ||
- | 3785 | ||
- | 3786 | nbox_this_time = gen3_get_rectangles(sna, &op->base, nbox); |
|
Line -... | Line 3787... | ||
- | 3787 | assert(nbox_this_time); |
|
- | 3788 | nbox -= nbox_this_time; |
|
- | 3789 | ||
- | 3790 | v = sna->render.vertices + sna->render.vertex_used; |
|
- | 3791 | sna->render.vertex_used += nbox_this_time * op->base.floats_per_rect; |
|
- | 3792 | ||
- | 3793 | sna_vertex_acquire__locked(&sna->render); |
|
Line -... | Line 3794... | ||
- | 3794 | sna_vertex_unlock(&sna->render); |
|
- | 3795 | ||
Line -... | Line 3796... | ||
- | 3796 | op->emit_boxes(op, box, nbox_this_time, v); |
|
- | 3797 | box += nbox_this_time; |
|
- | 3798 | ||
- | 3799 | sna_vertex_lock(&sna->render); |
|
- | 3800 | sna_vertex_release__locked(&sna->render); |
|
- | 3801 | } while (nbox); |
|
Line -... | Line 3802... | ||
- | 3802 | sna_vertex_unlock(&sna->render); |
|
- | 3803 | } |
|
Line -... | Line 3804... | ||
- | 3804 | ||
- | 3805 | fastcall static void |
|
- | 3806 | gen3_render_composite_spans_done(struct sna *sna, |
|
- | 3807 | const struct sna_composite_spans_op *op) |
|
- | 3808 | { |
|
- | 3809 | if (sna->render.vertex_offset) |
|
- | 3810 | gen3_vertex_flush(sna); |
|
- | 3811 | ||
- | 3812 | DBG(("%s()\n", __FUNCTION__)); |
|
- | 3813 | ||
- | 3814 | if (op->base.src.bo) |
|
- | 3815 | kgem_bo_destroy(&sna->kgem, op->base.src.bo); |
|
Line -... | Line 3816... | ||
- | 3816 | ||
- | 3817 | sna_render_composite_redirect_done(sna, &op->base); |
|
Line -... | Line 3818... | ||
- | 3818 | } |
|
Line -... | Line 3819... | ||
- | 3819 | ||
- | 3820 | static bool |
|
- | 3821 | gen3_check_composite_spans(struct sna *sna, |
|
- | 3822 | uint8_t op, PicturePtr src, PicturePtr dst, |
|
- | 3823 | int16_t width, int16_t height, unsigned flags) |
|
- | 3824 | { |
|
- | 3825 | if (op >= ARRAY_SIZE(gen3_blend_op)) |
|
Line -... | Line 3826... | ||
- | 3826 | return false; |
|
- | 3827 | ||
- | 3828 | if (gen3_composite_fallback(sna, op, src, NULL, dst)) |
|
- | 3829 | return false; |
|
- | 3830 | ||
- | 3831 | if (need_tiling(sna, width, height) && |
|
Line -... | Line 3832... | ||
- | 3832 | !is_gpu(sna, dst->pDrawable, PREFER_GPU_SPANS)) { |
|
- | 3833 | DBG(("%s: fallback, tiled operation not on GPU\n", |
|
- | 3834 | __FUNCTION__)); |
|
- | 3835 | return false; |
|
- | 3836 | } |
|
- | 3837 | ||
- | 3838 | return true; |
|
- | 3839 | } |
|
- | 3840 | ||
Line -... | Line 3841... | ||
- | 3841 | static bool |
|
- | 3842 | gen3_render_composite_spans(struct sna *sna, |
|
- | 3843 | uint8_t op, |
|
- | 3844 | PicturePtr src, |
|
- | 3845 | PicturePtr dst, |
|
- | 3846 | int16_t src_x, int16_t src_y, |
|
- | 3847 | int16_t dst_x, int16_t dst_y, |
|
- | 3848 | int16_t width, int16_t height, |
|
- | 3849 | unsigned flags, |
|
- | 3850 | struct sna_composite_spans_op *tmp) |
|
- | 3851 | { |
|
- | 3852 | bool no_offset; |
|
- | 3853 | ||
- | 3854 | DBG(("%s(src=(%d, %d), dst=(%d, %d), size=(%d, %d))\n", __FUNCTION__, |
|
- | 3855 | src_x, src_y, dst_x, dst_y, width, height)); |
|
- | 3856 | ||
- | 3857 | assert(gen3_check_composite_spans(sna, op, src, dst, width, height, flags)); |
|
- | 3858 | ||
Line -... | Line 3859... | ||
- | 3859 | if (need_tiling(sna, width, height)) { |
|
- | 3860 | DBG(("%s: tiling, operation (%dx%d) too wide for pipeline\n", |
|
Line -... | Line 3861... | ||
- | 3861 | __FUNCTION__, width, height)); |
|
- | 3862 | return sna_tiling_composite_spans(op, src, dst, |
|
- | 3863 | src_x, src_y, dst_x, dst_y, |
|
- | 3864 | width, height, flags, tmp); |
|
- | 3865 | } |
|
- | 3866 | ||
- | 3867 | if (!gen3_composite_set_target(sna, &tmp->base, dst, |
|
- | 3868 | dst_x, dst_y, width, height)) { |
|
- | 3869 | DBG(("%s: unable to set render target\n", |
|
- | 3870 | __FUNCTION__)); |
|
- | 3871 | return false; |
|
- | 3872 | } |
|
- | 3873 | ||
- | 3874 | tmp->base.op = op; |
|
- | 3875 | tmp->base.rb_reversed = gen3_dst_rb_reversed(tmp->base.dst.format); |
|
- | 3876 | if (too_large(tmp->base.dst.width, tmp->base.dst.height) || |
|
- | 3877 | !gen3_check_pitch_3d(tmp->base.dst.bo)) { |
|
- | 3878 | if (!sna_render_composite_redirect(sna, &tmp->base, |
|
- | 3879 | dst_x, dst_y, width, height, |
|
- | 3880 | true)) |
|
- | 3881 | return false; |
|
- | 3882 | } |
|
- | 3883 | ||
- | 3884 | tmp->base.src.u.gen3.type = SHADER_TEXTURE; |
|
- | 3885 | tmp->base.src.is_affine = true; |
|
- | 3886 | DBG(("%s: preparing source\n", __FUNCTION__)); |
|
- | 3887 | switch (gen3_composite_picture(sna, src, &tmp->base, &tmp->base.src, |
|
- | 3888 | src_x, src_y, |
|
- | 3889 | width, height, |
|
- | 3890 | dst_x, dst_y, |
|
- | 3891 | dst->polyMode == PolyModePrecise)) { |
|
- | 3892 | case -1: |
|
- | 3893 | goto cleanup_dst; |
|
- | 3894 | case 0: |
|
- | 3895 | tmp->base.src.u.gen3.type = SHADER_ZERO; |
|
- | 3896 | break; |
|
- | 3897 | case 1: |
|
- | 3898 | gen3_composite_channel_convert(&tmp->base.src); |
|
- | 3899 | break; |
|
- | 3900 | } |
|
- | 3901 | DBG(("%s: source type=%d\n", __FUNCTION__, tmp->base.src.u.gen3.type)); |
|
- | 3902 | ||
- | 3903 | if (tmp->base.src.u.gen3.type != SHADER_ZERO) |
|
- | 3904 | tmp->base.mask.u.gen3.type = SHADER_OPACITY; |
|
- | 3905 | ||
- | 3906 | no_offset = tmp->base.dst.x == 0 && tmp->base.dst.y == 0; |
|
- | 3907 | tmp->box = gen3_render_composite_spans_box; |
|
- | 3908 | tmp->boxes = gen3_render_composite_spans_boxes; |
|
- | 3909 | tmp->thread_boxes = gen3_render_composite_spans_boxes__thread; |
|
- | 3910 | tmp->done = gen3_render_composite_spans_done; |
|
- | 3911 | tmp->prim_emit = gen3_emit_composite_spans_primitive; |
|
- | 3912 | switch (tmp->base.src.u.gen3.type) { |
|
- | 3913 | case SHADER_NONE: |
|
- | 3914 | assert(0); |
|
- | 3915 | case SHADER_ZERO: |
|
- | 3916 | if (no_offset) { |
|
- | 3917 | tmp->prim_emit = gen3_emit_composite_spans_primitive_zero_no_offset; |
|
- | 3918 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_zero_no_offset__boxes; |
|
- | 3919 | } else { |
|
- | 3920 | tmp->prim_emit = gen3_emit_composite_spans_primitive_zero; |
|
- | 3921 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_zero__boxes; |
|
- | 3922 | } |
|
- | 3923 | break; |
|
- | 3924 | case SHADER_BLACK: |
|
- | 3925 | case SHADER_WHITE: |
|
- | 3926 | case SHADER_CONSTANT: |
|
- | 3927 | if (no_offset) { |
|
- | 3928 | #if defined(sse2) && !defined(__x86_64__) |
|
- | 3929 | if (sna->cpu_features & SSE2) { |
|
- | 3930 | tmp->box = gen3_render_composite_spans_constant_box__sse2; |
|
- | 3931 | tmp->thread_boxes = gen3_render_composite_spans_constant_thread__sse2__boxes; |
|
- | 3932 | tmp->prim_emit = gen3_emit_composite_spans_primitive_constant__sse2__no_offset; |
|
- | 3933 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_constant__sse2__no_offset__boxes; |
|
- | 3934 | } else |
|
- | 3935 | #endif |
|
- | 3936 | { |
|
- | 3937 | tmp->box = gen3_render_composite_spans_constant_box; |
|
- | 3938 | tmp->thread_boxes = gen3_render_composite_spans_constant_thread_boxes; |
|
- | 3939 | tmp->prim_emit = gen3_emit_composite_spans_primitive_constant_no_offset; |
|
- | 3940 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_constant_no_offset__boxes; |
|
- | 3941 | } |
|
- | 3942 | } else { |
|
- | 3943 | #if defined(sse2) && !defined(__x86_64__) |
|
- | 3944 | if (sna->cpu_features & SSE2) { |
|
- | 3945 | tmp->prim_emit = gen3_emit_composite_spans_primitive_constant__sse2; |
|
- | 3946 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_constant__sse2__boxes; |
|
- | 3947 | } else |
|
- | 3948 | #endif |
|
- | 3949 | { |
|
- | 3950 | tmp->prim_emit = gen3_emit_composite_spans_primitive_constant; |
|
- | 3951 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_constant__boxes; |
|
- | 3952 | } |
|
- | 3953 | } |
|
- | 3954 | break; |
|
- | 3955 | case SHADER_LINEAR: |
|
- | 3956 | case SHADER_RADIAL: |
|
- | 3957 | if (tmp->base.src.transform == NULL) { |
|
- | 3958 | #if defined(sse2) && !defined(__x86_64__) |
|
- | 3959 | if (sna->cpu_features & SSE2) { |
|
- | 3960 | tmp->prim_emit = gen3_emit_composite_spans_primitive_identity_gradient__sse2; |
|
- | 3961 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_identity_gradient__sse2__boxes; |
|
- | 3962 | } else |
|
- | 3963 | #endif |
|
- | 3964 | { |
|
- | 3965 | tmp->prim_emit = gen3_emit_composite_spans_primitive_identity_gradient; |
|
- | 3966 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_identity_gradient__boxes; |
|
Line -... | Line 3967... | ||
- | 3967 | } |
|
Line -... | Line 3968... | ||
- | 3968 | } else if (tmp->base.src.is_affine) { |
|
- | 3969 | tmp->base.src.scale[1] = tmp->base.src.scale[0] = 1. / tmp->base.src.transform->matrix[2][2]; |
|
- | 3970 | #if defined(sse2) && !defined(__x86_64__) |
|
- | 3971 | if (sna->cpu_features & SSE2) { |
|
- | 3972 | tmp->prim_emit = gen3_emit_composite_spans_primitive_affine_gradient__sse2; |
|
- | 3973 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_affine_gradient__sse2__boxes; |
|
Line -... | Line 3974... | ||
- | 3974 | } else |
|
- | 3975 | #endif |
|
- | 3976 | { |
|
- | 3977 | tmp->prim_emit = gen3_emit_composite_spans_primitive_affine_gradient; |
|
- | 3978 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_affine_gradient__boxes; |
|
- | 3979 | } |
|
- | 3980 | } |
|
- | 3981 | break; |
|
- | 3982 | case SHADER_TEXTURE: |
|
Line -... | Line 3983... | ||
- | 3983 | if (tmp->base.src.transform == NULL) { |
|
- | 3984 | #if defined(sse2) && !defined(__x86_64__) |
|
- | 3985 | if (sna->cpu_features & SSE2) { |
|
Line -... | Line 3986... | ||
- | 3986 | tmp->prim_emit = gen3_emit_composite_spans_primitive_identity_source__sse2; |
|
- | 3987 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_identity_source__sse2__boxes; |
|
- | 3988 | } else |
|
- | 3989 | #endif |
|
- | 3990 | { |
|
- | 3991 | tmp->prim_emit = gen3_emit_composite_spans_primitive_identity_source; |
|
- | 3992 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_identity_source__boxes; |
|
- | 3993 | } |
|
Line -... | Line 3994... | ||
- | 3994 | } else if (tmp->base.src.is_affine) { |
|
- | 3995 | tmp->base.src.scale[0] /= tmp->base.src.transform->matrix[2][2]; |
|
- | 3996 | tmp->base.src.scale[1] /= tmp->base.src.transform->matrix[2][2]; |
|
- | 3997 | #if defined(sse2) && !defined(__x86_64__) |
|
- | 3998 | if (sna->cpu_features & SSE2) { |
|
- | 3999 | tmp->prim_emit = gen3_emit_composite_spans_primitive_affine_source__sse2; |
|
- | 4000 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_affine_source__sse2__boxes; |
|
- | 4001 | } else |
|
- | 4002 | #endif |
|
- | 4003 | { |
|
- | 4004 | tmp->prim_emit = gen3_emit_composite_spans_primitive_affine_source; |
|
Line -... | Line 4005... | ||
- | 4005 | tmp->emit_boxes = gen3_emit_composite_spans_primitive_affine_source__boxes; |
|
- | 4006 | } |
|
Line -... | Line 4007... | ||
- | 4007 | } |
|
- | 4008 | break; |
|
- | 4009 | } |
|
- | 4010 | if (tmp->emit_boxes == NULL) |
|
- | 4011 | tmp->thread_boxes = NULL; |
|
- | 4012 | ||
- | 4013 | tmp->base.mask.bo = NULL; |
|
- | 4014 | ||
- | 4015 | tmp->base.floats_per_vertex = 2; |
|
- | 4016 | if (!is_constant_ps(tmp->base.src.u.gen3.type)) |
|
- | 4017 | tmp->base.floats_per_vertex += tmp->base.src.is_affine ? 2 : 3; |
|
- | 4018 | tmp->base.floats_per_vertex += |
|
- | 4019 | tmp->base.mask.u.gen3.type == SHADER_OPACITY; |
|
- | 4020 | tmp->base.floats_per_rect = 3 * tmp->base.floats_per_vertex; |
|
- | 4021 | ||
- | 4022 | if (!kgem_check_bo(&sna->kgem, |
|
- | 4023 | tmp->base.dst.bo, tmp->base.src.bo, |
|
Line -... | Line 4024... | ||
- | 4024 | NULL)) { |
|
- | 4025 | kgem_submit(&sna->kgem); |
|
- | 4026 | if (!kgem_check_bo(&sna->kgem, |
|
Line -... | Line 4027... | ||
- | 4027 | tmp->base.dst.bo, tmp->base.src.bo, |
|
- | 4028 | NULL)) |
|
- | 4029 | goto cleanup_src; |
|
- | 4030 | } |
|
- | 4031 | ||
- | 4032 | gen3_align_vertex(sna, &tmp->base); |
|
- | 4033 | gen3_emit_composite_state(sna, &tmp->base); |
|
- | 4034 | return true; |
|
- | 4035 | ||
- | 4036 | cleanup_src: |
|
- | 4037 | if (tmp->base.src.bo) |
|
- | 4038 | kgem_bo_destroy(&sna->kgem, tmp->base.src.bo); |
|
- | 4039 | cleanup_dst: |
|
- | 4040 | if (tmp->base.redirect.real_bo) |
|
- | 4041 | kgem_bo_destroy(&sna->kgem, tmp->base.dst.bo); |
|
- | 4042 | return false; |
|
Line -... | Line 4043... | ||
- | 4043 | } |
|
- | 4044 | ||
- | 4045 | static void |
|
- | 4046 | gen3_emit_video_state(struct sna *sna, |
|
- | 4047 | struct sna_video *video, |
|
- | 4048 | struct sna_video_frame *frame, |
|
- | 4049 | PixmapPtr pixmap, |
|
- | 4050 | struct kgem_bo *dst_bo, |
|
- | 4051 | int width, int height, |
|
- | 4052 | bool bilinear) |
|
- | 4053 | { |
|
- | 4054 | struct gen3_render_state *state = &sna->render_state.gen3; |
|
- | 4055 | uint32_t id, ms3, rewind; |
|
- | 4056 | ||
- | 4057 | gen3_emit_target(sna, dst_bo, width, height, |
|
- | 4058 | sna_format_for_depth(pixmap->drawable.depth)); |
|
- | 4059 | ||
- | 4060 | /* XXX share with composite? Is it worth the effort? */ |
|
Line -... | Line 4061... | ||
- | 4061 | if ((state->last_shader & (1<<31)) == 0) { |
|
- | 4062 | OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | |
|
- | 4063 | I1_LOAD_S(1) | I1_LOAD_S(2) | I1_LOAD_S(6) | |
|
- | 4064 | 2); |
|
- | 4065 | OUT_BATCH((4 << S1_VERTEX_WIDTH_SHIFT) | (4 << S1_VERTEX_PITCH_SHIFT)); |
|
- | 4066 | OUT_BATCH(S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D) | |
|
- | 4067 | S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT) | |
|
- | 4068 | S2_TEXCOORD_FMT(2, TEXCOORDFMT_NOT_PRESENT) | |
|
- | 4069 | S2_TEXCOORD_FMT(3, TEXCOORDFMT_NOT_PRESENT) | |
|
- | 4070 | S2_TEXCOORD_FMT(4, TEXCOORDFMT_NOT_PRESENT) | |
|
- | 4071 | S2_TEXCOORD_FMT(5, TEXCOORDFMT_NOT_PRESENT) | |
|
- | 4072 | S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT) | |
|
- | 4073 | S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT)); |
|
- | 4074 | OUT_BATCH((2 << S6_CBUF_SRC_BLEND_FACT_SHIFT) | |
|
- | 4075 | (1 << S6_CBUF_DST_BLEND_FACT_SHIFT) | |
|
- | 4076 | S6_COLOR_WRITE_ENABLE); |
|
- | 4077 | ||
- | 4078 | state->last_blend = 0; |
|
- | 4079 | state->floats_per_vertex = 4; |
|
- | 4080 | } |
|
- | 4081 | ||
- | 4082 | if (!is_planar_fourcc(frame->id)) { |
|
- | 4083 | rewind = sna->kgem.nbatch; |
|
- | 4084 | OUT_BATCH(_3DSTATE_PIXEL_SHADER_CONSTANTS | 4); |
|
- | 4085 | OUT_BATCH(0x0000001); /* constant 0 */ |
|
- | 4086 | /* constant 0: brightness/contrast */ |
|
- | 4087 | OUT_BATCH_F(video->brightness / 128.0); |
|
- | 4088 | OUT_BATCH_F(video->contrast / 255.0); |
|
- | 4089 | OUT_BATCH_F(0.0); |
|
- | 4090 | OUT_BATCH_F(0.0); |
|
- | 4091 | if (state->last_constants && |
|
- | 4092 | memcmp(&sna->kgem.batch[state->last_constants], |
|
- | 4093 | &sna->kgem.batch[rewind], |
|
- | 4094 | 6*sizeof(uint32_t)) == 0) |
|
- | 4095 | sna->kgem.nbatch = rewind; |
|
- | 4096 | else |
|
- | 4097 | state->last_constants = rewind; |
|
- | 4098 | ||
- | 4099 | rewind = sna->kgem.nbatch; |
|
- | 4100 | OUT_BATCH(_3DSTATE_SAMPLER_STATE | 3); |
|
- | 4101 | OUT_BATCH(0x00000001); |
|
- | 4102 | OUT_BATCH(SS2_COLORSPACE_CONVERSION | |
|
- | 4103 | (FILTER_LINEAR << SS2_MAG_FILTER_SHIFT) | |
|
- | 4104 | (FILTER_LINEAR << SS2_MIN_FILTER_SHIFT)); |
|
- | 4105 | OUT_BATCH((TEXCOORDMODE_CLAMP_EDGE << SS3_TCX_ADDR_MODE_SHIFT) | |
|
- | 4106 | (TEXCOORDMODE_CLAMP_EDGE << SS3_TCY_ADDR_MODE_SHIFT) | |
|
- | 4107 | (0 << SS3_TEXTUREMAP_INDEX_SHIFT) | |
|
- | 4108 | SS3_NORMALIZED_COORDS); |
|
- | 4109 | OUT_BATCH(0x00000000); |
|
- | 4110 | if (state->last_sampler && |
|
- | 4111 | memcmp(&sna->kgem.batch[state->last_sampler], |
|
- | 4112 | &sna->kgem.batch[rewind], |
|
- | 4113 | 5*sizeof(uint32_t)) == 0) |
|
- | 4114 | sna->kgem.nbatch = rewind; |
|
- | 4115 | else |
|
- | 4116 | state->last_sampler = rewind; |
|
- | 4117 | ||
- | 4118 | OUT_BATCH(_3DSTATE_MAP_STATE | 3); |
|
- | 4119 | OUT_BATCH(0x00000001); /* texture map #1 */ |
|
- | 4120 | OUT_BATCH(kgem_add_reloc(&sna->kgem, sna->kgem.nbatch, |
|
- | 4121 | frame->bo, |
|
- | 4122 | I915_GEM_DOMAIN_SAMPLER << 16, |
|
- | 4123 | 0)); |
|
- | 4124 | ||
- | 4125 | ms3 = MAPSURF_422; |
|
- | 4126 | switch (frame->id) { |
|
- | 4127 | case FOURCC_YUY2: |
|
- | 4128 | ms3 |= MT_422_YCRCB_NORMAL; |
|
- | 4129 | break; |
|
- | 4130 | case FOURCC_UYVY: |
|
- | 4131 | ms3 |= MT_422_YCRCB_SWAPY; |
|
- | 4132 | break; |
|
- | 4133 | } |
|
- | 4134 | ms3 |= (frame->height - 1) << MS3_HEIGHT_SHIFT; |
|
- | 4135 | ms3 |= (frame->width - 1) << MS3_WIDTH_SHIFT; |
|
- | 4136 | OUT_BATCH(ms3); |
|
- | 4137 | OUT_BATCH(((frame->pitch[0] / 4) - 1) << MS4_PITCH_SHIFT); |
|
- | 4138 | ||
- | 4139 | id = 1<<31 | 1<<1 | !!video->brightness; |
|
- | 4140 | if (state->last_shader != id) { |
|
- | 4141 | state->last_shader = id; |
|
- | 4142 | id = sna->kgem.nbatch++; |
|
- | 4143 | ||
- | 4144 | gen3_fs_dcl(FS_S0); |
|
- | 4145 | gen3_fs_dcl(FS_T0); |
|
- | 4146 | gen3_fs_texld(FS_OC, FS_S0, FS_T0); |
|
- | 4147 | if (video->brightness != 0) { |
|
- | 4148 | gen3_fs_add(FS_OC, |
|
- | 4149 | gen3_fs_operand_reg(FS_OC), |
|
- | 4150 | gen3_fs_operand(FS_C0, X, X, X, ZERO)); |
|
- | 4151 | } |
|
- | 4152 | ||
- | 4153 | sna->kgem.batch[id] = |
|
- | 4154 | _3DSTATE_PIXEL_SHADER_PROGRAM | |
|
- | 4155 | (sna->kgem.nbatch - id - 2); |
|
Line -... | Line 4156... | ||
- | 4156 | } |
|
- | 4157 | } else { |
|
- | 4158 | /* For the planar formats, we set up three samplers -- |
|
- | 4159 | * one for each plane, in a Y8 format. Because I |
|
- | 4160 | * couldn't get the special PLANAR_TO_PACKED |
|
- | 4161 | * shader setup to work, I did the manual pixel shader: |
|
- | 4162 | * |
|
- | 4163 | * y' = y - .0625 |
|
- | 4164 | * u' = u - .5 |
|
- | 4165 | * v' = v - .5; |
|
- | 4166 | * |
|
- | 4167 | * r = 1.1643 * y' + 0.0 * u' + 1.5958 * v' |
|
- | 4168 | * g = 1.1643 * y' - 0.39173 * u' - 0.81290 * v' |
|
- | 4169 | * b = 1.1643 * y' + 2.017 * u' + 0.0 * v' |
|
- | 4170 | * |
|
- | 4171 | * register assignment: |
|
- | 4172 | * r0 = (y',u',v',0) |
|
- | 4173 | * r1 = (y,y,y,y) |
|
- | 4174 | * r2 = (u,u,u,u) |
|
- | 4175 | * r3 = (v,v,v,v) |
|
- | 4176 | * OC = (r,g,b,1) |
|
- | 4177 | */ |
|
- | 4178 | rewind = sna->kgem.nbatch; |
|
- | 4179 | OUT_BATCH(_3DSTATE_PIXEL_SHADER_CONSTANTS | (22 - 2)); |
|
- | 4180 | OUT_BATCH(0x000001f); /* constants 0-4 */ |
|
- | 4181 | /* constant 0: normalization offsets */ |
|
- | 4182 | OUT_BATCH_F(-0.0625); |
|
- | 4183 | OUT_BATCH_F(-0.5); |
|
- | 4184 | OUT_BATCH_F(-0.5); |
|
- | 4185 | OUT_BATCH_F(0.0); |
|
- | 4186 | /* constant 1: r coefficients */ |
|
- | 4187 | OUT_BATCH_F(1.1643); |
|
- | 4188 | OUT_BATCH_F(0.0); |
|
- | 4189 | OUT_BATCH_F(1.5958); |
|
Line -... | Line 4190... | ||
- | 4190 | OUT_BATCH_F(0.0); |
|
- | 4191 | /* constant 2: g coefficients */ |
|
Line -... | Line 4192... | ||
- | 4192 | OUT_BATCH_F(1.1643); |
|
- | 4193 | OUT_BATCH_F(-0.39173); |
|
- | 4194 | OUT_BATCH_F(-0.81290); |
|
- | 4195 | OUT_BATCH_F(0.0); |
|
- | 4196 | /* constant 3: b coefficients */ |
|
- | 4197 | OUT_BATCH_F(1.1643); |
|
- | 4198 | OUT_BATCH_F(2.017); |
|
- | 4199 | OUT_BATCH_F(0.0); |
|
- | 4200 | OUT_BATCH_F(0.0); |
|
- | 4201 | /* constant 4: brightness/contrast */ |
|
- | 4202 | OUT_BATCH_F(video->brightness / 128.0); |
|
- | 4203 | OUT_BATCH_F(video->contrast / 255.0); |
|
- | 4204 | OUT_BATCH_F(0.0); |
|
- | 4205 | OUT_BATCH_F(0.0); |
|
- | 4206 | if (state->last_constants && |
|
- | 4207 | memcmp(&sna->kgem.batch[state->last_constants], |
|
- | 4208 | &sna->kgem.batch[rewind], |
|
Line -... | Line 4209... | ||
- | 4209 | 22*sizeof(uint32_t)) == 0) |
|
- | 4210 | sna->kgem.nbatch = rewind; |
|
- | 4211 | else |
|
- | 4212 | state->last_constants = rewind; |
|
- | 4213 | ||
- | 4214 | rewind = sna->kgem.nbatch; |
|
- | 4215 | OUT_BATCH(_3DSTATE_SAMPLER_STATE | 9); |
|
- | 4216 | OUT_BATCH(0x00000007); |
|
- | 4217 | /* sampler 0 */ |
|
- | 4218 | OUT_BATCH((FILTER_LINEAR << SS2_MAG_FILTER_SHIFT) | |
|
- | 4219 | (FILTER_LINEAR << SS2_MIN_FILTER_SHIFT)); |
|
- | 4220 | OUT_BATCH((TEXCOORDMODE_CLAMP_EDGE << SS3_TCX_ADDR_MODE_SHIFT) | |
|
- | 4221 | (TEXCOORDMODE_CLAMP_EDGE << SS3_TCY_ADDR_MODE_SHIFT) | |
|
- | 4222 | (0 << SS3_TEXTUREMAP_INDEX_SHIFT) | |
|
- | 4223 | SS3_NORMALIZED_COORDS); |
|
- | 4224 | OUT_BATCH(0x00000000); |
|
- | 4225 | /* sampler 1 */ |
|
- | 4226 | OUT_BATCH((FILTER_LINEAR << SS2_MAG_FILTER_SHIFT) | |
|
- | 4227 | (FILTER_LINEAR << SS2_MIN_FILTER_SHIFT)); |
|
- | 4228 | OUT_BATCH((TEXCOORDMODE_CLAMP_EDGE << SS3_TCX_ADDR_MODE_SHIFT) | |
|
- | 4229 | (TEXCOORDMODE_CLAMP_EDGE << SS3_TCY_ADDR_MODE_SHIFT) | |
|
- | 4230 | (1 << SS3_TEXTUREMAP_INDEX_SHIFT) | |
|
- | 4231 | SS3_NORMALIZED_COORDS); |
|
- | 4232 | OUT_BATCH(0x00000000); |
|
- | 4233 | /* sampler 2 */ |
|
- | 4234 | OUT_BATCH((FILTER_LINEAR << SS2_MAG_FILTER_SHIFT) | |
|
- | 4235 | (FILTER_LINEAR << SS2_MIN_FILTER_SHIFT)); |
|
- | 4236 | OUT_BATCH((TEXCOORDMODE_CLAMP_EDGE << SS3_TCX_ADDR_MODE_SHIFT) | |
|
- | 4237 | (TEXCOORDMODE_CLAMP_EDGE << SS3_TCY_ADDR_MODE_SHIFT) | |
|
- | 4238 | (2 << SS3_TEXTUREMAP_INDEX_SHIFT) | |
|
- | 4239 | SS3_NORMALIZED_COORDS); |
|
- | 4240 | OUT_BATCH(0x00000000); |
|
- | 4241 | if (state->last_sampler && |
|
- | 4242 | memcmp(&sna->kgem.batch[state->last_sampler], |
|
- | 4243 | &sna->kgem.batch[rewind], |
|
- | 4244 | 11*sizeof(uint32_t)) == 0) |
|
- | 4245 | sna->kgem.nbatch = rewind; |
|
Line -... | Line 4246... | ||
- | 4246 | else |
|
- | 4247 | state->last_sampler = rewind; |
|
- | 4248 | ||
- | 4249 | OUT_BATCH(_3DSTATE_MAP_STATE | 9); |
|
- | 4250 | OUT_BATCH(0x00000007); |
|
- | 4251 | ||
- | 4252 | OUT_BATCH(kgem_add_reloc(&sna->kgem, sna->kgem.nbatch, |
|
- | 4253 | frame->bo, |
|
- | 4254 | I915_GEM_DOMAIN_SAMPLER << 16, |
|
- | 4255 | 0)); |
|
- | 4256 | ||
- | 4257 | ms3 = MAPSURF_8BIT | MT_8BIT_I8; |
|
- | 4258 | ms3 |= (frame->height - 1) << MS3_HEIGHT_SHIFT; |
|
- | 4259 | ms3 |= (frame->width - 1) << MS3_WIDTH_SHIFT; |
|
- | 4260 | OUT_BATCH(ms3); |
|
- | 4261 | /* check to see if Y has special pitch than normal |
|
- | 4262 | * double u/v pitch, e.g i915 XvMC hw requires at |
|
- | 4263 | * least 1K alignment, so Y pitch might |
|
- | 4264 | * be same as U/V's.*/ |
|
- | 4265 | if (frame->pitch[1]) |
|
- | 4266 | OUT_BATCH(((frame->pitch[1] / 4) - 1) << MS4_PITCH_SHIFT); |
|
- | 4267 | else |
|
- | 4268 | OUT_BATCH(((frame->pitch[0] * 2 / 4) - 1) << MS4_PITCH_SHIFT); |
|
- | 4269 | ||
- | 4270 | OUT_BATCH(kgem_add_reloc(&sna->kgem, sna->kgem.nbatch, |
|
- | 4271 | frame->bo, |
|
- | 4272 | I915_GEM_DOMAIN_SAMPLER << 16, |
|
- | 4273 | frame->UBufOffset)); |
|
- | 4274 | ||
- | 4275 | ms3 = MAPSURF_8BIT | MT_8BIT_I8; |
|
- | 4276 | ms3 |= (frame->height / 2 - 1) << MS3_HEIGHT_SHIFT; |
|
- | 4277 | ms3 |= (frame->width / 2 - 1) << MS3_WIDTH_SHIFT; |
|
- | 4278 | OUT_BATCH(ms3); |
|
Line -... | Line 4279... | ||
- | 4279 | OUT_BATCH(((frame->pitch[0] / 4) - 1) << MS4_PITCH_SHIFT); |
|
- | 4280 | ||
- | 4281 | OUT_BATCH(kgem_add_reloc(&sna->kgem, sna->kgem.nbatch, |
|
- | 4282 | frame->bo, |
|
- | 4283 | I915_GEM_DOMAIN_SAMPLER << 16, |
|
Line -... | Line 4284... | ||
- | 4284 | frame->VBufOffset)); |
|
- | 4285 | ||
- | 4286 | ms3 = MAPSURF_8BIT | MT_8BIT_I8; |
|
- | 4287 | ms3 |= (frame->height / 2 - 1) << MS3_HEIGHT_SHIFT; |
|
- | 4288 | ms3 |= (frame->width / 2 - 1) << MS3_WIDTH_SHIFT; |
|
- | 4289 | OUT_BATCH(ms3); |
|
Line -... | Line 4290... | ||
- | 4290 | OUT_BATCH(((frame->pitch[0] / 4) - 1) << MS4_PITCH_SHIFT); |
|
- | 4291 | ||
- | 4292 | id = 1<<31 | 2<<1 | !!video->brightness; |
|
- | 4293 | if (state->last_shader != id) { |
|
Line -... | Line 4294... | ||
- | 4294 | state->last_shader = id; |
|
- | 4295 | id = sna->kgem.nbatch++; |
|
- | 4296 | ||
- | 4297 | /* Declare samplers */ |
|
- | 4298 | gen3_fs_dcl(FS_S0); /* Y */ |
|
- | 4299 | gen3_fs_dcl(FS_S1); /* U */ |
|
Line -... | Line 4300... | ||
- | 4300 | gen3_fs_dcl(FS_S2); /* V */ |
|
- | 4301 | gen3_fs_dcl(FS_T0); /* normalized coords */ |
|
- | 4302 | ||
Line -... | Line 4303... | ||
- | 4303 | /* Load samplers to temporaries. */ |
|
- | 4304 | gen3_fs_texld(FS_R1, FS_S0, FS_T0); |
|
- | 4305 | gen3_fs_texld(FS_R2, FS_S1, FS_T0); |
|
- | 4306 | gen3_fs_texld(FS_R3, FS_S2, FS_T0); |
|
- | 4307 | ||
Line -... | Line 4308... | ||
- | 4308 | /* Move the sampled YUV data in R[123] to the first |
|
- | 4309 | * 3 channels of R0. |
|
Line -... | Line 4310... | ||
- | 4310 | */ |
|
- | 4311 | gen3_fs_mov_masked(FS_R0, MASK_X, |
|
Line -... | Line 4312... | ||
- | 4312 | gen3_fs_operand_reg(FS_R1)); |
|
- | 4313 | gen3_fs_mov_masked(FS_R0, MASK_Y, |
|
- | 4314 | gen3_fs_operand_reg(FS_R2)); |
|
- | 4315 | gen3_fs_mov_masked(FS_R0, MASK_Z, |
|
- | 4316 | gen3_fs_operand_reg(FS_R3)); |
|
- | 4317 | ||
- | 4318 | /* Normalize the YUV data */ |
|
- | 4319 | gen3_fs_add(FS_R0, gen3_fs_operand_reg(FS_R0), |
|
- | 4320 | gen3_fs_operand_reg(FS_C0)); |
|
- | 4321 | /* dot-product the YUV data in R0 by the vectors of |
|
- | 4322 | * coefficients for calculating R, G, and B, storing |
|
- | 4323 | * the results in the R, G, or B channels of the output |
|
- | 4324 | * color. The OC results are implicitly clamped |
|
- | 4325 | * at the end of the program. |
|
- | 4326 | */ |
|
- | 4327 | gen3_fs_dp3(FS_OC, MASK_X, |
|
- | 4328 | gen3_fs_operand_reg(FS_R0), |
|
- | 4329 | gen3_fs_operand_reg(FS_C1)); |
|
- | 4330 | gen3_fs_dp3(FS_OC, MASK_Y, |
|
- | 4331 | gen3_fs_operand_reg(FS_R0), |
|
Line -... | Line 4332... | ||
- | 4332 | gen3_fs_operand_reg(FS_C2)); |
|
- | 4333 | gen3_fs_dp3(FS_OC, MASK_Z, |
|
Line -... | Line 4334... | ||
- | 4334 | gen3_fs_operand_reg(FS_R0), |
|
- | 4335 | gen3_fs_operand_reg(FS_C3)); |
|
- | 4336 | /* Set alpha of the output to 1.0, by wiring W to 1 |
|
Line -... | Line 4337... | ||
- | 4337 | * and not actually using the source. |
|
Line -... | Line 4338... | ||
- | 4338 | */ |
|
- | 4339 | gen3_fs_mov_masked(FS_OC, MASK_W, |
|
Line -... | Line 4340... | ||
- | 4340 | gen3_fs_operand_one()); |
|
- | 4341 | ||
- | 4342 | if (video->brightness != 0) { |
|
- | 4343 | gen3_fs_add(FS_OC, |
|
Line -... | Line 4344... | ||
- | 4344 | gen3_fs_operand_reg(FS_OC), |
|
- | 4345 | gen3_fs_operand(FS_C4, X, X, X, ZERO)); |
|
- | 4346 | } |
|
Line -... | Line 4347... | ||
- | 4347 | ||
- | 4348 | sna->kgem.batch[id] = |
|
Line -... | Line 4349... | ||
- | 4349 | _3DSTATE_PIXEL_SHADER_PROGRAM | |
|
- | 4350 | (sna->kgem.nbatch - id - 2); |
|
- | 4351 | } |
|
- | 4352 | } |
|
- | 4353 | } |
|
- | 4354 | ||
- | 4355 | static void |
|
- | 4356 | gen3_video_get_batch(struct sna *sna, struct kgem_bo *bo) |
|
Line -... | Line 4357... | ||
- | 4357 | { |
|
- | 4358 | kgem_set_mode(&sna->kgem, KGEM_RENDER, bo); |
|
- | 4359 | ||
- | 4360 | if (!kgem_check_batch(&sna->kgem, 120) || |
|
- | 4361 | !kgem_check_reloc(&sna->kgem, 4) || |
|
- | 4362 | !kgem_check_exec(&sna->kgem, 2)) { |
|
- | 4363 | _kgem_submit(&sna->kgem); |
|
- | 4364 | _kgem_set_mode(&sna->kgem, KGEM_RENDER); |
|
- | 4365 | } |
|
- | 4366 | ||
- | 4367 | if (sna->render_state.gen3.need_invariant) |
|
- | 4368 | gen3_emit_invariant(sna); |
|
- | 4369 | } |
|
- | 4370 | ||
Line -... | Line 4371... | ||
- | 4371 | static int |
|
- | 4372 | gen3_get_inline_rectangles(struct sna *sna, int want, int floats_per_vertex) |
|
- | 4373 | { |
|
Line -... | Line 4374... | ||
- | 4374 | int size = floats_per_vertex * 3; |
|
- | 4375 | int rem = batch_space(sna) - 1; |
|
- | 4376 | ||
- | 4377 | if (size * want > rem) |
|
- | 4378 | want = rem / size; |
|
- | 4379 | ||
- | 4380 | return want; |
|
- | 4381 | } |
|
- | 4382 | ||
- | 4383 | static bool |
|
- | 4384 | gen3_render_video(struct sna *sna, |
|
- | 4385 | struct sna_video *video, |
|
- | 4386 | struct sna_video_frame *frame, |
|
- | 4387 | RegionPtr dstRegion, |
|
- | 4388 | PixmapPtr pixmap) |
|
- | 4389 | { |
|
- | 4390 | struct sna_pixmap *priv = sna_pixmap(pixmap); |
|
- | 4391 | BoxPtr pbox = REGION_RECTS(dstRegion); |
|
- | 4392 | int nbox = REGION_NUM_RECTS(dstRegion); |
|
- | 4393 | int dst_width = dstRegion->extents.x2 - dstRegion->extents.x1; |
|
- | 4394 | int dst_height = dstRegion->extents.y2 - dstRegion->extents.y1; |
|
- | 4395 | int src_width = frame->src.x2 - frame->src.x1; |
|
- | 4396 | int src_height = frame->src.y2 - frame->src.y1; |
|
- | 4397 | float src_offset_x, src_offset_y; |
|
- | 4398 | float src_scale_x, src_scale_y; |
|
- | 4399 | int pix_xoff, pix_yoff; |
|
- | 4400 | struct kgem_bo *dst_bo; |
|
- | 4401 | bool bilinear; |
|
- | 4402 | int copy = 0; |
|
- | 4403 | ||
- | 4404 | DBG(("%s: src:%dx%d (frame:%dx%d) -> dst:%dx%d\n", __FUNCTION__, |
|
- | 4405 | src_width, src_height, frame->width, frame->height, dst_width, dst_height)); |
|
- | 4406 | ||
- | 4407 | dst_bo = priv->gpu_bo; |
|
- | 4408 | if (dst_bo == NULL) |
|
- | 4409 | return false; |
|
- | 4410 | ||
- | 4411 | bilinear = src_width != dst_width || src_height != dst_height; |
|
- | 4412 | ||
- | 4413 | src_scale_x = (float)src_width / dst_width / frame->width; |
|
- | 4414 | src_offset_x = (float)frame->src.x1 / frame->width - dstRegion->extents.x1 * src_scale_x; |
|
- | 4415 | ||
- | 4416 | src_scale_y = (float)src_height / dst_height / frame->height; |
|
- | 4417 | src_offset_y = (float)frame->src.y1 / frame->height - dstRegion->extents.y1 * src_scale_y; |
|
- | 4418 | DBG(("%s: src offset (%f, %f), scale (%f, %f)\n", |
|
- | 4419 | __FUNCTION__, src_offset_x, src_offset_y, src_scale_x, src_scale_y)); |
|
- | 4420 | ||
- | 4421 | if (too_large(pixmap->drawable.width, pixmap->drawable.height) || |
|
- | 4422 | !gen3_check_pitch_3d(dst_bo)) { |
|
- | 4423 | int bpp = pixmap->drawable.bitsPerPixel; |
|
- | 4424 | ||
- | 4425 | if (too_large(dst_width, dst_height)) |
|
- | 4426 | return false; |
|
- | 4427 | ||
- | 4428 | dst_bo = kgem_create_2d(&sna->kgem, |
|
- | 4429 | dst_width, dst_height, bpp, |
|
- | 4430 | kgem_choose_tiling(&sna->kgem, |
|
- | 4431 | I915_TILING_X, |
|
- | 4432 | dst_width, dst_height, bpp), |
|
- | 4433 | 0); |
|
- | 4434 | if (!dst_bo) |
|
- | 4435 | return false; |
|
- | 4436 | ||
- | 4437 | pix_xoff = -dstRegion->extents.x1; |
|
- | 4438 | pix_yoff = -dstRegion->extents.y1; |
|
- | 4439 | copy = 1; |
|
- | 4440 | } else { |
|
Line -... | Line 4441... | ||
- | 4441 | /* Set up the offset for translating from the given region |
|
- | 4442 | * (in screen coordinates) to the backing pixmap. |
|
- | 4443 | */ |
|
- | 4444 | #ifdef COMPOSITE |
|
- | 4445 | pix_xoff = -pixmap->screen_x + pixmap->drawable.x; |
|
- | 4446 | pix_yoff = -pixmap->screen_y + pixmap->drawable.y; |
|
- | 4447 | #else |
|
- | 4448 | pix_xoff = 0; |
|
- | 4449 | pix_yoff = 0; |
|
- | 4450 | #endif |
|
- | 4451 | ||
- | 4452 | dst_width = pixmap->drawable.width; |
|
- | 4453 | dst_height = pixmap->drawable.height; |
|
- | 4454 | } |
|
- | 4455 | ||
Line -... | Line 4456... | ||
- | 4456 | gen3_video_get_batch(sna, dst_bo); |
|
- | 4457 | gen3_emit_video_state(sna, video, frame, pixmap, |
|
Line -... | Line 4458... | ||
- | 4458 | dst_bo, dst_width, dst_height, bilinear); |
|
Line -... | Line 4621... | ||
- | 4621 | ||
- | 4622 | ||
- | 4623 | ||
- | 4624 | ||
- | 4625 | ||
- | 4626 | #if 0 |
|
- | 4627 | static bool |
|
- | 4628 | gen3_render_fill_one(struct sna *sna, PixmapPtr dst, struct kgem_bo *bo, |
|
- | 4629 | uint32_t color, |
|
- | 4630 | int16_t x1, int16_t y1, |
|
- | 4631 | int16_t x2, int16_t y2, |
|
- | 4632 | uint8_t alu) |
|
- | 4633 | { |
|
- | 4634 | struct sna_composite_op tmp; |
|
Line -... | Line 4635... | ||
- | 4635 | ||
- | 4636 | #if NO_FILL_ONE |
|
- | 4637 | return gen3_render_fill_one_try_blt(sna, dst, bo, color, |
|
- | 4638 | x1, y1, x2, y2, alu); |
|
- | 4639 | #endif |
|
Line -... | Line 4640... | ||
- | 4640 | ||
- | 4641 | /* Prefer to use the BLT if already engaged */ |
|
- | 4642 | if (prefer_fill_blt(sna) && |
|
- | 4643 | gen3_render_fill_one_try_blt(sna, dst, bo, color, |
|
- | 4644 | x1, y1, x2, y2, alu)) |
|
- | 4645 | return true; |
|
- | 4646 | ||
- | 4647 | /* Must use the BLT if we can't RENDER... */ |
|
- | 4648 | if (!(alu == GXcopy || alu == GXclear) || |
|
- | 4649 | too_large(dst->drawable.width, dst->drawable.height) || |
|
- | 4650 | bo->pitch > MAX_3D_PITCH) |
|
- | 4651 | return gen3_render_fill_one_try_blt(sna, dst, bo, color, |
|
- | 4652 | x1, y1, x2, y2, alu); |
|
- | 4653 | ||
- | 4654 | if (alu == GXclear) |
|
- | 4655 | color = 0; |
|
- | 4656 | ||
- | 4657 | tmp.op = color == 0 ? PictOpClear : PictOpSrc; |
|
- | 4658 | tmp.dst.pixmap = dst; |
|
- | 4659 | tmp.dst.width = dst->drawable.width; |
|
- | 4660 | tmp.dst.height = dst->drawable.height; |
|
- | 4661 | tmp.dst.format = sna_format_for_depth(dst->drawable.depth); |
|
- | 4662 | tmp.dst.bo = bo; |
|
- | 4663 | tmp.floats_per_vertex = 2; |
|
- | 4664 | tmp.floats_per_rect = 6; |
|
- | 4665 | tmp.need_magic_ca_pass = 0; |
|
- | 4666 | tmp.has_component_alpha = 0; |
|
Line -... | Line 4667... | ||
- | 4667 | tmp.rb_reversed = 0; |
|
- | 4668 | ||
Line -... | Line 4669... | ||
- | 4669 | gen3_init_solid(&tmp.src, |
|
- | 4670 | sna_rgba_for_color(color, dst->drawable.depth)); |
|
- | 4671 | tmp.mask.bo = NULL; |
|
Line -... | Line 4672... | ||
- | 4672 | tmp.mask.u.gen3.type = SHADER_NONE; |
|
- | 4673 | tmp.u.gen3.num_constants = 0; |
|
- | 4674 | ||
Line -... | Line 4675... | ||
- | 4675 | if (!kgem_check_bo(&sna->kgem, bo, NULL)) { |
|
- | 4676 | kgem_submit(&sna->kgem); |
|
- | 4677 | ||
- | 4678 | if (gen3_render_fill_one_try_blt(sna, dst, bo, color, |
|
- | 4679 | x1, y1, x2, y2, alu)) |
|
- | 4680 | return true; |
|
- | 4681 | ||
- | 4682 | if (!kgem_check_bo(&sna->kgem, bo, NULL)) |
|
- | 4683 | return false; |
|
- | 4684 | } |
|
- | 4685 | ||
Line -... | Line 4686... | ||
- | 4686 | gen3_align_vertex(sna, &tmp); |
|
- | 4687 | gen3_emit_composite_state(sna, &tmp); |
|
- | 4688 | gen3_get_rectangles(sna, &tmp, 1); |
|
Line 2648... | Line 4689... | ||
2648 | 4689 | DBG((" (%d, %d), (%d, %d): %x\n", x1, y1, x2, y2, color)); |
|
2649 | 4690 | OUT_VERTEX(x2); |
|
2650 | 4691 | OUT_VERTEX(y2); |
|
Line 2806... | Line 4847... | ||
2806 | tmp->dst.bo, tmp->src.bo, tmp->mask.bo, |
4847 | tmp->dst.bo, tmp->src.bo, tmp->mask.bo, |
2807 | NULL)) { |
4848 | NULL)) { |
2808 | kgem_submit(&sna->kgem); |
4849 | kgem_submit(&sna->kgem); |
2809 | } |
4850 | } |
Line 2810... | Line -... | ||
2810 | - | ||
2811 | gen3_emit_composite_state(sna, tmp); |
4851 | |
- | 4852 | gen3_align_vertex(sna, tmp); |
|
2812 | gen3_align_vertex(sna, tmp); |
4853 | gen3_emit_composite_state(sna, tmp); |
2813 | return true; |
4854 | return true; |