Skip to content

Commit

Permalink
dist files for 0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
frzi committed May 2, 2017
1 parent 3093756 commit 9700ee0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
47 changes: 41 additions & 6 deletions dist/blink.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ function closestDimensions(area) {
return [width, area / width]
}

/**
* Internal (helper) class.
*/
class Texture {
constructor(internalFormat, width, height, format, type, data, alignment, wrapS, wrapT) {
const previousTex = gl.getParameter(gl.TEXTURE_BINDING_2D);
Expand Down Expand Up @@ -216,7 +219,7 @@ class Texture {
upload(data) {
gl.bindTexture(gl.TEXTURE_2D, this.id);
gl.texImage2D(gl.TEXTURE_2D, 0, gl[this.internalFormat], this.width, this.height, 0, gl[this.format], gl[this.type], data);
gl.bindTexture(gl.TEXTURE_2D, this.id);
gl.bindTexture(gl.TEXTURE_2D, null);
return this
}

Expand All @@ -239,6 +242,22 @@ function withTemporaryFBO(fn) {
gl.deleteFramebuffer(fbo);
}

/**
* The `Buffer` object allocates memory on the host. Once the `Buffer`
* is requested on the device (GPU), the contents of `Buffer`'s data
* are allocated and copied from the host to the device.
*
* Once te device is done computing, the contents of the `Buffer` on
* the device are copied back to the host.
*
* All device copies are stored and mainted through `BufferCache`.
*
* NOTE: Data of a `Buffer` are NOT retained on the device. Once the
* data has been copied back to the host, the device copy will be
* destroyed immediately. To retain data on the device, please use
* the `DeviceBuffer` object.
*/

let readablesMap = new WeakMap();
let writablesMap = new WeakMap();

Expand Down Expand Up @@ -335,6 +354,16 @@ function textureForBuffer(buffer, data = null, wrap) {
return new Texture(internalFormat, width, height, format, type, data, bytes, ...buffer.wrap)
}

/**
* The `DeviceBuffer` only allocates memory on the host. Memory is
* allocated the moment the `DeviceBuffer` is constructed. Memory
* on the device is developer managed. Indeed, the device memory is
* retained until the developer destroys the `DeviceBuffer` using
* the `destroy()` method.
*
* Memory from the host can be copied to the device and vice versa.
*/

class DeviceBuffer {
constructor({alloc, data, type = FLOAT, vector = 1, wrap = CLAMP}) {
this.vector = Math.min(Math.max(vector, 1), 4);
Expand Down Expand Up @@ -440,9 +469,15 @@ class DeviceBuffer {

_finish() {
// Swap.
this._getReadable().delete();
readablesMap.set(this, this._getWritable());
writablesMap.delete(this);
let writableCopy = this._getWritable();
if (writableCopy) {
let readableCopy = this._getReadable();
if (readableCopy) {
readableCopy.delete();
}
readablesMap.set(this, writableCopy);
writablesMap.delete(this);
}
}
}

Expand All @@ -458,6 +493,7 @@ void main() {
bl_UV = pos * 0.5 + 0.5;
}`;

// Keep the vertex shader in memory.
const vertexShader = compileShader(gl.VERTEX_SHADER, vertexSource);

/**
Expand Down Expand Up @@ -779,7 +815,7 @@ function prepareFragmentShader(inputs, outputDescriptors, source) {
const VERSION = {
major: 0,
minor: 2,
patch: 3,
patch: 4,
toString() { return `${this.major}.${this.minor}.${this.patch}` }
};

Expand All @@ -803,4 +839,3 @@ exports.MIRROR = MIRROR;
Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=blink.js.map
1 change: 0 additions & 1 deletion dist/blink.js.map

This file was deleted.

Loading

0 comments on commit 9700ee0

Please sign in to comment.