Explorar o código

Merge pull request #88325 from akien-mga/texture-formats

Export: Unify settings for PC texture formats, removed obsoleted ETC feature
Rémi Verschelde hai 1 ano
pai
achega
59643bdb86

+ 1 - 4
drivers/gles3/storage/utilities.cpp

@@ -355,19 +355,16 @@ bool Utilities::has_os_feature(const String &p_feature) const {
 	if (p_feature == "rgtc") {
 		return config->rgtc_supported;
 	}
-
 	if (p_feature == "s3tc") {
 		return config->s3tc_supported;
 	}
-
 	if (p_feature == "bptc") {
 		return config->bptc_supported;
 	}
 	if (p_feature == "astc") {
 		return config->astc_supported;
 	}
-
-	if (p_feature == "etc" || p_feature == "etc2") {
+	if (p_feature == "etc2") {
 		return config->etc2_supported;
 	}
 

+ 0 - 1
editor/editor_property_name_processor.cpp

@@ -160,7 +160,6 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
 	capitalize_string_remaps["dtls"] = "DTLS";
 	capitalize_string_remaps["eol"] = "EOL";
 	capitalize_string_remaps["erp"] = "ERP";
-	capitalize_string_remaps["etc"] = "ETC";
 	capitalize_string_remaps["etc2"] = "ETC2";
 	capitalize_string_remaps["fabrik"] = "FABRIK";
 	capitalize_string_remaps["fbx"] = "FBX";

+ 16 - 15
editor/export/editor_export_platform_pc.cpp

@@ -34,17 +34,13 @@
 #include "scene/resources/image_texture.h"
 
 void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const {
-	if (p_preset->get("texture_format/bptc")) {
-		r_features->push_back("bptc");
-	}
-	if (p_preset->get("texture_format/s3tc")) {
+	if (p_preset->get("texture_format/s3tc_bptc")) {
 		r_features->push_back("s3tc");
+		r_features->push_back("bptc");
 	}
-	if (p_preset->get("texture_format/etc")) {
-		r_features->push_back("etc");
-	}
-	if (p_preset->get("texture_format/etc2")) {
+	if (p_preset->get("texture_format/etc2_astc")) {
 		r_features->push_back("etc2");
+		r_features->push_back("astc");
 	}
 	// PC platforms only have one architecture per export, since
 	// we export a single executable instead of a bundle.
@@ -60,10 +56,8 @@ void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) c
 
 	r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/embed_pck"), false));
 
-	r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/bptc"), true));
-	r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true));
-	r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
-	r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), false));
+	r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc_bptc"), true));
+	r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2_astc"), false));
 }
 
 String EditorExportPlatformPC::get_name() const {
@@ -103,6 +97,14 @@ bool EditorExportPlatformPC::has_valid_export_configuration(const Ref<EditorExpo
 	valid = dvalid || rvalid;
 	r_missing_templates = !valid;
 
+	bool uses_s3tc_bptc = p_preset->get("texture_format/s3tc_bptc");
+	bool uses_etc2_astc = p_preset->get("texture_format/etc2_astc");
+
+	if (!uses_s3tc_bptc && !uses_etc2_astc) {
+		valid = false;
+		err += TTR("A texture format must be selected to export the project. Please select at least one texture format.");
+	}
+
 	if (!err.is_empty()) {
 		r_error = err;
 	}
@@ -237,9 +239,8 @@ void EditorExportPlatformPC::set_logo(const Ref<Texture2D> &p_logo) {
 }
 
 void EditorExportPlatformPC::get_platform_features(List<String> *r_features) const {
-	r_features->push_back("pc"); //all pcs support "pc"
-	r_features->push_back("s3tc"); //all pcs support "s3tc" compression
-	r_features->push_back(get_os_name().to_lower()); //OS name is a feature
+	r_features->push_back("pc"); // Identify PC platforms as such.
+	r_features->push_back(get_os_name().to_lower()); // OS name is a feature.
 }
 
 void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) {

+ 0 - 1
editor/project_settings_editor.cpp

@@ -280,7 +280,6 @@ void ProjectSettingsEditor::_add_feature_overrides() {
 
 	presets.insert("bptc");
 	presets.insert("s3tc");
-	presets.insert("etc");
 	presets.insert("etc2");
 	presets.insert("editor");
 	presets.insert("template_debug");

+ 2 - 2
modules/basis_universal/register_types.cpp

@@ -190,9 +190,9 @@ static Ref<Image> basis_universal_unpacker_ptr(const uint8_t *p_data, int p_size
 			} else if (RS::get_singleton()->has_os_feature("s3tc")) {
 				format = basist::transcoder_texture_format::cTFBC1; // get this from renderer
 				imgfmt = Image::FORMAT_DXT1;
-			} else if (RS::get_singleton()->has_os_feature("etc")) {
+			} else if (RS::get_singleton()->has_os_feature("etc2")) {
 				format = basist::transcoder_texture_format::cTFETC1; // get this from renderer
-				imgfmt = Image::FORMAT_ETC;
+				imgfmt = Image::FORMAT_ETC2_RGB8;
 			} else {
 				format = basist::transcoder_texture_format::cTFBGR565; // get this from renderer
 				imgfmt = Image::FORMAT_RGB565;

+ 1 - 1
modules/ktx/texture_loader_ktx.cpp

@@ -287,7 +287,7 @@ static Ref<Image> load_from_file_access(Ref<FileAccess> f, Error *r_error) {
 							ktxfmt = KTX_TTF_BC7_RGBA;
 						} else if (RS::get_singleton()->has_os_feature("s3tc")) {
 							ktxfmt = KTX_TTF_BC1_RGB;
-						} else if (RS::get_singleton()->has_os_feature("etc")) {
+						} else if (RS::get_singleton()->has_os_feature("etc2")) {
 							ktxfmt = KTX_TTF_ETC1_RGB;
 						} else {
 							ktxfmt = KTX_TTF_RGBA32;

+ 4 - 10
platform/linuxbsd/doc_classes/EditorExportPlatformLinuxBSD.xml

@@ -57,17 +57,11 @@
 			- [code]{exe_name}[/code] - Name of application executable.
 			- [code]{cmd_args}[/code] - Array of the command line argument for the application.
 		</member>
-		<member name="texture_format/bptc" type="bool" setter="" getter="">
-			If [code]true[/code], project textures are exported in the BPTC format.
+		<member name="texture_format/etc2_astc" type="bool" setter="" getter="">
+			If [code]true[/code], project textures are exported in the ETC2/ASTC format.
 		</member>
-		<member name="texture_format/etc" type="bool" setter="" getter="">
-			If [code]true[/code], project textures are exported in the ETC format.
-		</member>
-		<member name="texture_format/etc2" type="bool" setter="" getter="">
-			If [code]true[/code], project textures are exported in the ETC2 format.
-		</member>
-		<member name="texture_format/s3tc" type="bool" setter="" getter="">
-			If [code]true[/code], project textures are exported in the S3TC format.
+		<member name="texture_format/s3tc_bptc" type="bool" setter="" getter="">
+			If [code]true[/code], project textures are exported in the S3TC/BPTC format.
 		</member>
 	</members>
 </class>

+ 4 - 10
platform/windows/doc_classes/EditorExportPlatformWindows.xml

@@ -129,17 +129,11 @@
 			- [code]{exe_name}[/code] - Name of application executable.
 			- [code]{cmd_args}[/code] - Array of the command line argument for the application.
 		</member>
-		<member name="texture_format/bptc" type="bool" setter="" getter="">
-			If [code]true[/code], project textures are exported in the BPTC format.
+		<member name="texture_format/etc2_astc" type="bool" setter="" getter="">
+			If [code]true[/code], project textures are exported in the ETC2/ASTC format.
 		</member>
-		<member name="texture_format/etc" type="bool" setter="" getter="">
-			If [code]true[/code], project textures are exported in the ETC format.
-		</member>
-		<member name="texture_format/etc2" type="bool" setter="" getter="">
-			If [code]true[/code], project textures are exported in the ETC2 format.
-		</member>
-		<member name="texture_format/s3tc" type="bool" setter="" getter="">
-			If [code]true[/code], project textures are exported in the S3TC format.
+		<member name="texture_format/s3tc_bptc" type="bool" setter="" getter="">
+			If [code]true[/code], project textures are exported in the S3TC/BPTC format.
 		</member>
 	</members>
 </class>

+ 1 - 1
servers/rendering/dummy/storage/utilities.h

@@ -108,7 +108,7 @@ public:
 	virtual void set_debug_generate_wireframes(bool p_generate) override {}
 
 	virtual bool has_os_feature(const String &p_feature) const override {
-		return p_feature == "rgtc" || p_feature == "bptc" || p_feature == "s3tc" || p_feature == "etc" || p_feature == "etc2";
+		return p_feature == "rgtc" || p_feature == "bptc" || p_feature == "s3tc" || p_feature == "etc2";
 	}
 
 	virtual void update_memory_info() override {}

+ 1 - 1
servers/rendering/renderer_rd/storage_rd/utilities.cpp

@@ -278,7 +278,7 @@ bool Utilities::has_os_feature(const String &p_feature) const {
 		return true;
 	}
 
-	if ((p_feature == "etc" || p_feature == "etc2") && RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT)) {
+	if (p_feature == "etc2" && RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT)) {
 		return true;
 	}