Skip to content

Commit

Permalink
Export: Unify settings for PC texture formats
Browse files Browse the repository at this point in the history
S3TC and BPTC should always be used together, and likewise for ETC2 and ASTC.
  • Loading branch information
akien-mga committed Feb 14, 2024
1 parent e457f41 commit a10b4bd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
27 changes: 16 additions & 11 deletions editor/export/editor_export_platform_pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +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/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.
Expand All @@ -57,9 +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/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 {
Expand Down Expand Up @@ -99,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;
}
Expand Down Expand Up @@ -233,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) {
Expand Down
11 changes: 4 additions & 7 deletions platform/linuxbsd/doc_classes/EditorExportPlatformLinuxBSD.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +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/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>
11 changes: 4 additions & 7 deletions platform/windows/doc_classes/EditorExportPlatformWindows.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,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/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>

0 comments on commit a10b4bd

Please sign in to comment.