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

Function AdvanceMip

trinityal/Tr2HalHelperStructures.cpp:275–309  ·  view source on GitHub ↗

Check if we're moving to a smaller mip, and if so, shrink the rectangle pointed at by sub in half.

Source from the content-addressed store, hash-verified

273// Check if we're moving to a smaller mip, and if so, shrink the rectangle pointed at by
274// sub in half.
275void AdvanceMip( Tr2TextureSubresource& sub, const Tr2BitmapDimensions& bd, uint32_t mip )
276{
277 if( bd.GetMipWidth( sub.m_startMipLevel + mip + 1 ) < bd.GetMipWidth( sub.m_startMipLevel + mip ) )
278 {
279 sub.m_box.left /= 2;
280 sub.m_box.right /= 2;
281
282 if( bd.IsCompressed() && sub.GetWidth() < 4 )
283 {
284 sub.m_box.right = sub.m_box.left + 4;
285 }
286 }
287
288 if( bd.GetMipHeight( sub.m_startMipLevel + mip + 1 ) < bd.GetMipHeight( sub.m_startMipLevel + mip ) )
289 {
290 sub.m_box.top /= 2;
291 sub.m_box.bottom /= 2;
292
293 if( bd.IsCompressed() && sub.GetHeight() < 4 )
294 {
295 sub.m_box.bottom = sub.m_box.top + 4;
296 }
297 }
298
299 if( bd.GetMipDepth( sub.m_startMipLevel + mip + 1 ) < bd.GetMipDepth( sub.m_startMipLevel + mip ) )
300 {
301 sub.m_box.front /= 2;
302 sub.m_box.back /= 2;
303
304 if( bd.IsCompressed() && sub.GetDepth() < 4 )
305 {
306 sub.m_box.bottom = sub.m_box.top + 4;
307 }
308 }
309}

Callers 3

CopySubresourceRegionMethod · 0.85
CopySubresourceRegionMethod · 0.85
TESTFunction · 0.85

Calls 3

GetWidthMethod · 0.45
GetHeightMethod · 0.45
GetDepthMethod · 0.45

Tested by 1

TESTFunction · 0.68