@@ -242,8 +242,17 @@ ANGLE_NO_DISCARD bool RotateAndFlipBuiltinVariable(TCompiler *compiler,
242
242
}
243
243
244
244
// 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
+ }
247
256
248
257
// Create the expression "(builtin.xy - pivot) * flipXY + pivot
249
258
TIntermBinary *removePivot = new TIntermBinary (EOpSub, rotatedXY, pivot);
@@ -571,14 +580,17 @@ ANGLE_NO_DISCARD bool AddBresenhamEmulationVS(TCompiler *compiler,
571
580
}
572
581
573
582
ANGLE_NO_DISCARD bool InsertFragCoordCorrection (TCompiler *compiler,
583
+ ShCompileOptions compileOptions,
574
584
TIntermBlock *root,
575
585
TIntermSequence *insertSequence,
576
586
TSymbolTable *symbolTable,
577
587
const TVariable *driverUniforms)
578
588
{
579
589
TIntermBinary *flipXY = CreateDriverUniformRef (driverUniforms, kFlipXY );
580
590
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 ;
582
594
return RotateAndFlipBuiltinVariable (compiler, root, insertSequence, flipXY, symbolTable,
583
595
BuiltInVariable::gl_FragCoord (), kFlippedFragCoordName ,
584
596
pivot, fragRotation);
@@ -618,6 +630,7 @@ ANGLE_NO_DISCARD bool InsertFragCoordCorrection(TCompiler *compiler,
618
630
// Note this emulation can not provide fully correct rasterization. See the docs more more info.
619
631
620
632
ANGLE_NO_DISCARD bool AddBresenhamEmulationFS (TCompiler *compiler,
633
+ ShCompileOptions compileOptions,
621
634
TInfoSinkBase &sink,
622
635
TIntermBlock *root,
623
636
TSymbolTable *symbolTable,
@@ -718,8 +731,8 @@ ANGLE_NO_DISCARD bool AddBresenhamEmulationFS(TCompiler *compiler,
718
731
// If the shader does not use frag coord, we should insert it inside the emulation if.
719
732
if (!usesFragCoord)
720
733
{
721
- if (!InsertFragCoordCorrection (compiler, root, emulationSequence, symbolTable ,
722
- driverUniforms))
734
+ if (!InsertFragCoordCorrection (compiler, compileOptions, root, emulationSequence ,
735
+ symbolTable, driverUniforms))
723
736
{
724
737
return false ;
725
738
}
@@ -933,15 +946,16 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
933
946
934
947
if (compileOptions & SH_ADD_BRESENHAM_LINE_RASTER_EMULATION)
935
948
{
936
- if (!AddBresenhamEmulationFS (this , sink, root, &getSymbolTable (), driverUniforms ,
937
- usesFragCoord))
949
+ if (!AddBresenhamEmulationFS (this , compileOptions, sink, root, &getSymbolTable (),
950
+ driverUniforms, usesFragCoord))
938
951
{
939
952
return false ;
940
953
}
941
954
}
942
955
943
956
bool hasGLFragColor = false ;
944
957
bool hasGLFragData = false ;
958
+ bool usePreRotation = compileOptions & SH_ADD_PRE_ROTATION;
945
959
946
960
for (const ShaderVariable &outputVar : mOutputVariables )
947
961
{
@@ -972,7 +986,8 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
972
986
{
973
987
TIntermBinary *flipXY = CreateDriverUniformRef (driverUniforms, kNegFlipXY );
974
988
TIntermConstantUnion *pivot = CreateFloatNode (0 .5f );
975
- TIntermBinary *fragRotation = CreateDriverUniformRef (driverUniforms, kFragRotation );
989
+ TIntermBinary *fragRotation =
990
+ usePreRotation ? CreateDriverUniformRef (driverUniforms, kFragRotation ) : nullptr ;
976
991
if (!RotateAndFlipBuiltinVariable (this , root, GetMainSequence (root), flipXY,
977
992
&getSymbolTable (), BuiltInVariable::gl_PointCoord (),
978
993
kFlippedPointCoordName , pivot, fragRotation))
@@ -983,16 +998,17 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
983
998
984
999
if (usesFragCoord)
985
1000
{
986
- if (!InsertFragCoordCorrection (this , root, GetMainSequence ( root), & getSymbolTable ( ),
987
- driverUniforms))
1001
+ if (!InsertFragCoordCorrection (this , compileOptions, root, GetMainSequence (root ),
1002
+ & getSymbolTable (), driverUniforms))
988
1003
{
989
1004
return false ;
990
1005
}
991
1006
}
992
1007
993
1008
{
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 ;
996
1012
if (!RewriteDfdy (this , root, getSymbolTable (), getShaderVersion (), flipXY,
997
1013
fragRotation))
998
1014
{
@@ -1047,7 +1063,8 @@ bool TranslatorVulkan::translateImpl(TIntermBlock *root,
1047
1063
{
1048
1064
return false ;
1049
1065
}
1050
- if (!AppendPreRotation (this , root, &getSymbolTable (), driverUniforms))
1066
+ if ((compileOptions & SH_ADD_PRE_ROTATION) != 0 &&
1067
+ !AppendPreRotation (this , root, &getSymbolTable (), driverUniforms))
1051
1068
{
1052
1069
return false ;
1053
1070
}
0 commit comments