Bug 1910306 - [angle] Cherry-pick zero-initialization of unwritten GLSL out params. a=dmeehan

Original Revision: https://phabricator.services.mozilla.com/D218019

Differential Revision: https://phabricator.services.mozilla.com/D218213
This commit is contained in:
Kelsey Gilbert 2024-08-01 12:59:54 +00:00
parent ca237fb9aa
commit 0bd00b014d
3 changed files with 51 additions and 3 deletions

View file

@ -1,5 +1,5 @@
#define ANGLE_COMMIT_HASH "791816843657"
#define ANGLE_COMMIT_HASH "419cd2c3213b"
#define ANGLE_COMMIT_HASH_SIZE 12
#define ANGLE_COMMIT_DATE "2024-06-06 10:35:11 -0700"
#define ANGLE_COMMIT_POSITION 19738
#define ANGLE_COMMIT_DATE "2024-07-29 14:40:59 -0700"
#define ANGLE_COMMIT_POSITION 19739
#define ANGLE_HAS_BINARY_LOADING

View file

@ -309,6 +309,37 @@ class InitializeLocalsTraverser : public TIntermTraverser
return false;
}
bool visitFunctionDefinition(Visit visit, TIntermFunctionDefinition *node) override
{
// Initialize output function arguments as well, the parameter passed in at call time may be
// clobbered if the function doesn't fully write to the argument.
TIntermSequence initCode;
const TFunction *function = node->getFunction();
for (size_t paramIndex = 0; paramIndex < function->getParamCount(); ++paramIndex)
{
const TVariable *paramVariable = function->getParam(paramIndex);
const TType &paramType = paramVariable->getType();
if (paramType.getQualifier() != EvqParamOut)
{
continue;
}
CreateInitCode(new TIntermSymbol(paramVariable), mCanUseLoopsToInitialize,
mHighPrecisionSupported, &initCode, mSymbolTable);
}
if (!initCode.empty())
{
TIntermSequence *body = node->getBody()->getSequence();
body->insert(body->begin(), initCode.begin(), initCode.end());
}
return true;
}
private:
int mShaderVersion;
bool mCanUseLoopsToInitialize;

View file

@ -1,3 +1,20 @@
commit 419cd2c3213b594f8e2488bf48034fed20ace81d
Author: Shahbaz Youssefi <syoussefi@chromium.org>
Date: Mon Mar 27 13:05:36 2023 -0400
Translator: Initialize out arguments too for WebGL
Local variables were initialized for WebGL, but not `out` arguments.
However, `out` arguments completely overwrite the passed-in variable at
call site, so they should also be zeroed out.
Bug: chromium:1425685
Change-Id: Ib2f61a962eea74c4933aafa4d5ad377189cec578
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4375137
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
commit 7918168436578718b234bfd56da152e34a85af1d
Author: Kelsey Gilbert <kelsey.gilbert@mozilla.com>
Date: Tue Jun 4 15:37:29 2024 -0700