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

Function CreateVolumeTexture

trinity/Tr2ImageIOHelpers.cpp:48–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48bool CreateVolumeTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL& out, uint32_t& memoryUse, Tr2PrimaryRenderContext& renderContext )
49{
50 CCP_STATS_ZONE( __FUNCTION__ );
51
52 if( !bitmap.IsValid() )
53 {
54 return false;
55 }
56
57 BeTimer create;
58
59 const unsigned trueMipLevelCount = bitmap.GetTrueMipCount();
60
61 std::vector<Tr2SubresourceData> initData;
62
63 //
64 // Copy the pixels into the locked D3D surface (one copy per mip)
65 //
66 for( unsigned i = 0; i != trueMipLevelCount; ++i )
67 {
68 Tr2SubresourceData srd;
69
70 srd.m_sysMem = const_cast<char*>( bitmap.GetMipRawData( i ) );
71 srd.m_sysMemSlicePitch = bitmap.GetMipSize( i ) / std::max( bitmap.GetMipDepth( i ), 1u );
72 srd.m_sysMemPitch = bitmap.GetMipPitch( i );
73
74 if( !srd.m_sysMem )
75 {
76 return false;
77 }
78
79 //const unsigned mipDepth = std::max( ih.GetDepth() >> i, 1u );
80 //srd.m_sysMemSlicePitch /= mipDepth;
81
82 initData.push_back( srd );
83
84 memoryUse += bitmap.GetMipSize( i );
85 }
86
87 return !FAILED( out.Create( bitmap, Tr2GpuUsage::SHADER_RESOURCE, &initData[0], renderContext ) );
88}
89
90}
91

Callers 1

CreateTextureFunction · 0.85

Calls 4

GetTrueMipCountMethod · 0.80
GetMipSizeMethod · 0.80
IsValidMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected