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

Method CreateArray

trinity/Tr2RenderTarget.cpp:130–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130int32_t Tr2RenderTarget::CreateArray(
131 unsigned width,
132 unsigned height,
133 unsigned arraySize,
134 unsigned mipLevelCount,
135 Tr2RenderContextEnum::PixelFormat format,
136 Tr2RenderContextEnum::ExFlag flags,
137 Tr2RenderContextEnum::TextureType type )
138{
139 CCP_STATS_ZONE( __FUNCTION__ );
140 USE_MAIN_THREAD_RENDER_CONTEXT();
141 if( IsAttached() )
142 {
143 return E_INVALIDARG;
144 }
145
146 auto gpuUsage = Tr2GpuUsage::NONE;
147 auto cpuUsage = Tr2CpuUsage::NONE;
148 GetUsage( 0u, flags, gpuUsage, cpuUsage );
149 if( !type )
150 {
151 type = TEX_TYPE_2D;
152 }
153
154 if( type == TEX_TYPE_CUBE )
155 {
156 arraySize *= 6;
157 }
158
159 auto hr = m_renderTarget.Create(
160 Tr2BitmapDimensions( type, format, width, height, 1, mipLevelCount, arraySize ),
161 Tr2MsaaDesc(),
162 gpuUsage,
163 cpuUsage,
164 nullptr,
165 renderContext )
166 .GetResult();
167 if( SUCCEEDED( hr ) )
168 {
169 m_width = width;
170 m_height = height;
171 m_arraySize = arraySize;
172 m_mipCount = mipLevelCount;
173 m_format = format;
174 m_msaa = Tr2MsaaDesc();
175 m_flags = ExFlag( flags );
176 m_type = type;
177 m_cpuUsage = cpuUsage;
178 m_gpuUsage = gpuUsage;
179 m_renderTarget.SetName( m_name.c_str() );
180 }
181 else
182 {
183 Destroy();
184 }
185 return hr;
186}
187

Callers

nothing calls this directly

Calls 7

GetUsageFunction · 0.85
ExFlagEnum · 0.85
DestroyFunction · 0.85
Tr2MsaaDescClass · 0.50
GetResultMethod · 0.45
CreateMethod · 0.45
SetNameMethod · 0.45

Tested by

no test coverage detected