Commit e86a8560 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Fewer subgroup ops in seamful cubemap emulation

Two values were retrieved from quad neighbors; layer and ma. The value of ma was retrieved as the helper invocations would otherwise have a different value as the major axis. This change makes the helpers rechoose ma based on the layer, which removes a number of subgroup operations. This is also more precise as the major axis value could be slightly different from the neighbor. Bug: angleproject:3732 Change-Id: I3c8ca724e91c52ca2f7edc03bb0e5dca67610ff4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1742215Reviewed-by: 's avatarTobin Ehlis <tobine@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 7270a6d5
...@@ -40,12 +40,8 @@ TIntermSymbol *GetValueFromNeighbor(TSymbolTable *symbolTable, ...@@ -40,12 +40,8 @@ TIntermSymbol *GetValueFromNeighbor(TSymbolTable *symbolTable,
} }
// If this is a helper invocation, retrieve the layer index (cube map face) from another invocation // If this is a helper invocation, retrieve the layer index (cube map face) from another invocation
// in the quad that is not a helper. Get the corresponding ma value from the same invocation as // in the quad that is not a helper. See comment in declareCoordTranslationFunction.
// well. See comment in declareCoordTranslationFunction. void GetLayerFromNonHelperInvocation(TSymbolTable *symbolTable, TIntermBlock *body, TIntermTyped *l)
void GetLayerFromNonHelperInvocation(TSymbolTable *symbolTable,
TIntermBlock *body,
TIntermTyped *l,
TIntermTyped *ma)
{ {
TVariable *gl_HelperInvocationVar = TVariable *gl_HelperInvocationVar =
new TVariable(symbolTable, ImmutableString("gl_HelperInvocation"), new TVariable(symbolTable, ImmutableString("gl_HelperInvocation"),
...@@ -85,14 +81,6 @@ void GetLayerFromNonHelperInvocation(TSymbolTable *symbolTable, ...@@ -85,14 +81,6 @@ void GetLayerFromNonHelperInvocation(TSymbolTable *symbolTable,
TIntermSymbol *lD = TIntermSymbol *lD =
GetValueFromNeighbor(symbolTable, body, quadSwapDiagonalFloat, l->deepCopy(), floatType); GetValueFromNeighbor(symbolTable, body, quadSwapDiagonalFloat, l->deepCopy(), floatType);
// Get the value of ma from the neighbors. Similarly, these should be done outside `if`s.
TIntermSymbol *maH =
GetValueFromNeighbor(symbolTable, body, quadSwapHorizontalFloat, ma, floatType);
TIntermSymbol *maV =
GetValueFromNeighbor(symbolTable, body, quadSwapVerticalFloat, ma->deepCopy(), floatType);
TIntermSymbol *maD =
GetValueFromNeighbor(symbolTable, body, quadSwapDiagonalFloat, ma->deepCopy(), floatType);
// Get the value of gl_HelperInvocation from the neighbors too. // Get the value of gl_HelperInvocation from the neighbors too.
TIntermSymbol *horizontalIsHelper = GetValueFromNeighbor( TIntermSymbol *horizontalIsHelper = GetValueFromNeighbor(
symbolTable, body, quadSwapHorizontalBool, gl_HelperInvocation->deepCopy(), boolType); symbolTable, body, quadSwapHorizontalBool, gl_HelperInvocation->deepCopy(), boolType);
...@@ -108,12 +96,8 @@ void GetLayerFromNonHelperInvocation(TSymbolTable *symbolTable, ...@@ -108,12 +96,8 @@ void GetLayerFromNonHelperInvocation(TSymbolTable *symbolTable,
TIntermTyped *lVD = new TIntermTernary(verticalIsNonHelper, lV, lD); TIntermTyped *lVD = new TIntermTernary(verticalIsNonHelper, lV, lD);
TIntermTyped *lHVD = new TIntermTernary(horizontalIsNonHelper, lH, lVD); TIntermTyped *lHVD = new TIntermTernary(horizontalIsNonHelper, lH, lVD);
TIntermTyped *maVD = new TIntermTernary(verticalIsNonHelper->deepCopy(), maV, maD);
TIntermTyped *maHVD = new TIntermTernary(horizontalIsNonHelper->deepCopy(), maH, maVD);
TIntermBlock *helperBody = new TIntermBlock; TIntermBlock *helperBody = new TIntermBlock;
helperBody->appendStatement(new TIntermBinary(EOpAssign, l->deepCopy(), lHVD)); helperBody->appendStatement(new TIntermBinary(EOpAssign, l->deepCopy(), lHVD));
helperBody->appendStatement(new TIntermBinary(EOpAssign, ma->deepCopy(), maHVD));
TIntermIfElse *ifHelper = new TIntermIfElse(gl_HelperInvocation, helperBody, nullptr); TIntermIfElse *ifHelper = new TIntermIfElse(gl_HelperInvocation, helperBody, nullptr);
body->appendStatement(ifHelper); body->appendStatement(ifHelper);
...@@ -566,13 +550,14 @@ class RewriteCubeMapSamplersAs2DArrayTraverser : public TIntermTraverser ...@@ -566,13 +550,14 @@ class RewriteCubeMapSamplersAs2DArrayTraverser : public TIntermTraverser
// helper invocations generate UVs out of range). // helper invocations generate UVs out of range).
if (mIsFragmentShader) if (mIsFragmentShader)
{ {
GetLayerFromNonHelperInvocation(mSymbolTable, body, l->deepCopy(), ma->deepCopy()); GetLayerFromNonHelperInvocation(mSymbolTable, body, l->deepCopy());
} }
// layer < 1.5 (covering faces 0 and 1, corresponding to major axis being X) and layer < 3.5 // layer < 1.5 (covering faces 0 and 1, corresponding to major axis being X) and layer < 3.5
// (covering faces 2 and 3, corresponding to major axis being Y). Used to determine which // (covering faces 2 and 3, corresponding to major axis being Y). Used to determine which
// of the three transformations to apply. Previously, ma == |X| and ma == |Y| was used, // of the three transformations to apply. Previously, ma == |X| and ma == |Y| was used,
// which is no longer correct for helper invocations. // which is no longer correct for helper invocations. The value of ma is updated in each
// case for these invocations.
isXMajor = new TIntermBinary(EOpLessThan, l->deepCopy(), CreateFloatNode(1.5f)); isXMajor = new TIntermBinary(EOpLessThan, l->deepCopy(), CreateFloatNode(1.5f));
isYMajor = new TIntermBinary(EOpLessThan, l->deepCopy(), CreateFloatNode(3.5f)); isYMajor = new TIntermBinary(EOpLessThan, l->deepCopy(), CreateFloatNode(3.5f));
...@@ -585,16 +570,22 @@ class RewriteCubeMapSamplersAs2DArrayTraverser : public TIntermTraverser ...@@ -585,16 +570,22 @@ class RewriteCubeMapSamplersAs2DArrayTraverser : public TIntermTraverser
TIntermSwizzle *dPdyZ = new TIntermSwizzle(dPdy->deepCopy(), {2}); TIntermSwizzle *dPdyZ = new TIntermSwizzle(dPdy->deepCopy(), {2});
TIntermBlock *calculateXUcVc = new TIntermBlock; TIntermBlock *calculateXUcVc = new TIntermBlock;
calculateXUcVc->appendStatement(
new TIntermBinary(EOpAssign, ma->deepCopy(), absX->deepCopy()));
TransformXMajor(calculateXUcVc, x, y, z, uc, vc); TransformXMajor(calculateXUcVc, x, y, z, uc, vc);
TransformXMajor(calculateXUcVc, dPdxX, dPdxY, dPdxZ, dUdx, dVdx); TransformXMajor(calculateXUcVc, dPdxX, dPdxY, dPdxZ, dUdx, dVdx);
TransformXMajor(calculateXUcVc, dPdyX, dPdyY, dPdyZ, dUdy, dVdy); TransformXMajor(calculateXUcVc, dPdyX, dPdyY, dPdyZ, dUdy, dVdy);
TIntermBlock *calculateYUcVc = new TIntermBlock; TIntermBlock *calculateYUcVc = new TIntermBlock;
calculateYUcVc->appendStatement(
new TIntermBinary(EOpAssign, ma->deepCopy(), absY->deepCopy()));
TransformYMajor(calculateYUcVc, x, y, z, uc, vc); TransformYMajor(calculateYUcVc, x, y, z, uc, vc);
TransformYMajor(calculateYUcVc, dPdxX, dPdxY, dPdxZ, dUdx, dVdx); TransformYMajor(calculateYUcVc, dPdxX, dPdxY, dPdxZ, dUdx, dVdx);
TransformYMajor(calculateYUcVc, dPdyX, dPdyY, dPdyZ, dUdy, dVdy); TransformYMajor(calculateYUcVc, dPdyX, dPdyY, dPdyZ, dUdy, dVdy);
TIntermBlock *calculateZUcVc = new TIntermBlock; TIntermBlock *calculateZUcVc = new TIntermBlock;
calculateZUcVc->appendStatement(
new TIntermBinary(EOpAssign, ma->deepCopy(), absZ->deepCopy()));
TransformZMajor(calculateZUcVc, x, y, z, uc, vc); TransformZMajor(calculateZUcVc, x, y, z, uc, vc);
TransformZMajor(calculateZUcVc, dPdxX, dPdxY, dPdxZ, dUdx, dVdx); TransformZMajor(calculateZUcVc, dPdxX, dPdxY, dPdxZ, dUdx, dVdx);
TransformZMajor(calculateZUcVc, dPdyX, dPdyY, dPdyZ, dUdy, dVdy); TransformZMajor(calculateZUcVc, dPdyX, dPdyY, dPdyZ, dUdy, dVdy);
......
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