Skip to content

Commit

Permalink
fix: #586
Browse files Browse the repository at this point in the history
  • Loading branch information
robertleeplummerjr committed Mar 24, 2020
1 parent 61dfe8a commit 1955ad3
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 30 deletions.
12 changes: 4 additions & 8 deletions dist/gpu-browser-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*
* GPU Accelerated JavaScript
*
* @version 2.9.0
* @date Sun Mar 22 2020 17:17:39 GMT-0400 (Eastern Daylight Time)
* @version 2.9.1
* @date Tue Mar 24 2020 07:52:55 GMT-0400 (Eastern Daylight Time)
*
* @license MIT
* The MIT License
Expand Down Expand Up @@ -10378,9 +10378,7 @@ class WebGLKernel extends GLKernel {
return failureResult;
}
const { texSize, context: gl, canvas } = this;
if (!this.pipeline) {
gl.enable(gl.SCISSOR_TEST);
}
gl.enable(gl.SCISSOR_TEST);
if (this.pipeline && this.precision === 'single') {
gl.viewport(0, 0, this.maxTexSize[0], this.maxTexSize[1]);
canvas.width = this.maxTexSize[0];
Expand Down Expand Up @@ -10505,9 +10503,7 @@ class WebGLKernel extends GLKernel {
const { kernelArguments, texSize, forceUploadKernelConstants, context: gl } = this;

gl.useProgram(this.program);
if (!this.pipeline) {
gl.scissor(0, 0, texSize[0], texSize[1]);
}
gl.scissor(0, 0, texSize[0], texSize[1]);
if (this.dynamicOutput) {
this.setUniform3iv('uOutputDim', new Int32Array(this.threadDim));
this.setUniform2iv('uTexSize', texSize);
Expand Down
6 changes: 3 additions & 3 deletions dist/gpu-browser-core.min.js

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions dist/gpu-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*
* GPU Accelerated JavaScript
*
* @version 2.9.0
* @date Sun Mar 22 2020 17:17:39 GMT-0400 (Eastern Daylight Time)
* @version 2.9.1
* @date Tue Mar 24 2020 07:52:55 GMT-0400 (Eastern Daylight Time)
*
* @license MIT
* The MIT License
Expand Down Expand Up @@ -14831,9 +14831,7 @@ class WebGLKernel extends GLKernel {
return failureResult;
}
const { texSize, context: gl, canvas } = this;
if (!this.pipeline) {
gl.enable(gl.SCISSOR_TEST);
}
gl.enable(gl.SCISSOR_TEST);
if (this.pipeline && this.precision === 'single') {
gl.viewport(0, 0, this.maxTexSize[0], this.maxTexSize[1]);
canvas.width = this.maxTexSize[0];
Expand Down Expand Up @@ -14958,9 +14956,7 @@ class WebGLKernel extends GLKernel {
const { kernelArguments, texSize, forceUploadKernelConstants, context: gl } = this;

gl.useProgram(this.program);
if (!this.pipeline) {
gl.scissor(0, 0, texSize[0], texSize[1]);
}
gl.scissor(0, 0, texSize[0], texSize[1]);
if (this.dynamicOutput) {
this.setUniform3iv('uOutputDim', new Int32Array(this.threadDim));
this.setUniform2iv('uTexSize', texSize);
Expand Down
6 changes: 3 additions & 3 deletions dist/gpu-browser.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gpu.js",
"version": "2.9.0",
"version": "2.9.1",
"description": "GPU Accelerated JavaScript",
"engines": {
"node": ">=8.0.0"
Expand Down
8 changes: 2 additions & 6 deletions src/backend/web-gl/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,7 @@ class WebGLKernel extends GLKernel {
return failureResult;
}
const { texSize, context: gl, canvas } = this;
if (!this.pipeline) {
gl.enable(gl.SCISSOR_TEST);
}
gl.enable(gl.SCISSOR_TEST);
if (this.pipeline && this.precision === 'single') {
gl.viewport(0, 0, this.maxTexSize[0], this.maxTexSize[1]);
canvas.width = this.maxTexSize[0];
Expand Down Expand Up @@ -610,9 +608,7 @@ class WebGLKernel extends GLKernel {
const { kernelArguments, texSize, forceUploadKernelConstants, context: gl } = this;

gl.useProgram(this.program);
if (!this.pipeline) {
gl.scissor(0, 0, texSize[0], texSize[1]);
}
gl.scissor(0, 0, texSize[0], texSize[1]);
if (this.dynamicOutput) {
this.setUniform3iv('uOutputDim', new Int32Array(this.threadDim));
this.setUniform2iv('uTexSize', texSize);
Expand Down
1 change: 1 addition & 0 deletions test/all.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
<script type="module" src="issues/560-minification-madness.js"></script>
<script type="module" src="issues/564-boolean.js"></script>
<script type="module" src="issues/567-wrong-modulus.js"></script>
<script type="module" src="issues/586-unable-to-resize.js"></script>
<script type="module" src="issues/91-create-kernel-map-array.js"></script>
<script type="module" src="issues/96-param-names.js"></script>
<script type="module" src="features/to-string/as-file.js"></script>
Expand Down
51 changes: 51 additions & 0 deletions test/issues/586-unable-to-resize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU } = require('../../src');

describe('issue #586 - unable to resize');

function testResize(convert, mode) {
const gpu = new GPU({ mode });
const createTexture1 = gpu.createKernel(function() {
return 1;
}, { output: [2, 2], pipeline: false});

const createTexture2 = gpu.createKernel(function() {
return 1;
}, { output: [4, 4], pipeline: true});

var t1 = createTexture1();
var t2 = createTexture2();

assert.deepEqual(convert(t2), [
new Float32Array([1,1,1,1]),
new Float32Array([1,1,1,1]),
new Float32Array([1,1,1,1]),
new Float32Array([1,1,1,1]),
]);

gpu.destroy();
}

test('auto', () => {
testResize(t => t.toArray());
});

test('gpu', () => {
testResize(t => t.toArray(), 'gpu');
});

(GPU.isWebGLSupported ? test : skip)('webgl', () => {
testResize(t => t.toArray(), 'webgl');
});

(GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
testResize(t => t.toArray(), 'webgl2');
});

(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
testResize(t => t.toArray(), 'headlessgl');
});

test('cpu', () => {
testResize(a => a, 'cpu');
});

0 comments on commit 1955ad3

Please sign in to comment.