| 1753 | } |
| 1754 | |
| 1755 | int GLTextureManager::createTexHelperProcess(QString texHelperAppStr, QString commandLine, unsigned int texhelperId, int lifetime, TexHelperResponse * outResponse, void ** outData) |
| 1756 | { |
| 1757 | if (GLOBAL(settings).disableLibSquish) |
| 1758 | commandLine += " -q\"\" "; |
| 1759 | |
| 1760 | if (0xFFFFFFFF == texhelperId) |
| 1761 | { |
| 1762 | // Some TexHelper requests come from the main thread and is not bound by _maxNumLoadingThreads, |
| 1763 | // so create new TexHelper process for these requests. |
| 1764 | PROCESS_INFORMATION ProcessInfo = {0}; |
| 1765 | STARTUPINFO StartupInfo = {0}; |
| 1766 | StartupInfo.cb = sizeof(StartupInfo); |
| 1767 | if(CreateProcess((LPWSTR) texHelperAppStr.utf16(), (LPWSTR) commandLine.utf16(), |
| 1768 | NULL,NULL, FALSE, CREATE_NO_WINDOW | DETACHED_PROCESS,NULL, |
| 1769 | NULL, &StartupInfo, &ProcessInfo)) |
| 1770 | { |
| 1771 | DWORD result = WaitForSingleObject(ProcessInfo.hProcess, lifetime); |
| 1772 | if (result == WAIT_TIMEOUT) |
| 1773 | { |
| 1774 | TerminateProcess(ProcessInfo.hProcess, 1); |
| 1775 | if (outResponse) |
| 1776 | *outResponse = TexHelperResponse(false, true, true); |
| 1777 | return -1; |
| 1778 | } |
| 1779 | else |
| 1780 | GetExitCodeProcess(ProcessInfo.hProcess, &result); |
| 1781 | CloseHandle(ProcessInfo.hThread); |
| 1782 | CloseHandle(ProcessInfo.hProcess); |
| 1783 | |
| 1784 | // if the texhelper has failed, then we should disable the texhelper and try again without it |
| 1785 | if (result > 0 && !GLOBAL(settings).disableLibSquish) |
| 1786 | { |
| 1787 | GLOBAL(settings).disableLibSquish = true; |
| 1788 | winOS->SaveSettingsFile(); |
| 1789 | // NOTE: we must set the disableLibSquish before recursing or we may get inf loop! |
| 1790 | result = createTexHelperProcess(texHelperAppStr, commandLine, texhelperId, lifetime, outResponse, outData); |
| 1791 | } |
| 1792 | if (outResponse) |
| 1793 | *outResponse = TexHelperResponse(false, true, 0 != result); |
| 1794 | return result; |
| 1795 | } |
| 1796 | if (outResponse) |
| 1797 | *outResponse = TexHelperResponse(false, true, true); |
| 1798 | return -1; |
| 1799 | } |
| 1800 | |
| 1801 | if (_texHelperManager) |
| 1802 | return _texHelperManager->texHelperOperation(commandLine, texhelperId, lifetime, outResponse, outData); |
| 1803 | else |
| 1804 | return -1; |
| 1805 | } |
| 1806 | |
| 1807 | QString GLTextureManager::ensureCompressedImage( const GLTextureObject& obj ) |
| 1808 | { |
nothing calls this directly
no test coverage detected