@@ -242,8 +242,17 @@ ANGLE_NO_DISCARD bool RotateAndFlipBuiltinVariable(TCompiler *compiler,
242242 }
243243
244244 // Create the expression "(builtin.xy * fragRotation)"
245- TIntermBinary *rotatedXY =
246- new TIntermBinary (EOpMatrixTimesVector, fragRotation->deepCopy (), builtinXY->deepCopy ());
245+ TIntermTyped *rotatedXY;
246+ if (fragRotation)
247+ {
248+ rotatedXY = new TIntermBinary (EOpMatrixTimesVector, fragRotation->deepCopy (),
249+ builtinXY->deepCopy ());
250+ }
251+ else
252+ {
253+ // No rotation applied, use original variable.
254+ rotatedXY = builtinXY->deepCopy ();
255+ }
247256
248257 // Create the expression "(builtin.xy - pivot) * flipXY + pivot
249258 TIntermBinary *removePivot = new TIntermBinary (EOpSub, rotatedXY, pivot);
@@ -571,14 +580,17 @@ ANGLE_NO_DISCARD bool AddBresenhamEmulationVS(TCompiler *compiler,
571580}
572581
573582ANGLE_NO_DISCARD bool InsertFragCoordCorrection (TCompiler *compiler,
583+ ShCompileOptions compileOptions,
574584 TIntermBlock *root,
575585 TIntermSequence *insertSequence,
576586 TSymbolTable *symbolTable,
577587 const TVariable *driverUniforms)
578588{
579589 TIntermBinary *flipXY = CreateDriverUniformRef (driverUniforms, kFlipXY );
580590 TIntermBinary *pivot = CreateDriverUniformRef (driverUniforms, kHalfRenderArea );
581- TIntermBinary *fragRotation = CreateDriverUniformRef (driverUniforms, kFragRotation );
591+ TIntermBinary *fragRotation = (compileOptions & SH_ADD_PRE_ROTATION)
592+ ? CreateDriverUniformRef (driverUniforms, kFragRotation )
593+ : nullptr ;
582594 return RotateAndFlipBuiltinVariable (compiler, root, insertSequence, flipXY, symbolTable,
583595 BuiltInVariable::gl_FragCoord (), kFlippedFragCoordName ,
584596 pivot, fragRotation);
@@ -618,6 +630,7 @@ ANGLE_NO_DISCARD bool InsertFragCoordCorrection(TCompiler *compiler,
618630// Note this emulation can not provide fully correct rasterization. See the docs more more info.
619631
620632ANGLE_NO_DISCARD bool AddBresenhamEmulationFS (TCompiler *compiler,
633+ ShCompileOptions compileOptions,
621634 TInfoSinkBase &sink,
622635 TIntermBlock *root,
623636 TSymbolTable *symbolTable,
@@ -718,8 +731,8 @@ ANGLE_NO_DISCARD bool AddBresenhamEmulationFS(TCompiler *compiler,
718731 // If the shader does not use frag coord, we should insert it inside the emulation if.
719732 if (!usesFragCoord)
720733 {
721- if (!InsertFragCoordCorrection (compiler, root, emulationSequence, symbolTable ,
722- driverUniforms))
734+ if (!InsertFragCoordCorrection (compiler, compileOptions, root, emulationSequence ,
735+ symbolTable, driverUniforms))
723736 {
724737 return false ;
725738 }
@@ -933,15 +946,16 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
933946
934947 if (compileOptions & SH_ADD_BRESENHAM_LINE_RASTER_EMULATION)
935948 {
936- if (!AddBresenhamEmulationFS (this , sink, root, &getSymbolTable (), driverUniforms ,
937- usesFragCoord))
949+ if (!AddBresenhamEmulationFS (this , compileOptions, sink, root, &getSymbolTable (),
950+ driverUniforms, usesFragCoord))
938951 {
939952 return false ;
940953 }
941954 }
942955
943956 bool hasGLFragColor = false ;
944957 bool hasGLFragData = false ;
958+ bool usePreRotation = compileOptions & SH_ADD_PRE_ROTATION;
945959
946960 for (const ShaderVariable &outputVar : mOutputVariables )
947961 {
@@ -972,7 +986,8 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
972986 {
973987 TIntermBinary *flipXY = CreateDriverUniformRef (driverUniforms, kNegFlipXY );
974988 TIntermConstantUnion *pivot = CreateFloatNode (0 .5f );
975- TIntermBinary *fragRotation = CreateDriverUniformRef (driverUniforms, kFragRotation );
989+ TIntermBinary *fragRotation =
990+ usePreRotation ? CreateDriverUniformRef (driverUniforms, kFragRotation ) : nullptr ;
976991 if (!RotateAndFlipBuiltinVariable (this , root, GetMainSequence (root), flipXY,
977992 &getSymbolTable (), BuiltInVariable::gl_PointCoord (),
978993 kFlippedPointCoordName , pivot, fragRotation))
@@ -983,16 +998,17 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
983998
984999 if (usesFragCoord)
9851000 {
986- if (!InsertFragCoordCorrection (this , root, GetMainSequence ( root), & getSymbolTable ( ),
987- driverUniforms))
1001+ if (!InsertFragCoordCorrection (this , compileOptions, root, GetMainSequence (root ),
1002+ & getSymbolTable (), driverUniforms))
9881003 {
9891004 return false ;
9901005 }
9911006 }
9921007
9931008 {
994- TIntermBinary *flipXY = CreateDriverUniformRef (driverUniforms, kFlipXY );
995- TIntermBinary *fragRotation = CreateDriverUniformRef (driverUniforms, kFragRotation );
1009+ TIntermBinary *flipXY = CreateDriverUniformRef (driverUniforms, kFlipXY );
1010+ TIntermBinary *fragRotation =
1011+ usePreRotation ? CreateDriverUniformRef (driverUniforms, kFragRotation ) : nullptr ;
9961012 if (!RewriteDfdy (this , root, getSymbolTable (), getShaderVersion (), flipXY,
9971013 fragRotation))
9981014 {
@@ -1047,7 +1063,8 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
10471063 {
10481064 return false ;
10491065 }
1050- if (!AppendPreRotation (this , root, &getSymbolTable (), driverUniforms))
1066+ if ((compileOptions & SH_ADD_PRE_ROTATION) != 0 &&
1067+ !AppendPreRotation (this , root, &getSymbolTable (), driverUniforms))
10511068 {
10521069 return false ;
10531070 }
0 commit comments