@@ -118,19 +118,19 @@ void DepthRasterTriangle(uint16_t *depthBuf, int stride, int x1, int y1, int x2,
118118 }
119119
120120 // TODO: Cull really small triangles here.
121+ int triArea = (v1y - v2y) * v0x + (v2x - v1x) * v0y + (v1x * v2y - v2x * v1y);
122+ if (triArea <= 0 ) {
123+ return ;
124+ }
125+
126+ float oneOverTriArea = 1 .0f / (float )triArea;
121127
122128 Edge e01 , e12 , e20 ;
123129
124130 Vec4S32 w0_row = e12 .init (v1x, v1y, v2x, v2y, minX, minY);
125131 Vec4S32 w1_row = e20 .init (v2x, v2y, v0x, v0y, minX, minY);
126132 Vec4S32 w2_row = e01 .init (v0x, v0y, v1x, v1y, minX, minY);
127133
128- int triArea = (v1y - v2y) * v0x + (v2x - v1x) * v0y + (v1x * v2y - v2x * v1y);
129- if (triArea <= 0 ) {
130- return ;
131- }
132- float oneOverTriArea = 1 .0f / (float )triArea;
133-
134134 // Prepare to interpolate Z
135135 Vec4F32 zz0 = Vec4F32::Splat ((float )v0z);
136136 Vec4F32 zz1 = Vec4F32::Splat ((float )(v1z - v0z) * oneOverTriArea);
@@ -320,10 +320,6 @@ void DepthRasterScreenVerts(uint16_t *depth, int depthStride, GEPrimitiveType pr
320320 ZCompareMode comp;
321321 // Ignore some useless compare modes.
322322 switch (compareMode) {
323- case GE_COMP_NEVER :
324- case GE_COMP_EQUAL :
325- // These will never have a useful effect in Z-only raster.
326- return ;
327323 case GE_COMP_ALWAYS :
328324 comp = ZCompareMode::Always;
329325 break ;
@@ -335,8 +331,14 @@ void DepthRasterScreenVerts(uint16_t *depth, int depthStride, GEPrimitiveType pr
335331 case GE_COMP_GREATER :
336332 comp = ZCompareMode::Greater; // Most common
337333 break ;
334+ case GE_COMP_NEVER :
335+ case GE_COMP_EQUAL :
336+ // These will never have a useful effect in Z-only raster.
337+ [[fallthrough]] ;
338338 case GE_COMP_NOTEQUAL :
339339 // This is highly unusual, let's just ignore it.
340+ [[fallthrough]] ;
341+ default :
340342 return ;
341343 }
342344
0 commit comments