MCPcopy Create free account
hub / github.com/NVIDIA-RTX/RTXNTC / CompressionThreadProc

Method CompressionThreadProc

tools/explorer/NtcExplorer.cpp:1866–1956  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

CreateTextureSetMethod · 0.80
BeginCompressionMethod · 0.80

Tested by

no test coverage detected