got a scaling window going, yay
-
debug rendering tiles that are skipped (red) and tiles that can do a fast path (cyan) because they're known to be fully covered and fully within the viewport, so they can skip inside/outside and pixel clipping checks
@eniko is that larger phase a "coarse triangle rasterizer" part of the "fine triangle rasterizer"?
-
@eniko is that larger phase a "coarse triangle rasterizer" part of the "fine triangle rasterizer"?
@fabiosantoscode sort of? i'm not actually splitting the triangle or anything
i step through the bounding box in 8x8 tiles and check the corners to see if all corners of the tile are either fully outside any given edge, in which case they're blank and i can skip the pixel by pixel rendering
and if all corners are inside the triangle (and the viewport) then i know i can do the fast path
then for each pixel in the 8x8 tile i plot the pixel if it's inside the triangle/viewport
-
@eniko Vulkan "Eniko Edition" looks good so far!
-
@fabiosantoscode sort of? i'm not actually splitting the triangle or anything
i step through the bounding box in 8x8 tiles and check the corners to see if all corners of the tile are either fully outside any given edge, in which case they're blank and i can skip the pixel by pixel rendering
and if all corners are inside the triangle (and the viewport) then i know i can do the fast path
then for each pixel in the 8x8 tile i plot the pixel if it's inside the triangle/viewport
@eniko it sounds like a great optimisation!
-
debug rendering tiles that are skipped (red) and tiles that can do a fast path (cyan) because they're known to be fully covered and fully within the viewport, so they can skip inside/outside and pixel clipping checks
@eniko this would make such a pretty logo in itself
-
@fabiosantoscode sort of? i'm not actually splitting the triangle or anything
i step through the bounding box in 8x8 tiles and check the corners to see if all corners of the tile are either fully outside any given edge, in which case they're blank and i can skip the pixel by pixel rendering
and if all corners are inside the triangle (and the viewport) then i know i can do the fast path
then for each pixel in the 8x8 tile i plot the pixel if it's inside the triangle/viewport
@eniko @fabiosantoscode what happens if a triangle is completely contained within a tile?
-
@eniko @fabiosantoscode what happens if a triangle is completely contained within a tile?
@nicklockwood I think we can return early because the amount of tiles is 1 in that case.
We can return early if the width or height of the bounding box rounded to the tile is 1, really.
-
@eniko @fabiosantoscode what happens if a triangle is completely contained within a tile?
@nicklockwood @fabiosantoscode if a triangle is within a single tile then by definition the corners of the tile cannot all be on the same side of any given edge and so it draws the tile without the fast path
-
debug rendering tiles that are skipped (red) and tiles that can do a fast path (cyan) because they're known to be fully covered and fully within the viewport, so they can skip inside/outside and pixel clipping checks
took a bit of doing but now i have a single header library where i can customize my triangle fill routine for different vertex attributes. in debug mode it uses a single triFill function with function pointers so there's no weirdness going on, and when optimized it includes the triFill function multiple times with different names and calls the helper functions directly by name so they get inlined*
*i checked the assembly to make sure
-
took a bit of doing but now i have a single header library where i can customize my triangle fill routine for different vertex attributes. in debug mode it uses a single triFill function with function pointers so there's no weirdness going on, and when optimized it includes the triFill function multiple times with different names and calls the helper functions directly by name so they get inlined*
*i checked the assembly to make sure
this is what the implementation for a vertex format looks like
InitGrads converts from the data to float (it's already float here),
GetPixel is the fragment shader
the TRI_STEP_COLOR_GRADS functions are there so i can use a compile time constant for the gradient loops so they get unrolled
and the rest is just injecting the triFill routine (if necessary) and creating a wrapper that calls it or the generic triFill with function pointers
not the prettiest but its C so it could be a lot worse
-
debug rendering tiles that are skipped because they're known to be blank
@eniko amogus
-
this is what the implementation for a vertex format looks like
InitGrads converts from the data to float (it's already float here),
GetPixel is the fragment shader
the TRI_STEP_COLOR_GRADS functions are there so i can use a compile time constant for the gradient loops so they get unrolled
and the rest is just injecting the triFill routine (if necessary) and creating a wrapper that calls it or the generic triFill with function pointers
not the prettiest but its C so it could be a lot worse
tfw the nested 8 count loops unroll perfectly 😌
-
tfw the nested 8 count loops unroll perfectly 😌
@eniko I can see the clean code take on this now. ZOMG, that should be a function call!