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

Method Create

trinity/Resources/TriTextureRes.cpp:1070–1130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1068}
1069
1070bool TriTextureRes::Create( uint32_t width,
1071 uint32_t height,
1072 uint32_t mipCount,
1073 PixelFormat format,
1074 BufferUsageFlags usage,
1075 Tr2PrimaryRenderContext& renderContext )
1076{
1077 DestroyOwnTexture();
1078
1079 auto gpuUsage = Tr2GpuUsage::SHADER_RESOURCE;
1080 auto cpuUsage = Tr2CpuUsage::NONE;
1081
1082 if( ( usage & Tr2RenderContextEnum::USAGE_IMMUTABLE ) != 0 )
1083 {
1084 cpuUsage = cpuUsage | Tr2CpuUsage::READ;
1085 }
1086 else if( ( usage & Tr2RenderContextEnum::USAGE_LOCK_FREQUENTLY ) != 0 )
1087 {
1088 cpuUsage = cpuUsage | Tr2CpuUsage::WRITE_OFTEN;
1089 }
1090 else
1091 {
1092 cpuUsage = cpuUsage | Tr2CpuUsage::WRITE;
1093 }
1094 if( ( usage & Tr2RenderContextEnum::USAGE_CPU_READ ) != 0 )
1095 {
1096 cpuUsage = cpuUsage | Tr2CpuUsage::READ;
1097 }
1098 if( ( usage & Tr2RenderContextEnum::USAGE_UNORDERED_ACCESS ) != 0 )
1099 {
1100 gpuUsage = gpuUsage | Tr2GpuUsage::UNORDERED_ACCESS;
1101 }
1102 if( ( usage & Tr2RenderContextEnum::USAGE_SHADER_RESOURCE ) != 0 )
1103 {
1104 gpuUsage = gpuUsage | Tr2GpuUsage::SHARED;
1105 }
1106
1107 CR_RETURN_VAL( m_ownTexture.Create(
1108 Tr2BitmapDimensions( width, height, mipCount, format ),
1109 gpuUsage,
1110 cpuUsage,
1111 renderContext ),
1112 false );
1113
1114 *static_cast<Tr2BitmapDimensions*>( this ) = m_ownTexture.GetDesc();
1115
1116 m_memoryUse = 0;
1117 auto trueMipCount = GetTrueMipCount();
1118 for( uint32_t i = 0; i < trueMipCount; ++i )
1119 {
1120 m_memoryUse += GetMipSize( i );
1121 }
1122 m_memoryUse *= std::max( 1u, GetArraySize() );
1123 m_originalMemoryUse = m_memoryUse;
1124
1125 CCP_STATS_ADD( textureResBytes, m_memoryUse );
1126 SetTexture( m_ownTexture );
1127 SetPrepared( true );

Callers 15

PyInitFunction · 0.45
ProcessLodRequestMethod · 0.45
CreateEmptyTextureMethod · 0.45
CreateFromTextureMethod · 0.45
ParseIesMethod · 0.45
GetThumbnailMethod · 0.45
RasterizeSolidColorFunction · 0.45
RasterizeGradientFunction · 0.45
LimitSizeMethod · 0.45
ExecuteMethod · 0.45
RenderShadowsMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected