-------------------------------------------------------------------------------------- Description: Clamps subresource values to a specific texture dimensions. Arguments: texture - Texture which dimensions are used to clamp subresource data --------------------------------------------------------------------------------------
| 55 | // texture - Texture which dimensions are used to clamp subresource data |
| 56 | // -------------------------------------------------------------------------------------- |
| 57 | void Tr2TextureSubresource::ClampToTexture( const Tr2BitmapDimensions& texture ) |
| 58 | { |
| 59 | uint32_t arraySize = std::max( texture.GetArraySize(), 1u ); |
| 60 | m_startFace = std::min( m_startFace, arraySize - 1 ); |
| 61 | m_endFace = std::min( m_endFace, arraySize ); |
| 62 | |
| 63 | m_startMipLevel = std::min( m_startMipLevel, texture.GetTrueMipCount() - 1 ); |
| 64 | m_endMipLevel = std::min( m_endMipLevel, texture.GetTrueMipCount() ); |
| 65 | |
| 66 | uint32_t mipWidth = texture.GetMipWidth( m_startMipLevel ); |
| 67 | uint32_t mipHeight = texture.GetMipHeight( m_startMipLevel ); |
| 68 | uint32_t mipDepth = std::max( texture.GetDepth() >> m_startMipLevel, 1u ); |
| 69 | |
| 70 | if( HasBox() ) |
| 71 | { |
| 72 | m_box.left = std::min( m_box.left, mipWidth - 1 ); |
| 73 | m_box.right = std::min( m_box.right, mipWidth ); |
| 74 | m_box.top = std::min( m_box.top, mipHeight - 1 ); |
| 75 | m_box.bottom = std::min( m_box.bottom, mipHeight ); |
| 76 | if( texture.GetType() == TEX_TYPE_3D ) |
| 77 | { |
| 78 | m_box.front = std::min( m_box.front, mipDepth - 1 ); |
| 79 | m_box.back = std::min( m_box.back, mipDepth ); |
| 80 | } |
| 81 | else |
| 82 | { |
| 83 | m_box.front = 0; |
| 84 | m_box.back = 1; |
| 85 | } |
| 86 | } |
| 87 | else |
| 88 | { |
| 89 | m_box = { 0, 0, 0, mipWidth, mipHeight, mipDepth }; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // -------------------------------------------------------------------------------------- |
| 94 | // Description: |