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

Method RestoreCompressedTextureSet

tools/explorer/NtcExplorer.cpp:1785–1864  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1783 }
1784
1785 bool RestoreCompressedTextureSet(const CompressionResult& result, bool useRightTextures)
1786 {
1787 ntc::MemoryStreamWrapper inputStream(m_ntcContext);
1788 ntc::Status ntcStatus = m_ntcContext->OpenReadOnlyMemory(result.compressedData->data(),
1789 result.compressedData->size(), inputStream.ptr());
1790 CHECK_NTC_RESULT(OpenReadOnlyMemory);
1791
1792 auto reportError = [this, &result, &ntcStatus]()
1793 {
1794 log::error("Failed to load compressed texture data from run #%d, code = %s: %s",
1795 result.ordinal, ntc::StatusToString(ntcStatus), ntc::GetLastErrorMessage());
1796 };
1797
1798 if (m_useGapiDecompression)
1799 {
1800 ntcStatus = DecompressWithGapi(inputStream, result.compressedData->size(), useRightTextures);
1801
1802 if (ntcStatus != ntc::Status::Ok)
1803 {
1804 reportError();
1805 return false;
1806 }
1807
1808 SetRestoredRunName(result, useRightTextures);
1809
1810 return true;
1811 }
1812
1813 if (m_textureSet)
1814 {
1815 ntcStatus = m_textureSet->LoadFromStream(inputStream);
1816 if (ntcStatus == ntc::Status::FileIncompatible)
1817 {
1818 m_ntcContext->DestroyTextureSet(m_textureSet);
1819 m_textureSet = nullptr;
1820 }
1821 else if (ntcStatus != ntc::Status::Ok)
1822 {
1823 // Reset the network and assume it's empty
1824 m_textureSet->AbortCompression();
1825
1826 reportError();
1827 return false;
1828 }
1829 }
1830
1831 if (!m_textureSet)
1832 {
1833 // Reset the stream to the beginning in case we tried and failed to load it above
1834 inputStream->Seek(0);
1835
1836 ntcStatus = m_ntcContext->CreateCompressedTextureSetFromStream(inputStream,
1837 GetTextureSetFeatures(false), &m_textureSet);
1838 if (ntcStatus != ntc::Status::Ok)
1839 {
1840 reportError();
1841 return false;
1842 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected