MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Load

Method Load

Source/Engine/Graphics/Materials/MaterialShader.cpp:234–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234bool MaterialShader::Load(MemoryReadStream& shaderCacheStream, const MaterialInfo& info)
235{
236 PROFILE_MEM(GraphicsMaterials);
237 ASSERT(!_isLoaded);
238
239 // Cache material info
240 _info = info;
241
242 // Create shader
243 if (_shader->Create(shaderCacheStream))
244 {
245 LOG(Warning, "Cannot load shader.");
246 return true;
247 }
248
249 // Init memory for a constant buffer
250 _cb = _shader->GetCB(0);
251 if (_cb)
252 {
253 int32 cbSize = _cb->GetSize();
254 if (cbSize == 0)
255 {
256 // Handle unused constant buffer (eg. postFx returning solid color)
257 cbSize = 1024;
258 _cb = nullptr;
259 }
260 _cbData.Resize(cbSize, false);
261 Platform::MemoryClear(_cbData.Get(), cbSize);
262 }
263
264 // Initialize the material based on type (create pipeline states and setup)
265 if (Load())
266 {
267 return true;
268 }
269
270 _isLoaded = true;
271 return false;
272}
273
274void MaterialShader::Unload()
275{

Callers 2

CreateMethod · 0.45
CreateDummyMethod · 0.45

Calls 6

MemoryClearFunction · 0.85
LoadFunction · 0.50
CreateMethod · 0.45
GetSizeMethod · 0.45
ResizeMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected