| 1623 | } |
| 1624 | |
| 1625 | GLenum initTestTexture(TextureFormat::Enum _format, bool _srgb, bool _mipmaps, bool _array, GLsizei _dim) |
| 1626 | { |
| 1627 | const TextureFormatInfo& tfi = s_textureFormat[_format]; |
| 1628 | GLenum internalFmt = _srgb |
| 1629 | ? tfi.m_internalFmtSrgb |
| 1630 | : tfi.m_internalFmt |
| 1631 | ; |
| 1632 | GLenum fmt = _srgb |
| 1633 | ? tfi.m_fmtSrgb |
| 1634 | : tfi.m_fmt |
| 1635 | ; |
| 1636 | |
| 1637 | GLsizei bpp = bimg::getBitsPerPixel(bimg::TextureFormat::Enum(_format) ); |
| 1638 | GLsizei size = (_dim*_dim*bpp)/8; |
| 1639 | void* data = NULL; |
| 1640 | |
| 1641 | if (bimg::isDepth(bimg::TextureFormat::Enum(_format) ) ) |
| 1642 | { |
| 1643 | _srgb = false; |
| 1644 | _mipmaps = false; |
| 1645 | _array = false; |
| 1646 | } |
| 1647 | else |
| 1648 | { |
| 1649 | data = bx::alignPtr(BX_STACK_ALLOC(size+16), 0, 16); |
| 1650 | } |
| 1651 | |
| 1652 | flushGlError(); |
| 1653 | GLenum err = 0; |
| 1654 | |
| 1655 | const GLenum target = _array |
| 1656 | ? GL_TEXTURE_2D_ARRAY |
| 1657 | : GL_TEXTURE_2D |
| 1658 | ; |
| 1659 | |
| 1660 | if (bimg::isCompressed(bimg::TextureFormat::Enum(_format) ) ) |
| 1661 | { |
| 1662 | for (uint32_t ii = 0, dim = _dim; ii < (_mipmaps ? 5u : 1u) && 0 == err; ++ii, dim >>= 1) |
| 1663 | { |
| 1664 | dim = bx::uint32_max(1, dim); |
| 1665 | uint32_t block = bx::uint32_max(4, dim); |
| 1666 | size = (block*block*bpp)/8; |
| 1667 | compressedTexImage(target, ii, internalFmt, dim, dim, 0, 0, size, data); |
| 1668 | err |= getGlError(); |
| 1669 | } |
| 1670 | } |
| 1671 | else |
| 1672 | { |
| 1673 | for (uint32_t ii = 0, dim = _dim; ii < (_mipmaps ? 5u : 1u) && 0 == err; ++ii, dim >>= 1) |
| 1674 | { |
| 1675 | dim = bx::uint32_max(1, dim); |
| 1676 | size = (dim*dim*bpp)/8; |
| 1677 | texImage(target, 0, ii, internalFmt, dim, dim, 0, 0, fmt, tfi.m_type, data); |
| 1678 | err |= getGlError(); |
| 1679 | } |
| 1680 | } |
| 1681 | |
| 1682 | return err; |
no test coverage detected