diff --git a/tools/shaderc/shaderc_metal.cpp b/tools/shaderc/shaderc_metal.cpp index 74434fb0a..d4c8765bc 100644 --- a/tools/shaderc/shaderc_metal.cpp +++ b/tools/shaderc/shaderc_metal.cpp @@ -625,15 +625,15 @@ namespace bgfx { namespace metal glslang::InitializeProcess(); - glslang::TProgram* program = new glslang::TProgram; - EShLanguage stage = getLang(_options.shaderType); if (EShLangCount == stage) { bx::printf("Error: Unknown shader type '%c'.\n", _options.shaderType); return false; } - glslang::TShader* shader = new glslang::TShader(stage); + + glslang::TProgram* program = new glslang::TProgram; + glslang::TShader* shader = new glslang::TShader(stage); EShMessages messages = EShMessages(0 | EShMsgDefault @@ -788,6 +788,8 @@ namespace bgfx { namespace metal } // recompile with the unused uniforms converted to statics + delete program; + delete shader; return compile(_options, _version, output.c_str(), _writer, false); } diff --git a/tools/shaderc/shaderc_spirv.cpp b/tools/shaderc/shaderc_spirv.cpp index b501e9fdc..9c2510e20 100644 --- a/tools/shaderc/shaderc_spirv.cpp +++ b/tools/shaderc/shaderc_spirv.cpp @@ -741,15 +741,15 @@ namespace bgfx { namespace spirv glslang::InitializeProcess(); - glslang::TProgram* program = new glslang::TProgram; - EShLanguage stage = getLang(_options.shaderType); if (EShLangCount == stage) { bx::printf("Error: Unknown shader type '%c'.\n", _options.shaderType); return false; } - glslang::TShader* shader = new glslang::TShader(stage); + + glslang::TProgram* program = new glslang::TProgram; + glslang::TShader* shader = new glslang::TShader(stage); EShMessages messages = EShMessages(0 | EShMsgDefault @@ -934,6 +934,8 @@ namespace bgfx { namespace spirv output = uniformBlock + output; // recompile with the unused uniforms converted to statics + delete program; + delete shader; return compile(_options, _version, output.c_str(), _writer, false); } else