MCPcopy Create free account
hub / github.com/carbonengine/trinity / MapForReading

Method MapForReading

trinityal/dx11/Tr2TextureALDx11.cpp:802–876  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

800}
801
802ALResult Tr2TextureAL::MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext )
803{
804
805 //Note: synchronize is ignored on DX11, as the current code needs significant refactoring to support asynchronous mapping.
806
807 data = nullptr;
808 if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ ) )
809 {
810 return E_INVALIDCALL;
811 }
812
813 if( !IsValid() || !renderContext.IsValid() )
814 {
815 return E_FAIL;
816 }
817 if( m_desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D )
818 {
819 return E_FAIL;
820 }
821
822 if( !region.IsValidForBitmap( m_desc ) )
823 {
824 return E_INVALIDARG;
825 }
826 if( !region.IsSingleSubresource() )
827 {
828 return E_INVALIDARG;
829 }
830
831 if( !m_stagingTexture )
832 {
833 D3D11_TEXTURE2D_DESC desc;
834 memset( &desc, 0, sizeof( desc ) );
835 desc.Width = m_desc.GetWidth();
836 desc.Height = m_desc.GetHeight();
837 desc.MipLevels = 1;
838 desc.ArraySize = 1;
839 desc.Format = static_cast<DXGI_FORMAT>( Tr2RenderContextEnum::MakeTypeless( m_desc.GetFormat() ) );
840
841 desc.Usage = D3D11_USAGE_STAGING;
842 desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
843
844 desc.SampleDesc.Count = 1;
845
846 if( !renderContext.m_secondaryDevice11 )
847 {
848 return E_FAIL;
849 }
850 FORWARD_HR( renderContext.m_secondaryDevice11->CreateTexture2D( &desc, nullptr, &m_stagingTexture ) );
851 if( !m_stagingTexture )
852 {
853 return E_FAIL;
854 }
855 }
856
857 if( region.HasBox() )
858 {
859 D3D11_BOX box = { region.m_box.left, region.m_box.top, region.m_box.front, region.m_box.right, region.m_box.bottom, region.m_box.back };

Callers

nothing calls this directly

Calls 13

IsValidForBitmapMethod · 0.80
IsSingleSubresourceMethod · 0.80
HasBoxMethod · 0.80
GetTrueMipCountMethod · 0.80
HasFlagFunction · 0.70
IsValidFunction · 0.70
IsValidMethod · 0.45
GetTypeMethod · 0.45
GetWidthMethod · 0.45
GetHeightMethod · 0.45
GetFormatMethod · 0.45
CopySubresourceRegionMethod · 0.45

Tested by

no test coverage detected