@@ -290,33 +290,33 @@ namespace sw
290
290
}
291
291
292
292
Byte8 value = *Pointer<Byte8>(buffer);
293
- Byte8 valueCCW = value;
293
+ Byte8 valueBack = value;
294
294
295
- if (! state.noStencilMask )
295
+ if (state.frontStencil . compareMask != 0xff )
296
296
{
297
297
value &= *Pointer<Byte8>(data + OFFSET (DrawData,stencil[0 ].testMaskQ ));
298
298
}
299
299
300
- stencilTest (value, state.stencilCompareMode , false );
300
+ stencilTest (value, state.frontStencil . compareOp , false );
301
301
302
302
if (state.twoSidedStencil )
303
303
{
304
- if (! state.noStencilMaskCCW )
304
+ if (state.backStencil . compareMask != 0xff )
305
305
{
306
- valueCCW &= *Pointer<Byte8>(data + OFFSET (DrawData,stencil[1 ].testMaskQ ));
306
+ valueBack &= *Pointer<Byte8>(data + OFFSET (DrawData,stencil[1 ].testMaskQ ));
307
307
}
308
308
309
- stencilTest (valueCCW , state.stencilCompareModeCCW , true );
309
+ stencilTest (valueBack , state.backStencil . compareOp , true );
310
310
311
311
value &= *Pointer<Byte8>(primitive + OFFSET (Primitive,clockwiseMask));
312
- valueCCW &= *Pointer<Byte8>(primitive + OFFSET (Primitive,invClockwiseMask));
313
- value |= valueCCW ;
312
+ valueBack &= *Pointer<Byte8>(primitive + OFFSET (Primitive,invClockwiseMask));
313
+ value |= valueBack ;
314
314
}
315
315
316
316
sMask = SignMask (value) & cMask;
317
317
}
318
318
319
- void PixelRoutine::stencilTest (Byte8 &value, VkCompareOp stencilCompareMode, bool CCW )
319
+ void PixelRoutine::stencilTest (Byte8 &value, VkCompareOp stencilCompareMode, bool isBack )
320
320
{
321
321
Byte8 equal;
322
322
@@ -330,31 +330,31 @@ namespace sw
330
330
break ;
331
331
case VK_COMPARE_OP_LESS: // a < b ~ b > a
332
332
value += Byte8 (0x80 , 0x80 , 0x80 , 0x80 , 0x80 , 0x80 , 0x80 , 0x80 );
333
- value = CmpGT (As<SByte8>(value), *Pointer<SByte8>(data + OFFSET (DrawData,stencil[CCW ].referenceMaskedSignedQ )));
333
+ value = CmpGT (As<SByte8>(value), *Pointer<SByte8>(data + OFFSET (DrawData,stencil[isBack ].referenceMaskedSignedQ )));
334
334
break ;
335
335
case VK_COMPARE_OP_EQUAL:
336
- value = CmpEQ (value, *Pointer<Byte8>(data + OFFSET (DrawData,stencil[CCW ].referenceMaskedQ )));
336
+ value = CmpEQ (value, *Pointer<Byte8>(data + OFFSET (DrawData,stencil[isBack ].referenceMaskedQ )));
337
337
break ;
338
338
case VK_COMPARE_OP_NOT_EQUAL: // a != b ~ !(a == b)
339
- value = CmpEQ (value, *Pointer<Byte8>(data + OFFSET (DrawData,stencil[CCW ].referenceMaskedQ )));
339
+ value = CmpEQ (value, *Pointer<Byte8>(data + OFFSET (DrawData,stencil[isBack ].referenceMaskedQ )));
340
340
value ^= Byte8 (0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF );
341
341
break ;
342
342
case VK_COMPARE_OP_LESS_OR_EQUAL: // a <= b ~ (b > a) || (a == b)
343
343
equal = value;
344
- equal = CmpEQ (equal, *Pointer<Byte8>(data + OFFSET (DrawData,stencil[CCW ].referenceMaskedQ )));
344
+ equal = CmpEQ (equal, *Pointer<Byte8>(data + OFFSET (DrawData,stencil[isBack ].referenceMaskedQ )));
345
345
value += Byte8 (0x80 , 0x80 , 0x80 , 0x80 , 0x80 , 0x80 , 0x80 , 0x80 );
346
- value = CmpGT (As<SByte8>(value), *Pointer<SByte8>(data + OFFSET (DrawData,stencil[CCW ].referenceMaskedSignedQ )));
346
+ value = CmpGT (As<SByte8>(value), *Pointer<SByte8>(data + OFFSET (DrawData,stencil[isBack ].referenceMaskedSignedQ )));
347
347
value |= equal;
348
348
break ;
349
349
case VK_COMPARE_OP_GREATER: // a > b
350
- equal = *Pointer<Byte8>(data + OFFSET (DrawData,stencil[CCW ].referenceMaskedSignedQ ));
350
+ equal = *Pointer<Byte8>(data + OFFSET (DrawData,stencil[isBack ].referenceMaskedSignedQ ));
351
351
value += Byte8 (0x80 , 0x80 , 0x80 , 0x80 , 0x80 , 0x80 , 0x80 , 0x80 );
352
352
equal = CmpGT (As<SByte8>(equal), As<SByte8>(value));
353
353
value = equal;
354
354
break ;
355
355
case VK_COMPARE_OP_GREATER_OR_EQUAL: // a >= b ~ !(a < b) ~ !(b > a)
356
356
value += Byte8 (0x80 , 0x80 , 0x80 , 0x80 , 0x80 , 0x80 , 0x80 , 0x80 );
357
- value = CmpGT (As<SByte8>(value), *Pointer<SByte8>(data + OFFSET (DrawData,stencil[CCW ].referenceMaskedSignedQ )));
357
+ value = CmpGT (As<SByte8>(value), *Pointer<SByte8>(data + OFFSET (DrawData,stencil[isBack ].referenceMaskedSignedQ )));
358
358
value ^= Byte8 (0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF );
359
359
break ;
360
360
default :
@@ -729,15 +729,15 @@ namespace sw
729
729
return ;
730
730
}
731
731
732
- if (state.stencilPassOperation == VK_STENCIL_OP_KEEP && state.stencilZFailOperation == VK_STENCIL_OP_KEEP && state.stencilFailOperation == VK_STENCIL_OP_KEEP)
732
+ if (state.frontStencil . passOp == VK_STENCIL_OP_KEEP && state.frontStencil . depthFailOp == VK_STENCIL_OP_KEEP && state.frontStencil . failOp == VK_STENCIL_OP_KEEP)
733
733
{
734
- if (!state.twoSidedStencil || (state.stencilPassOperationCCW == VK_STENCIL_OP_KEEP && state.stencilZFailOperationCCW == VK_STENCIL_OP_KEEP && state.stencilFailOperationCCW == VK_STENCIL_OP_KEEP))
734
+ if (!state.twoSidedStencil || (state.backStencil . passOp == VK_STENCIL_OP_KEEP && state.backStencil . depthFailOp == VK_STENCIL_OP_KEEP && state.backStencil . failOp == VK_STENCIL_OP_KEEP))
735
735
{
736
736
return ;
737
737
}
738
738
}
739
739
740
- if (state.stencilWriteMasked && (!state.twoSidedStencil || state.stencilWriteMaskedCCW ))
740
+ if (( state.frontStencil . writeMask == 0 ) && (!state.twoSidedStencil || ( state.backStencil . writeMask == 0 ) ))
741
741
{
742
742
return ;
743
743
}
@@ -752,9 +752,9 @@ namespace sw
752
752
Byte8 bufferValue = *Pointer<Byte8>(buffer);
753
753
754
754
Byte8 newValue;
755
- stencilOperation (newValue, bufferValue, state.stencilPassOperation , state. stencilZFailOperation , state. stencilFailOperation , false , zMask, sMask );
755
+ stencilOperation (newValue, bufferValue, state.frontStencil , false , zMask, sMask );
756
756
757
- if (! state.noStencilWriteMask )
757
+ if (state.frontStencil . writeMask != 0 )
758
758
{
759
759
Byte8 maskedValue = bufferValue;
760
760
newValue &= *Pointer<Byte8>(data + OFFSET (DrawData,stencil[0 ].writeMaskQ ));
@@ -764,21 +764,21 @@ namespace sw
764
764
765
765
if (state.twoSidedStencil )
766
766
{
767
- Byte8 newValueCCW ;
767
+ Byte8 newValueBack ;
768
768
769
- stencilOperation (newValueCCW , bufferValue, state.stencilPassOperationCCW , state. stencilZFailOperationCCW , state. stencilFailOperationCCW , true , zMask, sMask );
769
+ stencilOperation (newValueBack , bufferValue, state.backStencil , true , zMask, sMask );
770
770
771
- if (! state.noStencilWriteMaskCCW )
771
+ if (state.backStencil . writeMask != 0 )
772
772
{
773
773
Byte8 maskedValue = bufferValue;
774
- newValueCCW &= *Pointer<Byte8>(data + OFFSET (DrawData,stencil[1 ].writeMaskQ ));
774
+ newValueBack &= *Pointer<Byte8>(data + OFFSET (DrawData,stencil[1 ].writeMaskQ ));
775
775
maskedValue &= *Pointer<Byte8>(data + OFFSET (DrawData,stencil[1 ].invWriteMaskQ ));
776
- newValueCCW |= maskedValue;
776
+ newValueBack |= maskedValue;
777
777
}
778
778
779
779
newValue &= *Pointer<Byte8>(primitive + OFFSET (Primitive,clockwiseMask));
780
- newValueCCW &= *Pointer<Byte8>(primitive + OFFSET (Primitive,invClockwiseMask));
781
- newValue |= newValueCCW ;
780
+ newValueBack &= *Pointer<Byte8>(primitive + OFFSET (Primitive,invClockwiseMask));
781
+ newValue |= newValueBack ;
782
782
}
783
783
784
784
newValue &= *Pointer<Byte8>(constants + OFFSET (Constants,maskB4Q) + 8 * cMask);
@@ -788,27 +788,27 @@ namespace sw
788
788
*Pointer<Byte4>(buffer) = Byte4 (newValue);
789
789
}
790
790
791
- void PixelRoutine::stencilOperation (Byte8 &newValue, Byte8 &bufferValue, VkStencilOp stencilPassOperation, VkStencilOp stencilZFailOperation, VkStencilOp stencilFailOperation, bool CCW , Int &zMask, Int &sMask )
791
+ void PixelRoutine::stencilOperation (Byte8 &newValue, Byte8 &bufferValue, VkStencilOpState const &ops, bool isBack , Int &zMask, Int &sMask )
792
792
{
793
793
Byte8 &pass = newValue;
794
794
Byte8 fail;
795
795
Byte8 zFail;
796
796
797
- stencilOperation (pass, bufferValue, stencilPassOperation, CCW );
797
+ stencilOperation (pass, bufferValue, ops. passOp , isBack );
798
798
799
- if (stencilZFailOperation != stencilPassOperation )
799
+ if (ops. depthFailOp != ops. passOp )
800
800
{
801
- stencilOperation (zFail, bufferValue, stencilZFailOperation, CCW );
801
+ stencilOperation (zFail, bufferValue, ops. depthFailOp , isBack );
802
802
}
803
803
804
- if (stencilFailOperation != stencilPassOperation || stencilFailOperation != stencilZFailOperation )
804
+ if (ops. failOp != ops. passOp || ops. failOp != ops. depthFailOp )
805
805
{
806
- stencilOperation (fail, bufferValue, stencilFailOperation, CCW );
806
+ stencilOperation (fail, bufferValue, ops. failOp , isBack );
807
807
}
808
808
809
- if (stencilFailOperation != stencilPassOperation || stencilFailOperation != stencilZFailOperation )
809
+ if (ops. failOp != ops. passOp || ops. failOp != ops. depthFailOp )
810
810
{
811
- if (state.depthTestActive && stencilZFailOperation != stencilPassOperation ) // zMask valid and values not the same
811
+ if (state.depthTestActive && ops. depthFailOp != ops. passOp ) // zMask valid and values not the same
812
812
{
813
813
pass &= *Pointer<Byte8>(constants + OFFSET (Constants,maskB4Q) + 8 * zMask);
814
814
zFail &= *Pointer<Byte8>(constants + OFFSET (Constants,invMaskB4Q) + 8 * zMask);
@@ -821,7 +821,7 @@ namespace sw
821
821
}
822
822
}
823
823
824
- void PixelRoutine::stencilOperation (Byte8 &output, Byte8 &bufferValue, VkStencilOp operation, bool CCW )
824
+ void PixelRoutine::stencilOperation (Byte8 &output, Byte8 &bufferValue, VkStencilOp operation, bool isBack )
825
825
{
826
826
switch (operation)
827
827
{
@@ -832,7 +832,7 @@ namespace sw
832
832
output = Byte8 (0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 );
833
833
break ;
834
834
case VK_STENCIL_OP_REPLACE:
835
- output = *Pointer<Byte8>(data + OFFSET (DrawData,stencil[CCW ].referenceQ ));
835
+ output = *Pointer<Byte8>(data + OFFSET (DrawData,stencil[isBack ].referenceQ ));
836
836
break ;
837
837
case VK_STENCIL_OP_INCREMENT_AND_CLAMP:
838
838
output = AddSat (bufferValue, Byte8 (1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ));
0 commit comments