| 734 | } |
| 735 | |
| 736 | return (commandsExecuted > 0); |
| 737 | } |
| 738 | |
| 739 | void TextureCache::LoadingFinished() |
| 740 | { |
| 741 | m_CommandList = nullptr; |
| 742 | } |
| 743 | |
| 744 | void TextureCache::SetMaxTextureSize(uint32_t size) |
| 745 | { |
| 746 | m_MaxTextureSize = size; |
| 747 | } |
| 748 | |
| 749 | #ifdef _MSC_VER |
| 750 | #define strcasecmp _stricmp |
| 751 | #endif |
| 752 | |
| 753 | namespace donut::engine |
| 754 | { |
| 755 | bool SaveTextureToFile( |
| 756 | nvrhi::IDevice* device, |
| 757 | CommonRenderPasses* pPasses, |
| 758 | nvrhi::ITexture* texture, |
| 759 | nvrhi::ResourceStates textureState, |
| 760 | const char* fileName, |
| 761 | bool saveAlphaChannel) |
| 762 | { |
| 763 | if (!fileName) |
| 764 | return false; |
| 765 | |
| 766 | // Find the file's extension |
| 767 | char const* ext = strrchr(fileName, '.'); |
| 768 | |
| 769 | if (!ext) |
| 770 | return false; // No extension fond in the file name |
| 771 | |
| 772 | // Determine the image format from the extension |
| 773 | enum { BMP, PNG, JPG, TGA } destFormat; |
| 774 | if (strcasecmp(ext, ".bmp") == 0) |
| 775 | destFormat = BMP; |
| 776 | else if (strcasecmp(ext, ".png") == 0) |
| 777 | destFormat = PNG; |
| 778 | else if (strcasecmp(ext, ".jpg") == 0 || strcasecmp(ext, ".jpeg") == 0) |
| 779 | destFormat = JPG; |
| 780 | else if (strcasecmp(ext, ".tga") == 0) |
| 781 | destFormat = TGA; |
| 782 | else |
| 783 | return false; // Unknown file type |
| 784 | |
| 785 | if (destFormat == JPG) |
| 786 | saveAlphaChannel = false; |
| 787 | |
| 788 | nvrhi::TextureDesc desc = texture->getDesc(); |
| 789 | nvrhi::TextureHandle tempTexture; |
| 790 | nvrhi::FramebufferHandle tempFramebuffer; |
| 791 | |
| 792 | nvrhi::CommandListHandle commandList = device->createCommandList(); |
| 793 | commandList->open(); |
nothing calls this directly
no test coverage detected