Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
save
  • Loading branch information
nkreeger committed Sep 12, 2019
commit ef60a720aa377a892ad2ca7d04c0fd3f91b22c50
5 changes: 0 additions & 5 deletions tfjs-core/src/backends/webgl/gpgpu_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,12 @@ export class GPGPUContext {
const gl = getActiveContext();
checkWebGLError(gl);
callAndCheck(gl, debug, () => gl.finish());
// TODO(kreeger): This bind framebuffer call can throw an INVALID_OPERATION
// error on WebGL2 - fix this.
callAndCheck(gl, debug, () => gl.bindFramebuffer(gl.FRAMEBUFFER, null));
callAndCheck(gl, debug, () => gl.deleteFramebuffer(this.framebuffer));
callAndCheck(gl, debug, () => gl.bindBuffer(gl.ARRAY_BUFFER, null));
callAndCheck(gl, debug, () => gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null));
callAndCheck(gl, debug, () => gl.deleteBuffer(this.indexBuffer));
this.disposed = true;
// TODO(kreeger): Needed or used?
// disposeWebGLContext();
}

public createFloat32MatrixTexture(rows: number, columns: number):
Expand Down Expand Up @@ -177,7 +173,6 @@ export class GPGPUContext {
getActiveContext(), this.debug, this.framebuffer);
this.outputTexture = null;
}
// console.log(' texture: ' + texture);
callAndCheck(
getActiveContext(), true,
() => getActiveContext().deleteTexture(texture));
Expand Down
31 changes: 4 additions & 27 deletions tfjs-core/src/backends/webgl/webgl_context_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import {ENV} from '../../environment';

import {cleanupDOMCanvasWebGLRenderingContext, createDOMCanvasWebGLRenderingContext} from './canvas_util';
import {callAndCheck, checkWebGLError} from './webgl_check';
import {checkWebGLError} from './webgl_check';

let count = 0;
const contexts: {[key: string]: WebGLRenderingContext} = {};
Expand Down Expand Up @@ -59,7 +59,7 @@ export function getContextByVersion(version: number): WebGLRenderingContext {
// Default to browser context creation is running in the browser.
if (contextFactory == null) {
if (ENV.getBool('IS_BROWSER')) {
// TODO(kreeger): Is there a better place to register this?
// TODO(kreeger): Consider moving to global space.
contextFactory = createDOMCanvasWebGLRenderingContext;
} else {
throw new Error('Default WebGLRenderingContext factory was not set!');
Expand All @@ -85,7 +85,7 @@ function disposeWebGLContext(version: number) {
if ((version in contexts)) {
if (contextCleanup == null) {
if (ENV.getBool('IS_BROWSER')) {
// TODO(kreeger): Is there a better place to register this?
// TODO(kreeger): Consider moving to global space.
contextCleanup = cleanupDOMCanvasWebGLRenderingContext;
}
}
Expand All @@ -97,9 +97,7 @@ function disposeWebGLContext(version: number) {
}

function bootstrapWebGLContext(gl: WebGLRenderingContext) {
// TODO - check GL calls here too.
callAndCheck(gl, ENV.getBool('DEBUG'), () => gl.disable(gl.DEPTH_TEST));
// gl.disable(gl.DEPTH_TEST);
gl.disable(gl.DEPTH_TEST);
gl.disable(gl.STENCIL_TEST);
gl.disable(gl.BLEND);
gl.disable(gl.DITHER);
Expand All @@ -109,24 +107,3 @@ function bootstrapWebGLContext(gl: WebGLRenderingContext) {
gl.enable(gl.CULL_FACE);
gl.cullFace(gl.BACK);
}

// function traceGLCalls(ctx: WebGLRenderingContext, idx: number) {
// const handler = {
// // tslint:disable-next-line:no-any
// get(target: any, prop: PropertyKey, receiver: any): any {
// const propValue = target[prop];

// if (typeof (propValue) === 'function') {
// console.log(
// ' gl.' + prop.toString() + ' = ' + target.constructor.name +
// ' ' + idx);
// // tslint:disable-next-line:only-arrow-functions
// return function() {
// return propValue.apply(target, arguments);
// };
// }
// return propValue;
// },
// };
// return new Proxy(ctx, handler);
// }
7 changes: 0 additions & 7 deletions tfjs-core/src/backends/webgl/webgl_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,13 +660,6 @@ export function isWebGLFenceEnabled(webGLVersion: number) {
}
const gl = getContextByVersion(webGLVersion);

// TODO - fix this
// webgl_util.callAndCheck(
// gl, debug,
// () => gl.texImage2D(
// tex2d, 0, internalFormat, width, height, 0, textureFormat,
// textureType, null));

// tslint:disable-next-line:no-any
const isEnabled = (gl as any).fenceSync != null;
return isEnabled;
Expand Down
4 changes: 1 addition & 3 deletions tfjs-core/src/debug_mode_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ import {expectArraysClose} from './test_util';

describeWithFlags('debug on', SYNC_BACKEND_ENVS, () => {
beforeAll(() => {
console.log('--- setting debug to TRUE');
tf.ENV.set('DEBUG', true);
});

afterAll(() => {
console.log('--- setting debug to FALSE');
tf.ENV.set('DEBUG', false);
});

it('KREEGER debug mode does not error when no nans', async () => {
it('debug mode does not error when no nans', async () => {
const a = tf.tensor1d([2, -1, 0, 3]);
const res = tf.relu(a);
expectArraysClose(await res.data(), [2, 0, 0, 3]);
Expand Down