Commit 0c5409f8 by Arun Patole Committed by Jamie Madill

Support constant folding of fragment processing built-ins

This change adds constant folding support for following derivative functions: - dFdx, dFdy and fwidth. As per spec, derivatives of constant arguments should be 0, so this change just sets result components to zero when the above operations are performed on constant argument. BUG=angleproject:913 TEST=dEQP Tests dEQP-GLES3.functional.shaders.constant_expressions.builtin_functions. fragment_processing.* (All 12 tests started passing with this change.) Change-Id: I67b7c5abd970b740e15e3bd1ee56721e81bbecc4 Reviewed-on: https://chromium-review.googlesource.com/283759Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 551279e5
...@@ -1827,6 +1827,18 @@ TConstantUnion *TIntermConstantUnion::foldUnaryWithSameReturnType(TOperator op, ...@@ -1827,6 +1827,18 @@ TConstantUnion *TIntermConstantUnion::foldUnaryWithSameReturnType(TOperator op,
infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant"); infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant");
return nullptr; return nullptr;
case EOpDFdx:
case EOpDFdy:
case EOpFwidth:
if (getType().getBasicType() == EbtFloat)
{
// Derivatives of constant arguments should be 0.
resultArray[i].setFConst(0.0f);
break;
}
infoSink.info.message(EPrefixInternalError, getLine(), "Unary operation not folded into constant");
return nullptr;
default: default:
return nullptr; return nullptr;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment