Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone
Accepted Solution

[WebGL] Texture compression

[ Edited ]

Has anyone had success using compressed textures in WebGL?

 

I know about the different GPU's, encoding schemes and container formats. But it seems as if texture compression is not exposed in WebGL.

 

This article claims ETC1 is supported, but I cannot find any documentation on using ETC1 on WebGL in BB10 (or in WebGL at all, for that matter). Which extension should be loaded? Which internal format should be used?

 

I don't want to go down the PVRTC / ATC hardware-specific route. I don't need an alpha channel. Besides, those aren't documented either.

 

Some experimentation shows that  it does seem to support S3TC: it loads the extension (ext=gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc") succeeds), reports that compression formats DXT1, DXT3 and DXT5 are supported, it even loads the textures, but just renders black.

 

Some pointers or code snippets would be very welcome!

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,532
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: [WebGL] Texture compression

Hi there, I'll admit that the full implementation is a little beyond me, but here is the feedback that our engineering teams had.

 

On Qualcomm we support ATC compression, on SGX we do not; it's based on the underlying GL driver.

 

We may support some S3TC, but it's not in getSupportedExtensions because we don't support all of it (for example, on-the-fly DXT3 and DXT5 compression is unsupported.) In general, it's best to assume DXT is not supported.

 

It seems that there may be some conflicting / misleading evidence being reported by the extension that's loaded. It may actually be worth logging a JIRA here (and email me once you do; eoros@blackberry.com):

https://www.blackberry.com/jira/secure/Dashboard.jspa

 

That will take it directly to our development teams who can help address the confusion at the API level. I don't expect additional support to be added in the short-term, but it never hurts to show that there is interest in these APIs.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: [WebGL] Texture compression

[ Edited ]

Thanks for your reply, Eric, but I'm not sure that clarifies a whole lot...

 

I'm trying to find a feasible way to do any texture compression. If possible  a method that will work on all the current devices (and Chrome on Windows, for debugging), but if we have to go down chipset-specific routes and/or use a fallback for Chrome, then so be it.

 

OK, so we've established that S3TC is off limits, and that Dev Alpha C should support ATC.

 

So far I've only been able to get compressed textures working on Chrome with S3TC. None of the  compression schemes seem to work on STL100-1 or Dev Alpha C (or we don't have enough info to implement them).

 

It is my understanding that one first loads the appropriate extension using gl.getExtension(), passing an extension name that determines the compression "family" (ETC1, PVRTC, ATC etc). Then one loads and parses a container file (e.g. .dds, .ktx), extracts the textures and calls gl.compressedTexImage2D() passing an appropriate internalFormat parameter depening on the fourCC found in the container file. 

 

The specific questions I have:

 

  1. which extension names should be used in gl.getExtension() for each compression "family"?
  2. once the extension is loaded, what are the ID's to pass in the inernalFormat parameter of gl.compressedTexImage2D()?
  3. which texture compression is available on STL100-1?
  4. what about the defacto-standard ETC1? That woud suite my needs just fine. Is it supported in WebGL?
  5. how should a WebWorks app find out which chipset it is running on (i.e. which compression to use)?

I'll post a JIRA issue about the misreported S3TC support.

 

PS: it would be a good idea to standardize terminology. In the current info, scattered around the BB blogs and docs sites, Imagination, PowerVR, SGX, Qualcomm, Adreno, VZW, Chipset A/B, Z10, Q10 are being used interchangably, yet nowhere is it documented which device models have which chipsets. Just drop the brand names and talk about device models (STL100-1/2/3/4 etc). That's what devs and power-users use.

 

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: [WebGL] Texture compression

[ Edited ]

OK, I've found out a little more info...

 

Diving into the Khronos WebGL spec this should work: http://jsfiddle.net/jonno/KGEEQ/The snippet simply tries to load 3 WebGL extensions (for PVRTC, ATC and S3TC). Tested on:

 

  • Z10 STL100-1 on 10.0.10,738 (= Imagination PowerVR SGX GPU)
  • Dev Alpha C SQN100-3 on 10.1.0.1483 (undocumented, seems to be Qualcomm Adreno)

Both report the same:

 

  • PVRTC fails
  • ATC fails
  • S3TC succeeds (but does not work, see below)

 

I also found some Khronos WebGL comformance tests:

 

PVRTC

 

ATC

 

S3TC

 

  • extension loads but test fails on Z10 STL100-1
  • extension loads but test fails on DAC SQN100-3 (should support this!)
  • works on Chrome for Windows (to be expected)

According to this page:https://developer.blackberry.com/native/documentation/core/find_out_hardware_info.html

 

  • the Z10 STL100-1 should support PVRTC, PVRTC2 an ETC1 compression
  • the DAC SQN100-3 should support 3DC, and ETC1 compression, yet there is no mention of ATC in OpenGL 2.0.

Of course the name strings are different for plain-C OpenGL and WebGL. I've tried various permutations, without success...

 

Still stuck.

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,532
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: [WebGL] Texture compression

[ Edited ]

Hi there, I've forwarded this (along with your previous questions) along to our engineering team who are compiling the information that you're after. Unfortunately I haven't gone very deep into the texture compression avenue myself. I'll do my best to get an answer for this ASAP.

 

(And if it's taking too long, feel free to poke me at eoros@blackberry.com) :-)


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: [WebGL] Texture compression

[ Edited ]

Thanks Erik, get ready to be poked ;-)

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,532
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: [WebGL] Texture compression

