| 1864 | } |
| 1865 | |
| 1866 | bool CompressionThreadProc() |
| 1867 | { |
| 1868 | ntc::Status ntcStatus; |
| 1869 | |
| 1870 | bool uploadAllTextures = false; |
| 1871 | if (!m_textureSet) |
| 1872 | { |
| 1873 | ntcStatus = m_ntcContext->CreateTextureSet(m_textureSetDesc, GetTextureSetFeatures(true), &m_textureSet); |
| 1874 | CHECK_NTC_RESULT(CreateTextureSet); |
| 1875 | CHECK_CANCEL(false); |
| 1876 | |
| 1877 | uploadAllTextures = true; |
| 1878 | } |
| 1879 | |
| 1880 | if (!UploadReferenceImages(uploadAllTextures)) |
| 1881 | return false; |
| 1882 | |
| 1883 | m_textureSet->SetMaskChannelIndex(m_alphaMaskChannelIndex, m_discardMaskedOutPixels); |
| 1884 | m_textureSet->SetExperimentalKnob(m_experimentalKnob); |
| 1885 | |
| 1886 | ntcStatus = m_textureSet->SetLatentShape(m_latentShape); |
| 1887 | CHECK_NTC_RESULT(SetLatentShape); |
| 1888 | |
| 1889 | // Apply the per-image loss function scales to the appropriate channels |
| 1890 | for (auto const& image : m_images) |
| 1891 | { |
| 1892 | for (int channel = 0; channel < image.channels; ++channel) |
| 1893 | { |
| 1894 | m_compressionSettings.lossFunctionScales[image.firstChannel + channel] = image.lossFunctionScales[channel]; |
| 1895 | } |
| 1896 | } |
| 1897 | |
| 1898 | time_point beginTime = steady_clock::now(); |
| 1899 | |
| 1900 | ntcStatus = m_textureSet->BeginCompression(m_compressionSettings); |
| 1901 | CHECK_NTC_RESULT(BeginCompression); |
| 1902 | CHECK_CANCEL(true); |
| 1903 | |
| 1904 | ntc::CompressionStats stats; |
| 1905 | char textureName[32]; |
| 1906 | |
| 1907 | do |
| 1908 | { |
| 1909 | ntcStatus = m_textureSet->RunCompressionSteps(&stats); |
| 1910 | CHECK_CANCEL(true); |
| 1911 | if (ntcStatus == ntc::Status::Incomplete || ntcStatus == ntc::Status::Ok) |
| 1912 | { |
| 1913 | if (m_showCompressionProgress && ntcStatus == ntc::Status::Incomplete) |
| 1914 | { |
| 1915 | if (!DecompressIntoTextures(false, true, false, beginTime)) |
| 1916 | { |
| 1917 | // If the user clicks Cancel while decompression is running, DecompressIntoTextures(...) |
| 1918 | // doesn't call AbortCompression() - do that here to avoid leaving the texture set |
| 1919 | // in an incorrect state, which prevents further compression attempts. |
| 1920 | m_textureSet->AbortCompression(); |
| 1921 | return false; |
| 1922 | } |
| 1923 | } |
nothing calls this directly
no test coverage detected