Skip to content

Commit

Permalink
On shader compile error, add infolog div. (KhronosGroup#3215)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdashg authored Feb 3, 2021
1 parent accfd6e commit 08c57bd
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions sdk/tests/js/glsl-conformance-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,34 @@ function runOneTest(gl, info) {
var vSource = info.vShaderPrep ? info.vShaderPrep(info.vShaderSource) :
info.vShaderSource;

if (!quietMode())
if (!quietMode()) {
wtu.addShaderSource(consoleDiv, vLabel, vSource);
}

// Reuse identical shaders so we test shared shader.
var vShader = vShaderDB[vSource];
if (!vShader) {
vShader = wtu.loadShader(gl, vSource, gl.VERTEX_SHADER);
// loadShader, with opt_skipCompileStatus: true.
vShader = wtu.loadShader(gl, vSource, gl.VERTEX_SHADER, null, null, null, null, true);
let compiledVShader = vShader;
if (vShader && !gl.getShaderParameter(vShader, gl.COMPILE_STATUS)) {
compiledVShader = null;
}
if (info.vShaderTest) {
if (!info.vShaderTest(vShader)) {
if (!info.vShaderTest(compiledVShader)) {
testFailed("[vertex shader test] " + passMsg);
return;
}
}
// As per GLSL 1.0.17 10.27 we can only check for success on
// compileShader, not failure.
if (!info.ignoreResults && info.vShaderSuccess && !vShader) {
if (!info.ignoreResults && info.vShaderSuccess && !compiledVShader) {
testFailed("[unexpected vertex shader compile status] (expected: " +
info.vShaderSuccess + ") " + passMsg);
if (!quietMode() && vShader) {
const info = gl.getShaderInfoLog(vShader);
wtu.addShaderSource(consoleDiv, vLabel + " info log", info);
}
}
// Save the shaders so we test shared shader.
if (vShader) {
Expand All @@ -166,25 +176,35 @@ function runOneTest(gl, info) {
var fSource = info.fShaderPrep ? info.fShaderPrep(info.fShaderSource) :
info.fShaderSource;

if (!quietMode())
if (!quietMode()) {
wtu.addShaderSource(consoleDiv, fLabel, fSource);
}

// Reuse identical shaders so we test shared shader.
var fShader = fShaderDB[fSource];
if (!fShader) {
fShader = wtu.loadShader(gl, fSource, gl.FRAGMENT_SHADER);
// loadShader, with opt_skipCompileStatus: true.
fShader = wtu.loadShader(gl, fSource, gl.FRAGMENT_SHADER, null, null, null, null, true);
let compiledFShader = fShader;
if (fShader && !gl.getShaderParameter(fShader, gl.COMPILE_STATUS)) {
compiledFShader = null;
}
if (info.fShaderTest) {
if (!info.fShaderTest(fShader)) {
if (!info.fShaderTest(compiledFShader)) {
testFailed("[fragment shader test] " + passMsg);
return;
}
}
//debug(fShader == null ? "fail" : "succeed");
// As per GLSL 1.0.17 10.27 we can only check for success on
// compileShader, not failure.
if (!info.ignoreResults && info.fShaderSuccess && !fShader) {
if (!info.ignoreResults && info.fShaderSuccess && !compiledFShader) {
testFailed("[unexpected fragment shader compile status] (expected: " +
info.fShaderSuccess + ") " + passMsg);
if (!quietMode() && fShader) {
const info = gl.getShaderInfoLog(fShader);
wtu.addShaderSource(consoleDiv, fLabel + " info log", info);
}
return;
}

Expand Down

0 comments on commit 08c57bd

Please sign in to comment.