Skip to content

Commit

Permalink
ClipSpace, getParameters, resolveModules fixes (#1297)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsherif authored Nov 26, 2019
1 parent 5176c21 commit c2047d6
Show file tree
Hide file tree
Showing 20 changed files with 138 additions and 68 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## v8.0.0-alpha.7

- ClipSpace, getParameters, resolveModules fixes (#1297)

## v8.0.0-alpha.6

- Remove unpackFlipY option from Texture (#1295)
- Shadertools cleanup (#1296)
- (more-luma-cleanup) Small optimizations (#1294)
- Simplify and optimize state tracking (#1293)
- DevicePixelRatio: Handle invalid client sizes and remove custom width/height support. (#1290)

## v8.0.0-alpha.5

- Fix deps, simplify materials (#1292)

## v8.0.0-alpha.3

- Fix deps, simplify materials (#1292)
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lerna": "2.0.0",
"version": "8.0.0-alpha.6",
"version": "8.0.0-alpha.9",
"npmClient": "yarn",
"useWorkspaces": true,
"exact": true,
Expand Down
6 changes: 3 additions & 3 deletions modules/addons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@luma.gl/addons",
"version": "8.0.0-alpha.6",
"version": "8.0.0-alpha.9",
"description": "Experimental classes for luma.gl",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"dependencies": {
"@loaders.gl/gltf": "^1.3.0",
"@loaders.gl/images": "^1.3.0",
"@luma.gl/constants": "8.0.0-alpha.6",
"@luma.gl/constants": "8.0.0-alpha.9",
"math.gl": "^3.0.0"
},
"peerDependencies": {
Expand All @@ -45,5 +45,5 @@
"@loaders.gl/core": "^1.3.0",
"@loaders.gl/polyfills": "^1.3.0"
},
"gitHead": "1eb23cd12b4241742f6515daf4e0eaa5d6ee93a5"
"gitHead": "8deca643b658ddf6d8fb279df6417b8901a6fc93"
}
4 changes: 2 additions & 2 deletions modules/constants/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@luma.gl/constants",
"version": "8.0.0-alpha.6",
"version": "8.0.0-alpha.9",
"description": "WebGL and WebGL2 constants",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -28,5 +28,5 @@
"pre-build": "npm run build-bundle && npm run build-bundle -- --env.dev",
"build-bundle": "webpack --display=minimal --config ../../scripts/bundle.config.js"
},
"gitHead": "1eb23cd12b4241742f6515daf4e0eaa5d6ee93a5"
"gitHead": "8deca643b658ddf6d8fb279df6417b8901a6fc93"
}
12 changes: 6 additions & 6 deletions modules/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@luma.gl/core",
"version": "8.0.0-alpha.6",
"version": "8.0.0-alpha.9",
"description": "WebGL2 Components for High Performance Rendering and Computation",
"license": "MIT",
"publishConfig": {
Expand Down Expand Up @@ -31,13 +31,13 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0",
"@luma.gl/constants": "8.0.0-alpha.6",
"@luma.gl/engine": "8.0.0-alpha.6",
"@luma.gl/shadertools": "8.0.0-alpha.6",
"@luma.gl/webgl": "8.0.0-alpha.6",
"@luma.gl/constants": "8.0.0-alpha.9",
"@luma.gl/engine": "8.0.0-alpha.9",
"@luma.gl/shadertools": "8.0.0-alpha.9",
"@luma.gl/webgl": "8.0.0-alpha.9",
"math.gl": "^3.0.0",
"probe.gl": "^3.1.1",
"seer": "^0.2.4"
},
"gitHead": "1eb23cd12b4241742f6515daf4e0eaa5d6ee93a5"
"gitHead": "8deca643b658ddf6d8fb279df6417b8901a6fc93"
}
7 changes: 1 addition & 6 deletions modules/core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export {
ProgramManager,
Timeline,
Geometry,
ClipSpace,
ConeGeometry,
CubeGeometry,
CylinderGeometry,
Expand All @@ -94,12 +95,6 @@ export {
// We should have a minimal set of forwarding exports from shadertools (ideally none)
// Analyze risk of breaking apps
export {
registerShaderModules,
setDefaultShaderModules,
getDefaultShaderModules,
assembleShaders,
createShaderHook,
createModuleInjection,
// HELPERS
combineInjects,
normalizeShaderModule,
Expand Down
6 changes: 3 additions & 3 deletions modules/debug/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@luma.gl/debug",
"version": "8.0.0-alpha.6",
"version": "8.0.0-alpha.9",
"description": "Debug utilities for luma.gl",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -30,13 +30,13 @@
"build-bundle": "webpack --display=minimal --config ../../scripts/bundle.config.js"
},
"dependencies": {
"@luma.gl/constants": "8.0.0-alpha.6",
"@luma.gl/constants": "8.0.0-alpha.9",
"glsl-transpiler": "^1.8.5",
"math.gl": "^3.0.0",
"webgl-debug": "^2.0.1"
},
"peerDependencies": {
"@luma.gl/core": "^7.1.0"
},
"gitHead": "1eb23cd12b4241742f6515daf4e0eaa5d6ee93a5"
"gitHead": "8deca643b658ddf6d8fb279df6417b8901a6fc93"
}
10 changes: 5 additions & 5 deletions modules/engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@luma.gl/engine",
"version": "8.0.0-alpha.6",
"version": "8.0.0-alpha.9",
"description": "WebGL2 Components for High Performance Rendering and Computation",
"license": "MIT",
"publishConfig": {
Expand Down Expand Up @@ -31,12 +31,12 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0",
"@luma.gl/constants": "8.0.0-alpha.6",
"@luma.gl/shadertools": "8.0.0-alpha.6",
"@luma.gl/webgl": "8.0.0-alpha.6",
"@luma.gl/constants": "8.0.0-alpha.9",
"@luma.gl/shadertools": "8.0.0-alpha.9",
"@luma.gl/webgl": "8.0.0-alpha.9",
"math.gl": "^3.0.0",
"probe.gl": "^3.1.1",
"seer": "^0.2.4"
},
"gitHead": "1eb23cd12b4241742f6515daf4e0eaa5d6ee93a5"
"gitHead": "8deca643b658ddf6d8fb279df6417b8901a6fc93"
}
3 changes: 3 additions & 0 deletions modules/engine/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ export {default as TruncatedConeGeometry} from './geometries/truncated-cone-geom
// Animation
export {Timeline} from './animation/timeline';
export {KeyFrames} from './animation/key-frames';

// Utils
export {default as ClipSpace} from './utils/clip-space';
47 changes: 47 additions & 0 deletions modules/engine/src/utils/clip-space.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// ClipSpace
import GL from '@luma.gl/constants';
import Model from '../lib/model';
import Geometry from '../geometry/geometry';

const CLIPSPACE_VERTEX_SHADER = `\
attribute vec2 aClipSpacePosition;
attribute vec2 aTexCoord;
attribute vec2 aCoordinate;
varying vec2 position;
varying vec2 coordinate;
varying vec2 uv;
void main(void) {
gl_Position = vec4(aClipSpacePosition, 0., 1.);
position = aClipSpacePosition;
coordinate = aCoordinate;
uv = aTexCoord;
}
`;

/* eslint-disable indent, no-multi-spaces */
const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];

export default class ClipSpace extends Model {
constructor(gl, opts) {
const TEX_COORDS = POSITIONS.map(coord => (coord === -1 ? 0 : coord));

super(
gl,
Object.assign({}, opts, {
vs: CLIPSPACE_VERTEX_SHADER,
geometry: new Geometry({
drawMode: GL.TRIANGLE_STRIP,
vertexCount: 4,
attributes: {
aClipSpacePosition: {size: 2, value: new Float32Array(POSITIONS)},
aTexCoord: {size: 2, value: new Float32Array(TEX_COORDS)},
aCoordinate: {size: 2, value: new Float32Array(TEX_COORDS)}
}
})
})
);
this.setVertexCount(4);
}
}
6 changes: 3 additions & 3 deletions modules/gltools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@luma.gl/gltools",
"version": "8.0.0-alpha.6",
"version": "8.0.0-alpha.9",
"description": "WebGL2 API Polyfills for WebGL1 WebGLRenderingContext",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0",
"@luma.gl/constants": "8.0.0-alpha.6"
"@luma.gl/constants": "8.0.0-alpha.9"
},
"gitHead": "1eb23cd12b4241742f6515daf4e0eaa5d6ee93a5"
"gitHead": "8deca643b658ddf6d8fb279df6417b8901a6fc93"
}
8 changes: 8 additions & 0 deletions modules/gltools/src/state-tracker/unified-parameter-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ export function getParameters(gl, parameters) {
// default to querying all parameters
parameters = parameters || GL_PARAMETER_DEFAULTS;
// support both arrays of parameters and objects (keys represent parameters)

if (typeof parameters === 'number') {
// single GL enum
const key = parameters;
const getter = GL_PARAMETER_GETTERS[key];
return getter ? getter(gl, key) : gl.getParameter(key);
}

const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);

const state = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ const fixture = {
gl2: createTestContext({webgl2: true, webgl1: false})
};

function getParameter(gl, param) {
return getParameters(gl, [param])[param];
}

test('WebGL#state', t => {
t.ok(getParameters, 'getParameters imported ok');
t.ok(setParameters, 'setParameters imported ok');
Expand Down Expand Up @@ -398,14 +394,14 @@ test('WebGLState#bindFramebuffer (WebGL1)', t => {

resetParameters(gl);

fbHandle = getParameter(gl, gl.FRAMEBUFFER_BINDING);
fbHandle = getParameters(gl, gl.FRAMEBUFFER_BINDING);
t.equal(fbHandle, null, 'Initial draw frambuffer binding should be null');

setParameters(gl, {
framebuffer
});

fbHandle = getParameter(gl, gl.FRAMEBUFFER_BINDING);
fbHandle = getParameters(gl, gl.FRAMEBUFFER_BINDING);
t.equal(fbHandle, framebuffer.handle, 'setParameters should set framebuffer binding');

t.end();
Expand Down Expand Up @@ -480,26 +476,26 @@ test('WebGLState#withParameters framebuffer', t => {
resetParameters(gl);

let fbHandle;
fbHandle = getParameter(gl, gl.FRAMEBUFFER_BINDING);
fbHandle = getParameters(gl, gl.FRAMEBUFFER_BINDING);
t.equal(fbHandle, null, 'Initial draw frambuffer binding should be null');

withParameters(gl, {framebuffer: framebufferOne}, () => {
fbHandle = getParameter(gl, gl.FRAMEBUFFER_BINDING);
fbHandle = getParameters(gl, gl.FRAMEBUFFER_BINDING);
t.deepEqual(fbHandle, framebufferOne.handle, 'withParameters should bind framebuffer');

withParameters(gl, {framebuffer: framebufferTwo}, () => {
fbHandle = getParameter(gl, gl.FRAMEBUFFER_BINDING);
fbHandle = getParameters(gl, gl.FRAMEBUFFER_BINDING);
t.deepEqual(fbHandle, framebufferTwo.handle, 'Inner withParameters should bind framebuffer');
});

fbHandle = getParameter(gl, gl.FRAMEBUFFER_BINDING);
fbHandle = getParameters(gl, gl.FRAMEBUFFER_BINDING);
t.deepEqual(
fbHandle,
framebufferOne.handle,
'Inner withParameters should restore draw framebuffer binding'
);
});
fbHandle = getParameter(gl, gl.FRAMEBUFFER_BINDING);
fbHandle = getParameters(gl, gl.FRAMEBUFFER_BINDING);
t.deepEqual(fbHandle, null, 'withParameters should restore framebuffer bidning');

t.end();
Expand All @@ -515,20 +511,20 @@ test('WebGLState#withParameters empty parameters object', t => {
[GL.BLEND]: false
});

let clearColor = getParameter(gl, GL.COLOR_CLEAR_VALUE);
let blendState = getParameter(gl, GL.BLEND);
let clearColor = getParameters(gl, GL.COLOR_CLEAR_VALUE);
let blendState = getParameters(gl, GL.BLEND);
t.deepEqual(clearColor, [0, 0, 0, 0], `got expected value ${stringifyTypedArray(clearColor)}`);
t.deepEqual(blendState, false, `got expected value ${stringifyTypedArray(blendState)}`);

withParameters(gl, {}, () => {
clearColor = getParameter(gl, GL.COLOR_CLEAR_VALUE);
blendState = getParameter(gl, GL.BLEND);
clearColor = getParameters(gl, GL.COLOR_CLEAR_VALUE);
blendState = getParameters(gl, GL.BLEND);
t.deepEqual(clearColor, [0, 0, 0, 0], `got expected value ${stringifyTypedArray(clearColor)}`);
t.deepEqual(blendState, false, `got expected value ${stringifyTypedArray(blendState)}`);
});

clearColor = getParameter(gl, GL.COLOR_CLEAR_VALUE);
blendState = getParameter(gl, GL.BLEND);
clearColor = getParameters(gl, GL.COLOR_CLEAR_VALUE);
blendState = getParameters(gl, GL.BLEND);
t.deepEqual(clearColor, [0, 0, 0, 0], `got expected value ${stringifyTypedArray(clearColor)}`);
t.deepEqual(blendState, false, `got expected value ${stringifyTypedArray(blendState)}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ function stringifyTypedArray(v) {
return JSON.stringify(v);
}

function getParameter(gl, param) {
return getParameters(gl, [param])[param];
}

// Settings test, don't reuse a context
const fixture = {
gl: createTestContext({debug: true})
Expand Down Expand Up @@ -183,19 +179,19 @@ test('WebGLState#intercept gl calls', t => {
pushContextState(gl);

gl.blendEquation(gl.FUNC_SUBTRACT, gl.FUNC_SUBTRACT);
t.is(getParameter(gl, gl.BLEND_EQUATION_RGB), gl.FUNC_SUBTRACT, 'direct gl call is tracked');
t.is(getParameters(gl, gl.BLEND_EQUATION_RGB), gl.FUNC_SUBTRACT, 'direct gl call is tracked');

gl.blendFunc(gl.ONE, gl.ONE);
t.is(getParameter(gl, gl.BLEND_SRC_RGB), gl.ONE, 'direct gl call is tracked');
t.is(getParameters(gl, gl.BLEND_SRC_RGB), gl.ONE, 'direct gl call is tracked');

gl.stencilMask(8);
t.is(getParameter(gl, gl.STENCIL_WRITEMASK), 8, 'direct gl call is tracked');
t.is(getParameters(gl, gl.STENCIL_WRITEMASK), 8, 'direct gl call is tracked');

gl.stencilFunc(gl.NEVER, 0, 1);
t.is(getParameter(gl, gl.STENCIL_FUNC), gl.NEVER, 'direct gl call is tracked');
t.is(getParameters(gl, gl.STENCIL_FUNC), gl.NEVER, 'direct gl call is tracked');

gl.stencilOp(gl.KEEP, gl.ZERO, gl.REPLACE);
t.is(getParameter(gl, gl.STENCIL_PASS_DEPTH_FAIL), gl.ZERO, 'direct gl call is tracked');
t.is(getParameters(gl, gl.STENCIL_PASS_DEPTH_FAIL), gl.ZERO, 'direct gl call is tracked');

popContextState(gl);
const parameters = getParameters(gl);
Expand Down
4 changes: 2 additions & 2 deletions modules/shadertools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@luma.gl/shadertools",
"version": "8.0.0-alpha.6",
"version": "8.0.0-alpha.9",
"description": "Shader module system for luma.gl",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -39,5 +39,5 @@
"@babel/runtime": "^7.0.0",
"math.gl": "^3.0.0"
},
"gitHead": "1eb23cd12b4241742f6515daf4e0eaa5d6ee93a5"
"gitHead": "8deca643b658ddf6d8fb279df6417b8901a6fc93"
}
Loading

0 comments on commit c2047d6

Please sign in to comment.