Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JS string templates in src/library_glemu.js. NFC #21261

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 12 additions & 41 deletions src/library_glemu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1075,14 +1075,14 @@ var LibraryGLEmulation = {
func = "textureCube";
break;
default:
return abort_sanity("Unknown texType: " + ptrToString(texType));
return abort_sanity(`Unknown texType: ${ptrToString(texType)}`);
}

var texCoordExpr = TEX_COORD_VARYING_PREFIX + texUnitID;
if (TEX_MATRIX_UNIFORM_PREFIX != null) {
texCoordExpr = "(" + TEX_MATRIX_UNIFORM_PREFIX + texUnitID + " * " + texCoordExpr + ")";
texCoordExpr = `(${TEX_MATRIX_UNIFORM_PREFIX}${texUnitID} * ${texCoordExpr})`;
}
return func + "(" + TEX_UNIT_UNIFORM_PREFIX + texUnitID + ", " + texCoordExpr + ".xy)";
return `${func}(${TEX_UNIT_UNIFORM_PREFIX}${texUnitID}, ${texCoordExpr}.xy)`;
}

function getTypeFromCombineOp(op) {
Expand Down Expand Up @@ -1499,58 +1499,29 @@ var LibraryGLEmulation = {
var lines = null;
switch (combiner) {
case GL_REPLACE: {
var line = [
outputType + " " + outputVar,
" = ",
src0Expr,
";",
];
lines = [line.join("")];
lines = [`${outputType} ${outputVar} = ${src0Expr};`]
break;
}
case GL_MODULATE: {
var line = [
outputType + " " + outputVar + " = ",
src0Expr + " * " + src1Expr,
";",
];
lines = [line.join("")];
lines = [`${outputType} ${outputVar} = ${src0Expr} * ${src1Expr};`];
break;
}
case GL_ADD: {
var line = [
outputType + " " + outputVar + " = ",
src0Expr + " + " + src1Expr,
";",
];
lines = [line.join("")];
lines = [`${outputType} ${outputVar} = ${src0Expr} + ${src1Expr};`]
break;
}
case GL_SUBTRACT: {
var line = [
outputType + " " + outputVar + " = ",
src0Expr + " - " + src1Expr,
";",
];
lines = [line.join("")];
lines = [`${outputType} ${outputVar} = ${src0Expr} - ${src1Expr};`]
break;
}
case GL_INTERPOLATE: {
var prefix = TEXENVJIT_NAMESPACE_PREFIX + 'env' + texUnitID + "_";
var arg2Var = prefix + "colorSrc2";
var arg2Line = getTypeFromCombineOp(this.colorOp[2]) + " " + arg2Var + " = " + src2Expr + ";";
var prefix = `${TEXENVJIT_NAMESPACE_PREFIX}env${texUnitID}_`;
var arg2Var = `${prefix}colorSrc2`;
var arg2Type = getTypeFromCombineOp(this.colorOp[2]);

var line = [
outputType + " " + outputVar,
" = ",
src0Expr + " * " + arg2Var,
" + ",
src1Expr + " * (1.0 - " + arg2Var + ")",
";",
];
lines = [
arg2Line,
line.join(""),
`${arg2Type} ${arg2Var} = ${src2Expr};`,
`${outputType} ${outputVar} = ${src0Expr} * ${arg2Var} + ${src1Expr} * (1.0 - ${arg2Var});`,
];
break;
}
Expand Down
Loading