Skip to content

Load all available texture mip levels in ResourceManager - #505

Merged
mosra merged 3 commits into
masterfrom
texture-mip-levels
Feb 26, 2020
Merged

Load all available texture mip levels in ResourceManager#505
mosra merged 3 commits into
masterfrom
texture-mip-levels

Conversation

@mosra

@mosra mosra commented Feb 25, 2020

Copy link
Copy Markdown
Contributor

Motivation and Context

The "basisified" MP3D files @erikwijmans encoded a while ago contain a mip pyramid for each image, however until earlier today, Magnum APIs were only able to load the first one (see mosra/magnum#369 for the corresponding change on Magnum's side). While this is a relatively minor change, it has non-negligible impact on rendering times. A very rough artificial benchmark is below, showing clear advantage of having the extra mip levels loaded.

image

Originally, before the files were basisified, the loaded JPEGs got their mip levels generated during import (second bar in the plot above). Above that is comparison to JPEGs loaded in a single level, which is slower due to extra memory fetches needed for minifying the full-size textures.

What is interesting that, on my machine at least, the cost of decoding an ASTC texture makes it similarly slow as uncompressed textures (however the memory used is four times less). That isn't the case for BC7/BC3 formats (even though BC7 isn't exactly simple either), there I suppose the high vertex count dominated the times, and not texture access, thus the difference with mips loaded not being too large. — I have no way to test on NVidia to compare, but I suspect this is due to ASTC still being relatively new and not fully optimized in AMD/Intel hardware.

Would be great to hear about what speed impact this has on the usual workflows.

Besides the above, this drags along:

How Has This Been Tested

Loaded a random basisified MP3D file in the viewer, verified textures show up correctly. The change on Habitat's side actually mirrors an update I did for magnum-player, where I also did the above benchmark and verified other corner case.

ℹ️ The CI fails, but jobs from other branches have the same error, so this time it's not my fault :)

E       AssertionError: No forward action actuation noise detected.
E       assert 0.7185574918985367 > 1.1

Types of changes

  • Docs change / refactoring / dependency upgrade
  • New feature (non-breaking change which adds functionality)

Generating the mipmap only if the loaded image has a single uncompressed
level. Also keeping the existing unused/obsolete on-the-fly texture
compression, as it's still wired into the API.
@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Feb 25, 2020

@erikwijmans erikwijmans left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The CI failure is due to an unreliable test, this should be fixed now.

@codecov

codecov Bot commented Feb 26, 2020

Copy link
Copy Markdown

Codecov Report

Merging #505 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #505   +/-   ##
=======================================
  Coverage   59.86%   59.86%           
=======================================
  Files         158      158           
  Lines        7114     7114           
  Branches       84       84           
=======================================
  Hits         4259     4259           
  Misses       2855     2855           
Flag Coverage Δ
#CPP 55.29% <ø> (+2.58%) ⬆️
#JavaScript 10.00% <ø> (-90.00%) ⬇️
#Python 79.59% <ø> (ø) ⬆️
Impacted Files Coverage Δ
src/esp/bindings_js/modules/web_demo.js 0.00% <0.00%> (ø) ⬆️
src/esp/bindings_js/index.js 0.00% <0.00%> (ø) ⬆️
src/esp/bindings_js/modules/navigate.js 0.00% <0.00%> (ø) ⬆️
src/esp/bindings_js/modules/object_sensor.js 0.00% <0.00%> (ø) ⬆️
src/esp/bindings_js/modules/topdown.js 0.00% <0.00%> (ø) ⬆️
src/esp/bindings_js/modules/vr_demo.js 0.00% <0.00%> (ø) ⬆️
src/esp/bindings_js/modules/viewer_demo.js 0.00% <0.00%> (ø) ⬆️
src/esp/bindings_js/modules/utils.js 50.00% <0.00%> (ø) ⬆️
src/esp/bindings_js/tests/test_utils.js 90.62% <0.00%> (ø) ⬆️
src/esp/bindings_js/modules/defaults.js 88.88% <0.00%> (ø) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 599bebb...f7d34ee. Read the comment docs.

@mosra
mosra merged commit 01a8e36 into master Feb 26, 2020
@mosra
mosra deleted the texture-mip-levels branch February 26, 2020 07:36
@mosra mosra mentioned this pull request Feb 26, 2020
Ram81 pushed a commit to Ram81/habitat-web-sim that referenced this pull request Dec 10, 2020
…earch#505)

* Update Magnum submodules for mip level loading.

* Update Magnum submodules for mip level loading.

* assets: load all texture mip levels in ResourceManager.

Generating the mipmap only if the loaded image has a single uncompressed
level. Also keeping the existing unused/obsolete on-the-fly texture
compression, as it's still wired into the API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants