KTX2Loader: Improve target format selection and examples#32966
KTX2Loader: Improve target format selection and examples#32966epreston wants to merge 6 commits intomrdoob:devfrom
Conversation
for webgl2, bc4 and bc5 are provided by "rgtc". This is GL_COMPRESSED_RED_RGTC1 and GL_COMPRESSED_SIGNED_RG_RGTC2. for webgpu, bc4 and bc5 and provided by "bptc". This is bc4-r-unorm and bc5-rg-unorm
add missing texture from original source: https://github.com/donmccurdy/KTX2-Samples
update webgl2 example. use the support matrix given to worker threads to populate the "supported" field already expected by the example code. bc1 and bc3 are dxt on webgl, bptc on webgpu bc4 and bc5 are rgtc on webgl, bptc on webgpu
clarify webgpu texture support matrix support
update webgpu example. use the support matrix given to worker threads to populate the "supported" field already expected by the example code. some rearrangement required to have an initialized renderer to populate the data fields. ect1 and ect2 support are from the ect2 extension bc1-bc7 are from bptc on webgpu
|
@donmccurdy you might be the best to eyeball this. I wrote my notes in each commit on formats from testing and reviewing ktx and basis repos. |
|
looks like CI is hung on physics sim because its seeing more balls |
trigger CI on PR
donmccurdy
left a comment
There was a problem hiding this comment.
Thanks @epreston! I think this is a good change, just a couple comments/questions about how we approach it.
As FYI to other readers, this change allows the KTX2 loader examples to show a placeholder image for textures that the device doesn't support. For example if my GPU didn't support BC4-7, I'd see this:
If we don't like "LOAD FAIL" as the text, I'm happy to regenerate the .ktx2 image... just note that it's a 40x40px image and a pixel-aligned monospace font, so we can only fit 5 characters per line. :)
| etc2Supported: renderer.hasFeature( 'texture-compression-etc2' ), | ||
| dxtSupported: renderer.hasFeature( 'texture-compression-s3tc' ), | ||
| dxtSupported: false, // rgb565 smooth and hard alpha provided by bc (bptc) | ||
| rgtcSupported: false, // 1 and 2 channel textures provided by bc (bptc) |
There was a problem hiding this comment.
Would it make sense to check renderer.hasFeature( 'texture-compression-bc' ) here instead? It'd be ideal if the 'supported' lists for each sample texture could be the same in the WebGL and WebGPU examples.
In retrospect... I think I wish that workerConfig just listed all the THREE.FooFormat enum values that the device supports, without the intermediate representation of these rgtcSupported, bptcSupported, ... booleans, which don't really line up well with WebGPU extensions. But that's a bigger change, no pressure to do so in this PR.
There was a problem hiding this comment.
I would trust your judgement on this. Yes, compression-bc covers everything and might make selection simpler for webgpu. The "GL format constants"? are different for the types but they are equivalent. Only matters if it matters.
It was helpful to me to see identical support matrixes side by side, showing how they differ between the backends. (ec1 is rolled into ec2 on webgpu, webgl2 requires a mix of dxt and rgtc to get what webgpu gets by default with compression-bc).
I didnt want to disturb worker code and hoped to keep changes to minimum. It is helpful for me to have consistent keys for tests, further improvements could make things simpler.
| { path: '2d_bc1.ktx2', supported: formats[ 'dxtSupported' ] || formats[ 'bptcSupported' ] }, | ||
| { path: '2d_bc3.ktx2', supported: formats[ 'dxtSupported' ] || formats[ 'bptcSupported' ] }, | ||
| { path: '2d_bc4.ktx2', supported: formats[ 'rgtcSupported' ] || formats[ 'bptcSupported' ] }, | ||
| { path: '2d_bc5.ktx2', supported: formats[ 'rgtcSupported' ] || formats[ 'bptcSupported' ] }, | ||
| { path: '2d_bc7.ktx2', supported: formats[ 'bptcSupported' ] } |
There was a problem hiding this comment.
See above -- would it be possible to have the WebGL and WebGPU renderers set the same workerConfig flags, so we don't have to use different ways of checking support for the same sample texture?
There was a problem hiding this comment.
Yes, I think we could.
I would need to look at it again to ensure we are not losing information that informs choices.
epreston
left a comment
There was a problem hiding this comment.
Anytime, happy to do what's needed to add some clarity.
| etc2Supported: renderer.hasFeature( 'texture-compression-etc2' ), | ||
| dxtSupported: renderer.hasFeature( 'texture-compression-s3tc' ), | ||
| dxtSupported: false, // rgb565 smooth and hard alpha provided by bc (bptc) | ||
| rgtcSupported: false, // 1 and 2 channel textures provided by bc (bptc) |
There was a problem hiding this comment.
I would trust your judgement on this. Yes, compression-bc covers everything and might make selection simpler for webgpu. The "GL format constants"? are different for the types but they are equivalent. Only matters if it matters.
It was helpful to me to see identical support matrixes side by side, showing how they differ between the backends. (ec1 is rolled into ec2 on webgpu, webgl2 requires a mix of dxt and rgtc to get what webgpu gets by default with compression-bc).
I didnt want to disturb worker code and hoped to keep changes to minimum. It is helpful for me to have consistent keys for tests, further improvements could make things simpler.
| { path: '2d_bc1.ktx2', supported: formats[ 'dxtSupported' ] || formats[ 'bptcSupported' ] }, | ||
| { path: '2d_bc3.ktx2', supported: formats[ 'dxtSupported' ] || formats[ 'bptcSupported' ] }, | ||
| { path: '2d_bc4.ktx2', supported: formats[ 'rgtcSupported' ] || formats[ 'bptcSupported' ] }, | ||
| { path: '2d_bc5.ktx2', supported: formats[ 'rgtcSupported' ] || formats[ 'bptcSupported' ] }, | ||
| { path: '2d_bc7.ktx2', supported: formats[ 'bptcSupported' ] } |
There was a problem hiding this comment.
Yes, I think we could.
I would need to look at it again to ensure we are not losing information that informs choices.
Related issue: errors when running examples and code
Description
update ktx2loader and examples for both webgl2 and webgpu
Changes include:
Changes to
ktx2loader: update the webgl2 and webgpu compressed texture support settings provided to web workers. Additional notes illustrate the usage of extensions and how they differ between backends.Changes to the
examples: use the worker settings in the examples to avoid errors and illustrate how extensions map to gpu compression formats.Both Chrome and Safari (where possible) used for local testing completed on: