Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: Fix multiple issues with PVRTC import, disable ETC1 #38076

Merged
merged 1 commit into from
Sep 28, 2020

Conversation

DrMoriarty
Copy link
Contributor

@DrMoriarty DrMoriarty commented Apr 21, 2020

and some other VRAM compression formats.

For iOS we enable pvrtc feature by default for both GLES2/GLES3
Etc1 for iOS doesn't have any sense, so it disabled.
Fixed checks in export editor.
Fixed pvrtc ability detection in GLES2 driver.
Fixed pvrtc encoding procedure.
Compressed stream texture now saves right image dimensions for every compression format.
Also it allows to compressor resize image on it's side to make it more optimized.
So ETC1 format becames smaller then before. Pvrtc format always saves square texture.

Bugsquad edit: closes #28683, closes #28621, closes #28596 and maybe others
For #38040 and #35851, the fix has been moved to #42118.

@DrMoriarty DrMoriarty requested a review from reduz as a code owner April 21, 2020 12:30
@DrMoriarty
Copy link
Contributor Author

I'm not sure that it will work for master, so make PR for 3.2 branch.

@Filippopotamus
Copy link

Loading textures on iOS using GLES2 is still an issue. Is there a plan to merge this fix?

@HEAVYPOLY
Copy link
Contributor

+1 this is a big one for my project.

@akien-mga
Copy link
Member

I need contributors familiar with iOS to help review it, CC @bruvzg @naithar.

The fixes should also be ported to the master branch.

@Filippopotamus
Copy link

@akien-mga I have cherry picked it to our 3.2.2 fork and it does seem to fix the GLES2 loading resource issue in iOS

Comment on lines 230 to 244
bool resize_to_po2 = false;

if (p_compress_mode == COMPRESS_VIDEO_RAM && p_force_po2_for_compressed && (p_mipmaps || p_texture_flags & Texture::FLAG_REPEAT)) {
resize_to_po2 = true;
f->store_16(next_power_of_2(p_image->get_width()));
f->store_16(p_image->get_width());
f->store_16(next_power_of_2(p_image->get_height()));
f->store_16(p_image->get_height());
} else {
f->store_16(p_image->get_width());
f->store_16(0);
f->store_16(p_image->get_height());
f->store_16(0);
}
f->store_32(p_texture_flags);
Copy link
Member

@akien-mga akien-mga Sep 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the only changes I'm not confident with as they impact all formats, so I want @reduz to review this more closely.

The rest of the changes seem good though (with some obvious bugfixes like in drivers/gles2 or platform/iphone/export/export.cpp), so I'd suggest splitting the texture importer change to a dedicated PR and remove it here, so that the rest can be merged first.

Pretty good changes overall, thanks for your work and sorry for the late review.

@DrMoriarty
Copy link
Contributor Author

@akien-mga #42118

@akien-mga akien-mga changed the title Ultimate fix for PVRTC iOS: Fix multiple issues with PVRTC import, disable ETC1 Sep 23, 2020
@akien-mga
Copy link
Member

Rebased to remove the unrelated CHANGELOG conflict, and made the commit log a bit more explicit.

Could you check if the issues referenced as fixed by this PR are still all fixed, or if some of them are fixed by #42118 instead (or only fixed once both are merged)?


String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name");
bool driver_fallback = ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2");
bool etc_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess etc_supported is not relevant for iOS (and now disabled by platform/iphone/export/export.cpp changes), so maybe it can be removed from the checks / error messages?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think so

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed an amend that removes the etc_supported check.

@DrMoriarty
Copy link
Contributor Author

@akien-mga
issues #38040 and #35851 related to PR #42118
Other related to this PR

Fixes: godotengine#28683, godotengine#28621, godotengine#28596 and maybe others

For iOS we enable pvrtc feature by default for both GLES2/GLES3
Etc1 for iOS doesn't have any sense, so it disabled.
Fixed checks in export editor.
Fixed pvrtc ability detection in GLES2 driver.
Fixed pvrtc encoding procedure.
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me. I can't really assess the modules/pvr/texture_loader_pvr.cpp changes but I trust that you tested them and that they make things work as they should. The rest is 👍

akien-mga added a commit to akien-mga/godot that referenced this pull request Sep 23, 2020
Fixes: godotengine#28683, godotengine#28621, godotengine#28596 and maybe others

For iOS we enable pvrtc feature by default for all backends
Etc1 for iOS doesn't have any sense, so it disabled.
Fixed checks in export editor.
Fixed pvrtc encoding procedure.

Edit by Akien: Forward-ported from godotengine#38076, this may not make sense as is for
Godot 4.0, but it's important that we have the latest code in sync with 3.2
for when more rendering backends and proper iOS support are added back.

Co-authored-by: Rémi Verschelde <[email protected]>
@akien-mga
Copy link
Member

I forward-ported the relevant changes for the master branch with #42262 (untested, and some of it might not make sense for Vulkan, hence the TODOs).

@reduz
Copy link
Member

reduz commented Sep 27, 2020

As most users dont go iOS out of the box, I think disabling PVRTC by default is likely the best idea, and only enable it if you are planning to export to iOS.

@DrMoriarty
Copy link
Contributor Author

@reduz this PR don't change default enabled compressed textures formats. So PVRTC will be disabled until user enabled it.

@akien-mga
Copy link
Member

Yes @reduz seems to have misinterpreted the code, this doesn't change the fact that PVRTC is off by default (but it should be toggled on if you want to target iOS with GLES2, just like ETC1 needs to be toggled on manually if you want to target Android with GLES2).

@akien-mga akien-mga merged commit 8ca9680 into godotengine:3.2 Sep 28, 2020
@akien-mga
Copy link
Member

Thanks!

@DrMoriarty DrMoriarty deleted the fix_pvrtc branch September 28, 2020 08:30
MarcusElg pushed a commit to MarcusElg/godot that referenced this pull request Oct 19, 2020
Fixes: godotengine#28683, godotengine#28621, godotengine#28596 and maybe others

For iOS we enable pvrtc feature by default for all backends
Etc1 for iOS doesn't have any sense, so it disabled.
Fixed checks in export editor.
Fixed pvrtc encoding procedure.

Edit by Akien: Forward-ported from godotengine#38076, this may not make sense as is for
Godot 4.0, but it's important that we have the latest code in sync with 3.2
for when more rendering backends and proper iOS support are added back.

Co-authored-by: Rémi Verschelde <[email protected]>
@akien-mga akien-mga modified the milestones: 3.2, 3.3 Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants