Fix, matc crash when building mobile materials (#3296)

This commit is contained in:
Ben Doherty
2020-11-16 14:37:55 -08:00
committed by Benjamin Doherty
parent 34707431f7
commit 40e7a86f5f

View File

@@ -640,6 +640,7 @@ bool MaterialBuilder::generateShaders(const std::vector<Variant>& variants, Chun
const bool targetApiNeedsSpirv =
(targetApi == TargetApi::VULKAN || targetApi == TargetApi::METAL);
const bool targetApiNeedsMsl = targetApi == TargetApi::METAL;
const bool targetApiNeedsGlsl = targetApi == TargetApi::OPENGL;
std::vector<uint32_t>* pSpirv = targetApiNeedsSpirv ? &spirv : nullptr;
std::string* pMsl = targetApiNeedsMsl ? &msl : nullptr;
@@ -678,6 +679,11 @@ bool MaterialBuilder::generateShaders(const std::vector<Variant>& variants, Chun
#endif
}
std::string* pGlsl = nullptr;
if (targetApiNeedsGlsl) {
pGlsl = &shader;
}
#ifndef FILAMAT_LITE
GLSLPostProcessor::Config config{
@@ -690,7 +696,7 @@ bool MaterialBuilder::generateShaders(const std::vector<Variant>& variants, Chun
config.glsl.subpassInputToColorLocation.emplace_back(0, 0);
}
bool ok = postProcessor.process(shader, config, &shader, pSpirv, pMsl);
bool ok = postProcessor.process(shader, config, pGlsl, pSpirv, pMsl);
#else
bool ok = true;
#endif