-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add crunch compressed texture support #4814
Conversation
…s. Update CHANGES.md.
If we are going to have a permanent fork, it should probably be under the |
+1 to everything above. Here is the fork to use: https://github.com/AnalyticalGraphicsInc/crunch |
* @param {Number} height The height of the texture. | ||
* @param {Uint8Array} buffer The compressed texture buffer. | ||
*/ | ||
function CompressedTextureBuffer(internalFormat, width, height, buffer) { |
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.
Add to CHANGES.md.
* @param {CompressedTextureBuffer} object The compressed texture buffer to be cloned. | ||
* @return {CompressedTextureBuffer} A shallow clone of the compressed texture buffer. | ||
*/ | ||
CompressedTextureBuffer.clone = function(object) { |
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.
We generally add a member clone
in addition to the static clone
even if it isn't used in Cesium proper.
when) { | ||
'use strict'; | ||
|
||
var transcodeTaskProcessor = new TaskProcessor('transcodeCRNToDXT', Number.POSITIVE_INFINITY); |
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.
Are you sure about Number.POSITIVE_INFINITY
?
We have some bigger work to do on parallelism, but, in the meantime, what is a reasonable default?
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 the only option because anytime we load an image we expect a promise that will resolve to an image. Otherwise, we have to change that behavior so when undefined
is returned the task is rescheduled. We use this option for geometry web workers as well.
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.
Gotcha, actually the request scheduler implicitly helps here. We'll flush this out later.
* @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing} | ||
* @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A} | ||
*/ | ||
function loadCRN(urlOrBuffer, headers) { |
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.
There's a lot of duplication among load*
functions. Is it reasonable to implement them in terms of a @private
load function that takes a callback?
/*global define*/ | ||
define([], function() { | ||
|
||
// crunch/crnlib v1.04 - Advanced DXTn texture compression library |
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.
Update LICENSE.md.
) { | ||
'use strict'; | ||
|
||
// Modified from: https://github.com/toji/texture-tester/blob/master/js/webgl-texture-util.js |
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.
Update LICENSE.md.
} | ||
} | ||
|
||
function transcodeCRNToDXT(arrayBuffer, transferableObjects) { |
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.
Not sure how we document workers, but I would explicitly mark this @private
as we do elsewhere.
Just those comments. |
@pjcozzi This is ready for another look. |
Looks good! Also deleted the unnecessary fork. |
Note that this is a PR into #4758.
Any image with a
.crn
extension or aimage/crn
mime-type will be transcoded to DXTc on a web worker. Crunch supports a few formats, but only DXT1 RGB and DXT5 are supported here.crunch.js
was compiled to javascript with Emcripten. The compiler options are listed in the comments incrunch.js
. Thecrn.cpp
file is also needed. Right now I have it submitted to a fork. Where do we want to keep this file and the instructions for compiling?