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

Method MapForWriting

trinityal/stub/Tr2TextureALStub.cpp:186–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186ALResult 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
228void Tr2TextureAL::UnmapForWriting( Tr2RenderContextAL& )
229{

Callers

nothing calls this directly

Calls 10

IsValidForBitmapMethod · 0.80
IsSingleSubresourceMethod · 0.80
HasBoxMethod · 0.80
sizeMethod · 0.80
emptyMethod · 0.80
getMethod · 0.80
HasFlagFunction · 0.70
IsValidFunction · 0.50
IsValidMethod · 0.45
GetFormatMethod · 0.45

Tested by

no test coverage detected