MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / TextureToVRAM

Method TextureToVRAM

Source/Graphics/textures.cpp:860–1244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

858}
859
860void 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

Callers

nothing calls this directly

Calls 15

maxFunction · 0.85
DebugTracePrintMethod · 0.80
EnsureInRAMMethod · 0.80
IsCubeMethod · 0.80
GetColorSpaceMethod · 0.80
SetColorSpaceMethod · 0.80
GetMipLevelsMethod · 0.80
anisotropyMethod · 0.80
GetGLInternalFormatMethod · 0.80
GetGLTypeMethod · 0.80
HasMipmapsMethod · 0.80

Tested by

no test coverage detected