| 858 | } |
| 859 | |
| 860 | void Textures::TextureToVRAM(unsigned int which) { |
| 861 | PROFILER_GPU_ZONE(g_profiler_ctx, "TextureToVRAM"); |
| 862 | CHECK_GL_ERROR(); |
| 863 | |
| 864 | if (!deferred_delete_textures.empty()) { |
| 865 | for (unsigned int tex_id : deferred_delete_textures) { |
| 866 | LOGI << "Deferred delete of texture " << tex_id << std::endl; |
| 867 | glDeleteTextures(1, &tex_id); |
| 868 | } |
| 869 | deferred_delete_textures.clear(); |
| 870 | } |
| 871 | |
| 872 | Texture& tex = textures[which]; |
| 873 | |
| 874 | if (tex.sub_textures.empty()) { |
| 875 | LOGW << "Calling TextureToVRAM on a texture with no sub_textures" << std::endl; |
| 876 | return; |
| 877 | } |
| 878 | |
| 879 | Graphics::Instance()->DebugTracePrint(tex.sub_textures[0].texture_name.c_str()); |
| 880 | |
| 881 | bool tex_compressed = tex.sub_textures[0].texture_data->IsCompressed(); |
| 882 | // TODO: silently fix the issue |
| 883 | for (int i = 1, len = tex.sub_textures.size(); i < len; ++i) { |
| 884 | const SubTexture& s = tex.sub_textures[i]; |
| 885 | if (s.texture_data->IsCompressed() != tex_compressed) { |
| 886 | LOGE << "TextureToVRAM failed (compression mismatch) for " << s.load_name << std::endl; |
| 887 | return; |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | if (tex.gl_texture_id != UNLOADED_ID) return; |
| 892 | |
| 893 | for (auto& sub_texture : tex.sub_textures) { |
| 894 | sub_texture.texture_data->EnsureInRAM(); |
| 895 | } |
| 896 | |
| 897 | bool is_array = (tex.sub_textures.size() > 1); |
| 898 | bool is_cube = tex.sub_textures[0].texture_data->IsCube(); |
| 899 | |
| 900 | if (is_array && is_cube) { |
| 901 | // GL 4.0 feature, we have minimum requirement 3.2 |
| 902 | LOGE << "cube map arrays not supported" << std::endl; |
| 903 | return; |
| 904 | } |
| 905 | |
| 906 | // FIXME? |
| 907 | if (tex.use_srgb) { |
| 908 | if (tex.sub_textures[0].texture_data->GetColorSpace() != TextureData::sRGB) { |
| 909 | // LOGW << "Texture " << tex.sub_textures[0].load_name << " uses sRGB color space but does not specify it in file name" << std::endl; |
| 910 | } |
| 911 | tex.sub_textures[0].texture_data->SetColorSpace(TextureData::sRGB); |
| 912 | } else { |
| 913 | if (tex.sub_textures[0].texture_data->GetColorSpace() != TextureData::Linear) { |
| 914 | // LOGW << "Texture " << tex.sub_textures[0].load_name << " specifies sRGB color space in file name but linear internally" << std::endl; |
| 915 | } |
| 916 | } |
| 917 |
nothing calls this directly
no test coverage detected