| 1006 | } |
| 1007 | |
| 1008 | void Tr2TextureAL::UnmapForWriting( Tr2RenderContextAL& renderContext ) |
| 1009 | { |
| 1010 | if( !renderContext.IsValid() ) |
| 1011 | { |
| 1012 | return; |
| 1013 | } |
| 1014 | #if TRINITY_AL_GUARD_LOCKS |
| 1015 | m_lockGuard.Unlock(); |
| 1016 | #endif |
| 1017 | if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) |
| 1018 | { |
| 1019 | renderContext.m_context->Unmap( m_texture, m_lockedSubresource ); |
| 1020 | } |
| 1021 | else |
| 1022 | { |
| 1023 | const uint32_t w = m_writeBox.GetWidth(); |
| 1024 | const uint32_t pitch = w * Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ); |
| 1025 | |
| 1026 | if( renderContext.m_context ) |
| 1027 | { |
| 1028 | D3D11_BOX box; |
| 1029 | box.left = m_writeBox.left; |
| 1030 | box.top = m_writeBox.top; |
| 1031 | box.right = m_writeBox.right; |
| 1032 | box.bottom = m_writeBox.bottom; |
| 1033 | box.front = m_writeBox.front; |
| 1034 | box.back = m_writeBox.back; |
| 1035 | |
| 1036 | auto mip = m_lockedSubresource % m_desc.GetTrueMipCount(); |
| 1037 | |
| 1038 | if( m_writeBox.right > m_desc.GetMipWidth( mip ) || m_writeBox.bottom > m_desc.GetMipHeight( mip ) || m_writeBox.back > m_desc.GetMipDepth( mip ) ) |
| 1039 | { |
| 1040 | CCP_LOGERR( "TrinityAL: invalid rectangle in Tr2TextureAL::UnlockWriting" ); |
| 1041 | return; |
| 1042 | } |
| 1043 | |
| 1044 | renderContext.m_context->UpdateSubresource( m_texture, m_lockedSubresource, &box, m_writeStaging.get(), pitch, pitch * m_writeBox.GetHeight() ); |
| 1045 | } |
| 1046 | |
| 1047 | m_writeStaging.clear(); |
| 1048 | m_writeBox = { 0, 0, 0, 0, 0, 0 }; |
| 1049 | } |
| 1050 | } |
| 1051 | |
| 1052 | ALResult Tr2TextureAL::UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t slicePitch, Tr2RenderContextAL& renderContext ) |
| 1053 | { |
nothing calls this directly
no test coverage detected