8000 [DO-NOT-REVIEW] webgl auto-version/feature WIP by nkreeger · Pull Request #1855 · tensorflow/tfjs-core · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

[DO-NOT-REVIEW] webgl auto-version/feature WIP #1855

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
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 Jul 22, 2019
commit ce5c84924f6ca5a031612b4e9205513cdeb43c05
20 changes: 11 additions & 9 deletions src/backends/webgl/flags_webgl_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,16 @@ describe('WEBGL_MAX_TEXTURE_SIZE', () => {
ENV.reset();
webgl_util.MAX_TEXTURE_SIZE = null;

spyOn(WebGLContextManager, 'getActiveContext').and.returnValue({
MAX_TEXTURE_SIZE: 101,
getParameter: (param: number) => {
if (param === 101) {
return 50;
WebGLContextManager.getInstance().setContextFactory((version: number) => {
return {
MAX_TEXTURE_SIZE: 101,
getParameter: (param: number) => {
if (param === 101) {
return 50;
}
throw new Error(`Got undefined param ${param}.`);
}
throw new Error(`Got undefined param ${param}.`);
}
} as WebGLRenderingContext;
});
});
afterAll(() => {
Expand All @@ -222,7 +224,7 @@ describe('WEBGL_MAX_TEXTURES_IN_SHADER', () => {
ENV.reset();
webgl_util.MAX_TEXTURES_IN_SHADER = null;

spyOn(WebGLContextManager, 'getActiveContext').and.callFake(() => {
WebGLContextManager.getInstance().setContextFactory((version: number) => {
return {
MAX_TEXTURE_IMAGE_UNITS: 101,
getParameter: (param: number) => {
Expand All @@ -231,7 +233,7 @@ describe('WEBGL_MAX_TEXTURES_IN_SHADER', () => {
}
throw new Error(`Got undefined param ${param}.`);
}
};
} as WebGLRenderingContext;
});
});
afterAll(() => {
Expand Down
3 changes: 3 additions & 0 deletions src/backends/webgl/webgl_context_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export class WebGLContextManager {
*/
setContextFactory(factory: (version: number) => WebGLRenderingContext) {
this.factory = factory;

// Clear out items (TODO kreeger): write a unit test for this?
this.contexts = {};
}

/**
Expand Down
0