| 184 | } |
| 185 | |
| 186 | ALResult Tr2TextureAL::MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) |
| 187 | { |
| 188 | data = nullptr; |
| 189 | |
| 190 | if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) ) |
| 191 | { |
| 192 | return E_INVALIDCALL; |
| 193 | } |
| 194 | if( !IsValid() || !renderContext.IsValid() ) |
| 195 | { |
| 196 | return E_FAIL; |
| 197 | } |
| 198 | if( !region.IsValidForBitmap( m_desc ) ) |
| 199 | { |
| 200 | return E_INVALIDARG; |
| 201 | } |
| 202 | if( !region.IsSingleSubresource() ) |
| 203 | { |
| 204 | return E_INVALIDARG; |
| 205 | } |
| 206 | if( region.HasBox() && Tr2RenderContextEnum::IsCompressedFormat( m_desc.GetFormat() ) ) |
| 207 | { |
| 208 | return E_INVALIDARG; |
| 209 | } |
| 210 | |
| 211 | auto mipPitch = m_desc.GetMipPitch( region.m_startMipLevel ); |
| 212 | auto size = mipPitch * m_desc.GetMipHeight( region.m_startMipLevel ); |
| 213 | |
| 214 | if( m_data.size() != size ) |
| 215 | { |
| 216 | m_data.resize( "Tr2TextureAL::m_data", size ); |
| 217 | if( m_data.empty() ) |
| 218 | { |
| 219 | return E_FAIL; |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | pitch = mipPitch; |
| 224 | data = m_data.get(); |
| 225 | return S_OK; |
| 226 | } |
| 227 | |
| 228 | void Tr2TextureAL::UnmapForWriting( Tr2RenderContextAL& ) |
| 229 | { |
nothing calls this directly
no test coverage detected