@luma.gl/shadertools
Advanced tools
Comparing version 7.0.0-alpha.5 to 7.0.0-alpha.6
@@ -108,3 +108,3 @@ "use strict"; | ||
if (injectStandardStubs) { | ||
source = source.replace('}\s*$', function (match) { | ||
source = source.replace('}s*$', function (match) { | ||
return match + MODULE_INJECTORS[type]; | ||
@@ -111,0 +111,0 @@ }); |
@@ -34,3 +34,3 @@ "use strict"; | ||
if (value === 0) { | ||
return "NO_ERROR"; | ||
return 'NO_ERROR'; | ||
} | ||
@@ -44,10 +44,8 @@ | ||
return "0x" + value.toString(16); | ||
return '0x' + value.toString(16); | ||
} | ||
; | ||
function addSpan(contents, div) { | ||
if (div == undefined) { | ||
var divs = _global.document.body.getElementsByClassName("testInfo"); | ||
var divs = _global.document.body.getElementsByClassName('testInfo'); | ||
@@ -58,3 +56,3 @@ var lastDiv = divs[divs.length - 1]; | ||
var span = _global.document.createElement("span"); | ||
var span = _global.document.createElement('span'); | ||
@@ -66,7 +64,7 @@ div.appendChild(span); | ||
function addDiv(contents) { | ||
var testInfoDiv = _global.document.createElement("div"); | ||
var testInfoDiv = _global.document.createElement('div'); | ||
_global.document.body.appendChild(testInfoDiv); | ||
testInfoDiv.setAttribute("class", "testInfo"); | ||
testInfoDiv.setAttribute('class', 'testInfo'); | ||
return testInfoDiv; | ||
@@ -80,3 +78,3 @@ } | ||
function escapeHTML(text) { | ||
return text.replace(/&/g, "&").replace(/</g, "<"); | ||
return text.replace(/&/g, '&').replace(/</g, '<'); | ||
} | ||
@@ -99,3 +97,3 @@ | ||
opt_msg = opt_msg || ""; | ||
opt_msg = opt_msg || ''; | ||
var err = gl.getError(); | ||
@@ -109,13 +107,12 @@ var ndx = glErrors.indexOf(err); | ||
var expected = errStrs.join(" or "); | ||
var expected = errStrs.join(' or '); | ||
if (ndx < 0) { | ||
var msg = "getError expected" + (glErrors.length > 1 ? " one of: " : ": "); | ||
testFailed(msg + expected + ". Was " + glEnumToString(gl, err) + " : " + opt_msg); | ||
var msg = 'getError expected' + (glErrors.length > 1 ? ' one of: ' : ': '); | ||
testFailed(msg + expected + '. Was ' + glEnumToString(gl, err) + ' : ' + opt_msg); | ||
} else {//var msg = "getError was " + ((glErrors.length > 1) ? "one of: " : "expected value: "); | ||
//testPassed(msg + expected + " : " + opt_msg); | ||
} | ||
} | ||
} // Special utility functions for df64 tests | ||
; // Special utility functions for df64 tests | ||
@@ -182,3 +179,3 @@ function fp64ify(a) { | ||
gl.drawArrays(5, 0, 4); | ||
glErrorShouldBe(gl, 0, "no error from draw"); | ||
glErrorShouldBe(gl, 0, 'no error from draw'); | ||
} | ||
@@ -197,3 +194,3 @@ | ||
var line; | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
var referece64 = reference[0] + reference[1]; | ||
@@ -203,5 +200,5 @@ var result64 = result[0] + result[1]; | ||
addSpan(line, currentDiv); | ||
line = "GPU output: (" + result[0].toString() + ',' + result[1].toString() + ',' + result[2].toString() + ',' + result[3].toString() + ') = ' + result64.toString() + '<br>'; | ||
line = 'GPU output: (' + result[0].toString() + ',' + result[1].toString() + ',' + result[2].toString() + ',' + result[3].toString() + ') = ' + result64.toString() + '<br>'; | ||
addSpan(line, currentDiv); | ||
line = "error: " + Math.abs((referece64 - result64) / referece64) + '<br>'; | ||
line = 'error: ' + Math.abs((referece64 - result64) / referece64) + '<br>'; | ||
addSpan(line, currentDiv); // var referenceBits = new Int32Array(reference.buffer); | ||
@@ -258,3 +255,3 @@ // var resultBits = new Int32Array(result.buffer); | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') + (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') + (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -291,3 +288,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') - (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') - (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -324,3 +321,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') * (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') * (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -357,3 +354,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') / (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') / (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -387,3 +384,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "sqrt(" + float0_vec2.toString() + ')<br>'; | ||
line = 'sqrt(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -417,3 +414,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "exp(" + float0_vec2.toString() + ')<br>'; | ||
line = 'exp(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -447,3 +444,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "log(" + float0_vec2.toString() + ')<br>'; | ||
line = 'log(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -477,3 +474,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "sin(" + float0_vec2.toString() + ')<br>'; | ||
line = 'sin(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -507,3 +504,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "cos(" + float0_vec2.toString() + ')<br>'; | ||
line = 'cos(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -537,3 +534,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "tan(" + float0_vec2.toString() + ')<br>'; | ||
line = 'tan(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -567,3 +564,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "tan(" + float0_vec2.toString() + ')<br>'; | ||
line = 'tan(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -591,9 +588,9 @@ return float_ref_vec2; | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_add(gl, "Float addition test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_add(gl, 'Float addition test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -603,9 +600,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_sub(gl, "Float subtraction test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_sub(gl, 'Float subtraction test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -615,9 +612,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_mul(gl, "Float multiplication test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_mul(gl, 'Float multiplication test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -627,9 +624,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_div(gl, "Float division test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_div(gl, 'Float division test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -639,9 +636,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_sqrt(gl, "Float sqrt test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_sqrt(gl, 'Float sqrt test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -651,9 +648,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_exp(gl, "Float exp test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_exp(gl, 'Float exp test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -663,9 +660,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_log(gl, "Float log test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_log(gl, 'Float log test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -675,9 +672,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_sin(gl, "Float sin test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_sin(gl, 'Float sin test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -687,9 +684,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_cos(gl, "Float cos test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_cos(gl, 'Float cos test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -699,9 +696,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_tan(gl, "Float tan test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_tan(gl, 'Float tan test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -711,11 +708,11 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_radians(gl, "Float radians test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_radians(gl, 'Float radians test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
}; | ||
//# sourceMappingURL=fp64-shader.spec.js.map |
@@ -25,7 +25,7 @@ "use strict"; | ||
/* global WebGL2RenderingContext */ | ||
var GL_TEXTURE_BINDING_3D = 0x806A; | ||
var GL_VENDOR = 0x1F00; | ||
var GL_RENDERER = 0x1F01; | ||
var GL_VERSION = 0x1F02; | ||
var GL_SHADING_LANGUAGE_VERSION = 0x8B8C; // Defines luma.gl "feature" names and semantics | ||
var GL_TEXTURE_BINDING_3D = 0x806a; | ||
var GL_VENDOR = 0x1f00; | ||
var GL_RENDERER = 0x1f01; | ||
var GL_VERSION = 0x1f02; | ||
var GL_SHADING_LANGUAGE_VERSION = 0x8b8c; // Defines luma.gl "feature" names and semantics | ||
@@ -32,0 +32,0 @@ var WEBGL_FEATURES = { |
@@ -76,3 +76,3 @@ import { MODULE_INJECTORS_VS, MODULE_INJECTORS_FS } from '../modules/module-injectors'; | ||
if (injectStandardStubs) { | ||
source = source.replace('}\s*$', match => match + MODULE_INJECTORS[type]); | ||
source = source.replace('}s*$', match => match + MODULE_INJECTORS[type]); | ||
} | ||
@@ -79,0 +79,0 @@ |
@@ -30,3 +30,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
if (value === 0) { | ||
return "NO_ERROR"; | ||
return 'NO_ERROR'; | ||
} | ||
@@ -40,10 +40,8 @@ | ||
return "0x" + value.toString(16); | ||
return '0x' + value.toString(16); | ||
} | ||
; | ||
function addSpan(contents, div) { | ||
if (div == undefined) { | ||
var divs = document.body.getElementsByClassName("testInfo"); | ||
var divs = document.body.getElementsByClassName('testInfo'); | ||
var lastDiv = divs[divs.length - 1]; | ||
@@ -53,3 +51,3 @@ div = lastDiv; | ||
var span = document.createElement("span"); | ||
var span = document.createElement('span'); | ||
div.appendChild(span); | ||
@@ -60,5 +58,5 @@ span.innerHTML = contents + '<br />'; | ||
function addDiv(contents) { | ||
var testInfoDiv = document.createElement("div"); | ||
var testInfoDiv = document.createElement('div'); | ||
document.body.appendChild(testInfoDiv); | ||
testInfoDiv.setAttribute("class", "testInfo"); | ||
testInfoDiv.setAttribute('class', 'testInfo'); | ||
return testInfoDiv; | ||
@@ -72,3 +70,3 @@ } | ||
function escapeHTML(text) { | ||
return text.replace(/&/g, "&").replace(/</g, "<"); | ||
return text.replace(/&/g, '&').replace(/</g, '<'); | ||
} | ||
@@ -91,3 +89,3 @@ | ||
opt_msg = opt_msg || ""; | ||
opt_msg = opt_msg || ''; | ||
var err = gl.getError(); | ||
@@ -101,13 +99,12 @@ var ndx = glErrors.indexOf(err); | ||
var expected = errStrs.join(" or "); | ||
var expected = errStrs.join(' or '); | ||
if (ndx < 0) { | ||
var msg = "getError expected" + (glErrors.length > 1 ? " one of: " : ": "); | ||
testFailed(msg + expected + ". Was " + glEnumToString(gl, err) + " : " + opt_msg); | ||
var msg = 'getError expected' + (glErrors.length > 1 ? ' one of: ' : ': '); | ||
testFailed(msg + expected + '. Was ' + glEnumToString(gl, err) + ' : ' + opt_msg); | ||
} else {//var msg = "getError was " + ((glErrors.length > 1) ? "one of: " : "expected value: "); | ||
//testPassed(msg + expected + " : " + opt_msg); | ||
} | ||
} | ||
} // Special utility functions for df64 tests | ||
; // Special utility functions for df64 tests | ||
@@ -173,3 +170,3 @@ function fp64ify(a) { | ||
gl.drawArrays(5, 0, 4); | ||
glErrorShouldBe(gl, 0, "no error from draw"); | ||
glErrorShouldBe(gl, 0, 'no error from draw'); | ||
} | ||
@@ -188,3 +185,3 @@ | ||
var line; | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
let referece64 = reference[0] + reference[1]; | ||
@@ -194,5 +191,5 @@ let result64 = result[0] + result[1]; | ||
addSpan(line, currentDiv); | ||
line = "GPU output: (" + result[0].toString() + ',' + result[1].toString() + ',' + result[2].toString() + ',' + result[3].toString() + ') = ' + result64.toString() + '<br>'; | ||
line = 'GPU output: (' + result[0].toString() + ',' + result[1].toString() + ',' + result[2].toString() + ',' + result[3].toString() + ') = ' + result64.toString() + '<br>'; | ||
addSpan(line, currentDiv); | ||
line = "error: " + Math.abs((referece64 - result64) / referece64) + '<br>'; | ||
line = 'error: ' + Math.abs((referece64 - result64) / referece64) + '<br>'; | ||
addSpan(line, currentDiv); // var referenceBits = new Int32Array(reference.buffer); | ||
@@ -249,3 +246,3 @@ // var resultBits = new Int32Array(result.buffer); | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') + (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') + (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -282,3 +279,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') - (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') - (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -315,3 +312,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') * (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') * (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -348,3 +345,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') / (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') / (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -378,3 +375,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "sqrt(" + float0_vec2.toString() + ')<br>'; | ||
line = 'sqrt(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -408,3 +405,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "exp(" + float0_vec2.toString() + ')<br>'; | ||
line = 'exp(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -438,3 +435,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "log(" + float0_vec2.toString() + ')<br>'; | ||
line = 'log(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -468,3 +465,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "sin(" + float0_vec2.toString() + ')<br>'; | ||
line = 'sin(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -498,3 +495,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "cos(" + float0_vec2.toString() + ')<br>'; | ||
line = 'cos(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -528,3 +525,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "tan(" + float0_vec2.toString() + ')<br>'; | ||
line = 'tan(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -558,3 +555,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "tan(" + float0_vec2.toString() + ')<br>'; | ||
line = 'tan(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -580,9 +577,9 @@ return float_ref_vec2; | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_add(gl, "Float addition test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_add(gl, 'Float addition test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -592,9 +589,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_sub(gl, "Float subtraction test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_sub(gl, 'Float subtraction test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -604,9 +601,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_mul(gl, "Float multiplication test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_mul(gl, 'Float multiplication test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -616,9 +613,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_div(gl, "Float division test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_div(gl, 'Float division test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -628,9 +625,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_sqrt(gl, "Float sqrt test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_sqrt(gl, 'Float sqrt test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -640,9 +637,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_exp(gl, "Float exp test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_exp(gl, 'Float exp test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -652,9 +649,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_log(gl, "Float log test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_log(gl, 'Float log test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -664,9 +661,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_sin(gl, "Float sin test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_sin(gl, 'Float sin test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -676,9 +673,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_cos(gl, "Float cos test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_cos(gl, 'Float cos test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -688,9 +685,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_tan(gl, "Float tan test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_tan(gl, 'Float tan test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -700,11 +697,11 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_radians(gl, "Float radians test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_radians(gl, 'Float radians test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
}; | ||
//# sourceMappingURL=fp64-shader.spec.js.map |
@@ -11,7 +11,7 @@ // Feature detection for WebGL | ||
import assert from './assert'; | ||
const GL_TEXTURE_BINDING_3D = 0x806A; | ||
const GL_VENDOR = 0x1F00; | ||
const GL_RENDERER = 0x1F01; | ||
const GL_VERSION = 0x1F02; | ||
const GL_SHADING_LANGUAGE_VERSION = 0x8B8C; // Defines luma.gl "feature" names and semantics | ||
const GL_TEXTURE_BINDING_3D = 0x806a; | ||
const GL_VENDOR = 0x1f00; | ||
const GL_RENDERER = 0x1f01; | ||
const GL_VERSION = 0x1f02; | ||
const GL_SHADING_LANGUAGE_VERSION = 0x8b8c; // Defines luma.gl "feature" names and semantics | ||
@@ -18,0 +18,0 @@ const WEBGL_FEATURES = { |
@@ -95,3 +95,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
if (injectStandardStubs) { | ||
source = source.replace('}\s*$', function (match) { | ||
source = source.replace('}s*$', function (match) { | ||
return match + MODULE_INJECTORS[type]; | ||
@@ -98,0 +98,0 @@ }); |
@@ -30,3 +30,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
if (value === 0) { | ||
return "NO_ERROR"; | ||
return 'NO_ERROR'; | ||
} | ||
@@ -40,10 +40,8 @@ | ||
return "0x" + value.toString(16); | ||
return '0x' + value.toString(16); | ||
} | ||
; | ||
function addSpan(contents, div) { | ||
if (div == undefined) { | ||
var divs = document.body.getElementsByClassName("testInfo"); | ||
var divs = document.body.getElementsByClassName('testInfo'); | ||
var lastDiv = divs[divs.length - 1]; | ||
@@ -53,3 +51,3 @@ div = lastDiv; | ||
var span = document.createElement("span"); | ||
var span = document.createElement('span'); | ||
div.appendChild(span); | ||
@@ -60,5 +58,5 @@ span.innerHTML = contents + '<br />'; | ||
function addDiv(contents) { | ||
var testInfoDiv = document.createElement("div"); | ||
var testInfoDiv = document.createElement('div'); | ||
document.body.appendChild(testInfoDiv); | ||
testInfoDiv.setAttribute("class", "testInfo"); | ||
testInfoDiv.setAttribute('class', 'testInfo'); | ||
return testInfoDiv; | ||
@@ -72,3 +70,3 @@ } | ||
function escapeHTML(text) { | ||
return text.replace(/&/g, "&").replace(/</g, "<"); | ||
return text.replace(/&/g, '&').replace(/</g, '<'); | ||
} | ||
@@ -91,3 +89,3 @@ | ||
opt_msg = opt_msg || ""; | ||
opt_msg = opt_msg || ''; | ||
var err = gl.getError(); | ||
@@ -101,13 +99,12 @@ var ndx = glErrors.indexOf(err); | ||
var expected = errStrs.join(" or "); | ||
var expected = errStrs.join(' or '); | ||
if (ndx < 0) { | ||
var msg = "getError expected" + (glErrors.length > 1 ? " one of: " : ": "); | ||
testFailed(msg + expected + ". Was " + glEnumToString(gl, err) + " : " + opt_msg); | ||
var msg = 'getError expected' + (glErrors.length > 1 ? ' one of: ' : ': '); | ||
testFailed(msg + expected + '. Was ' + glEnumToString(gl, err) + ' : ' + opt_msg); | ||
} else {//var msg = "getError was " + ((glErrors.length > 1) ? "one of: " : "expected value: "); | ||
//testPassed(msg + expected + " : " + opt_msg); | ||
} | ||
} | ||
} // Special utility functions for df64 tests | ||
; // Special utility functions for df64 tests | ||
@@ -174,3 +171,3 @@ function fp64ify(a) { | ||
gl.drawArrays(5, 0, 4); | ||
glErrorShouldBe(gl, 0, "no error from draw"); | ||
glErrorShouldBe(gl, 0, 'no error from draw'); | ||
} | ||
@@ -189,3 +186,3 @@ | ||
var line; | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
var referece64 = reference[0] + reference[1]; | ||
@@ -195,5 +192,5 @@ var result64 = result[0] + result[1]; | ||
addSpan(line, currentDiv); | ||
line = "GPU output: (" + result[0].toString() + ',' + result[1].toString() + ',' + result[2].toString() + ',' + result[3].toString() + ') = ' + result64.toString() + '<br>'; | ||
line = 'GPU output: (' + result[0].toString() + ',' + result[1].toString() + ',' + result[2].toString() + ',' + result[3].toString() + ') = ' + result64.toString() + '<br>'; | ||
addSpan(line, currentDiv); | ||
line = "error: " + Math.abs((referece64 - result64) / referece64) + '<br>'; | ||
line = 'error: ' + Math.abs((referece64 - result64) / referece64) + '<br>'; | ||
addSpan(line, currentDiv); // var referenceBits = new Int32Array(reference.buffer); | ||
@@ -250,3 +247,3 @@ // var resultBits = new Int32Array(result.buffer); | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') + (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') + (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -283,3 +280,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') - (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') - (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -316,3 +313,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') * (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') * (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -349,3 +346,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') / (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') / (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -379,3 +376,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "sqrt(" + float0_vec2.toString() + ')<br>'; | ||
line = 'sqrt(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -409,3 +406,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "exp(" + float0_vec2.toString() + ')<br>'; | ||
line = 'exp(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -439,3 +436,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "log(" + float0_vec2.toString() + ')<br>'; | ||
line = 'log(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -469,3 +466,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "sin(" + float0_vec2.toString() + ')<br>'; | ||
line = 'sin(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -499,3 +496,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "cos(" + float0_vec2.toString() + ')<br>'; | ||
line = 'cos(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -529,3 +526,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "tan(" + float0_vec2.toString() + ')<br>'; | ||
line = 'tan(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -559,3 +556,3 @@ return float_ref_vec2; | ||
var line; | ||
line = "tan(" + float0_vec2.toString() + ')<br>'; | ||
line = 'tan(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -581,9 +578,9 @@ return float_ref_vec2; | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_add(gl, "Float addition test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_add(gl, 'Float addition test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -593,9 +590,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_sub(gl, "Float subtraction test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_sub(gl, 'Float subtraction test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -605,9 +602,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_mul(gl, "Float multiplication test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_mul(gl, 'Float multiplication test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -617,9 +614,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_div(gl, "Float division test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_div(gl, 'Float division test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -629,9 +626,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_sqrt(gl, "Float sqrt test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_sqrt(gl, 'Float sqrt test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -641,9 +638,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_exp(gl, "Float exp test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_exp(gl, 'Float exp test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -653,9 +650,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_log(gl, "Float log test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_log(gl, 'Float log test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -665,9 +662,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_sin(gl, "Float sin test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_sin(gl, 'Float sin test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -677,9 +674,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_cos(gl, "Float cos test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_cos(gl, 'Float cos test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -689,9 +686,9 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_tan(gl, "Float tan test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_tan(gl, 'Float tan test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -701,11 +698,11 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
var cpu_result = test_float_radians(gl, "Float radians test"); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_radians(gl, 'Float radians test'); | ||
render(gl); | ||
var gpu_result = getGPUOutput(gl); | ||
checkError(gpu_result, cpu_result); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
}; | ||
//# sourceMappingURL=fp64-shader.spec.js.map |
@@ -11,7 +11,7 @@ // Feature detection for WebGL | ||
import assert from './assert'; | ||
var GL_TEXTURE_BINDING_3D = 0x806A; | ||
var GL_VENDOR = 0x1F00; | ||
var GL_RENDERER = 0x1F01; | ||
var GL_VERSION = 0x1F02; | ||
var GL_SHADING_LANGUAGE_VERSION = 0x8B8C; // Defines luma.gl "feature" names and semantics | ||
var GL_TEXTURE_BINDING_3D = 0x806a; | ||
var GL_VENDOR = 0x1f00; | ||
var GL_RENDERER = 0x1f01; | ||
var GL_VERSION = 0x1f02; | ||
var GL_SHADING_LANGUAGE_VERSION = 0x8b8c; // Defines luma.gl "feature" names and semantics | ||
@@ -18,0 +18,0 @@ var WEBGL_FEATURES = { |
{ | ||
"name": "@luma.gl/shadertools", | ||
"version": "7.0.0-alpha.5", | ||
"version": "7.0.0-alpha.6", | ||
"description": "Shader module system for luma.gl", | ||
@@ -45,4 +45,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@luma.gl/constants": "^7.0.0-alpha.3" | ||
"@luma.gl/constants": "^7.0.0-alpha.6" | ||
} | ||
} |
@@ -5,7 +5,4 @@ // shadertools exports | ||
export { | ||
registerShaderModules, | ||
setDefaultShaderModules} from './lib/resolve-modules'; | ||
export { | ||
assembleShaders} from './lib/assemble-shaders'; | ||
export {registerShaderModules, setDefaultShaderModules} from './lib/resolve-modules'; | ||
export {assembleShaders} from './lib/assemble-shaders'; | ||
@@ -12,0 +9,0 @@ // HELPERS |
@@ -34,12 +34,6 @@ import {VERTEX_SHADER, FRAGMENT_SHADER} from './constants'; | ||
// adding prologues, requested module chunks, and any final injections. | ||
function assembleShader(gl, { | ||
id, | ||
source, | ||
type, | ||
modules = [], | ||
defines = {}, | ||
inject = {}, | ||
prologue = true, | ||
log | ||
}) { | ||
function assembleShader( | ||
gl, | ||
{id, source, type, modules = [], defines = {}, inject = {}, prologue = true, log} | ||
) { | ||
assert(typeof source === 'string', 'shader source must be a string'); | ||
@@ -64,3 +58,4 @@ | ||
// Add precision declaration for fragment shaders | ||
let assembledSource = prologue ? `\ | ||
let assembledSource = prologue | ||
? `\ | ||
${versionLine} | ||
@@ -72,3 +67,4 @@ ${getShaderName({id, source, type})} | ||
${isVertex ? '' : FRAGMENT_SHADER_PROLOGUE} | ||
` : `${versionLine} | ||
` | ||
: `${versionLine} | ||
`; | ||
@@ -80,11 +76,11 @@ | ||
switch (module.name) { | ||
case 'inject': | ||
injectStandardStubs = true; | ||
break; | ||
case 'inject': | ||
injectStandardStubs = true; | ||
break; | ||
default: | ||
module.checkDeprecations(coreSource, log); | ||
const moduleSource = module.getModuleSource(type, glslVersion); | ||
// Add the module source, and a #define that declares it presence | ||
assembledSource += moduleSource; | ||
default: | ||
module.checkDeprecations(coreSource, log); | ||
const moduleSource = module.getModuleSource(type, glslVersion); | ||
// Add the module source, and a #define that declares it presence | ||
assembledSource += moduleSource; | ||
} | ||
@@ -107,3 +103,2 @@ } | ||
function assembleGetUniforms(modules) { | ||
return function getUniforms(opts) { | ||
@@ -119,3 +114,2 @@ const uniforms = {}; | ||
}; | ||
} | ||
@@ -140,6 +134,8 @@ | ||
const injectShaderName = id && typeof id === 'string' && source.indexOf('SHADER_NAME') === -1; | ||
return injectShaderName ? ` | ||
return injectShaderName | ||
? ` | ||
#define SHADER_NAME ${id}_${SHADER_TYPE[type]} | ||
` : ''; | ||
` | ||
: ''; | ||
} | ||
@@ -146,0 +142,0 @@ |
@@ -43,21 +43,21 @@ // // import assert from 'assert'; // TODO | ||
switch (getTypeOf(propDef)) { | ||
case 'object': | ||
propDef = normalizePropType(name, propDef); | ||
return parsePropDefinition(propDef); | ||
case 'object': | ||
propDef = normalizePropType(name, propDef); | ||
return parsePropDefinition(propDef); | ||
case 'array': | ||
return guessArrayType(name, propDef); | ||
case 'array': | ||
return guessArrayType(name, propDef); | ||
case 'boolean': | ||
return {name, type: 'boolean', value: propDef}; | ||
case 'boolean': | ||
return {name, type: 'boolean', value: propDef}; | ||
case 'number': | ||
return guessNumberType(name, propDef); | ||
case 'number': | ||
return guessNumberType(name, propDef); | ||
case 'function': | ||
return {name, type: 'function', value: propDef}; | ||
// return guessFunctionType(name, propDef); | ||
case 'function': | ||
return {name, type: 'function', value: propDef}; | ||
// return guessFunctionType(name, propDef); | ||
default: | ||
return {name, type: 'unknown', value: propDef}; | ||
default: | ||
return {name, type: 'unknown', value: propDef}; | ||
} | ||
@@ -97,3 +97,3 @@ } | ||
const isKnownProp = | ||
(/radius|scale|width|height|pixel|size|miter/i).test(name) && (/^((?!scale).)*$/).test(name); | ||
/radius|scale|width|height|pixel|size|miter/i.test(name) && /^((?!scale).)*$/.test(name); | ||
const max = isKnownProp ? 100 : 1; | ||
@@ -100,0 +100,0 @@ const min = 0; |
@@ -24,36 +24,36 @@ import {MODULE_INJECTORS_VS, MODULE_INJECTORS_FS} from '../modules/module-injectors'; | ||
// declarations are injected before the main function | ||
case 'vs:#decl': | ||
if (isVertex) { | ||
source = source.replace(REGEX_START_OF_MAIN, match => `${fragment}\n${match}`); | ||
} | ||
break; | ||
// main code is injected at the end of main function | ||
case 'vs:#main-start': | ||
if (isVertex) { | ||
source = source.replace(REGEX_START_OF_MAIN, match => match + fragment); | ||
} | ||
break; | ||
case 'vs:#main-end': | ||
if (isVertex) { | ||
source = source.replace(REGEX_END_OF_MAIN, match => fragment + match); | ||
} | ||
break; | ||
case 'fs:#decl': | ||
if (!isVertex) { | ||
source = source.replace(REGEX_START_OF_MAIN, match => `${fragment}\n${match}`); | ||
} | ||
break; | ||
case 'fs:#main-start': | ||
if (!isVertex) { | ||
source = source.replace(REGEX_START_OF_MAIN, match => match + fragment); | ||
} | ||
break; | ||
case 'fs:#main-end': | ||
if (!isVertex) { | ||
source = source.replace(REGEX_END_OF_MAIN, match => fragment + match); | ||
} | ||
break; | ||
default: | ||
// inject code after key, leaving key in place | ||
source = source.replace(key, match => match + fragment); | ||
case 'vs:#decl': | ||
if (isVertex) { | ||
source = source.replace(REGEX_START_OF_MAIN, match => `${fragment}\n${match}`); | ||
} | ||
break; | ||
// main code is injected at the end of main function | ||
case 'vs:#main-start': | ||
if (isVertex) { | ||
source = source.replace(REGEX_START_OF_MAIN, match => match + fragment); | ||
} | ||
break; | ||
case 'vs:#main-end': | ||
if (isVertex) { | ||
source = source.replace(REGEX_END_OF_MAIN, match => fragment + match); | ||
} | ||
break; | ||
case 'fs:#decl': | ||
if (!isVertex) { | ||
source = source.replace(REGEX_START_OF_MAIN, match => `${fragment}\n${match}`); | ||
} | ||
break; | ||
case 'fs:#main-start': | ||
if (!isVertex) { | ||
source = source.replace(REGEX_START_OF_MAIN, match => match + fragment); | ||
} | ||
break; | ||
case 'fs:#main-end': | ||
if (!isVertex) { | ||
source = source.replace(REGEX_END_OF_MAIN, match => fragment + match); | ||
} | ||
break; | ||
default: | ||
// inject code after key, leaving key in place | ||
source = source.replace(key, match => match + fragment); | ||
} | ||
@@ -64,3 +64,3 @@ } | ||
if (injectStandardStubs) { | ||
source = source.replace('}\s*$', match => match + MODULE_INJECTORS[type]); | ||
source = source.replace('}s*$', match => match + MODULE_INJECTORS[type]); | ||
} | ||
@@ -83,2 +83,1 @@ | ||
} | ||
import {getContextInfo, hasFeatures, canCompileGLGSExtension, FEATURES} from '../utils/webgl-info'; | ||
export function getPlatformShaderDefines(gl) { | ||
const debugInfo = getContextInfo(gl); | ||
switch (debugInfo.gpuVendor.toLowerCase()) { | ||
case 'nvidia': | ||
return `\ | ||
case 'nvidia': | ||
return `\ | ||
#define NVIDIA_GPU | ||
@@ -15,4 +14,4 @@ // Nvidia optimizes away the calculation necessary for emulated fp64 | ||
case 'intel': | ||
return `\ | ||
case 'intel': | ||
return `\ | ||
#define INTEL_GPU | ||
@@ -27,13 +26,13 @@ // Intel optimizes away the calculation necessary for emulated fp64 | ||
case 'amd': | ||
// AMD Does not eliminate fp64 code | ||
return `\ | ||
case 'amd': | ||
// AMD Does not eliminate fp64 code | ||
return `\ | ||
#define AMD_GPU | ||
`; | ||
default: | ||
// We don't know what GPU it is, could be that the GPU driver or | ||
// browser is not implementing UNMASKED_RENDERER constant and not | ||
// reporting a correct name | ||
return `\ | ||
default: | ||
// We don't know what GPU it is, could be that the GPU driver or | ||
// browser is not implementing UNMASKED_RENDERER constant and not | ||
// reporting a correct name | ||
return `\ | ||
#define DEFAULT_GPU | ||
@@ -51,3 +50,3 @@ // Prevent driver from optimizing away the calculation necessary for emulated fp64 | ||
export function getVersionDefines(gl, glslVersion, isFragment) { | ||
// Add shadertools defines to let shaders portably v1/v3 check for features | ||
// Add shadertools defines to let shaders portably v1/v3 check for features | ||
let versionDefines = `\ | ||
@@ -86,4 +85,5 @@ #if (__VERSION__ > 120) | ||
} | ||
if (hasFeatures(gl, FEATURES.GLSL_FRAG_DATA) && | ||
canCompileGLGSExtension(gl, FEATURES.GLSL_FRAG_DATA, {behavior: 'require'}) | ||
if ( | ||
hasFeatures(gl, FEATURES.GLSL_FRAG_DATA) && | ||
canCompileGLGSExtension(gl, FEATURES.GLSL_FRAG_DATA, {behavior: 'require'}) | ||
) { | ||
@@ -90,0 +90,0 @@ versionDefines += `\ |
@@ -19,5 +19,6 @@ import ShaderModuleRegistry from './shader-module-registry'; | ||
*/ | ||
export function registerShaderModules(shaderModuleList, { | ||
ignoreMultipleRegistrations = false | ||
} = {}) { | ||
export function registerShaderModules( | ||
shaderModuleList, | ||
{ignoreMultipleRegistrations = false} = {} | ||
) { | ||
shaderModuleRegistry.registerShaderModules(shaderModuleList, {ignoreMultipleRegistrations}); | ||
@@ -24,0 +25,0 @@ } |
@@ -32,10 +32,10 @@ import transpileShader from './transpile-shader'; | ||
switch (type) { | ||
case VERTEX_SHADER: | ||
moduleSource = transpileShader(this.vs || '', targetGLSLVersion, true); | ||
break; | ||
case FRAGMENT_SHADER: | ||
moduleSource = transpileShader(this.fs || '', targetGLSLVersion, false); | ||
break; | ||
default: | ||
assert(false); | ||
case VERTEX_SHADER: | ||
moduleSource = transpileShader(this.vs || '', targetGLSLVersion, true); | ||
break; | ||
case FRAGMENT_SHADER: | ||
moduleSource = transpileShader(this.fs || '', targetGLSLVersion, false); | ||
break; | ||
default: | ||
assert(false); | ||
} | ||
@@ -75,7 +75,7 @@ | ||
switch (def.type) { | ||
case 'function': | ||
def.regex = new RegExp(`\\b${def.old}\\(`); | ||
break; | ||
default: | ||
def.regex = new RegExp(`${def.type} ${def.old};`); | ||
case 'function': | ||
def.regex = new RegExp(`\\b${def.old}\\(`); | ||
break; | ||
default: | ||
def.regex = new RegExp(`${def.type} ${def.old};`); | ||
} | ||
@@ -82,0 +82,0 @@ }); |
@@ -10,5 +10,6 @@ import assert from '../utils/assert'; | ||
*/ | ||
export function registerShaderModules(shaderModuleList, { | ||
ignoreMultipleRegistrations = false | ||
} = {}) { | ||
export function registerShaderModules( | ||
shaderModuleList, | ||
{ignoreMultipleRegistrations = false} = {} | ||
) { | ||
for (const shaderModule of shaderModuleList) { | ||
@@ -131,7 +132,7 @@ registerShaderModule(shaderModule, {ignoreMultipleRegistrations}); | ||
switch (def.type) { | ||
case 'function': | ||
def.regex = new RegExp(`\\b${def.old}\\(`); | ||
break; | ||
default: | ||
def.regex = new RegExp(`${def.type} ${def.old};`); | ||
case 'function': | ||
def.regex = new RegExp(`\\b${def.old}\\(`); | ||
break; | ||
default: | ||
def.regex = new RegExp(`${def.type} ${def.old};`); | ||
} | ||
@@ -138,0 +139,0 @@ }); |
@@ -6,8 +6,8 @@ // Transpiles shader source code to target GLSL version | ||
switch (targetGLSLVersion) { | ||
case 300: | ||
return isVertex ? convertVertexShaderTo300(source) : convertFragmentShaderTo300(source); | ||
case 100: | ||
return isVertex ? convertVertexShaderTo100(source) : convertFragmentShaderTo100(source); | ||
default: | ||
throw new Error(`unknown GLSL version ${targetGLSLVersion}`); | ||
case 300: | ||
return isVertex ? convertVertexShaderTo300(source) : convertFragmentShaderTo300(source); | ||
case 100: | ||
return isVertex ? convertVertexShaderTo100(source) : convertFragmentShaderTo100(source); | ||
default: | ||
throw new Error(`unknown GLSL version ${targetGLSLVersion}`); | ||
} | ||
@@ -23,4 +23,4 @@ } | ||
// Deal with fragColor | ||
// .replace(/gl_fragColor/g, 'fragColor '); | ||
// Deal with fragColor | ||
// .replace(/gl_fragColor/g, 'fragColor '); | ||
} | ||
@@ -34,4 +34,4 @@ | ||
// Deal with fragColor | ||
// .replace(/gl_fragColor/g, 'fragColor '); | ||
// Deal with fragColor | ||
// .replace(/gl_fragColor/g, 'fragColor '); | ||
} | ||
@@ -49,8 +49,6 @@ | ||
// /gm - treats each line as a string, so that ^ matches after newlines | ||
return source | ||
.replace(/^in\s+/gm, 'varying ') | ||
.replace(/texture\(/g, 'texture2D('); | ||
return source.replace(/^in\s+/gm, 'varying ').replace(/texture\(/g, 'texture2D('); | ||
// Deal with fragColor | ||
// .replace(/^out\s+/g, 'varying ') | ||
// Deal with fragColor | ||
// .replace(/^out\s+/g, 'varying ') | ||
} |
@@ -43,3 +43,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
test('fp64#sqrt_fp64', t => { | ||
testcase(gl, {glslFunc: 'sqrt_fp64', op: (a) => Math.sqrt(a), limit: 128, t}); | ||
testcase(gl, {glslFunc: 'sqrt_fp64', op: a => Math.sqrt(a), limit: 128, t}); | ||
}); |
@@ -27,3 +27,8 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
import {Buffer, Program, assembleShaders, registerShaderModules, fp64} from 'luma.gl'; | ||
import {initializeGL, initializeTexTarget, render, getGPUOutput} from '../../../test/gpu-test-utils'; | ||
import { | ||
initializeGL, | ||
initializeTexTarget, | ||
render, | ||
getGPUOutput | ||
} from '../../../test/gpu-test-utils'; | ||
@@ -102,7 +107,10 @@ const BUFFER_DATA = new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]); | ||
const program = new Program(gl, assembleShaders(gl, { | ||
vs, | ||
fs: FS_RENDER_VCOLOR, | ||
modules: ['fp64'] | ||
})); | ||
const program = new Program( | ||
gl, | ||
assembleShaders(gl, { | ||
vs, | ||
fs: FS_RENDER_VCOLOR, | ||
modules: ['fp64'] | ||
}) | ||
); | ||
@@ -128,3 +136,6 @@ program | ||
const {a, b, a_fp64, b_fp64, expected_fp64} = setupFloatTest(gl, { | ||
glslFunc, binary, op, limit | ||
glslFunc, | ||
binary, | ||
op, | ||
limit | ||
}); | ||
@@ -131,0 +142,0 @@ render(gl); |
@@ -25,3 +25,11 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
import {document, window} from 'global'; | ||
import {Buffer, createGLContext, Program, setParameters, assembleShaders, registerShaderModules, fp64} from 'luma.gl'; | ||
import { | ||
Buffer, | ||
createGLContext, | ||
Program, | ||
setParameters, | ||
assembleShaders, | ||
registerShaderModules, | ||
fp64 | ||
} from 'luma.gl'; | ||
@@ -35,3 +43,3 @@ const BUFFER_DATA = new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]); | ||
if (value === gl.NO_ERROR) { | ||
return "NO_ERROR"; | ||
return 'NO_ERROR'; | ||
} | ||
@@ -43,8 +51,8 @@ for (var p in gl) { | ||
} | ||
return "0x" + value.toString(16); | ||
}; | ||
return '0x' + value.toString(16); | ||
} | ||
function addSpan(contents, div) { | ||
if (div == undefined) { | ||
var divs = document.body.getElementsByClassName("testInfo"); | ||
var divs = document.body.getElementsByClassName('testInfo'); | ||
var lastDiv = divs[divs.length - 1]; | ||
@@ -54,3 +62,3 @@ div = lastDiv; | ||
var span = document.createElement("span"); | ||
var span = document.createElement('span'); | ||
div.appendChild(span); | ||
@@ -61,5 +69,5 @@ span.innerHTML = contents + '<br />'; | ||
function addDiv(contents) { | ||
var testInfoDiv = document.createElement("div"); | ||
var testInfoDiv = document.createElement('div'); | ||
document.body.appendChild(testInfoDiv); | ||
testInfoDiv.setAttribute("class", "testInfo"); | ||
testInfoDiv.setAttribute('class', 'testInfo'); | ||
@@ -70,12 +78,13 @@ return testInfoDiv; | ||
function logToConsole(msg) { | ||
if (window.console) | ||
window.console.log(msg); | ||
if (window.console) window.console.log(msg); | ||
} | ||
function escapeHTML(text) { | ||
return text.replace(/&/g, "&").replace(/</g, "<"); | ||
return text.replace(/&/g, '&').replace(/</g, '<'); | ||
} | ||
function testPassed(msg) { | ||
addSpan('<span><span class="pass" style="color:green">PASS</span> ' + escapeHTML(msg) + '</span>'); | ||
addSpan( | ||
'<span><span class="pass" style="color:green">PASS</span> ' + escapeHTML(msg) + '</span>' | ||
); | ||
logToConsole('PASS ' + msg); | ||
@@ -93,3 +102,3 @@ } | ||
} | ||
opt_msg = opt_msg || ""; | ||
opt_msg = opt_msg || ''; | ||
var err = gl.getError(); | ||
@@ -101,6 +110,6 @@ var ndx = glErrors.indexOf(err); | ||
} | ||
var expected = errStrs.join(" or "); | ||
var expected = errStrs.join(' or '); | ||
if (ndx < 0) { | ||
var msg = "getError expected" + ((glErrors.length > 1) ? " one of: " : ": "); | ||
testFailed(msg + expected + ". Was " + glEnumToString(gl, err) + " : " + opt_msg); | ||
var msg = 'getError expected' + (glErrors.length > 1 ? ' one of: ' : ': '); | ||
testFailed(msg + expected + '. Was ' + glEnumToString(gl, err) + ' : ' + opt_msg); | ||
} else { | ||
@@ -110,3 +119,3 @@ //var msg = "getError was " + ((glErrors.length > 1) ? "one of: " : "expected value: "); | ||
} | ||
}; | ||
} | ||
@@ -126,3 +135,3 @@ // Special utility functions for df64 tests | ||
function getVec4Float64() { | ||
return [getFloat64(), getFloat64(), getFloat64(), getFloat64()] | ||
return [getFloat64(), getFloat64(), getFloat64(), getFloat64()]; | ||
} | ||
@@ -132,4 +141,3 @@ | ||
var result = []; | ||
for (var i = 0; i < 16; i++) | ||
{ | ||
for (var i = 0; i < 16; i++) { | ||
result.push(getFloat64()); | ||
@@ -140,4 +148,3 @@ } | ||
function initializeGL(canvas) | ||
{ | ||
function initializeGL(canvas) { | ||
const gl = createGLContext(canvas); | ||
@@ -159,4 +166,3 @@ setParameters(gl, { | ||
function initializeTexTarget(gl) | ||
{ | ||
function initializeTexTarget(gl) { | ||
var framebuffer = gl.createFramebuffer(); | ||
@@ -172,22 +178,33 @@ gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); | ||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, framebuffer.width, framebuffer.height, 0, gl.RGBA, gl.FLOAT, null); | ||
gl.texImage2D( | ||
gl.TEXTURE_2D, | ||
0, | ||
gl.RGBA32F, | ||
framebuffer.width, | ||
framebuffer.height, | ||
0, | ||
gl.RGBA, | ||
gl.FLOAT, | ||
null | ||
); | ||
var renderbuffer = gl.createRenderbuffer(); | ||
gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer); | ||
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, framebuffer.width, framebuffer.height); | ||
gl.renderbufferStorage( | ||
gl.RENDERBUFFER, | ||
gl.DEPTH_COMPONENT16, | ||
framebuffer.width, | ||
framebuffer.height | ||
); | ||
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0); | ||
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, renderbuffer); | ||
} | ||
function render(gl) | ||
{ | ||
function render(gl) { | ||
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); | ||
glErrorShouldBe(gl, gl.NO_ERROR, "no error from draw"); | ||
glErrorShouldBe(gl, gl.NO_ERROR, 'no error from draw'); | ||
} | ||
function getGPUOutput(gl) | ||
{ | ||
function getGPUOutput(gl) { | ||
var width = gl.canvas.width; | ||
@@ -202,7 +219,6 @@ var height = gl.canvas.height; | ||
function checkError(result, reference) | ||
{ | ||
function checkError(result, reference) { | ||
var currentDiv = addDiv(); | ||
var line; | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
@@ -212,11 +228,28 @@ let referece64 = reference[0] + reference[1]; | ||
line = 'CPU output: (' + reference[0].toString() + ',' + reference[1].toString() + ') = ' + referece64.toString() + '<br>'; | ||
line = | ||
'CPU output: (' + | ||
reference[0].toString() + | ||
',' + | ||
reference[1].toString() + | ||
') = ' + | ||
referece64.toString() + | ||
'<br>'; | ||
addSpan(line, currentDiv); | ||
line = "GPU output: (" + result[0].toString() + ',' + result[1].toString() + ',' + result[2].toString() + ',' + result[3].toString() + ') = ' + result64.toString() + '<br>'; | ||
line = | ||
'GPU output: (' + | ||
result[0].toString() + | ||
',' + | ||
result[1].toString() + | ||
',' + | ||
result[2].toString() + | ||
',' + | ||
result[3].toString() + | ||
') = ' + | ||
result64.toString() + | ||
'<br>'; | ||
addSpan(line, currentDiv); | ||
line = "error: " + Math.abs((referece64 - result64) / referece64) + '<br>'; | ||
line = 'error: ' + Math.abs((referece64 - result64) / referece64) + '<br>'; | ||
addSpan(line, currentDiv); | ||
// var referenceBits = new Int32Array(reference.buffer); | ||
@@ -255,3 +288,3 @@ // var resultBits = new Int32Array(result.buffer); | ||
// float + | ||
// float + | ||
const float0 = getFloat64(); | ||
@@ -265,18 +298,22 @@ const float1 = getFloat64(); | ||
const program = new Program(gl, assembleShaders(gl, { | ||
vs: require('./vs_float_add.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
} | ||
)); | ||
program.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}).setUniforms({ | ||
a: float0_vec2, | ||
b: float1_vec2, | ||
ONE: 1.0 | ||
}); | ||
const program = new Program( | ||
gl, | ||
assembleShaders(gl, { | ||
vs: require('./vs_float_add.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
}) | ||
); | ||
program | ||
.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}) | ||
.setUniforms({ | ||
a: float0_vec2, | ||
b: float1_vec2, | ||
ONE: 1.0 | ||
}); | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') + (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') + (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -290,3 +327,3 @@ return float_ref_vec2; | ||
// float - | ||
// float - | ||
const float0 = getFloat64(); | ||
@@ -300,18 +337,23 @@ const float1 = getFloat64(); | ||
const program = new Program(gl, assembleShaders(gl, { | ||
const program = new Program( | ||
gl, | ||
assembleShaders(gl, { | ||
vs: require('./vs_float_sub.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
})); | ||
}) | ||
); | ||
program.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}).setUniforms({ | ||
a: float0_vec2, | ||
b: float1_vec2, | ||
ONE: 1.0 | ||
}); | ||
program | ||
.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}) | ||
.setUniforms({ | ||
a: float0_vec2, | ||
b: float1_vec2, | ||
ONE: 1.0 | ||
}); | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') - (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') - (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -325,3 +367,3 @@ return float_ref_vec2; | ||
// float x | ||
// float x | ||
const float0 = getFloat64(128); | ||
@@ -336,18 +378,23 @@ const float1 = getFloat64(128); | ||
const program = new Program(gl, assembleShaders(gl, { | ||
vs: require('./vs_float_mul.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
})); | ||
const program = new Program( | ||
gl, | ||
assembleShaders(gl, { | ||
vs: require('./vs_float_mul.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
}) | ||
); | ||
program.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}).setUniforms({ | ||
a: float0_vec2, | ||
b: float1_vec2, | ||
ONE: 1.0 | ||
}); | ||
program | ||
.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}) | ||
.setUniforms({ | ||
a: float0_vec2, | ||
b: float1_vec2, | ||
ONE: 1.0 | ||
}); | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') * (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') * (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -361,3 +408,3 @@ return float_ref_vec2; | ||
// float / | ||
// float / | ||
const float0 = getFloat64(128); | ||
@@ -371,18 +418,23 @@ const float1 = getFloat64(128); | ||
const program = new Program(gl, assembleShaders(gl, { | ||
vs: require('./vs_float_div.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
})); | ||
const program = new Program( | ||
gl, | ||
assembleShaders(gl, { | ||
vs: require('./vs_float_div.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
}) | ||
); | ||
program.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}).setUniforms({ | ||
a: float0_vec2, | ||
b: float1_vec2, | ||
ONE: 1.0 | ||
}); | ||
program | ||
.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}) | ||
.setUniforms({ | ||
a: float0_vec2, | ||
b: float1_vec2, | ||
ONE: 1.0 | ||
}); | ||
var line; | ||
line = "(" + float0_vec2.toString() + ') / (' + float1_vec2.toString() + ')<br>'; | ||
line = '(' + float0_vec2.toString() + ') / (' + float1_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -396,3 +448,3 @@ return float_ref_vec2; | ||
// sqrt | ||
// sqrt | ||
const float0 = getFloat64(128); | ||
@@ -404,17 +456,22 @@ const float_ref = Math.sqrt(float0); | ||
const program = new Program(gl, assembleShaders(gl, { | ||
vs: require('./vs_float_sqrt.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
})); | ||
const program = new Program( | ||
gl, | ||
assembleShaders(gl, { | ||
vs: require('./vs_float_sqrt.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
}) | ||
); | ||
program.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}).setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
program | ||
.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}) | ||
.setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
var line; | ||
line = "sqrt(" + float0_vec2.toString() + ')<br>'; | ||
line = 'sqrt(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -428,3 +485,3 @@ return float_ref_vec2; | ||
// exp | ||
// exp | ||
const float0 = getFloat64(6); | ||
@@ -436,17 +493,22 @@ const float_ref = Math.exp(float0); | ||
const program = new Program(gl, assembleShaders(gl, { | ||
vs: require('./vs_float_exp.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
})); | ||
const program = new Program( | ||
gl, | ||
assembleShaders(gl, { | ||
vs: require('./vs_float_exp.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
}) | ||
); | ||
program.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}).setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
program | ||
.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}) | ||
.setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
var line; | ||
line = "exp(" + float0_vec2.toString() + ')<br>'; | ||
line = 'exp(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -460,3 +522,3 @@ return float_ref_vec2; | ||
// log | ||
// log | ||
const float0 = getFloat64(24); | ||
@@ -468,17 +530,22 @@ const float_ref = Math.log(float0); | ||
const program = new Program(gl, assembleShaders(gl, { | ||
vs: require('./vs_float_log.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
})); | ||
const program = new Program( | ||
gl, | ||
assembleShaders(gl, { | ||
vs: require('./vs_float_log.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
}) | ||
); | ||
program.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}).setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
program | ||
.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}) | ||
.setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
var line; | ||
line = "log(" + float0_vec2.toString() + ')<br>'; | ||
line = 'log(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -488,3 +555,2 @@ return float_ref_vec2; | ||
function test_float_sin(gl, testName) { | ||
@@ -494,3 +560,3 @@ var currentDiv = addDiv(); | ||
// sin | ||
// sin | ||
const float0 = getFloat64(8); | ||
@@ -502,17 +568,22 @@ const float_ref = Math.sin(float0); | ||
const program = new Program(gl, assembleShaders(gl, { | ||
vs: require('./vs_float_sin.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
})); | ||
const program = new Program( | ||
gl, | ||
assembleShaders(gl, { | ||
vs: require('./vs_float_sin.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
}) | ||
); | ||
program.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}).setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
program | ||
.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}) | ||
.setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
var line; | ||
line = "sin(" + float0_vec2.toString() + ')<br>'; | ||
line = 'sin(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -526,3 +597,3 @@ return float_ref_vec2; | ||
// cos | ||
// cos | ||
const float0 = getFloat64(8); | ||
@@ -534,17 +605,22 @@ const float_ref = Math.cos(float0); | ||
const program = new Program(gl, assembleShaders(gl, { | ||
vs: require('./vs_float_cos.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
})); | ||
const program = new Program( | ||
gl, | ||
assembleShaders(gl, { | ||
vs: require('./vs_float_cos.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
}) | ||
); | ||
program.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}).setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
program | ||
.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}) | ||
.setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
var line; | ||
line = "cos(" + float0_vec2.toString() + ')<br>'; | ||
line = 'cos(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -558,3 +634,3 @@ return float_ref_vec2; | ||
// tan | ||
// tan | ||
const float0 = getFloat64(8); | ||
@@ -566,17 +642,22 @@ const float_ref = Math.tan(float0); | ||
const program = new Program(gl, assembleShaders(gl, { | ||
vs: require('./vs_float_tan.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
})); | ||
const program = new Program( | ||
gl, | ||
assembleShaders(gl, { | ||
vs: require('./vs_float_tan.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
}) | ||
); | ||
program.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}).setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
program | ||
.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}) | ||
.setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
var line; | ||
line = "tan(" + float0_vec2.toString() + ')<br>'; | ||
line = 'tan(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -590,5 +671,5 @@ return float_ref_vec2; | ||
// radians | ||
// radians | ||
const float0 = getFloat64(16); | ||
const float_ref = float0 * Math.PI / 180.0; | ||
const float_ref = (float0 * Math.PI) / 180.0; | ||
@@ -598,17 +679,22 @@ const float0_vec2 = fp64ify(float0); | ||
const program = new Program(gl, assembleShaders(gl, { | ||
vs: require('./vs_float_radians.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
})); | ||
const program = new Program( | ||
gl, | ||
assembleShaders(gl, { | ||
vs: require('./vs_float_radians.glsl'), | ||
fs: require('./fs.glsl'), | ||
modules: ['fp64'] | ||
}) | ||
); | ||
program.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}).setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
program | ||
.setBuffers({ | ||
positions: new Buffer(gl, {target: gl.ARRAY_BUFFER, data: BUFFER_DATA, size: 2}) | ||
}) | ||
.setUniforms({ | ||
a: float0_vec2, | ||
ONE: 1.0 | ||
}); | ||
var line; | ||
line = "tan(" + float0_vec2.toString() + ')<br>'; | ||
line = 'tan(' + float0_vec2.toString() + ')<br>'; | ||
addSpan(line, currentDiv); | ||
@@ -631,3 +717,2 @@ return float_ref_vec2; | ||
registerShaderModules([fp64]); | ||
@@ -641,6 +726,6 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_add(gl, "Float addition test"); | ||
var cpu_result = test_float_add(gl, 'Float addition test'); | ||
@@ -653,3 +738,3 @@ render(gl); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -659,6 +744,6 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_sub(gl, "Float subtraction test"); | ||
var cpu_result = test_float_sub(gl, 'Float subtraction test'); | ||
@@ -671,3 +756,3 @@ render(gl); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -677,6 +762,6 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_mul(gl, "Float multiplication test"); | ||
var cpu_result = test_float_mul(gl, 'Float multiplication test'); | ||
@@ -689,3 +774,3 @@ render(gl); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -695,6 +780,6 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_div(gl, "Float division test"); | ||
var cpu_result = test_float_div(gl, 'Float division test'); | ||
@@ -707,3 +792,3 @@ render(gl); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -713,6 +798,6 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_sqrt(gl, "Float sqrt test"); | ||
var cpu_result = test_float_sqrt(gl, 'Float sqrt test'); | ||
@@ -725,3 +810,3 @@ render(gl); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -731,6 +816,6 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_exp(gl, "Float exp test"); | ||
var cpu_result = test_float_exp(gl, 'Float exp test'); | ||
@@ -743,3 +828,3 @@ render(gl); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -749,6 +834,6 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_log(gl, "Float log test"); | ||
var cpu_result = test_float_log(gl, 'Float log test'); | ||
@@ -761,3 +846,3 @@ render(gl); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -767,6 +852,6 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_sin(gl, "Float sin test"); | ||
var cpu_result = test_float_sin(gl, 'Float sin test'); | ||
@@ -779,11 +864,11 @@ render(gl); | ||
addSpan("------------------------", currentDiv); | ||
} | ||
addSpan('------------------------', currentDiv); | ||
} | ||
for (idx0 = 0; idx0 < loop; idx0++) { | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_cos(gl, "Float cos test"); | ||
var cpu_result = test_float_cos(gl, 'Float cos test'); | ||
@@ -796,5 +881,3 @@ render(gl); | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -804,8 +887,7 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_tan(gl, 'Float tan test'); | ||
var cpu_result = test_float_tan(gl, "Float tan test"); | ||
render(gl); | ||
@@ -817,3 +899,3 @@ | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
@@ -823,8 +905,7 @@ | ||
var currentDiv = addDiv(); | ||
addSpan("------------------------", currentDiv); | ||
addSpan("Loop No. " + test_no++, currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
addSpan('Loop No. ' + test_no++, currentDiv); | ||
var cpu_result = test_float_radians(gl, 'Float radians test'); | ||
var cpu_result = test_float_radians(gl, "Float radians test"); | ||
render(gl); | ||
@@ -836,4 +917,4 @@ | ||
addSpan("------------------------", currentDiv); | ||
addSpan('------------------------', currentDiv); | ||
} | ||
} | ||
}; |
// Cheap lighting - single directional light, single dot product, one uniform | ||
/* eslint-disable camelcase */ | ||
const DEFAULT_MODULE_OPTIONS = { | ||
}; | ||
const DEFAULT_MODULE_OPTIONS = {}; | ||
@@ -7,0 +6,0 @@ function getUniforms(opts = DEFAULT_MODULE_OPTIONS) { |
@@ -51,5 +51,3 @@ import {Vector3} from 'math.gl'; | ||
// Normalize lighting direction vector | ||
const dir = new Vector3(direction.x, direction.y, direction.z) | ||
.normalize() | ||
.scale(-1, -1, -1); | ||
const dir = new Vector3(direction.x, direction.y, direction.z).normalize().scale(-1, -1, -1); | ||
@@ -56,0 +54,0 @@ return { |
@@ -54,8 +54,3 @@ import lightingShader from './phong-lighting.glsl'; | ||
function getUniforms(opts = INITIAL_MODULE_OPTIONS) { | ||
const { | ||
ambientLight, | ||
pointLights, | ||
directionalLights, | ||
material | ||
} = opts; | ||
const {ambientLight, pointLights, directionalLights, material} = opts; | ||
@@ -62,0 +57,0 @@ if (!(ambientLight || pointLights || directionalLights) || !material) { |
@@ -33,4 +33,5 @@ import {Matrix4} from 'math.gl'; | ||
if (opts.projectionMatrix !== undefined || opts.viewMatrix !== undefined) { | ||
uniforms.viewProjectionMatrix = new Matrix4(opts.projectionMatrix) | ||
.multiplyRight(opts.viewMatrix); | ||
uniforms.viewProjectionMatrix = new Matrix4(opts.projectionMatrix).multiplyRight( | ||
opts.viewMatrix | ||
); | ||
} | ||
@@ -37,0 +38,0 @@ |
@@ -1,2 +0,1 @@ | ||
// Private shader module used by `Transform` | ||
@@ -3,0 +2,0 @@ |
@@ -11,7 +11,3 @@ import assert from 'assert'; | ||
const [qualifier, type, definition] = words; | ||
if ( | ||
!qualifiers.includes(qualifier) || | ||
!type || | ||
!definition | ||
) { | ||
if (!qualifiers.includes(qualifier) || !type || !definition) { | ||
return null; | ||
@@ -50,9 +46,13 @@ } | ||
switch (type) { | ||
case 'float': return 'x'; | ||
case 'vec2': return 'xy'; | ||
case 'vec3': return 'xyz'; | ||
case 'vec4': return 'xyzw'; | ||
default : | ||
assert(false); | ||
return null; | ||
case 'float': | ||
return 'x'; | ||
case 'vec2': | ||
return 'xy'; | ||
case 'vec3': | ||
return 'xyz'; | ||
case 'vec4': | ||
return 'xyzw'; | ||
default: | ||
assert(false); | ||
return null; | ||
} | ||
@@ -64,9 +64,13 @@ } | ||
switch (type) { | ||
case 'float': return 1; | ||
case 'vec2': return 2; | ||
case 'vec3': return 3; | ||
case 'vec4': return 4; | ||
default : | ||
assert(false); | ||
return null; | ||
case 'float': | ||
return 1; | ||
case 'vec2': | ||
return 2; | ||
case 'vec3': | ||
return 3; | ||
case 'vec4': | ||
return 4; | ||
default: | ||
assert(false); | ||
return null; | ||
} | ||
@@ -78,10 +82,14 @@ } | ||
switch (type) { | ||
case 'float': return `vec4(${variable}, 0.0, 0.0, 1.0)`; | ||
case 'vec2': return `vec4(${variable}, 0.0, 1.0)`; | ||
case 'vec3': return `vec4(${variable}, 1.0)`; | ||
case 'vec4': return variable; | ||
default : | ||
assert(false); | ||
return null; | ||
case 'float': | ||
return `vec4(${variable}, 0.0, 0.0, 1.0)`; | ||
case 'vec2': | ||
return `vec4(${variable}, 0.0, 1.0)`; | ||
case 'vec3': | ||
return `vec4(${variable}, 1.0)`; | ||
case 'vec4': | ||
return variable; | ||
default: | ||
assert(false); | ||
return null; | ||
} | ||
} |
@@ -11,8 +11,8 @@ // Feature detection for WebGL | ||
const GL_TEXTURE_BINDING_3D = 0x806A; | ||
const GL_TEXTURE_BINDING_3D = 0x806a; | ||
const GL_VENDOR = 0x1F00; | ||
const GL_RENDERER = 0x1F01; | ||
const GL_VERSION = 0x1F02; | ||
const GL_SHADING_LANGUAGE_VERSION = 0x8B8C; | ||
const GL_VENDOR = 0x1f00; | ||
const GL_RENDERER = 0x1f01; | ||
const GL_VERSION = 0x1f02; | ||
const GL_SHADING_LANGUAGE_VERSION = 0x8b8c; | ||
@@ -37,6 +37,7 @@ // Defines luma.gl "feature" names and semantics | ||
function isWebGL2(gl) { | ||
return Boolean(gl && ( | ||
(typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext || | ||
gl.TEXTURE_BINDING_3D === GL_TEXTURE_BINDING_3D) | ||
)); | ||
return Boolean( | ||
gl && | ||
((typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) || | ||
gl.TEXTURE_BINDING_3D === GL_TEXTURE_BINDING_3D) | ||
); | ||
} | ||
@@ -66,4 +67,8 @@ | ||
} | ||
if (vendor.match(/AMD/i) || renderer.match(/AMD/i) || | ||
vendor.match(/ATI/i) || renderer.match(/ATI/i)) { | ||
if ( | ||
vendor.match(/AMD/i) || | ||
renderer.match(/AMD/i) || | ||
vendor.match(/ATI/i) || | ||
renderer.match(/ATI/i) | ||
) { | ||
return 'AMD'; | ||
@@ -120,10 +125,7 @@ } | ||
// Get extension name from table | ||
const extensionName = isWebGL2(gl) ? | ||
feature[1] || feature[0] : | ||
feature[0]; | ||
const extensionName = isWebGL2(gl) ? feature[1] || feature[0] : feature[0]; | ||
// Check if the value is dependent on checking an extension | ||
const value = typeof extensionName === 'string' ? | ||
Boolean(gl.getExtension(extensionName)) : | ||
extensionName; | ||
const value = | ||
typeof extensionName === 'string' ? Boolean(gl.getExtension(extensionName)) : extensionName; | ||
@@ -130,0 +132,0 @@ assert(value === false || value === true); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1345239
14620
1