Should have an update for you soon. Just verifying a few pieces with the gurus and will follow-up on here once confirmed.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,532
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: [WebGL] Texture compression

[ Edited ]

EDIT: Note that Group 1 and Group2 are not standard ways to refer to these devices, I'm just using them in this post to simplify how I refer to the specific devices.

 

Apologies for the novel here. Do let me know if you have any further questions.

 

In terms of device model values...

 

STL100-1 (aka Group 1) would refer to:

Texas Instruments OMAP 4470 1.5Ghz / Imagination GPU PowerVR SGX 544

 

The remaining models (STL100-2, STL100-3, STL100-4; aka Group 2) all refer to:

Qualcomm Snapdragon MSM8960 1.5Ghz / Qualcomm GPU Adreno 225

 

The SQN and SQR models are also Qualcomm based and should follow the same behaviour as Group 2.

 

Our development team has been doing some digging and have found the following. Group 1 (i.e. STL100-1) supports:

  • GL_OES_compressed_ETC1_RGB8_texture
  • GL_IMG_texture_compression_pvrtc
  • GL_IMG_texture_compression_pvrtc2

Whereas Group 2 (the remainder) support:

  • GL_AMD_compressed_ATC_texture
  • GL_OES_compressed_ETC1_RGB8_texture
  • GL_AMD_compressed_3DC_texture

What we’ve discovered is that while the underlying implementation supports these, they haven’t actually been exposed except for one (1) within Group 2, which is:

  • WEBKIT_WEBGL_compressed_texture_atc

Furthermore, this specific format is not a cross-platform format and is specific to STL100-3.

 

What our development team has done today is updated the implementation to exposed the following:

  • Group 1 (STL100-1)
    • GL_OES_compressed_ETC1_RGB8_texture
    • GL_IMG_texture_compression_pvrtc
  • Group 2 (the remainder)
    • GL_OES_compressed_ETC1_RGB8_texture

This does not include PVRTC2 as it is not exposed at all by WebGL in WebKit and we want to stay in sync with the upstream enumerations as much as possible.

 

So, to your question about which compression method can be used across all devices; the answer would be ETC1 as soon as the next update is released where these have been exposed.

 

As for your other questions...

 

which extension names should be used in gl.getExtension() for each compression "family"?

console.log(gl.getSupportedExtensions());

 

This tells you which extensions are supported and the names given are what you put into gl.getExtensions()

 

once the extension is loaded, what are the ID's to pass in the inernalFormat parameter of gl.compressedTexImage2D()? which texture compression is available on STL100-1?

You would do something like:

 

var ext = gl.getExtensions(WEBGL_compressed_texture_etc1);

 

Then the internalFormat would be ext.COMPRESSED_RGB_ETC1_WEBGL for gl.compressedTexImage2D(...)

We are currently in the process of adding this extension. Presently only ATC is supported on certain devices.

 

what about the defacto-standard ETC1? That woud suite my needs just fine. Is it supported in WebGL?

We are working on getting ETC1 support in WebGL.

 

how should a WebWorks app find out which chipset it is running on (i.e. which compression to use)?

Unfortunately there is no API available to do this sort of low-level query. There may be something on the native side which I will look into but I don't think there will be anything for this. Generally you can use one common compression (in this case ETC1) method and submit one BAR for all graphics chip variations. Or you can build two separate BAR files and associate them with the appropriate graphics chip variations in App World, and rely on App World to deliver the correct build to a particular device.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: [WebGL] Texture compression

[ Edited ]

Hi Erik,

 

Thanks for the follow up and your excellent explanation. I somehow had the feeling there was a difference between the native implementation and the exposure in WebGL. Too bad we can't use compression just yet (unless you have an STL100-3, which I don't). But it's comforting to know I wasn't barking up the wrong tree and have helped fix some bugs.

 

So the support matrix for texture compression in WebGL is:

 

modelPVRTCPVRTC2ATCS3TCETC1
Z10 STL100-1 soon no no limited soon
Z10 STL100-2 no no soon limited soon
Z10 STL100-3 no no yes limited soon
Z10 STL100-4 no no soon limited soon
Q10 SQN no no soon limited soon
DAC SQN no no soon limited soon
Q5 SQR no no soon limited soon

 

Correct?

 

ETC1 compression will be very useful in my current project. Though I don't need it right now, please consider exposing ATC to STL100-2, STL100-4, SQN and SQR, so there is a format with alpha support on all models.

 

Also, proper S3TC support would be desirable so the same code & assets can be used while developing on Chrome/Ripple and at runtime in BB10.

 

Good support for texture compression is not only to reduce the .bar file size, it should also allow faster loading of textures into memory, from memory into the GPU and more/larger textures in GPU simultaneously. Separate .bar files per device model aren't always a good idea. A reliable way of querying TC support or device model at runtime is needed.

 

I'll have another Q for you soon, as it appears textures in WebGL are limited to 2048x2048px, not 4096 as the specs state. But I'll start another thread for that.

 

Thanks!

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,532
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: [WebGL] Texture compression

The table looks good to me. And thank you for asking the questions. I learned some things myself and ultimately some important functionality was exposed thanks to your questions :-)

I'll see what the follow-up plans are for exposing ATC and, if none currently, I'll file a JIRA with the development team to push it forward or get some official justification for why it can not be (I'm not saying it will / won't, just stating the possible outcomes.) :-)

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.