-
Notifications
You must be signed in to change notification settings - Fork 345
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
Ktx2 compressed textures support #1254
Conversation
Basis support
Update from upstream
fix: Flickering due to incorrect timing of clear https://github.com/…
…RenderContext fix; Making separate alpha handling configurable in h2d.RenderContex…
Enable high precision shaders if supported
chore: Merge latest heaps master
Fix missing condition wrapping
refactor: Remove old not used MAX_PRECISION
Custom max precision
…eaps into upstream_master
h3d/impl/GlDriver.hx
Outdated
@@ -1409,12 +1428,13 @@ class GlDriver extends Driver { | |||
case RGB10A2, RG11B10UF: new Uint32Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset, dataLen>>2); | |||
default: new Uint8Array(@:privateAccess pixels.bytes.b.buffer, pixels.offset, dataLen); | |||
} | |||
if( t.format.match(S3TC(_)) ) { | |||
switch (t.format) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use match(S3TC()|STC()|ETC(_)) instead ?
hxd/PixelFormat.hx
Outdated
S3TC( v : Int ); | ||
ASTC( ?v : Int ); | ||
ETC( ?v : Int ); | ||
S3TC( ?v : Int ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is v optional ? it shouldn't be for S3TC
hxd/PixelFormat.hx
Outdated
|
||
enum abstract ASTC_FORMAT(Int) from Int to Int { | ||
final RGBA_4x4 = 0x93B0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These constants are for GL and should not be in PixelFormat
hxd/Pixels.hx
Outdated
case S3TC(n): | ||
var w = ((width + 3) >> 2) << 2; // Round up width to next multiple of 4 | ||
var h = ((height + 3) >> 2) << 2; // Round up height to next multiple of 4 | ||
var blocks = (w >> 2) * (h >> 2); // Total number of blocks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be simplified without <<2 and blocks = w*h (same for other formats)
@@ -32,7 +32,7 @@ class BinaryLoader { | |||
onError(xhr.statusText); | |||
return; | |||
} | |||
onLoaded(haxe.io.Bytes.ofData(xhr.response)); | |||
onLoaded(raw ? xhr.response : haxe.io.Bytes.ofData(xhr.response)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unrelated to the PR. Please submit separately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used by Ktx2Decoder.initTranscoder when loading the wasm module.
hxd/res/Image.hx
Outdated
getInfo(); | ||
return h2d.Tile.fromTexture(toTexture()).sub(0, 0, inf.width, inf.height); | ||
final tex = toTexture(); | ||
return h2d.Tile.fromTexture(tex).sub(0, 0, tex.width, tex.height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unrelated to the PR. Please submit separately
Also I'm a bit curious whereas the support for it is widely spread enough |
chore: Make format type value required for ASTC, ETC and S3TC chore: Simplify compressed texture data size calculations
All resolved. If you mean support on devices, it will transcode to either BPTC, DXT, ETC2 or ASTC, which should cover pretty much all desktop and mobile. There is a CLI transcoder that could be used instead of the wasm module to enable support on native targets. I removed support for PVRTC since that is only needed for iOS devices with pre A7 chip, so older than 2013, and could not even find a device to test on, and it has limitations. |
Made a new PR from a fresh fork to get rid of the messy history. #1260 |
Replaces #710
Support for parsing Ktx2 files with ETC or UASTC encoded textures, transcoding to BPTC, DXT, ETC2 or ASTC.
WIP since we are currently not using the res system and doing our own loading, so is not integrated with res system and only supports js target.
However we are working on a new framework where we would like to make use of res system and pak loading. I tried to implement async loading for compressed textures using the AsyncLoading flag, but could not make it work.
Will revisit this soon and try to solve the res integration, but leaving this up here for now if anyone has ideas or is interested in getting this working for native.