MCPcopy Create free account
hub / github.com/GPUOpen-Tools/compressonator / CMP_LoadTexture

Function CMP_LoadTexture

cmp_framework/compute_base.cpp:723–781  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

721}
722
723CMP_ERROR CMP_API CMP_LoadTexture(const char* SourceFile, CMP_MipSet* MipSetIn)
724{
725 CMP_RegisterHostPlugins(); // Keep for legacy, user should now use CMP_InitFramework
726
727 CMP_CMIPS CMips;
728 CMP_ERROR status = CMP_OK;
729
730 const std::string& fn = SourceFile;
731
732 std::string file_extension = fn.substr(fn.find_last_of('.') + 1);
733
734 std::transform(file_extension.begin(), file_extension.end(), file_extension.begin(), toupperChar);
735
736 PluginInterface_Image* plugin_Image;
737 do
738 {
739 plugin_Image = reinterpret_cast<PluginInterface_Image*>(g_pluginManager.GetPlugin("IMAGE", (char*)file_extension.c_str()));
740 // do the load
741 if (plugin_Image == NULL)
742 {
743 status = CMP_ERR_PLUGIN_FILE_NOT_FOUND;
744 break;
745 }
746 else
747 {
748 plugin_Image->TC_PluginSetSharedIO(&CMips);
749 if (plugin_Image->TC_PluginFileLoadTexture(SourceFile, MipSetIn) != 0)
750 {
751 // Process Error
752 delete plugin_Image;
753 plugin_Image = NULL;
754 status = CMP_ERR_UNABLE_TO_LOAD_FILE;
755 break;
756 }
757
758 delete plugin_Image;
759 plugin_Image = NULL;
760 }
761 } while (0);
762
763 // load failed: try stb lib
764 if (status != CMP_OK)
765 {
766 status = stb_load(SourceFile, MipSetIn);
767 }
768 else
769 {
770 // Make sure MipSetIn->pData is at top mip level
771 if (MipSetIn->pData == NULL)
772 {
773 CMP_MipLevel* pOutMipLevel = CMips.GetMipLevel(MipSetIn, 0, 0);
774 MipSetIn->pData = pOutMipLevel->m_pbData;
775 MipSetIn->dwDataSize = pOutMipLevel->m_dwLinearSize;
776 MipSetIn->dwHeight = pOutMipLevel->m_nHeight;
777 MipSetIn->dwWidth = pOutMipLevel->m_nWidth;
778 }
779 }
780 return status;

Callers 7

mipmap_tests.cppFile · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 9

CMP_RegisterHostPluginsFunction · 0.85
stb_loadFunction · 0.85
GetPluginMethod · 0.80
GetMipLevelMethod · 0.80
transformFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
TC_PluginSetSharedIOMethod · 0.45

Tested by

no test coverage detected