aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2012-08-09 10:34:15 -0400
committerAlex Deucher <alexander.deucher@amd.com>2012-08-13 10:50:55 -0400
commitf00245f182fab57c5eed28a50764600b2bf1ccdb (patch)
tree79cf14879f516f73074fee57edc8d9359ba1fb59 /drivers/gpu/drm/radeon
parente43b5ec05afdc232be25aa481315035c1888d389 (diff)
drm/radeon/kms: reorder code in r600_check_texture_resource
Signed-off-by: Marek Olšák <maraeo@gmail.com> Reviewed-by: Jerome Glisse <jglisse@redhat.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/radeon')
-rw-r--r--drivers/gpu/drm/radeon/r600_cs.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c
index 1119e31e5c2f..ff61402ef795 100644
--- a/drivers/gpu/drm/radeon/r600_cs.c
+++ b/drivers/gpu/drm/radeon/r600_cs.c
@@ -1559,13 +1559,14 @@ static int r600_check_texture_resource(struct radeon_cs_parser *p, u32 idx,
1559 u32 tiling_flags) 1559 u32 tiling_flags)
1560{ 1560{
1561 struct r600_cs_track *track = p->track; 1561 struct r600_cs_track *track = p->track;
1562 u32 nfaces, llevel, blevel, w0, h0, d0; 1562 u32 dim, nfaces, llevel, blevel, w0, h0, d0;
1563 u32 word0, word1, l0_size, mipmap_size, word2, word3; 1563 u32 word0, word1, l0_size, mipmap_size, word2, word3, word4, word5;
1564 u32 height_align, pitch, pitch_align, depth_align; 1564 u32 height_align, pitch, pitch_align, depth_align;
1565 u32 array, barray, larray; 1565 u32 barray, larray;
1566 u64 base_align; 1566 u64 base_align;
1567 struct array_mode_checker array_check; 1567 struct array_mode_checker array_check;
1568 u32 format; 1568 u32 format;
1569 bool is_array;
1569 1570
1570 /* on legacy kernel we don't perform advanced check */ 1571 /* on legacy kernel we don't perform advanced check */
1571 if (p->rdev == NULL) 1572 if (p->rdev == NULL)
@@ -1583,12 +1584,28 @@ static int r600_check_texture_resource(struct radeon_cs_parser *p, u32 idx,
1583 word0 |= S_038000_TILE_MODE(V_038000_ARRAY_1D_TILED_THIN1); 1584 word0 |= S_038000_TILE_MODE(V_038000_ARRAY_1D_TILED_THIN1);
1584 } 1585 }
1585 word1 = radeon_get_ib_value(p, idx + 1); 1586 word1 = radeon_get_ib_value(p, idx + 1);
1587 word2 = radeon_get_ib_value(p, idx + 2) << 8;
1588 word3 = radeon_get_ib_value(p, idx + 3) << 8;
1589 word4 = radeon_get_ib_value(p, idx + 4);
1590 word5 = radeon_get_ib_value(p, idx + 5);
1591 dim = G_038000_DIM(word0);
1586 w0 = G_038000_TEX_WIDTH(word0) + 1; 1592 w0 = G_038000_TEX_WIDTH(word0) + 1;
1593 pitch = (G_038000_PITCH(word0) + 1) * 8;
1587 h0 = G_038004_TEX_HEIGHT(word1) + 1; 1594 h0 = G_038004_TEX_HEIGHT(word1) + 1;
1588 d0 = G_038004_TEX_DEPTH(word1); 1595 d0 = G_038004_TEX_DEPTH(word1);
1596 format = G_038004_DATA_FORMAT(word1);
1597 blevel = G_038010_BASE_LEVEL(word4);
1598 llevel = G_038014_LAST_LEVEL(word5);
1599 /* pitch in texels */
1600 array_check.array_mode = G_038000_TILE_MODE(word0);
1601 array_check.group_size = track->group_size;
1602 array_check.nbanks = track->nbanks;
1603 array_check.npipes = track->npipes;
1604 array_check.nsamples = 1;
1605 array_check.blocksize = r600_fmt_get_blocksize(format);
1589 nfaces = 1; 1606 nfaces = 1;
1590 array = 0; 1607 is_array = false;
1591 switch (G_038000_DIM(word0)) { 1608 switch (dim) {
1592 case V_038000_SQ_TEX_DIM_1D: 1609 case V_038000_SQ_TEX_DIM_1D:
1593 case V_038000_SQ_TEX_DIM_2D: 1610 case V_038000_SQ_TEX_DIM_2D:
1594 case V_038000_SQ_TEX_DIM_3D: 1611 case V_038000_SQ_TEX_DIM_3D:
@@ -1601,7 +1618,7 @@ static int r600_check_texture_resource(struct radeon_cs_parser *p, u32 idx,
1601 break; 1618 break;
1602 case V_038000_SQ_TEX_DIM_1D_ARRAY: 1619 case V_038000_SQ_TEX_DIM_1D_ARRAY:
1603 case V_038000_SQ_TEX_DIM_2D_ARRAY: 1620 case V_038000_SQ_TEX_DIM_2D_ARRAY:
1604 array = 1; 1621 is_array = true;
1605 break; 1622 break;
1606 case V_038000_SQ_TEX_DIM_2D_MSAA: 1623 case V_038000_SQ_TEX_DIM_2D_MSAA:
1607 case V_038000_SQ_TEX_DIM_2D_ARRAY_MSAA: 1624 case V_038000_SQ_TEX_DIM_2D_ARRAY_MSAA:
@@ -1609,21 +1626,12 @@ static int r600_check_texture_resource(struct radeon_cs_parser *p, u32 idx,
1609 dev_warn(p->dev, "this kernel doesn't support %d texture dim\n", G_038000_DIM(word0)); 1626 dev_warn(p->dev, "this kernel doesn't support %d texture dim\n", G_038000_DIM(word0));
1610 return -EINVAL; 1627 return -EINVAL;
1611 } 1628 }
1612 format = G_038004_DATA_FORMAT(word1);
1613 if (!r600_fmt_is_valid_texture(format, p->family)) { 1629 if (!r600_fmt_is_valid_texture(format, p->family)) {
1614 dev_warn(p->dev, "%s:%d texture invalid format %d\n", 1630 dev_warn(p->dev, "%s:%d texture invalid format %d\n",
1615 __func__, __LINE__, format); 1631 __func__, __LINE__, format);
1616 return -EINVAL; 1632 return -EINVAL;
1617 } 1633 }
1618 1634
1619 /* pitch in texels */
1620 pitch = (G_038000_PITCH(word0) + 1) * 8;
1621 array_check.array_mode = G_038000_TILE_MODE(word0);
1622 array_check.group_size = track->group_size;
1623 array_check.nbanks = track->nbanks;
1624 array_check.npipes = track->npipes;
1625 array_check.nsamples = 1;
1626 array_check.blocksize = r600_fmt_get_blocksize(format);
1627 if (r600_get_array_mode_alignment(&array_check, 1635 if (r600_get_array_mode_alignment(&array_check,
1628 &pitch_align, &height_align, &depth_align, &base_align)) { 1636 &pitch_align, &height_align, &depth_align, &base_align)) {
1629 dev_warn(p->dev, "%s:%d tex array mode (%d) invalid\n", 1637 dev_warn(p->dev, "%s:%d tex array mode (%d) invalid\n",
@@ -1649,20 +1657,13 @@ static int r600_check_texture_resource(struct radeon_cs_parser *p, u32 idx,
1649 return -EINVAL; 1657 return -EINVAL;
1650 } 1658 }
1651 1659
1652 word2 = radeon_get_ib_value(p, idx + 2) << 8;
1653 word3 = radeon_get_ib_value(p, idx + 3) << 8;
1654
1655 word0 = radeon_get_ib_value(p, idx + 4);
1656 word1 = radeon_get_ib_value(p, idx + 5);
1657 blevel = G_038010_BASE_LEVEL(word0);
1658 llevel = G_038014_LAST_LEVEL(word1);
1659 if (blevel > llevel) { 1660 if (blevel > llevel) {
1660 dev_warn(p->dev, "texture blevel %d > llevel %d\n", 1661 dev_warn(p->dev, "texture blevel %d > llevel %d\n",
1661 blevel, llevel); 1662 blevel, llevel);
1662 } 1663 }
1663 if (array == 1) { 1664 if (is_array) {
1664 barray = G_038014_BASE_ARRAY(word1); 1665 barray = G_038014_BASE_ARRAY(word5);
1665 larray = G_038014_LAST_ARRAY(word1); 1666 larray = G_038014_LAST_ARRAY(word5);
1666 1667
1667 nfaces = larray - barray + 1; 1668 nfaces = larray - barray + 1;
1668 } 1669 }
@@ -1679,7 +1680,6 @@ static int r600_check_texture_resource(struct radeon_cs_parser *p, u32 idx,
1679 return -EINVAL; 1680 return -EINVAL;
1680 } 1681 }
1681 /* using get ib will give us the offset into the mipmap bo */ 1682 /* using get ib will give us the offset into the mipmap bo */
1682 word3 = radeon_get_ib_value(p, idx + 3) << 8;
1683 if ((mipmap_size + word3) > radeon_bo_size(mipmap)) { 1683 if ((mipmap_size + word3) > radeon_bo_size(mipmap)) {
1684 /*dev_warn(p->dev, "mipmap bo too small (%d %d %d %d %d %d -> %d have %ld)\n", 1684 /*dev_warn(p->dev, "mipmap bo too small (%d %d %d %d %d %d -> %d have %ld)\n",
1685 w0, h0, format, blevel, nlevels, word3, mipmap_size, radeon_bo_size(texture));*/ 1685 w0, h0, format, blevel, nlevels, word3, mipmap_size, radeon_bo_size(texture));*/