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

Method CopySubresourceRegion

trinityal/dx11/Tr2TextureALDx11.cpp:1099–1165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1097}
1098
1099ALResult Tr2TextureAL::CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext )
1100{
1101 if( !IsValid() || !renderContext.IsValid() )
1102 {
1103 return E_INVALIDCALL;
1104 }
1105 if( !source.IsValid() )
1106 {
1107 return E_INVALIDARG;
1108 }
1109 if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) )
1110 {
1111 return E_INVALIDCALL;
1112 }
1113
1114 if( destSubresource.IsSubresourceFull( m_desc ) && sourceSubresource.IsSubresourceFull( source.m_desc ) )
1115 {
1116 renderContext.m_context->CopyResource( m_texture, source.m_texture );
1117 return S_OK;
1118 }
1119
1120 Tr2TextureSubresource src = sourceSubresource;
1121 Tr2TextureSubresource dst = destSubresource;
1122
1123 if( !Crop( src, source.m_desc, dst, m_desc ) )
1124 {
1125 return E_FAIL;
1126 }
1127
1128 D3D11_BOX box = { src.m_box.left, src.m_box.top, src.m_box.front, src.m_box.right, src.m_box.bottom, src.m_box.back };
1129
1130 const uint32_t srcMipCount = source.m_desc.GetTrueMipCount();
1131 const uint32_t dstMipCount = m_desc.GetTrueMipCount();
1132
1133 const uint32_t mipCount = std::min( src.GetMipCount(), dst.GetMipCount() );
1134
1135 for( uint32_t mip = 0; mip != mipCount; ++mip )
1136 {
1137 for( uint32_t face = 0; face != src.GetFaceCount(); ++face )
1138 {
1139 renderContext.m_context->CopySubresourceRegion(
1140 m_texture,
1141 D3D10CalcSubresource( dst.m_startMipLevel + mip, dst.m_startFace + face, dstMipCount ),
1142 dst.m_box.left,
1143 dst.m_box.top,
1144 dst.m_box.front,
1145 source.m_texture,
1146 D3D10CalcSubresource( src.m_startMipLevel + mip, src.m_startFace + face, srcMipCount ),
1147 &box );
1148 }
1149
1150 if( mip + 1 != src.GetMipCount() )
1151 {
1152 AdvanceMip( src, source.m_desc, mip );
1153 AdvanceMip( dst, m_desc, mip );
1154 }
1155
1156 box.left = box.left >> 1;

Callers 3

MapForReadingMethod · 0.45
MapForReadingMethod · 0.45
ResolveMethod · 0.45

Calls 11

IsWritableFunction · 0.85
CropFunction · 0.85
AdvanceMipFunction · 0.85
IsSubresourceFullMethod · 0.80
CopyResourceMethod · 0.80
GetTrueMipCountMethod · 0.80
GetFaceCountMethod · 0.80
IsValidFunction · 0.70
HasFlagFunction · 0.70
IsValidMethod · 0.45
GetMipCountMethod · 0.45

Tested by

no test coverage detected