Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

WASM: Fix glyph transparency on GL #2217

Merged
merged 1 commit into from Apr 5, 2020
Merged

Conversation

chemicstry
Copy link
Member

@chemicstry chemicstry commented Apr 4, 2020

This PR fixes UI glyph rendering on GL. Previously glyph data was provided as R8Unorm and swizzled into alpha channel, however, GL backend (and dx11 if it's ever used) does not support swizzling. So we build the full texture instead. I'm not sure if this could cause performance problems? This also makes #1698 obsolete, so I removed redudant shader attributes.

Tested on GL and vulkan, but not on metal (would appreciate someone testing UI examples).

Although vulkan complains about image layout, but this already existed before the changes. I was unable to fix it.

[WARN][gfx_backend_vulkan] 
PERFORMANCE [UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout (0)] : vkCmdCopyBufferToImage(): For optimal performance VkNonDispatchableHandle 0xde3f1a000000001f[] layout should be VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL instead of GENERAL.
object info: (type: COMMAND_BUFFER, hndl: 219292848)

Part of #2192

@codecov
Copy link

codecov bot commented Apr 4, 2020

Codecov Report

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

Impacted file tree graph

@@           Coverage Diff           @@
##             wasm    #2217   +/-   ##
=======================================
  Coverage   83.14%   83.14%           
=======================================
  Files          74       74           
  Lines        6088     6088           
=======================================
  Hits         5062     5062           
  Misses       1026     1026           

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 59901ff...6d68db6. Read the comment docs.

@chemicstry
Copy link
Member Author

Did some profiling on performance. Ran states_ui example and measured execution times of 2 glyph rendering batches (one to render menu and other to render demo screen).

Before this PR: 43.37 ms and 175.43 ms
After this PR: 47.59 ms and 184.59 ms

So there is some performance hit. Alternative would be to cfg everything into GL and non-GL, but in my opinion that would really affect readability of the code. Any thoughts?

On a side note, I looked into implementing swizzling in gfx, but their API abstractions make it really hard for GL backend.

Copy link
Member

@azriel91 azriel91 left a comment

Choose a reason for hiding this comment

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

✌️

@azriel91
Copy link
Member

azriel91 commented Apr 5, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 5, 2020

Build succeeded

@bors bors bot merged commit 6657c22 into amethyst:wasm Apr 5, 2020
@azriel91 azriel91 added the feat: WASM support This issue is related to WebAssembly compilation target support label Apr 11, 2020
@azriel91 azriel91 added this to the WASM Rush milestone Apr 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: WASM support This issue is related to WebAssembly compilation target support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants