diff --git a/panda/src/tinydisplay/Sources.pp b/panda/src/tinydisplay/Sources.pp index b964367a57..261f7333d3 100644 --- a/panda/src/tinydisplay/Sources.pp +++ b/panda/src/tinydisplay/Sources.pp @@ -30,7 +30,8 @@ specbuf.cxx \ texture.cxx vertex.cxx \ zbuffer.cxx zbuffer.h zdither.cxx zfeatures.h zgl.h zline.cxx \ - zline.h zmath.cxx zmath.h ztriangle.cxx ztriangle.h ztriangle_two.h + zline.h zmath.cxx zmath.h ztriangle.cxx ztriangle.h ztriangle_two.h \ + ztriangle_code.h ztriangle_table.h #end lib_target diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index 2d27bf706d..d51f18d06b 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -29,470 +29,13 @@ #include "bitMask.h" #include "zgl.h" #include "zmath.h" +#include "ztriangle_table.h" TypeHandle TinyGraphicsStateGuardian::_type_handle; PStatCollector TinyGraphicsStateGuardian::_vertices_immediate_pcollector("Vertices:Immediate mode"); PStatCollector TinyGraphicsStateGuardian::_draw_transform_pcollector("Draw:Transform"); - -static const ZB_fillTriangleFunc fill_tri_funcs -[2 /* depth write: zon, zoff */] -[3 /* color write: noblend, blend, nocolor */] -[3 /* alpha test: anone, aless, amore */] -[2 /* depth test: znone, zless */] -[3 /* shading: white, flat, smooth */] -[3 /* texturing: untextured, textured, perspective textured */] = { - { // depth write zon - { // color write noblend - { // alpha test anone - { - { ZB_fillTriangleFlat_xx_zon_noblend_anone_znone, - ZB_fillTriangleMapping_xx_zon_noblend_anone_znone, - ZB_fillTriangleMappingPerspective_xx_zon_noblend_anone_znone }, - { ZB_fillTriangleFlat_xx_zon_noblend_anone_znone, - ZB_fillTriangleMappingFlat_xx_zon_noblend_anone_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_anone_znone }, - { ZB_fillTriangleSmooth_xx_zon_noblend_anone_znone, - ZB_fillTriangleMappingSmooth_xx_zon_noblend_anone_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_anone_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zon_noblend_anone_zless, - ZB_fillTriangleMapping_xx_zon_noblend_anone_zless, - ZB_fillTriangleMappingPerspective_xx_zon_noblend_anone_zless }, - { ZB_fillTriangleFlat_xx_zon_noblend_anone_zless, - ZB_fillTriangleMappingFlat_xx_zon_noblend_anone_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_anone_zless }, - { ZB_fillTriangleSmooth_xx_zon_noblend_anone_zless, - ZB_fillTriangleMappingSmooth_xx_zon_noblend_anone_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_anone_zless }, - }, - }, - { // alpha test aless - { - { ZB_fillTriangleFlat_xx_zon_noblend_aless_znone, - ZB_fillTriangleMapping_xx_zon_noblend_aless_znone, - ZB_fillTriangleMappingPerspective_xx_zon_noblend_aless_znone }, - { ZB_fillTriangleFlat_xx_zon_noblend_aless_znone, - ZB_fillTriangleMappingFlat_xx_zon_noblend_aless_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_aless_znone }, - { ZB_fillTriangleSmooth_xx_zon_noblend_aless_znone, - ZB_fillTriangleMappingSmooth_xx_zon_noblend_aless_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_aless_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zon_noblend_aless_zless, - ZB_fillTriangleMapping_xx_zon_noblend_aless_zless, - ZB_fillTriangleMappingPerspective_xx_zon_noblend_aless_zless }, - { ZB_fillTriangleFlat_xx_zon_noblend_aless_zless, - ZB_fillTriangleMappingFlat_xx_zon_noblend_aless_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_aless_zless }, - { ZB_fillTriangleSmooth_xx_zon_noblend_aless_zless, - ZB_fillTriangleMappingSmooth_xx_zon_noblend_aless_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_aless_zless }, - }, - }, - { // alpha test amore - { - { ZB_fillTriangleFlat_xx_zon_noblend_amore_znone, - ZB_fillTriangleMapping_xx_zon_noblend_amore_znone, - ZB_fillTriangleMappingPerspective_xx_zon_noblend_amore_znone }, - { ZB_fillTriangleFlat_xx_zon_noblend_amore_znone, - ZB_fillTriangleMappingFlat_xx_zon_noblend_amore_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_amore_znone }, - { ZB_fillTriangleSmooth_xx_zon_noblend_amore_znone, - ZB_fillTriangleMappingSmooth_xx_zon_noblend_amore_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_amore_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zon_noblend_amore_zless, - ZB_fillTriangleMapping_xx_zon_noblend_amore_zless, - ZB_fillTriangleMappingPerspective_xx_zon_noblend_amore_zless }, - { ZB_fillTriangleFlat_xx_zon_noblend_amore_zless, - ZB_fillTriangleMappingFlat_xx_zon_noblend_amore_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_amore_zless }, - { ZB_fillTriangleSmooth_xx_zon_noblend_amore_zless, - ZB_fillTriangleMappingSmooth_xx_zon_noblend_amore_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_amore_zless }, - }, - }, - }, - { // color write blend - { // alpha test anone - { - { ZB_fillTriangleFlat_xx_zon_blend_anone_znone, - ZB_fillTriangleMapping_xx_zon_blend_anone_znone, - ZB_fillTriangleMappingPerspective_xx_zon_blend_anone_znone }, - { ZB_fillTriangleFlat_xx_zon_blend_anone_znone, - ZB_fillTriangleMappingFlat_xx_zon_blend_anone_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_anone_znone }, - { ZB_fillTriangleSmooth_xx_zon_blend_anone_znone, - ZB_fillTriangleMappingSmooth_xx_zon_blend_anone_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_anone_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zon_blend_anone_zless, - ZB_fillTriangleMapping_xx_zon_blend_anone_zless, - ZB_fillTriangleMappingPerspective_xx_zon_blend_anone_zless }, - { ZB_fillTriangleFlat_xx_zon_blend_anone_zless, - ZB_fillTriangleMappingFlat_xx_zon_blend_anone_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_anone_zless }, - { ZB_fillTriangleSmooth_xx_zon_blend_anone_zless, - ZB_fillTriangleMappingSmooth_xx_zon_blend_anone_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_anone_zless }, - }, - }, - { // alpha test aless - { - { ZB_fillTriangleFlat_xx_zon_blend_aless_znone, - ZB_fillTriangleMapping_xx_zon_blend_aless_znone, - ZB_fillTriangleMappingPerspective_xx_zon_blend_aless_znone }, - { ZB_fillTriangleFlat_xx_zon_blend_aless_znone, - ZB_fillTriangleMappingFlat_xx_zon_blend_aless_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_aless_znone }, - { ZB_fillTriangleSmooth_xx_zon_blend_aless_znone, - ZB_fillTriangleMappingSmooth_xx_zon_blend_aless_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_aless_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zon_blend_aless_zless, - ZB_fillTriangleMapping_xx_zon_blend_aless_zless, - ZB_fillTriangleMappingPerspective_xx_zon_blend_aless_zless }, - { ZB_fillTriangleFlat_xx_zon_blend_aless_zless, - ZB_fillTriangleMappingFlat_xx_zon_blend_aless_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_aless_zless }, - { ZB_fillTriangleSmooth_xx_zon_blend_aless_zless, - ZB_fillTriangleMappingSmooth_xx_zon_blend_aless_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_aless_zless }, - }, - }, - { // alpha test amore - { - { ZB_fillTriangleFlat_xx_zon_blend_amore_znone, - ZB_fillTriangleMapping_xx_zon_blend_amore_znone, - ZB_fillTriangleMappingPerspective_xx_zon_blend_amore_znone }, - { ZB_fillTriangleFlat_xx_zon_blend_amore_znone, - ZB_fillTriangleMappingFlat_xx_zon_blend_amore_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_amore_znone }, - { ZB_fillTriangleSmooth_xx_zon_blend_amore_znone, - ZB_fillTriangleMappingSmooth_xx_zon_blend_amore_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_amore_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zon_blend_amore_zless, - ZB_fillTriangleMapping_xx_zon_blend_amore_zless, - ZB_fillTriangleMappingPerspective_xx_zon_blend_amore_zless }, - { ZB_fillTriangleFlat_xx_zon_blend_amore_zless, - ZB_fillTriangleMappingFlat_xx_zon_blend_amore_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_amore_zless }, - { ZB_fillTriangleSmooth_xx_zon_blend_amore_zless, - ZB_fillTriangleMappingSmooth_xx_zon_blend_amore_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_amore_zless }, - }, - }, - }, - { // color write nocolor - { // alpha test anone - { - { ZB_fillTriangleFlat_xx_zon_nocolor_anone_znone, - ZB_fillTriangleMapping_xx_zon_nocolor_anone_znone, - ZB_fillTriangleMappingPerspective_xx_zon_nocolor_anone_znone }, - { ZB_fillTriangleFlat_xx_zon_nocolor_anone_znone, - ZB_fillTriangleMappingFlat_xx_zon_nocolor_anone_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_anone_znone }, - { ZB_fillTriangleSmooth_xx_zon_nocolor_anone_znone, - ZB_fillTriangleMappingSmooth_xx_zon_nocolor_anone_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_anone_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zon_nocolor_anone_zless, - ZB_fillTriangleMapping_xx_zon_nocolor_anone_zless, - ZB_fillTriangleMappingPerspective_xx_zon_nocolor_anone_zless }, - { ZB_fillTriangleFlat_xx_zon_nocolor_anone_zless, - ZB_fillTriangleMappingFlat_xx_zon_nocolor_anone_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_anone_zless }, - { ZB_fillTriangleSmooth_xx_zon_nocolor_anone_zless, - ZB_fillTriangleMappingSmooth_xx_zon_nocolor_anone_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_anone_zless }, - }, - }, - { // alpha test aless - { - { ZB_fillTriangleFlat_xx_zon_nocolor_aless_znone, - ZB_fillTriangleMapping_xx_zon_nocolor_aless_znone, - ZB_fillTriangleMappingPerspective_xx_zon_nocolor_aless_znone }, - { ZB_fillTriangleFlat_xx_zon_nocolor_aless_znone, - ZB_fillTriangleMappingFlat_xx_zon_nocolor_aless_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_aless_znone }, - { ZB_fillTriangleSmooth_xx_zon_nocolor_aless_znone, - ZB_fillTriangleMappingSmooth_xx_zon_nocolor_aless_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_aless_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zon_nocolor_aless_zless, - ZB_fillTriangleMapping_xx_zon_nocolor_aless_zless, - ZB_fillTriangleMappingPerspective_xx_zon_nocolor_aless_zless }, - { ZB_fillTriangleFlat_xx_zon_nocolor_aless_zless, - ZB_fillTriangleMappingFlat_xx_zon_nocolor_aless_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_aless_zless }, - { ZB_fillTriangleSmooth_xx_zon_nocolor_aless_zless, - ZB_fillTriangleMappingSmooth_xx_zon_nocolor_aless_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_aless_zless }, - }, - }, - { // alpha test amore - { - { ZB_fillTriangleFlat_xx_zon_nocolor_amore_znone, - ZB_fillTriangleMapping_xx_zon_nocolor_amore_znone, - ZB_fillTriangleMappingPerspective_xx_zon_nocolor_amore_znone }, - { ZB_fillTriangleFlat_xx_zon_nocolor_amore_znone, - ZB_fillTriangleMappingFlat_xx_zon_nocolor_amore_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_amore_znone }, - { ZB_fillTriangleSmooth_xx_zon_nocolor_amore_znone, - ZB_fillTriangleMappingSmooth_xx_zon_nocolor_amore_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_amore_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zon_nocolor_amore_zless, - ZB_fillTriangleMapping_xx_zon_nocolor_amore_zless, - ZB_fillTriangleMappingPerspective_xx_zon_nocolor_amore_zless }, - { ZB_fillTriangleFlat_xx_zon_nocolor_amore_zless, - ZB_fillTriangleMappingFlat_xx_zon_nocolor_amore_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_amore_zless }, - { ZB_fillTriangleSmooth_xx_zon_nocolor_amore_zless, - ZB_fillTriangleMappingSmooth_xx_zon_nocolor_amore_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_amore_zless }, - }, - }, - }, - }, - { // depth write zoff - { // color write noblend - { // alpha test anone - { - { ZB_fillTriangleFlat_xx_zoff_noblend_anone_znone, - ZB_fillTriangleMapping_xx_zoff_noblend_anone_znone, - ZB_fillTriangleMappingPerspective_xx_zoff_noblend_anone_znone }, - { ZB_fillTriangleFlat_xx_zoff_noblend_anone_znone, - ZB_fillTriangleMappingFlat_xx_zoff_noblend_anone_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_anone_znone }, - { ZB_fillTriangleSmooth_xx_zoff_noblend_anone_znone, - ZB_fillTriangleMappingSmooth_xx_zoff_noblend_anone_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_anone_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zoff_noblend_anone_zless, - ZB_fillTriangleMapping_xx_zoff_noblend_anone_zless, - ZB_fillTriangleMappingPerspective_xx_zoff_noblend_anone_zless }, - { ZB_fillTriangleFlat_xx_zoff_noblend_anone_zless, - ZB_fillTriangleMappingFlat_xx_zoff_noblend_anone_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_anone_zless }, - { ZB_fillTriangleSmooth_xx_zoff_noblend_anone_zless, - ZB_fillTriangleMappingSmooth_xx_zoff_noblend_anone_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_anone_zless }, - }, - }, - { // alpha test aless - { - { ZB_fillTriangleFlat_xx_zoff_noblend_aless_znone, - ZB_fillTriangleMapping_xx_zoff_noblend_aless_znone, - ZB_fillTriangleMappingPerspective_xx_zoff_noblend_aless_znone }, - { ZB_fillTriangleFlat_xx_zoff_noblend_aless_znone, - ZB_fillTriangleMappingFlat_xx_zoff_noblend_aless_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_aless_znone }, - { ZB_fillTriangleSmooth_xx_zoff_noblend_aless_znone, - ZB_fillTriangleMappingSmooth_xx_zoff_noblend_aless_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_aless_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zoff_noblend_aless_zless, - ZB_fillTriangleMapping_xx_zoff_noblend_aless_zless, - ZB_fillTriangleMappingPerspective_xx_zoff_noblend_aless_zless }, - { ZB_fillTriangleFlat_xx_zoff_noblend_aless_zless, - ZB_fillTriangleMappingFlat_xx_zoff_noblend_aless_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_aless_zless }, - { ZB_fillTriangleSmooth_xx_zoff_noblend_aless_zless, - ZB_fillTriangleMappingSmooth_xx_zoff_noblend_aless_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_aless_zless }, - }, - }, - { // alpha test amore - { - { ZB_fillTriangleFlat_xx_zoff_noblend_amore_znone, - ZB_fillTriangleMapping_xx_zoff_noblend_amore_znone, - ZB_fillTriangleMappingPerspective_xx_zoff_noblend_amore_znone }, - { ZB_fillTriangleFlat_xx_zoff_noblend_amore_znone, - ZB_fillTriangleMappingFlat_xx_zoff_noblend_amore_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_amore_znone }, - { ZB_fillTriangleSmooth_xx_zoff_noblend_amore_znone, - ZB_fillTriangleMappingSmooth_xx_zoff_noblend_amore_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_amore_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zoff_noblend_amore_zless, - ZB_fillTriangleMapping_xx_zoff_noblend_amore_zless, - ZB_fillTriangleMappingPerspective_xx_zoff_noblend_amore_zless }, - { ZB_fillTriangleFlat_xx_zoff_noblend_amore_zless, - ZB_fillTriangleMappingFlat_xx_zoff_noblend_amore_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_amore_zless }, - { ZB_fillTriangleSmooth_xx_zoff_noblend_amore_zless, - ZB_fillTriangleMappingSmooth_xx_zoff_noblend_amore_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_amore_zless }, - }, - }, - }, - { // color write blend - { // alpha test anone - { - { ZB_fillTriangleFlat_xx_zoff_blend_anone_znone, - ZB_fillTriangleMapping_xx_zoff_blend_anone_znone, - ZB_fillTriangleMappingPerspective_xx_zoff_blend_anone_znone }, - { ZB_fillTriangleFlat_xx_zoff_blend_anone_znone, - ZB_fillTriangleMappingFlat_xx_zoff_blend_anone_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_anone_znone }, - { ZB_fillTriangleSmooth_xx_zoff_blend_anone_znone, - ZB_fillTriangleMappingSmooth_xx_zoff_blend_anone_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_anone_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zoff_blend_anone_zless, - ZB_fillTriangleMapping_xx_zoff_blend_anone_zless, - ZB_fillTriangleMappingPerspective_xx_zoff_blend_anone_zless }, - { ZB_fillTriangleFlat_xx_zoff_blend_anone_zless, - ZB_fillTriangleMappingFlat_xx_zoff_blend_anone_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_anone_zless }, - { ZB_fillTriangleSmooth_xx_zoff_blend_anone_zless, - ZB_fillTriangleMappingSmooth_xx_zoff_blend_anone_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_anone_zless }, - }, - }, - { // alpha test aless - { - { ZB_fillTriangleFlat_xx_zoff_blend_aless_znone, - ZB_fillTriangleMapping_xx_zoff_blend_aless_znone, - ZB_fillTriangleMappingPerspective_xx_zoff_blend_aless_znone }, - { ZB_fillTriangleFlat_xx_zoff_blend_aless_znone, - ZB_fillTriangleMappingFlat_xx_zoff_blend_aless_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_aless_znone }, - { ZB_fillTriangleSmooth_xx_zoff_blend_aless_znone, - ZB_fillTriangleMappingSmooth_xx_zoff_blend_aless_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_aless_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zoff_blend_aless_zless, - ZB_fillTriangleMapping_xx_zoff_blend_aless_zless, - ZB_fillTriangleMappingPerspective_xx_zoff_blend_aless_zless }, - { ZB_fillTriangleFlat_xx_zoff_blend_aless_zless, - ZB_fillTriangleMappingFlat_xx_zoff_blend_aless_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_aless_zless }, - { ZB_fillTriangleSmooth_xx_zoff_blend_aless_zless, - ZB_fillTriangleMappingSmooth_xx_zoff_blend_aless_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_aless_zless }, - }, - }, - { // alpha test amore - { - { ZB_fillTriangleFlat_xx_zoff_blend_amore_znone, - ZB_fillTriangleMapping_xx_zoff_blend_amore_znone, - ZB_fillTriangleMappingPerspective_xx_zoff_blend_amore_znone }, - { ZB_fillTriangleFlat_xx_zoff_blend_amore_znone, - ZB_fillTriangleMappingFlat_xx_zoff_blend_amore_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_amore_znone }, - { ZB_fillTriangleSmooth_xx_zoff_blend_amore_znone, - ZB_fillTriangleMappingSmooth_xx_zoff_blend_amore_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_amore_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zoff_blend_amore_zless, - ZB_fillTriangleMapping_xx_zoff_blend_amore_zless, - ZB_fillTriangleMappingPerspective_xx_zoff_blend_amore_zless }, - { ZB_fillTriangleFlat_xx_zoff_blend_amore_zless, - ZB_fillTriangleMappingFlat_xx_zoff_blend_amore_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_amore_zless }, - { ZB_fillTriangleSmooth_xx_zoff_blend_amore_zless, - ZB_fillTriangleMappingSmooth_xx_zoff_blend_amore_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_amore_zless }, - }, - }, - }, - { // color write nocolor - { // alpha test anone - { - { ZB_fillTriangleFlat_xx_zoff_nocolor_anone_znone, - ZB_fillTriangleMapping_xx_zoff_nocolor_anone_znone, - ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_anone_znone }, - { ZB_fillTriangleFlat_xx_zoff_nocolor_anone_znone, - ZB_fillTriangleMappingFlat_xx_zoff_nocolor_anone_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_anone_znone }, - { ZB_fillTriangleSmooth_xx_zoff_nocolor_anone_znone, - ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_anone_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_anone_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zoff_nocolor_anone_zless, - ZB_fillTriangleMapping_xx_zoff_nocolor_anone_zless, - ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_anone_zless }, - { ZB_fillTriangleFlat_xx_zoff_nocolor_anone_zless, - ZB_fillTriangleMappingFlat_xx_zoff_nocolor_anone_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_anone_zless }, - { ZB_fillTriangleSmooth_xx_zoff_nocolor_anone_zless, - ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_anone_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_anone_zless }, - }, - }, - { // alpha test aless - { - { ZB_fillTriangleFlat_xx_zoff_nocolor_aless_znone, - ZB_fillTriangleMapping_xx_zoff_nocolor_aless_znone, - ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_aless_znone }, - { ZB_fillTriangleFlat_xx_zoff_nocolor_aless_znone, - ZB_fillTriangleMappingFlat_xx_zoff_nocolor_aless_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_aless_znone }, - { ZB_fillTriangleSmooth_xx_zoff_nocolor_aless_znone, - ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_aless_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_aless_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zoff_nocolor_aless_zless, - ZB_fillTriangleMapping_xx_zoff_nocolor_aless_zless, - ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_aless_zless }, - { ZB_fillTriangleFlat_xx_zoff_nocolor_aless_zless, - ZB_fillTriangleMappingFlat_xx_zoff_nocolor_aless_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_aless_zless }, - { ZB_fillTriangleSmooth_xx_zoff_nocolor_aless_zless, - ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_aless_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_aless_zless }, - }, - }, - { // alpha test amore - { - { ZB_fillTriangleFlat_xx_zoff_nocolor_amore_znone, - ZB_fillTriangleMapping_xx_zoff_nocolor_amore_znone, - ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_amore_znone }, - { ZB_fillTriangleFlat_xx_zoff_nocolor_amore_znone, - ZB_fillTriangleMappingFlat_xx_zoff_nocolor_amore_znone, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_amore_znone }, - { ZB_fillTriangleSmooth_xx_zoff_nocolor_amore_znone, - ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_amore_znone, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_amore_znone }, - }, - { - { ZB_fillTriangleFlat_xx_zoff_nocolor_amore_zless, - ZB_fillTriangleMapping_xx_zoff_nocolor_amore_zless, - ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_amore_zless }, - { ZB_fillTriangleFlat_xx_zoff_nocolor_amore_zless, - ZB_fillTriangleMappingFlat_xx_zoff_nocolor_amore_zless, - ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_amore_zless }, - { ZB_fillTriangleSmooth_xx_zoff_nocolor_amore_zless, - ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_amore_zless, - ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_amore_zless }, - }, - }, - }, - }, -}; - //////////////////////////////////////////////////////////////////// // Function: TinyGraphicsStateGuardian::Constructor // Access: Public @@ -1196,14 +739,16 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } int texturing_state = 0; // untextured + int texfilter_state = 0; // nearest if (_c->texture_2d_enabled) { + texfilter_state = _texfilter_state; texturing_state = 2; // perspective-correct textures if (_c->matrix_model_projection_no_w_transform) { texturing_state = 1; // non-perspective-correct textures } } - _c->zb_fill_tri = fill_tri_funcs[depth_write_state][color_write_state][alpha_test_state][depth_test_state][shading_state][texturing_state]; + _c->zb_fill_tri = fill_tri_funcs[depth_write_state][color_write_state][alpha_test_state][depth_test_state][texfilter_state][shading_state][texturing_state]; return true; } @@ -1449,9 +994,11 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr, TinyTextureContext *gtc = DCAST(TinyTextureContext, tc); GLTexture *gltex = gtc->_gltex; - setup_gltex(gltex, tex->get_x_size(), tex->get_y_size()); + if (!setup_gltex(gltex, tex->get_x_size(), tex->get_y_size(), 1)) { + return; + } - PIXEL *ip = gltex->pixmap + gltex->xsize * gltex->ysize; + PIXEL *ip = gltex->levels[0].pixmap + gltex->xsize * gltex->ysize; PIXEL *fo = _c->zb->pbuf + xo + yo * _c->zb->linesize / PSZB; for (int y = 0; y < gltex->ysize; ++y) { ip -= gltex->xsize; @@ -1668,8 +1215,12 @@ release_texture(TextureContext *tc) { _c->texture_2d_enabled = false; } - if (gltex->pixmap != NULL) { - gl_free(gltex->pixmap); + for (int i = 0; i < gltex->num_levels; ++i) { + gl_free(gltex->levels[i].pixmap); + } + if (gltex->levels != NULL) { + gl_free(gltex->levels); + gltex->levels = NULL; } gl_free(gltex); @@ -2058,21 +1609,26 @@ apply_texture(TextureContext *tc) { _c->current_texture = gtc->_gltex; _c->texture_2d_enabled = true; + _texfilter_state = 0; + if (gtc->get_texture()->uses_mipmaps()) { + _texfilter_state = 1; + } + GLTexture *gltex = gtc->_gltex; - if (gtc->was_image_modified() || gltex->pixmap == NULL) { + if (gtc->was_image_modified() || gltex->num_levels == 0) { // If the texture image was modified, reload the texture. if (!upload_texture(gtc)) { + tinydisplay_cat.error() + << "Could not load " << *gtc->get_texture() + << ": inappropriate size.\n"; _c->texture_2d_enabled = false; } gtc->mark_loaded(); } gtc->enqueue_lru(&_textures_lru); - _c->zb->current_texture.pixmap = gltex->pixmap; - _c->zb->current_texture.s_mask = gltex->s_mask; - _c->zb->current_texture.t_mask = gltex->t_mask; - _c->zb->current_texture.t_shift = gltex->t_shift; + _c->zb->current_texture = gltex->levels; } //////////////////////////////////////////////////////////////////// @@ -2101,55 +1657,77 @@ upload_texture(TinyTextureContext *gtc) { _data_transferred_pcollector.add_level(tex->get_ram_image_size()); #endif GLTexture *gltex = gtc->_gltex; - setup_gltex(gltex, tex->get_x_size(), tex->get_y_size()); - switch (tex->get_format()) { - case Texture::F_rgb: - case Texture::F_rgb5: - case Texture::F_rgb8: - case Texture::F_rgb12: - case Texture::F_rgb332: - copy_rgb_image(gltex, tex); - break; - - case Texture::F_rgba: - case Texture::F_rgbm: - case Texture::F_rgba4: - case Texture::F_rgba5: - case Texture::F_rgba8: - case Texture::F_rgba12: - case Texture::F_rgba16: - case Texture::F_rgba32: - copy_rgba_image(gltex, tex); - break; - - case Texture::F_luminance: - copy_lum_image(gltex, tex); - break; - - case Texture::F_red: - copy_one_channel_image(gltex, tex, 0); - break; - - case Texture::F_green: - copy_one_channel_image(gltex, tex, 1); - break; - - case Texture::F_blue: - copy_one_channel_image(gltex, tex, 2); - break; - - case Texture::F_alpha: - copy_alpha_image(gltex, tex); - break; - - case Texture::F_luminance_alphamask: - case Texture::F_luminance_alpha: - copy_la_image(gltex, tex); - break; + int num_levels = 1; + if (tex->uses_mipmaps()) { + if (!tex->has_all_ram_mipmap_images()) { + tex->generate_ram_mipmap_images(); + } + num_levels = tex->get_num_ram_mipmap_images(); + } + + if (!setup_gltex(gltex, tex->get_x_size(), tex->get_y_size(), num_levels)) { + return false; + } + + int bytecount = 0; + int xsize = gltex->xsize; + int ysize = gltex->ysize; + + for (int level = 0; level < gltex->num_levels; ++level) { + ZTextureLevel *dest = &gltex->levels[level]; + + switch (tex->get_format()) { + case Texture::F_rgb: + case Texture::F_rgb5: + case Texture::F_rgb8: + case Texture::F_rgb12: + case Texture::F_rgb332: + copy_rgb_image(dest, xsize, ysize, tex, level); + break; + + case Texture::F_rgba: + case Texture::F_rgbm: + case Texture::F_rgba4: + case Texture::F_rgba5: + case Texture::F_rgba8: + case Texture::F_rgba12: + case Texture::F_rgba16: + case Texture::F_rgba32: + copy_rgba_image(dest, xsize, ysize, tex, level); + break; + + case Texture::F_luminance: + copy_lum_image(dest, xsize, ysize, tex, level); + break; + + case Texture::F_red: + copy_one_channel_image(dest, xsize, ysize, tex, level, 0); + break; + + case Texture::F_green: + copy_one_channel_image(dest, xsize, ysize, tex, level, 1); + break; + + case Texture::F_blue: + copy_one_channel_image(dest, xsize, ysize, tex, level, 2); + break; + + case Texture::F_alpha: + copy_alpha_image(dest, xsize, ysize, tex, level); + break; + + case Texture::F_luminance_alphamask: + case Texture::F_luminance_alpha: + copy_la_image(dest, xsize, ysize, tex, level); + break; + } + + bytecount += xsize * ysize * 4; + xsize = max(xsize >> 1, 1); + ysize = max(ysize >> 1, 1); } - int bytecount = gltex->xsize * gltex->ysize * 4; gtc->update_data_size_bytes(bytecount); tex->texture_uploaded(); @@ -2162,70 +1740,96 @@ upload_texture(TinyTextureContext *gtc) { // Access: Private // Description: Sets the GLTexture size, bits, and masks appropriate, // and allocates space for a pixmap. Does not fill the -// pixmap contents. +// pixmap contents. Returns true if the texture is a +// valid size, false otherwise. //////////////////////////////////////////////////////////////////// -void TinyGraphicsStateGuardian:: -setup_gltex(GLTexture *gltex, int orig_x_size, int orig_y_size) { - // Ensure we have a power of two size, no more than our max. - int s_size, s_bits; - choose_tex_size(s_size, s_bits, orig_x_size); - - int t_size, t_bits; - choose_tex_size(t_size, t_bits, orig_y_size); - - int bytecount = s_size * t_size * 4; - - gltex->xsize = s_size; - gltex->ysize = t_size; - - if (gltex->pixmap != NULL) { - gl_free(gltex->pixmap); +bool TinyGraphicsStateGuardian:: +setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels) { + int s_bits = get_tex_shift(x_size); + int t_bits = get_tex_shift(y_size); + + if (s_bits < 0 || t_bits < 0) { + return false; } - gltex->pixmap = (PIXEL *)gl_malloc(bytecount); + + gltex->xsize = x_size; + gltex->ysize = y_size; gltex->s_max = 1 << (s_bits + ZB_POINT_ST_FRAC_BITS); - gltex->s_mask = (1 << (s_bits + ZB_POINT_ST_FRAC_BITS)) - (1 << ZB_POINT_ST_FRAC_BITS); gltex->t_max = 1 << (t_bits + ZB_POINT_ST_FRAC_BITS); - gltex->t_mask = (1 << (t_bits + ZB_POINT_ST_FRAC_BITS)) - (1 << ZB_POINT_ST_FRAC_BITS); - gltex->t_shift = (ZB_POINT_ST_FRAC_BITS - s_bits); + + for (int i = 0; i < gltex->num_levels; ++i) { + gl_free(gltex->levels[i].pixmap); + } + if (gltex->levels != NULL) { + gl_free(gltex->levels); + gltex->levels = NULL; + } + + gltex->levels = (ZTextureLevel *)gl_malloc(sizeof(ZTextureLevel) * MAX_MIPMAP_LEVELS); + gltex->num_levels = num_levels; + + int level = 0; + ZTextureLevel *dest = NULL; + while (level < num_levels) { + dest = &gltex->levels[level]; + int bytecount = x_size * y_size * 4; + dest->pixmap = (PIXEL *)gl_malloc(bytecount); + + dest->s_mask = (1 << (s_bits + ZB_POINT_ST_FRAC_BITS)) - (1 << ZB_POINT_ST_FRAC_BITS); + dest->t_mask = (1 << (t_bits + ZB_POINT_ST_FRAC_BITS)) - (1 << ZB_POINT_ST_FRAC_BITS); + dest->t_shift = (ZB_POINT_ST_FRAC_BITS - s_bits); + + x_size = max((x_size >> 1), 1); + y_size = max((y_size >> 1), 1); + s_bits = max(s_bits - 1, 0); + t_bits = max(t_bits - 1, 0); + + ++level; + } + + // Fill out the remaining mipmap arrays with copies of the last + // level, so we don't have to be concerned with running off the end + // of this array while scanning out triangles. + while (level < MAX_MIPMAP_LEVELS) { + gltex->levels[level] = *dest; + ++level; + } + + return true; } //////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::choose_tex_size +// Function: TinyGraphicsStateGuardian::get_tex_shift // Access: Private -// Description: Chooses the suitable texture size that is the closest -// power-of-2 match to the indicated original size. -// Also calculates the bit shift count, such that (1 << -// bits) == size. +// Description: Calculates the bit shift count, such that (1 << shift) +// == size. Returns -1 if the size is not a power of 2 +// or is larger than our largest allowable size. //////////////////////////////////////////////////////////////////// -void TinyGraphicsStateGuardian:: -choose_tex_size(int &size, int &bits, int orig_size) { - unsigned int filled = flood_bits_down((unsigned int)orig_size); - size = filled + 1; - if (size > orig_size) { - // Round down, not up, to next lowest power of 2. - size >>= 1; - } - if (size > _max_texture_dimension) { - size = _max_texture_dimension; +int TinyGraphicsStateGuardian:: +get_tex_shift(int orig_size) { + unsigned int filled = flood_bits_down((unsigned int)(orig_size - 1)); + int size = filled + 1; + if (size != orig_size || size > _max_texture_dimension) { + return -1; } - bits = count_bits_in_word((unsigned int)size - 1); + return count_bits_in_word((unsigned int)size - 1); } //////////////////////////////////////////////////////////////////// // Function: TinyGraphicsStateGuardian::copy_lum_image // Access: Private, Static // Description: Copies and scales the one-channel luminance image -// from the texture into the indicated GLTexture. +// from the texture into the indicated ZTexture pixmap. //////////////////////////////////////////////////////////////////// void TinyGraphicsStateGuardian:: -copy_lum_image(GLTexture *gltex, Texture *tex) { +copy_lum_image(ZTextureLevel *dest, int xsize, int ysize, Texture *tex, int level) { nassertv(tex->get_num_components() == 1); + nassertv(tex->get_expected_mipmap_x_size(level) == xsize && + tex->get_expected_mipmap_y_size(level) == ysize); - int xsize_src = tex->get_x_size(); - int ysize_src = tex->get_y_size(); - CPTA_uchar src_image = tex->get_ram_image(); + CPTA_uchar src_image = tex->get_ram_mipmap_image(level); nassertv(!src_image.is_null()); const unsigned char *src = src_image.p(); @@ -2239,32 +1843,18 @@ copy_lum_image(GLTexture *gltex, Texture *tex) { int co = cw - 1; #endif - int xsize_dest = gltex->xsize; - int ysize_dest = gltex->ysize; - unsigned char *dest = (unsigned char *)gltex->pixmap; - nassertv(dest != NULL); - - int sx_inc = (int)((float)(xsize_src) / (float)(xsize_dest)); - int sy_inc = (int)((float)(ysize_src) / (float)(ysize_dest)); - - unsigned char *dpix = dest; - int syn = 0; - for (int dy = 0; dy < ysize_dest; dy++) { - int sy = syn / ysize_dest; - int sxn = 0; - for (int dx = 0; dx < xsize_dest; dx++) { - int sx = sxn / xsize_dest; - const unsigned char *spix = src + (sy * xsize_src + sx) * 1 * cw; + unsigned char *dpix = (unsigned char *)dest->pixmap; + nassertv(dpix != NULL); + const unsigned char *spix = src; + int pixel_count = xsize * ysize; + while (pixel_count-- > 0) { + dpix[0] = spix[co]; + dpix[1] = spix[co]; + dpix[2] = spix[co]; + dpix[3] = 0xff; - dpix[0] = spix[co]; - dpix[1] = spix[co]; - dpix[2] = spix[co]; - dpix[3] = 0xff; - - dpix += 4; - sxn += xsize_src; - } - syn += ysize_src; + dpix += 4; + spix += cw; } } @@ -2272,15 +1862,13 @@ copy_lum_image(GLTexture *gltex, Texture *tex) { // Function: TinyGraphicsStateGuardian::copy_alpha_image // Access: Private, Static // Description: Copies and scales the one-channel alpha image -// from the texture into the indicated GLTexture pixmap. +// from the texture into the indicated ZTexture pixmap. //////////////////////////////////////////////////////////////////// void TinyGraphicsStateGuardian:: -copy_alpha_image(GLTexture *gltex, Texture *tex) { +copy_alpha_image(ZTextureLevel *dest, int xsize, int ysize, Texture *tex, int level) { nassertv(tex->get_num_components() == 1); - int xsize_src = tex->get_x_size(); - int ysize_src = tex->get_y_size(); - CPTA_uchar src_image = tex->get_ram_image(); + CPTA_uchar src_image = tex->get_ram_mipmap_image(level); nassertv(!src_image.is_null()); const unsigned char *src = src_image.p(); @@ -2294,32 +1882,18 @@ copy_alpha_image(GLTexture *gltex, Texture *tex) { int co = cw - 1; #endif - int xsize_dest = gltex->xsize; - int ysize_dest = gltex->ysize; - unsigned char *dest = (unsigned char *)gltex->pixmap; - nassertv(dest != NULL); - - int sx_inc = (int)((float)(xsize_src) / (float)(xsize_dest)); - int sy_inc = (int)((float)(ysize_src) / (float)(ysize_dest)); - - unsigned char *dpix = dest; - int syn = 0; - for (int dy = 0; dy < ysize_dest; dy++) { - int sy = syn / ysize_dest; - int sxn = 0; - for (int dx = 0; dx < xsize_dest; dx++) { - int sx = sxn / xsize_dest; - const unsigned char *spix = src + (sy * xsize_src + sx) * 1 * cw; + unsigned char *dpix = (unsigned char *)dest->pixmap; + nassertv(dpix != NULL); + const unsigned char *spix = src; + int pixel_count = xsize * ysize; + while (pixel_count-- > 0) { + dpix[0] = 0xff; + dpix[1] = 0xff; + dpix[2] = 0xff; + dpix[3] = spix[co]; - dpix[0] = 0xff; - dpix[1] = 0xff; - dpix[2] = 0xff; - dpix[3] = spix[co]; - - dpix += 4; - sxn += xsize_src; - } - syn += ysize_src; + dpix += 4; + spix += cw; } } @@ -2328,15 +1902,13 @@ copy_alpha_image(GLTexture *gltex, Texture *tex) { // Access: Private, Static // Description: Copies and scales the one-channel image (with a // single channel, e.g. red, green, or blue) from -// the texture into the indicated GLTexture pixmap. +// the texture into the indicated ZTexture pixmap. //////////////////////////////////////////////////////////////////// void TinyGraphicsStateGuardian:: -copy_one_channel_image(GLTexture *gltex, Texture *tex, int channel) { +copy_one_channel_image(ZTextureLevel *dest, int xsize, int ysize, Texture *tex, int level, int channel) { nassertv(tex->get_num_components() == 1); - int xsize_src = tex->get_x_size(); - int ysize_src = tex->get_y_size(); - CPTA_uchar src_image = tex->get_ram_image(); + CPTA_uchar src_image = tex->get_ram_mipmap_image(level); nassertv(!src_image.is_null()); const unsigned char *src = src_image.p(); @@ -2350,33 +1922,19 @@ copy_one_channel_image(GLTexture *gltex, Texture *tex, int channel) { int co = cw - 1; #endif - int xsize_dest = gltex->xsize; - int ysize_dest = gltex->ysize; - unsigned char *dest = (unsigned char *)gltex->pixmap; - nassertv(dest != NULL); - - int sx_inc = (int)((float)(xsize_src) / (float)(xsize_dest)); - int sy_inc = (int)((float)(ysize_src) / (float)(ysize_dest)); - - unsigned char *dpix = dest; - int syn = 0; - for (int dy = 0; dy < ysize_dest; dy++) { - int sy = syn / ysize_dest; - int sxn = 0; - for (int dx = 0; dx < xsize_dest; dx++) { - int sx = sxn / xsize_dest; - const unsigned char *spix = src + (sy * xsize_src + sx) * 1 * cw; - - dpix[0] = 0; - dpix[1] = 0; - dpix[2] = 0; - dpix[3] = 0xff; - dpix[channel] = spix[co]; + unsigned char *dpix = (unsigned char *)dest->pixmap; + nassertv(dpix != NULL); + const unsigned char *spix = src; + int pixel_count = xsize * ysize; + while (pixel_count-- > 0) { + dpix[0] = 0; + dpix[1] = 0; + dpix[2] = 0; + dpix[3] = 0xff; + dpix[channel] = spix[co]; - dpix += 4; - sxn += xsize_src; - } - syn += ysize_src; + dpix += 4; + spix += cw; } } @@ -2384,16 +1942,14 @@ copy_one_channel_image(GLTexture *gltex, Texture *tex, int channel) { // Function: TinyGraphicsStateGuardian::copy_la_image // Access: Private, Static // Description: Copies and scales the two-channel luminance-alpha -// image from the texture into the indicated GLTexture +// image from the texture into the indicated ZTexture // pixmap. //////////////////////////////////////////////////////////////////// void TinyGraphicsStateGuardian:: -copy_la_image(GLTexture *gltex, Texture *tex) { +copy_la_image(ZTextureLevel *dest, int xsize, int ysize, Texture *tex, int level) { nassertv(tex->get_num_components() == 2); - int xsize_src = tex->get_x_size(); - int ysize_src = tex->get_y_size(); - CPTA_uchar src_image = tex->get_ram_image(); + CPTA_uchar src_image = tex->get_ram_mipmap_image(level); nassertv(!src_image.is_null()); const unsigned char *src = src_image.p(); @@ -2407,32 +1963,18 @@ copy_la_image(GLTexture *gltex, Texture *tex) { int co = cw - 1; #endif - int xsize_dest = gltex->xsize; - int ysize_dest = gltex->ysize; - unsigned char *dest = (unsigned char *)gltex->pixmap; - nassertv(dest != NULL); - - int sx_inc = (int)((float)(xsize_src) / (float)(xsize_dest)); - int sy_inc = (int)((float)(ysize_src) / (float)(ysize_dest)); - - unsigned char *dpix = dest; - int syn = 0; - for (int dy = 0; dy < ysize_dest; dy++) { - int sy = syn / ysize_dest; - int sxn = 0; - for (int dx = 0; dx < xsize_dest; dx++) { - int sx = sxn / xsize_dest; - const unsigned char *spix = src + (sy * xsize_src + sx) * 2 * cw; + unsigned char *dpix = (unsigned char *)dest->pixmap; + nassertv(dpix != NULL); + const unsigned char *spix = src; + int pixel_count = xsize * ysize; + while (pixel_count-- > 0) { + dpix[0] = spix[co]; + dpix[1] = spix[co]; + dpix[2] = spix[co]; + dpix[3] = spix[cw + co]; - dpix[0] = spix[co]; - dpix[1] = spix[co]; - dpix[2] = spix[co]; - dpix[3] = spix[cw + co]; - - dpix += 4; - sxn += xsize_src; - } - syn += ysize_src; + dpix += 4; + spix += 2 * cw; } } @@ -2440,15 +1982,13 @@ copy_la_image(GLTexture *gltex, Texture *tex) { // Function: TinyGraphicsStateGuardian::copy_rgb_image // Access: Private, Static // Description: Copies and scales the three-channel RGB image from -// the texture into the indicated GLTexture pixmap. +// the texture into the indicated ZTexture pixmap. //////////////////////////////////////////////////////////////////// void TinyGraphicsStateGuardian:: -copy_rgb_image(GLTexture *gltex, Texture *tex) { +copy_rgb_image(ZTextureLevel *dest, int xsize, int ysize, Texture *tex, int level) { nassertv(tex->get_num_components() == 3); - int xsize_src = tex->get_x_size(); - int ysize_src = tex->get_y_size(); - CPTA_uchar src_image = tex->get_ram_image(); + CPTA_uchar src_image = tex->get_ram_mipmap_image(level); nassertv(!src_image.is_null()); const unsigned char *src = src_image.p(); @@ -2462,32 +2002,18 @@ copy_rgb_image(GLTexture *gltex, Texture *tex) { int co = cw - 1; #endif - int xsize_dest = gltex->xsize; - int ysize_dest = gltex->ysize; - unsigned char *dest = (unsigned char *)gltex->pixmap; - nassertv(dest != NULL); - - int sx_inc = (int)((float)(xsize_src) / (float)(xsize_dest)); - int sy_inc = (int)((float)(ysize_src) / (float)(ysize_dest)); - - unsigned char *dpix = dest; - int syn = 0; - for (int dy = 0; dy < ysize_dest; dy++) { - int sy = syn / ysize_dest; - int sxn = 0; - for (int dx = 0; dx < xsize_dest; dx++) { - int sx = sxn / xsize_dest; - const unsigned char *spix = src + (sy * xsize_src + sx) * 3 * cw; + unsigned char *dpix = (unsigned char *)dest->pixmap; + nassertv(dpix != NULL); + const unsigned char *spix = src; + int pixel_count = xsize * ysize; + while (pixel_count-- > 0) { + dpix[0] = spix[co]; + dpix[1] = spix[cw + co]; + dpix[2] = spix[cw + cw + co]; + dpix[3] = 0xff; - dpix[0] = spix[co]; - dpix[1] = spix[cw + co]; - dpix[2] = spix[cw + cw + co]; - dpix[3] = 0xff; - - dpix += 4; - sxn += xsize_src; - } - syn += ysize_src; + dpix += 4; + spix += 3 * cw; } } @@ -2495,15 +2021,13 @@ copy_rgb_image(GLTexture *gltex, Texture *tex) { // Function: TinyGraphicsStateGuardian::copy_rgba_image // Access: Private, Static // Description: Copies and scales the four-channel RGBA image from -// the texture into the indicated GLTexture pixmap. +// the texture into the indicated ZTexture pixmap. //////////////////////////////////////////////////////////////////// void TinyGraphicsStateGuardian:: -copy_rgba_image(GLTexture *gltex, Texture *tex) { +copy_rgba_image(ZTextureLevel *dest, int xsize, int ysize, Texture *tex, int level) { nassertv(tex->get_num_components() == 4); - int xsize_src = tex->get_x_size(); - int ysize_src = tex->get_y_size(); - CPTA_uchar src_image = tex->get_ram_image(); + CPTA_uchar src_image = tex->get_ram_mipmap_image(level); nassertv(!src_image.is_null()); const unsigned char *src = src_image.p(); @@ -2517,32 +2041,18 @@ copy_rgba_image(GLTexture *gltex, Texture *tex) { int co = cw - 1; #endif - int xsize_dest = gltex->xsize; - int ysize_dest = gltex->ysize; - unsigned char *dest = (unsigned char *)gltex->pixmap; - nassertv(dest != NULL); - - int sx_inc = (int)((float)(xsize_src) / (float)(xsize_dest)); - int sy_inc = (int)((float)(ysize_src) / (float)(ysize_dest)); - - unsigned char *dpix = dest; - int syn = 0; - for (int dy = 0; dy < ysize_dest; dy++) { - int sy = syn / ysize_dest; - int sxn = 0; - for (int dx = 0; dx < xsize_dest; dx++) { - int sx = sxn / xsize_dest; - const unsigned char *spix = src + (sy * xsize_src + sx) * 4 * cw; + unsigned char *dpix = (unsigned char *)dest->pixmap; + nassertv(dpix != NULL); + const unsigned char *spix = src; + int pixel_count = xsize * ysize; + while (pixel_count-- > 0) { + dpix[0] = spix[co]; + dpix[1] = spix[cw + co]; + dpix[2] = spix[cw + cw + co]; + dpix[3] = spix[cw + cw + cw + co]; - dpix[0] = spix[co]; - dpix[1] = spix[cw + co]; - dpix[2] = spix[cw + cw + co]; - dpix[3] = spix[cw + cw + cw + co]; - - dpix += 4; - sxn += xsize_src; - } - syn += ysize_src; + dpix += 4; + spix += 4 * cw; } } diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.h b/panda/src/tinydisplay/tinyGraphicsStateGuardian.h index d6badb941f..2178a8493b 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.h +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.h @@ -106,15 +106,15 @@ private: void apply_texture(TextureContext *tc); bool upload_texture(TinyTextureContext *gtc); - void setup_gltex(GLTexture *gltex, int orig_x_size, int orig_y_size); - void choose_tex_size(int &size, int &bits, int orig_size); + bool setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels); + int get_tex_shift(int orig_size); - static void copy_lum_image(GLTexture *gltex, Texture *tex); - static void copy_alpha_image(GLTexture *gltex, Texture *tex); - static void copy_one_channel_image(GLTexture *gltex, Texture *tex, int channel); - static void copy_la_image(GLTexture *gltex, Texture *tex); - static void copy_rgb_image(GLTexture *gltex, Texture *tex); - static void copy_rgba_image(GLTexture *gltex, Texture *tex); + static void copy_lum_image(ZTextureLevel *dest, int xsize, int ysize, Texture *tex, int level); + static void copy_alpha_image(ZTextureLevel *dest, int xsize, int ysize, Texture *tex, int level); + static void copy_one_channel_image(ZTextureLevel *dest, int xsize, int ysize, Texture *tex, int level, int channel); + static void copy_la_image(ZTextureLevel *dest, int xsize, int ysize, Texture *tex, int level); + static void copy_rgb_image(ZTextureLevel *dest, int xsize, int ysize, Texture *tex, int level); + static void copy_rgba_image(ZTextureLevel *dest, int xsize, int ysize, Texture *tex, int level); void setup_material(GLMaterial *gl_material, const Material *material); static void load_matrix(M4 *matrix, const TransformState *transform); @@ -135,6 +135,7 @@ private: CMF_diffuse = 0x002, }; int _color_material_flags; + int _texfilter_state; SimpleLru _textures_lru; diff --git a/panda/src/tinydisplay/tinyTextureContext.cxx b/panda/src/tinydisplay/tinyTextureContext.cxx index 8a9ddcf069..3293d84a16 100644 --- a/panda/src/tinydisplay/tinyTextureContext.cxx +++ b/panda/src/tinydisplay/tinyTextureContext.cxx @@ -40,10 +40,14 @@ void TinyTextureContext:: evict_lru() { dequeue_lru(); - if (_gltex->pixmap != NULL) { - gl_free(_gltex->pixmap); - _gltex->pixmap = NULL; + for (int i = 0; i < _gltex->num_levels; ++i) { + gl_free(_gltex->levels[i].pixmap); } + if (_gltex->levels != NULL) { + gl_free(_gltex->levels); + _gltex->levels = NULL; + } + _gltex->num_levels = 0; set_resident(false); } diff --git a/panda/src/tinydisplay/zbuffer.cxx b/panda/src/tinydisplay/zbuffer.cxx index aa7dc881fd..8a919004a3 100644 --- a/panda/src/tinydisplay/zbuffer.cxx +++ b/panda/src/tinydisplay/zbuffer.cxx @@ -67,7 +67,7 @@ ZBuffer *ZB_open(int xsize, int ysize, int mode, zb->pbuf = (PIXEL *)frame_buffer; } - zb->current_texture.pixmap = NULL; + zb->current_texture = NULL; return zb; error: @@ -343,18 +343,18 @@ void ZB_clear_viewport(ZBuffer * zb, int clear_z, ZPOINT z, #define ZB_ST_FRAC_HIGH (1 << ZB_POINT_ST_FRAC_BITS) #define ZB_ST_FRAC_MASK (ZB_ST_FRAC_HIGH - 1) -PIXEL lookup_texture_bilinear(ZTexture *texture, unsigned int s, unsigned int t) +PIXEL lookup_texture_bilinear(ZTextureLevel *base_level, int s, int t) { PIXEL p1, p2, p3, p4; - unsigned int sf, tf; - unsigned int r, g, b, a; + int sf, tf; + int r, g, b, a; - p1 = ZB_LOOKUP_TEXTURE_NEAREST(texture, s, t); - p2 = ZB_LOOKUP_TEXTURE_NEAREST(texture, s + ZB_ST_FRAC_HIGH, t); + p1 = ZB_LOOKUP_TEXTURE_NEAREST(base_level, s, t); + p2 = ZB_LOOKUP_TEXTURE_NEAREST(base_level, s + ZB_ST_FRAC_HIGH, t); sf = s & ZB_ST_FRAC_MASK; - p3 = ZB_LOOKUP_TEXTURE_NEAREST(texture, s, t + ZB_ST_FRAC_HIGH); - p4 = ZB_LOOKUP_TEXTURE_NEAREST(texture, s + ZB_ST_FRAC_HIGH, t + ZB_ST_FRAC_HIGH); + p3 = ZB_LOOKUP_TEXTURE_NEAREST(base_level, s, t + ZB_ST_FRAC_HIGH); + p4 = ZB_LOOKUP_TEXTURE_NEAREST(base_level, s + ZB_ST_FRAC_HIGH, t + ZB_ST_FRAC_HIGH); tf = t & ZB_ST_FRAC_MASK; r = (((PIXEL_R(p4) * sf + PIXEL_R(p3) * (ZB_ST_FRAC_HIGH - sf)) >> ZB_POINT_ST_FRAC_BITS) * tf + @@ -371,4 +371,3 @@ PIXEL lookup_texture_bilinear(ZTexture *texture, unsigned int s, unsigned int t) return RGBA_TO_PIXEL(r, g, b, a); } - diff --git a/panda/src/tinydisplay/zbuffer.h b/panda/src/tinydisplay/zbuffer.h index 3a78282b9a..05f159d378 100644 --- a/panda/src/tinydisplay/zbuffer.h +++ b/panda/src/tinydisplay/zbuffer.h @@ -6,6 +6,7 @@ */ #include "zfeatures.h" +#include "bitMask.h" typedef unsigned short ZPOINT; #define ZB_Z_BITS 16 @@ -19,25 +20,30 @@ typedef unsigned short ZPOINT; cannot exceed this number of bits).*/ #define ZB_POINT_ST_FRAC_BITS 12 -/* Returns the index within a texture for the given (s, t) texel. */ -#define ZB_TEXEL(texture, s, t) \ - ((((t) & (texture)->t_mask) >> (texture)->t_shift) | \ - (((s) & (texture)->s_mask) >> ZB_POINT_ST_FRAC_BITS)) +/* This is the theoretical max number of bits we have available to + shift down to achieve each next mipmap level, based on the size of + a 32-bit int. We need to preallocate mipmap arrays of this size. */ +#define MAX_MIPMAP_LEVELS (32 - ZB_POINT_ST_FRAC_BITS) -#define ZB_LOOKUP_TEXTURE_NEAREST(texture, s, t) \ - (texture)->pixmap[ZB_TEXEL(texture, s, t)] +/* Returns the index within a texture level for the given (s, t) texel. */ +#define ZB_TEXEL(level, s, t) \ + ((((t) & (level)->t_mask) >> (level)->t_shift) | \ + (((s) & (level)->s_mask) >> ZB_POINT_ST_FRAC_BITS)) -#if 1 -/* Use no texture filtering by default. It's faster, even though it - looks terrible. */ -#define ZB_LOOKUP_TEXTURE(texture, s, t) \ - ZB_LOOKUP_TEXTURE_NEAREST(texture, s, t) +#define ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) \ + (texture_levels)->pixmap[ZB_TEXEL(texture_levels, s, t)] -#else +#define ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) \ + ZB_LOOKUP_TEXTURE_NEAREST((texture_levels) + (level), (s) >> (level), (t) >> (level)) + +#define DO_CALC_MIPMAP_LEVEL \ + mipmap_level = count_bits_in_word(flood_bits_down((unsigned int)max(abs(dsdx), abs(dtdx)) >> ZB_POINT_ST_FRAC_BITS)) + +#if 0 /* Experiment with bilinear filtering. Looks great, but seems to run about 25% slower. */ -#define ZB_LOOKUP_TEXTURE(texture, s, t) \ - lookup_texture_bilinear((texture), (s), (t)) +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) \ + lookup_texture_bilinear((texture_levels), (s), (t)) #endif @@ -85,22 +91,22 @@ typedef unsigned int PIXEL; typedef struct { PIXEL *pixmap; unsigned int s_mask, t_mask, t_shift; -} ZTexture; +} ZTextureLevel; typedef struct { - int xsize,ysize; - int linesize; /* line size, in bytes */ - int mode; - - ZPOINT *zbuf; - PIXEL *pbuf; - int frame_buffer_allocated; - - int nb_colors; - unsigned char *dctable; - int *ctable; - ZTexture current_texture; - unsigned int reference_alpha; + int xsize,ysize; + int linesize; /* line size, in bytes */ + int mode; + + ZPOINT *zbuf; + PIXEL *pbuf; + int frame_buffer_allocated; + + int nb_colors; + unsigned char *dctable; + int *ctable; + ZTextureLevel *current_texture; // This is actually an array of texture levels. + unsigned int reference_alpha; } ZBuffer; typedef struct { @@ -129,7 +135,7 @@ void ZB_clear_viewport(ZBuffer * zb, int clear_z, ZPOINT z, int clear_color, unsigned int r, unsigned int g, unsigned int b, unsigned int a, int xmin, int ymin, int xsize, int ysize); -PIXEL lookup_texture_bilinear(ZTexture *texture, unsigned int s, unsigned int t); +PIXEL lookup_texture_bilinear(ZTextureLevel *base_level, int s, int t); /* linesize is in BYTES */ void ZB_copyFrameBuffer(ZBuffer *zb,void *buf,int linesize); diff --git a/panda/src/tinydisplay/zgl.h b/panda/src/tinydisplay/zgl.h index 20efc8760a..ee4bb699d1 100644 --- a/panda/src/tinydisplay/zgl.h +++ b/panda/src/tinydisplay/zgl.h @@ -113,10 +113,11 @@ typedef struct GLVertex { /* textures */ +/* The combination of all mipmap levels: one complete texture. */ typedef struct GLTexture { - PIXEL *pixmap; + ZTextureLevel *levels; + int num_levels; int xsize, ysize; - int s_mask, t_mask, t_shift; int s_max, t_max; } GLTexture; diff --git a/panda/src/tinydisplay/ztriangle.cxx b/panda/src/tinydisplay/ztriangle.cxx index 74b744e12d..0721a9f826 100644 --- a/panda/src/tinydisplay/ztriangle.cxx +++ b/panda/src/tinydisplay/ztriangle.cxx @@ -2,254 +2,8 @@ #include #include "zbuffer.h" -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) 1 -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zon_noblend_anone_znone -#include "ztriangle_two.h" +/* Pick up all of the generated code references to ztriangle_two.h, + which ultimately calls ztriangle.h, many, many times. */ -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) 1 -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zon_noblend_anone_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zon_noblend_aless_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zon_noblend_aless_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zon_noblend_amore_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zon_noblend_amore_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) 1 -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zon_blend_anone_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) 1 -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zon_blend_anone_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zon_blend_aless_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zon_blend_aless_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zon_blend_amore_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zon_blend_amore_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) 1 -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zon_nocolor_anone_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) 1 -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zon_nocolor_anone_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zon_nocolor_aless_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zon_nocolor_aless_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zon_nocolor_amore_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) (zpix) = (z) -#define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zon_nocolor_amore_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) 1 -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zoff_noblend_anone_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) 1 -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zoff_noblend_anone_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zoff_noblend_aless_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zoff_noblend_aless_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zoff_noblend_amore_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) -#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zoff_noblend_amore_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) 1 -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zoff_blend_anone_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) 1 -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zoff_blend_anone_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zoff_blend_aless_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zoff_blend_aless_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zoff_blend_amore_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zoff_blend_amore_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) 1 -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zoff_nocolor_anone_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) 1 -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zoff_nocolor_anone_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zoff_nocolor_aless_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) < (zb)->reference_alpha) -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zoff_nocolor_aless_zless -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) -#define ZCMP(zpix, z) 1 -#define FNAME(name) name ## _xx_zoff_nocolor_amore_znone -#include "ztriangle_two.h" - -#define STORE_Z(zpix, z) -#define STORE_PIX(pix, rgb, r, g, b, a) -#define ACMP(zb,a) (((unsigned int)(a)) > (zb)->reference_alpha) -#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) -#define FNAME(name) name ## _xx_zoff_nocolor_amore_zless -#include "ztriangle_two.h" +#include "ztriangle_table.h" +#include "ztriangle_code.h" diff --git a/panda/src/tinydisplay/ztriangle.h b/panda/src/tinydisplay/ztriangle.h index 916d9d2d08..3ad69b4a38 100644 --- a/panda/src/tinydisplay/ztriangle.h +++ b/panda/src/tinydisplay/ztriangle.h @@ -33,6 +33,9 @@ float sz1,dszdx,dszdy,dszdl_min,dszdl_max; float tz1,dtzdx,dtzdy,dtzdl_min,dtzdl_max; #endif +#if defined(INTERP_MIPMAP) && (defined(INTERP_ST) || defined(INTERP_STZ)) + int mipmap_level; +#endif EARLY_OUT(); @@ -111,6 +114,8 @@ d2 = (float) (p2->t - p0->t); dtdx = (int) (fdy2 * d1 - fdy1 * d2); dtdy = (int) (fdx1 * d2 - fdx2 * d1); + + CALC_MIPMAP_LEVEL; #endif #ifdef INTERP_STZ diff --git a/panda/src/tinydisplay/ztriangle.py b/panda/src/tinydisplay/ztriangle.py new file mode 100755 index 0000000000..8506376c08 --- /dev/null +++ b/panda/src/tinydisplay/ztriangle.py @@ -0,0 +1,160 @@ +""" This simple Python script can be run to generate ztriangle_code.h +and ztriangle_table.h, which are a poor man's form of generated code +to cover the explosion of different rendering options while scanning +out triangles. + +Each different combination of options is compiled to a different +inner-loop triangle scan function. The code in +tinyGraphicsStateGuardian.cxx will select the appropriate function +pointer at draw time. """ + +# We generate an #include "ztriangle_two.h" for each combination of +# these options. +Options = [ + # depth write + [ 'zon', 'zoff' ], + + # color write + [ 'noblend', 'blend', 'nocolor' ], + + # alpha test + [ 'anone', 'aless', 'amore' ], + + # depth test + [ 'znone', 'zless' ], + + # texture filters + [ 'nearest', 'mipmap' ], + ] + +# The various combinations of these options are explicit within +# ztriangle_two.h. +ExtraOptions = [ + # shading + [ 'white', 'flat', 'smooth' ], + + # texturing + [ 'untextured', 'textured', 'perspective' ], + ] + +FullOptions = Options + ExtraOptions + +CodeTable = { + # depth write + 'zon' : '#define STORE_Z(zpix, z) (zpix) = (z)', + 'zoff' : '#define STORE_Z(zpix, z)', + + # color write + 'noblend' : '#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)', + 'blend' : '#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)', + 'nocolor' : '#define STORE_PIX(pix, rgb, r, g, b, a)', + + # alpha test + 'anone' : '#define ACMP(zb, a) 1', + 'aless' : '#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha)', + 'amore' : '#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha)', + + # depth test + 'znone' : '#define ZCMP(zpix, z) 1', + 'zless' : '#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z))', + + # texture filters + 'nearest' : '#define CALC_MIPMAP_LEVEL\n#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t)', + 'mipmap' : '#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL\n#define INTERP_MIPMAP\n#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level)', +} + +ops = [0] * len(Options) + +class DoneException: + pass + +def incrementOptions(ops, i = -1): + if i < -len(ops): + raise DoneException + + # Increment the least-significant place if we can. + if ops[i] + 1 < len(Options[i]): + ops[i] += 1 + return + + # Recurse for the next-most-significant place. + ops[i] = 0 + incrementOptions(ops, i - 1) + +def getFname(ops): + # Returns the function name corresponding to the indicated ops + # vector. + keywordList = [] + for i in range(len(ops)): + keyword = FullOptions[i][ops[i]] + keywordList.append(keyword) + + fname = 'FB_triangle_%s' % ('_'.join(keywordList)) + return fname + +# We write the code that actually instantiates the various +# triangle-filling functions to ztriangle_code.h. +code = open('ztriangle_code.h', 'wb') +print >> code, '/* This file is generated code--do not edit. See ztriangle.py. */' +print >> code, '' + +# The external reference for the table containing the above function +# pointers gets written here. +table = open('ztriangle_table.h', 'wb') +print >> table, '/* This file is generated code--do not edit. See ztriangle.py. */' +print >> table, '' + +# First, generate the code. +try: + while True: + for i in range(len(ops)): + keyword = Options[i][ops[i]] + print >> code, CodeTable[keyword] + + fname = getFname(ops) + print >> code, '#define FNAME(name) %s_ ## name' % (fname) + print >> code, '#include "ztriangle_two.h"' + print >> code, '' + + incrementOptions(ops) + +except DoneException: + pass + + +# Now, generate the table of function pointers. +arraySizeList = [] +for opList in FullOptions: + arraySizeList.append('[%s]' % (len(opList))) +arraySize = ''.join(arraySizeList) + +print >> code, 'const ZB_fillTriangleFunc fill_tri_funcs%s = {' % (arraySize) +print >> table, 'extern const ZB_fillTriangleFunc fill_tri_funcs%s;' % (arraySize) + +def writeTableEntry(ops): + indent = ' ' * (len(ops) + 1) + i = len(ops) + numOps = len(FullOptions[i]) + + if i + 1 == len(FullOptions): + # The last level: write out the actual function names. + for j in range(numOps - 1): + print >> code, indent + getFname(ops + [j]) + ',' + print >> code, indent + getFname(ops + [numOps - 1]) + + else: + # Intermediate levels: write out a nested reference. + for j in range(numOps - 1): + print >> code, indent + '{' + writeTableEntry(ops + [j]) + print >> code, indent + '},' + print >> code, indent + '{' + writeTableEntry(ops + [numOps - 1]) + print >> code, indent + '}' + +writeTableEntry([]) +print >> code, '};' + + + + diff --git a/panda/src/tinydisplay/ztriangle_code.h b/panda/src/tinydisplay/ztriangle_code.h new file mode 100755 index 0000000000..65165ed165 --- /dev/null +++ b/panda/src/tinydisplay/ztriangle_code.h @@ -0,0 +1,2036 @@ +/* This file is generated code--do not edit. See ztriangle.py. */ + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_noblend_anone_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_noblend_anone_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_noblend_anone_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_noblend_anone_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_noblend_aless_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_noblend_aless_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_noblend_aless_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_noblend_aless_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_noblend_amore_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_noblend_amore_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_noblend_amore_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_noblend_amore_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_blend_anone_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_blend_anone_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_blend_anone_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_blend_anone_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_blend_aless_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_blend_aless_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_blend_aless_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_blend_aless_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_blend_amore_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_blend_amore_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_blend_amore_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_blend_amore_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_nocolor_anone_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_nocolor_anone_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_nocolor_anone_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_nocolor_anone_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_nocolor_aless_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_nocolor_aless_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_nocolor_aless_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_nocolor_aless_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_nocolor_amore_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_nocolor_amore_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zon_nocolor_amore_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) (zpix) = (z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zon_nocolor_amore_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_noblend_anone_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_noblend_anone_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_noblend_anone_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_noblend_anone_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_noblend_aless_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_noblend_aless_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_noblend_aless_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_noblend_aless_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_noblend_amore_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_noblend_amore_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_noblend_amore_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_noblend_amore_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_blend_anone_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_blend_anone_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_blend_anone_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_blend_anone_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_blend_aless_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_blend_aless_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_blend_aless_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_blend_aless_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_blend_amore_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_blend_amore_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_blend_amore_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_blend_amore_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_nocolor_anone_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_nocolor_anone_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_nocolor_anone_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) 1 +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_nocolor_anone_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_nocolor_aless_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_nocolor_aless_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_nocolor_aless_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) < (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_nocolor_aless_zless_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_nocolor_amore_znone_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) 1 +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_nocolor_amore_znone_mipmap_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST(texture_levels, s, t) +#define FNAME(name) FB_triangle_zoff_nocolor_amore_zless_nearest_ ## name +#include "ztriangle_two.h" + +#define STORE_Z(zpix, z) +#define STORE_PIX(pix, rgb, r, g, b, a) +#define ACMP(zb, a) (((unsigned int)(a)) > (zb)->reference_alpha) +#define ZCMP(zpix, z) ((ZPOINT)(zpix) < (ZPOINT)(z)) +#define CALC_MIPMAP_LEVEL DO_CALC_MIPMAP_LEVEL +#define INTERP_MIPMAP +#define ZB_LOOKUP_TEXTURE(texture_levels, s, t, level) ZB_LOOKUP_TEXTURE_NEAREST_MIPMAP(texture_levels, s, t, level) +#define FNAME(name) FB_triangle_zoff_nocolor_amore_zless_mipmap_ ## name +#include "ztriangle_two.h" + +const ZB_fillTriangleFunc fill_tri_funcs[2][3][3][2][2][3][3] = { + { + { + { + { + { + { + FB_triangle_zon_noblend_anone_znone_nearest_white_untextured, + FB_triangle_zon_noblend_anone_znone_nearest_white_textured, + FB_triangle_zon_noblend_anone_znone_nearest_white_perspective + }, + { + FB_triangle_zon_noblend_anone_znone_nearest_flat_untextured, + FB_triangle_zon_noblend_anone_znone_nearest_flat_textured, + FB_triangle_zon_noblend_anone_znone_nearest_flat_perspective + }, + { + FB_triangle_zon_noblend_anone_znone_nearest_smooth_untextured, + FB_triangle_zon_noblend_anone_znone_nearest_smooth_textured, + FB_triangle_zon_noblend_anone_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_noblend_anone_znone_mipmap_white_untextured, + FB_triangle_zon_noblend_anone_znone_mipmap_white_textured, + FB_triangle_zon_noblend_anone_znone_mipmap_white_perspective + }, + { + FB_triangle_zon_noblend_anone_znone_mipmap_flat_untextured, + FB_triangle_zon_noblend_anone_znone_mipmap_flat_textured, + FB_triangle_zon_noblend_anone_znone_mipmap_flat_perspective + }, + { + FB_triangle_zon_noblend_anone_znone_mipmap_smooth_untextured, + FB_triangle_zon_noblend_anone_znone_mipmap_smooth_textured, + FB_triangle_zon_noblend_anone_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zon_noblend_anone_zless_nearest_white_untextured, + FB_triangle_zon_noblend_anone_zless_nearest_white_textured, + FB_triangle_zon_noblend_anone_zless_nearest_white_perspective + }, + { + FB_triangle_zon_noblend_anone_zless_nearest_flat_untextured, + FB_triangle_zon_noblend_anone_zless_nearest_flat_textured, + FB_triangle_zon_noblend_anone_zless_nearest_flat_perspective + }, + { + FB_triangle_zon_noblend_anone_zless_nearest_smooth_untextured, + FB_triangle_zon_noblend_anone_zless_nearest_smooth_textured, + FB_triangle_zon_noblend_anone_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_noblend_anone_zless_mipmap_white_untextured, + FB_triangle_zon_noblend_anone_zless_mipmap_white_textured, + FB_triangle_zon_noblend_anone_zless_mipmap_white_perspective + }, + { + FB_triangle_zon_noblend_anone_zless_mipmap_flat_untextured, + FB_triangle_zon_noblend_anone_zless_mipmap_flat_textured, + FB_triangle_zon_noblend_anone_zless_mipmap_flat_perspective + }, + { + FB_triangle_zon_noblend_anone_zless_mipmap_smooth_untextured, + FB_triangle_zon_noblend_anone_zless_mipmap_smooth_textured, + FB_triangle_zon_noblend_anone_zless_mipmap_smooth_perspective + } + } + } + }, + { + { + { + { + FB_triangle_zon_noblend_aless_znone_nearest_white_untextured, + FB_triangle_zon_noblend_aless_znone_nearest_white_textured, + FB_triangle_zon_noblend_aless_znone_nearest_white_perspective + }, + { + FB_triangle_zon_noblend_aless_znone_nearest_flat_untextured, + FB_triangle_zon_noblend_aless_znone_nearest_flat_textured, + FB_triangle_zon_noblend_aless_znone_nearest_flat_perspective + }, + { + FB_triangle_zon_noblend_aless_znone_nearest_smooth_untextured, + FB_triangle_zon_noblend_aless_znone_nearest_smooth_textured, + FB_triangle_zon_noblend_aless_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_noblend_aless_znone_mipmap_white_untextured, + FB_triangle_zon_noblend_aless_znone_mipmap_white_textured, + FB_triangle_zon_noblend_aless_znone_mipmap_white_perspective + }, + { + FB_triangle_zon_noblend_aless_znone_mipmap_flat_untextured, + FB_triangle_zon_noblend_aless_znone_mipmap_flat_textured, + FB_triangle_zon_noblend_aless_znone_mipmap_flat_perspective + }, + { + FB_triangle_zon_noblend_aless_znone_mipmap_smooth_untextured, + FB_triangle_zon_noblend_aless_znone_mipmap_smooth_textured, + FB_triangle_zon_noblend_aless_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zon_noblend_aless_zless_nearest_white_untextured, + FB_triangle_zon_noblend_aless_zless_nearest_white_textured, + FB_triangle_zon_noblend_aless_zless_nearest_white_perspective + }, + { + FB_triangle_zon_noblend_aless_zless_nearest_flat_untextured, + FB_triangle_zon_noblend_aless_zless_nearest_flat_textured, + FB_triangle_zon_noblend_aless_zless_nearest_flat_perspective + }, + { + FB_triangle_zon_noblend_aless_zless_nearest_smooth_untextured, + FB_triangle_zon_noblend_aless_zless_nearest_smooth_textured, + FB_triangle_zon_noblend_aless_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_noblend_aless_zless_mipmap_white_untextured, + FB_triangle_zon_noblend_aless_zless_mipmap_white_textured, + FB_triangle_zon_noblend_aless_zless_mipmap_white_perspective + }, + { + FB_triangle_zon_noblend_aless_zless_mipmap_flat_untextured, + FB_triangle_zon_noblend_aless_zless_mipmap_flat_textured, + FB_triangle_zon_noblend_aless_zless_mipmap_flat_perspective + }, + { + FB_triangle_zon_noblend_aless_zless_mipmap_smooth_untextured, + FB_triangle_zon_noblend_aless_zless_mipmap_smooth_textured, + FB_triangle_zon_noblend_aless_zless_mipmap_smooth_perspective + } + } + } + }, + { + { + { + { + FB_triangle_zon_noblend_amore_znone_nearest_white_untextured, + FB_triangle_zon_noblend_amore_znone_nearest_white_textured, + FB_triangle_zon_noblend_amore_znone_nearest_white_perspective + }, + { + FB_triangle_zon_noblend_amore_znone_nearest_flat_untextured, + FB_triangle_zon_noblend_amore_znone_nearest_flat_textured, + FB_triangle_zon_noblend_amore_znone_nearest_flat_perspective + }, + { + FB_triangle_zon_noblend_amore_znone_nearest_smooth_untextured, + FB_triangle_zon_noblend_amore_znone_nearest_smooth_textured, + FB_triangle_zon_noblend_amore_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_noblend_amore_znone_mipmap_white_untextured, + FB_triangle_zon_noblend_amore_znone_mipmap_white_textured, + FB_triangle_zon_noblend_amore_znone_mipmap_white_perspective + }, + { + FB_triangle_zon_noblend_amore_znone_mipmap_flat_untextured, + FB_triangle_zon_noblend_amore_znone_mipmap_flat_textured, + FB_triangle_zon_noblend_amore_znone_mipmap_flat_perspective + }, + { + FB_triangle_zon_noblend_amore_znone_mipmap_smooth_untextured, + FB_triangle_zon_noblend_amore_znone_mipmap_smooth_textured, + FB_triangle_zon_noblend_amore_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zon_noblend_amore_zless_nearest_white_untextured, + FB_triangle_zon_noblend_amore_zless_nearest_white_textured, + FB_triangle_zon_noblend_amore_zless_nearest_white_perspective + }, + { + FB_triangle_zon_noblend_amore_zless_nearest_flat_untextured, + FB_triangle_zon_noblend_amore_zless_nearest_flat_textured, + FB_triangle_zon_noblend_amore_zless_nearest_flat_perspective + }, + { + FB_triangle_zon_noblend_amore_zless_nearest_smooth_untextured, + FB_triangle_zon_noblend_amore_zless_nearest_smooth_textured, + FB_triangle_zon_noblend_amore_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_noblend_amore_zless_mipmap_white_untextured, + FB_triangle_zon_noblend_amore_zless_mipmap_white_textured, + FB_triangle_zon_noblend_amore_zless_mipmap_white_perspective + }, + { + FB_triangle_zon_noblend_amore_zless_mipmap_flat_untextured, + FB_triangle_zon_noblend_amore_zless_mipmap_flat_textured, + FB_triangle_zon_noblend_amore_zless_mipmap_flat_perspective + }, + { + FB_triangle_zon_noblend_amore_zless_mipmap_smooth_untextured, + FB_triangle_zon_noblend_amore_zless_mipmap_smooth_textured, + FB_triangle_zon_noblend_amore_zless_mipmap_smooth_perspective + } + } + } + } + }, + { + { + { + { + { + FB_triangle_zon_blend_anone_znone_nearest_white_untextured, + FB_triangle_zon_blend_anone_znone_nearest_white_textured, + FB_triangle_zon_blend_anone_znone_nearest_white_perspective + }, + { + FB_triangle_zon_blend_anone_znone_nearest_flat_untextured, + FB_triangle_zon_blend_anone_znone_nearest_flat_textured, + FB_triangle_zon_blend_anone_znone_nearest_flat_perspective + }, + { + FB_triangle_zon_blend_anone_znone_nearest_smooth_untextured, + FB_triangle_zon_blend_anone_znone_nearest_smooth_textured, + FB_triangle_zon_blend_anone_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_blend_anone_znone_mipmap_white_untextured, + FB_triangle_zon_blend_anone_znone_mipmap_white_textured, + FB_triangle_zon_blend_anone_znone_mipmap_white_perspective + }, + { + FB_triangle_zon_blend_anone_znone_mipmap_flat_untextured, + FB_triangle_zon_blend_anone_znone_mipmap_flat_textured, + FB_triangle_zon_blend_anone_znone_mipmap_flat_perspective + }, + { + FB_triangle_zon_blend_anone_znone_mipmap_smooth_untextured, + FB_triangle_zon_blend_anone_znone_mipmap_smooth_textured, + FB_triangle_zon_blend_anone_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zon_blend_anone_zless_nearest_white_untextured, + FB_triangle_zon_blend_anone_zless_nearest_white_textured, + FB_triangle_zon_blend_anone_zless_nearest_white_perspective + }, + { + FB_triangle_zon_blend_anone_zless_nearest_flat_untextured, + FB_triangle_zon_blend_anone_zless_nearest_flat_textured, + FB_triangle_zon_blend_anone_zless_nearest_flat_perspective + }, + { + FB_triangle_zon_blend_anone_zless_nearest_smooth_untextured, + FB_triangle_zon_blend_anone_zless_nearest_smooth_textured, + FB_triangle_zon_blend_anone_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_blend_anone_zless_mipmap_white_untextured, + FB_triangle_zon_blend_anone_zless_mipmap_white_textured, + FB_triangle_zon_blend_anone_zless_mipmap_white_perspective + }, + { + FB_triangle_zon_blend_anone_zless_mipmap_flat_untextured, + FB_triangle_zon_blend_anone_zless_mipmap_flat_textured, + FB_triangle_zon_blend_anone_zless_mipmap_flat_perspective + }, + { + FB_triangle_zon_blend_anone_zless_mipmap_smooth_untextured, + FB_triangle_zon_blend_anone_zless_mipmap_smooth_textured, + FB_triangle_zon_blend_anone_zless_mipmap_smooth_perspective + } + } + } + }, + { + { + { + { + FB_triangle_zon_blend_aless_znone_nearest_white_untextured, + FB_triangle_zon_blend_aless_znone_nearest_white_textured, + FB_triangle_zon_blend_aless_znone_nearest_white_perspective + }, + { + FB_triangle_zon_blend_aless_znone_nearest_flat_untextured, + FB_triangle_zon_blend_aless_znone_nearest_flat_textured, + FB_triangle_zon_blend_aless_znone_nearest_flat_perspective + }, + { + FB_triangle_zon_blend_aless_znone_nearest_smooth_untextured, + FB_triangle_zon_blend_aless_znone_nearest_smooth_textured, + FB_triangle_zon_blend_aless_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_blend_aless_znone_mipmap_white_untextured, + FB_triangle_zon_blend_aless_znone_mipmap_white_textured, + FB_triangle_zon_blend_aless_znone_mipmap_white_perspective + }, + { + FB_triangle_zon_blend_aless_znone_mipmap_flat_untextured, + FB_triangle_zon_blend_aless_znone_mipmap_flat_textured, + FB_triangle_zon_blend_aless_znone_mipmap_flat_perspective + }, + { + FB_triangle_zon_blend_aless_znone_mipmap_smooth_untextured, + FB_triangle_zon_blend_aless_znone_mipmap_smooth_textured, + FB_triangle_zon_blend_aless_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zon_blend_aless_zless_nearest_white_untextured, + FB_triangle_zon_blend_aless_zless_nearest_white_textured, + FB_triangle_zon_blend_aless_zless_nearest_white_perspective + }, + { + FB_triangle_zon_blend_aless_zless_nearest_flat_untextured, + FB_triangle_zon_blend_aless_zless_nearest_flat_textured, + FB_triangle_zon_blend_aless_zless_nearest_flat_perspective + }, + { + FB_triangle_zon_blend_aless_zless_nearest_smooth_untextured, + FB_triangle_zon_blend_aless_zless_nearest_smooth_textured, + FB_triangle_zon_blend_aless_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_blend_aless_zless_mipmap_white_untextured, + FB_triangle_zon_blend_aless_zless_mipmap_white_textured, + FB_triangle_zon_blend_aless_zless_mipmap_white_perspective + }, + { + FB_triangle_zon_blend_aless_zless_mipmap_flat_untextured, + FB_triangle_zon_blend_aless_zless_mipmap_flat_textured, + FB_triangle_zon_blend_aless_zless_mipmap_flat_perspective + }, + { + FB_triangle_zon_blend_aless_zless_mipmap_smooth_untextured, + FB_triangle_zon_blend_aless_zless_mipmap_smooth_textured, + FB_triangle_zon_blend_aless_zless_mipmap_smooth_perspective + } + } + } + }, + { + { + { + { + FB_triangle_zon_blend_amore_znone_nearest_white_untextured, + FB_triangle_zon_blend_amore_znone_nearest_white_textured, + FB_triangle_zon_blend_amore_znone_nearest_white_perspective + }, + { + FB_triangle_zon_blend_amore_znone_nearest_flat_untextured, + FB_triangle_zon_blend_amore_znone_nearest_flat_textured, + FB_triangle_zon_blend_amore_znone_nearest_flat_perspective + }, + { + FB_triangle_zon_blend_amore_znone_nearest_smooth_untextured, + FB_triangle_zon_blend_amore_znone_nearest_smooth_textured, + FB_triangle_zon_blend_amore_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_blend_amore_znone_mipmap_white_untextured, + FB_triangle_zon_blend_amore_znone_mipmap_white_textured, + FB_triangle_zon_blend_amore_znone_mipmap_white_perspective + }, + { + FB_triangle_zon_blend_amore_znone_mipmap_flat_untextured, + FB_triangle_zon_blend_amore_znone_mipmap_flat_textured, + FB_triangle_zon_blend_amore_znone_mipmap_flat_perspective + }, + { + FB_triangle_zon_blend_amore_znone_mipmap_smooth_untextured, + FB_triangle_zon_blend_amore_znone_mipmap_smooth_textured, + FB_triangle_zon_blend_amore_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zon_blend_amore_zless_nearest_white_untextured, + FB_triangle_zon_blend_amore_zless_nearest_white_textured, + FB_triangle_zon_blend_amore_zless_nearest_white_perspective + }, + { + FB_triangle_zon_blend_amore_zless_nearest_flat_untextured, + FB_triangle_zon_blend_amore_zless_nearest_flat_textured, + FB_triangle_zon_blend_amore_zless_nearest_flat_perspective + }, + { + FB_triangle_zon_blend_amore_zless_nearest_smooth_untextured, + FB_triangle_zon_blend_amore_zless_nearest_smooth_textured, + FB_triangle_zon_blend_amore_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_blend_amore_zless_mipmap_white_untextured, + FB_triangle_zon_blend_amore_zless_mipmap_white_textured, + FB_triangle_zon_blend_amore_zless_mipmap_white_perspective + }, + { + FB_triangle_zon_blend_amore_zless_mipmap_flat_untextured, + FB_triangle_zon_blend_amore_zless_mipmap_flat_textured, + FB_triangle_zon_blend_amore_zless_mipmap_flat_perspective + }, + { + FB_triangle_zon_blend_amore_zless_mipmap_smooth_untextured, + FB_triangle_zon_blend_amore_zless_mipmap_smooth_textured, + FB_triangle_zon_blend_amore_zless_mipmap_smooth_perspective + } + } + } + } + }, + { + { + { + { + { + FB_triangle_zon_nocolor_anone_znone_nearest_white_untextured, + FB_triangle_zon_nocolor_anone_znone_nearest_white_textured, + FB_triangle_zon_nocolor_anone_znone_nearest_white_perspective + }, + { + FB_triangle_zon_nocolor_anone_znone_nearest_flat_untextured, + FB_triangle_zon_nocolor_anone_znone_nearest_flat_textured, + FB_triangle_zon_nocolor_anone_znone_nearest_flat_perspective + }, + { + FB_triangle_zon_nocolor_anone_znone_nearest_smooth_untextured, + FB_triangle_zon_nocolor_anone_znone_nearest_smooth_textured, + FB_triangle_zon_nocolor_anone_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_nocolor_anone_znone_mipmap_white_untextured, + FB_triangle_zon_nocolor_anone_znone_mipmap_white_textured, + FB_triangle_zon_nocolor_anone_znone_mipmap_white_perspective + }, + { + FB_triangle_zon_nocolor_anone_znone_mipmap_flat_untextured, + FB_triangle_zon_nocolor_anone_znone_mipmap_flat_textured, + FB_triangle_zon_nocolor_anone_znone_mipmap_flat_perspective + }, + { + FB_triangle_zon_nocolor_anone_znone_mipmap_smooth_untextured, + FB_triangle_zon_nocolor_anone_znone_mipmap_smooth_textured, + FB_triangle_zon_nocolor_anone_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zon_nocolor_anone_zless_nearest_white_untextured, + FB_triangle_zon_nocolor_anone_zless_nearest_white_textured, + FB_triangle_zon_nocolor_anone_zless_nearest_white_perspective + }, + { + FB_triangle_zon_nocolor_anone_zless_nearest_flat_untextured, + FB_triangle_zon_nocolor_anone_zless_nearest_flat_textured, + FB_triangle_zon_nocolor_anone_zless_nearest_flat_perspective + }, + { + FB_triangle_zon_nocolor_anone_zless_nearest_smooth_untextured, + FB_triangle_zon_nocolor_anone_zless_nearest_smooth_textured, + FB_triangle_zon_nocolor_anone_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_nocolor_anone_zless_mipmap_white_untextured, + FB_triangle_zon_nocolor_anone_zless_mipmap_white_textured, + FB_triangle_zon_nocolor_anone_zless_mipmap_white_perspective + }, + { + FB_triangle_zon_nocolor_anone_zless_mipmap_flat_untextured, + FB_triangle_zon_nocolor_anone_zless_mipmap_flat_textured, + FB_triangle_zon_nocolor_anone_zless_mipmap_flat_perspective + }, + { + FB_triangle_zon_nocolor_anone_zless_mipmap_smooth_untextured, + FB_triangle_zon_nocolor_anone_zless_mipmap_smooth_textured, + FB_triangle_zon_nocolor_anone_zless_mipmap_smooth_perspective + } + } + } + }, + { + { + { + { + FB_triangle_zon_nocolor_aless_znone_nearest_white_untextured, + FB_triangle_zon_nocolor_aless_znone_nearest_white_textured, + FB_triangle_zon_nocolor_aless_znone_nearest_white_perspective + }, + { + FB_triangle_zon_nocolor_aless_znone_nearest_flat_untextured, + FB_triangle_zon_nocolor_aless_znone_nearest_flat_textured, + FB_triangle_zon_nocolor_aless_znone_nearest_flat_perspective + }, + { + FB_triangle_zon_nocolor_aless_znone_nearest_smooth_untextured, + FB_triangle_zon_nocolor_aless_znone_nearest_smooth_textured, + FB_triangle_zon_nocolor_aless_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_nocolor_aless_znone_mipmap_white_untextured, + FB_triangle_zon_nocolor_aless_znone_mipmap_white_textured, + FB_triangle_zon_nocolor_aless_znone_mipmap_white_perspective + }, + { + FB_triangle_zon_nocolor_aless_znone_mipmap_flat_untextured, + FB_triangle_zon_nocolor_aless_znone_mipmap_flat_textured, + FB_triangle_zon_nocolor_aless_znone_mipmap_flat_perspective + }, + { + FB_triangle_zon_nocolor_aless_znone_mipmap_smooth_untextured, + FB_triangle_zon_nocolor_aless_znone_mipmap_smooth_textured, + FB_triangle_zon_nocolor_aless_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zon_nocolor_aless_zless_nearest_white_untextured, + FB_triangle_zon_nocolor_aless_zless_nearest_white_textured, + FB_triangle_zon_nocolor_aless_zless_nearest_white_perspective + }, + { + FB_triangle_zon_nocolor_aless_zless_nearest_flat_untextured, + FB_triangle_zon_nocolor_aless_zless_nearest_flat_textured, + FB_triangle_zon_nocolor_aless_zless_nearest_flat_perspective + }, + { + FB_triangle_zon_nocolor_aless_zless_nearest_smooth_untextured, + FB_triangle_zon_nocolor_aless_zless_nearest_smooth_textured, + FB_triangle_zon_nocolor_aless_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_nocolor_aless_zless_mipmap_white_untextured, + FB_triangle_zon_nocolor_aless_zless_mipmap_white_textured, + FB_triangle_zon_nocolor_aless_zless_mipmap_white_perspective + }, + { + FB_triangle_zon_nocolor_aless_zless_mipmap_flat_untextured, + FB_triangle_zon_nocolor_aless_zless_mipmap_flat_textured, + FB_triangle_zon_nocolor_aless_zless_mipmap_flat_perspective + }, + { + FB_triangle_zon_nocolor_aless_zless_mipmap_smooth_untextured, + FB_triangle_zon_nocolor_aless_zless_mipmap_smooth_textured, + FB_triangle_zon_nocolor_aless_zless_mipmap_smooth_perspective + } + } + } + }, + { + { + { + { + FB_triangle_zon_nocolor_amore_znone_nearest_white_untextured, + FB_triangle_zon_nocolor_amore_znone_nearest_white_textured, + FB_triangle_zon_nocolor_amore_znone_nearest_white_perspective + }, + { + FB_triangle_zon_nocolor_amore_znone_nearest_flat_untextured, + FB_triangle_zon_nocolor_amore_znone_nearest_flat_textured, + FB_triangle_zon_nocolor_amore_znone_nearest_flat_perspective + }, + { + FB_triangle_zon_nocolor_amore_znone_nearest_smooth_untextured, + FB_triangle_zon_nocolor_amore_znone_nearest_smooth_textured, + FB_triangle_zon_nocolor_amore_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_nocolor_amore_znone_mipmap_white_untextured, + FB_triangle_zon_nocolor_amore_znone_mipmap_white_textured, + FB_triangle_zon_nocolor_amore_znone_mipmap_white_perspective + }, + { + FB_triangle_zon_nocolor_amore_znone_mipmap_flat_untextured, + FB_triangle_zon_nocolor_amore_znone_mipmap_flat_textured, + FB_triangle_zon_nocolor_amore_znone_mipmap_flat_perspective + }, + { + FB_triangle_zon_nocolor_amore_znone_mipmap_smooth_untextured, + FB_triangle_zon_nocolor_amore_znone_mipmap_smooth_textured, + FB_triangle_zon_nocolor_amore_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zon_nocolor_amore_zless_nearest_white_untextured, + FB_triangle_zon_nocolor_amore_zless_nearest_white_textured, + FB_triangle_zon_nocolor_amore_zless_nearest_white_perspective + }, + { + FB_triangle_zon_nocolor_amore_zless_nearest_flat_untextured, + FB_triangle_zon_nocolor_amore_zless_nearest_flat_textured, + FB_triangle_zon_nocolor_amore_zless_nearest_flat_perspective + }, + { + FB_triangle_zon_nocolor_amore_zless_nearest_smooth_untextured, + FB_triangle_zon_nocolor_amore_zless_nearest_smooth_textured, + FB_triangle_zon_nocolor_amore_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zon_nocolor_amore_zless_mipmap_white_untextured, + FB_triangle_zon_nocolor_amore_zless_mipmap_white_textured, + FB_triangle_zon_nocolor_amore_zless_mipmap_white_perspective + }, + { + FB_triangle_zon_nocolor_amore_zless_mipmap_flat_untextured, + FB_triangle_zon_nocolor_amore_zless_mipmap_flat_textured, + FB_triangle_zon_nocolor_amore_zless_mipmap_flat_perspective + }, + { + FB_triangle_zon_nocolor_amore_zless_mipmap_smooth_untextured, + FB_triangle_zon_nocolor_amore_zless_mipmap_smooth_textured, + FB_triangle_zon_nocolor_amore_zless_mipmap_smooth_perspective + } + } + } + } + } + }, + { + { + { + { + { + { + FB_triangle_zoff_noblend_anone_znone_nearest_white_untextured, + FB_triangle_zoff_noblend_anone_znone_nearest_white_textured, + FB_triangle_zoff_noblend_anone_znone_nearest_white_perspective + }, + { + FB_triangle_zoff_noblend_anone_znone_nearest_flat_untextured, + FB_triangle_zoff_noblend_anone_znone_nearest_flat_textured, + FB_triangle_zoff_noblend_anone_znone_nearest_flat_perspective + }, + { + FB_triangle_zoff_noblend_anone_znone_nearest_smooth_untextured, + FB_triangle_zoff_noblend_anone_znone_nearest_smooth_textured, + FB_triangle_zoff_noblend_anone_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_noblend_anone_znone_mipmap_white_untextured, + FB_triangle_zoff_noblend_anone_znone_mipmap_white_textured, + FB_triangle_zoff_noblend_anone_znone_mipmap_white_perspective + }, + { + FB_triangle_zoff_noblend_anone_znone_mipmap_flat_untextured, + FB_triangle_zoff_noblend_anone_znone_mipmap_flat_textured, + FB_triangle_zoff_noblend_anone_znone_mipmap_flat_perspective + }, + { + FB_triangle_zoff_noblend_anone_znone_mipmap_smooth_untextured, + FB_triangle_zoff_noblend_anone_znone_mipmap_smooth_textured, + FB_triangle_zoff_noblend_anone_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zoff_noblend_anone_zless_nearest_white_untextured, + FB_triangle_zoff_noblend_anone_zless_nearest_white_textured, + FB_triangle_zoff_noblend_anone_zless_nearest_white_perspective + }, + { + FB_triangle_zoff_noblend_anone_zless_nearest_flat_untextured, + FB_triangle_zoff_noblend_anone_zless_nearest_flat_textured, + FB_triangle_zoff_noblend_anone_zless_nearest_flat_perspective + }, + { + FB_triangle_zoff_noblend_anone_zless_nearest_smooth_untextured, + FB_triangle_zoff_noblend_anone_zless_nearest_smooth_textured, + FB_triangle_zoff_noblend_anone_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_noblend_anone_zless_mipmap_white_untextured, + FB_triangle_zoff_noblend_anone_zless_mipmap_white_textured, + FB_triangle_zoff_noblend_anone_zless_mipmap_white_perspective + }, + { + FB_triangle_zoff_noblend_anone_zless_mipmap_flat_untextured, + FB_triangle_zoff_noblend_anone_zless_mipmap_flat_textured, + FB_triangle_zoff_noblend_anone_zless_mipmap_flat_perspective + }, + { + FB_triangle_zoff_noblend_anone_zless_mipmap_smooth_untextured, + FB_triangle_zoff_noblend_anone_zless_mipmap_smooth_textured, + FB_triangle_zoff_noblend_anone_zless_mipmap_smooth_perspective + } + } + } + }, + { + { + { + { + FB_triangle_zoff_noblend_aless_znone_nearest_white_untextured, + FB_triangle_zoff_noblend_aless_znone_nearest_white_textured, + FB_triangle_zoff_noblend_aless_znone_nearest_white_perspective + }, + { + FB_triangle_zoff_noblend_aless_znone_nearest_flat_untextured, + FB_triangle_zoff_noblend_aless_znone_nearest_flat_textured, + FB_triangle_zoff_noblend_aless_znone_nearest_flat_perspective + }, + { + FB_triangle_zoff_noblend_aless_znone_nearest_smooth_untextured, + FB_triangle_zoff_noblend_aless_znone_nearest_smooth_textured, + FB_triangle_zoff_noblend_aless_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_noblend_aless_znone_mipmap_white_untextured, + FB_triangle_zoff_noblend_aless_znone_mipmap_white_textured, + FB_triangle_zoff_noblend_aless_znone_mipmap_white_perspective + }, + { + FB_triangle_zoff_noblend_aless_znone_mipmap_flat_untextured, + FB_triangle_zoff_noblend_aless_znone_mipmap_flat_textured, + FB_triangle_zoff_noblend_aless_znone_mipmap_flat_perspective + }, + { + FB_triangle_zoff_noblend_aless_znone_mipmap_smooth_untextured, + FB_triangle_zoff_noblend_aless_znone_mipmap_smooth_textured, + FB_triangle_zoff_noblend_aless_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zoff_noblend_aless_zless_nearest_white_untextured, + FB_triangle_zoff_noblend_aless_zless_nearest_white_textured, + FB_triangle_zoff_noblend_aless_zless_nearest_white_perspective + }, + { + FB_triangle_zoff_noblend_aless_zless_nearest_flat_untextured, + FB_triangle_zoff_noblend_aless_zless_nearest_flat_textured, + FB_triangle_zoff_noblend_aless_zless_nearest_flat_perspective + }, + { + FB_triangle_zoff_noblend_aless_zless_nearest_smooth_untextured, + FB_triangle_zoff_noblend_aless_zless_nearest_smooth_textured, + FB_triangle_zoff_noblend_aless_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_noblend_aless_zless_mipmap_white_untextured, + FB_triangle_zoff_noblend_aless_zless_mipmap_white_textured, + FB_triangle_zoff_noblend_aless_zless_mipmap_white_perspective + }, + { + FB_triangle_zoff_noblend_aless_zless_mipmap_flat_untextured, + FB_triangle_zoff_noblend_aless_zless_mipmap_flat_textured, + FB_triangle_zoff_noblend_aless_zless_mipmap_flat_perspective + }, + { + FB_triangle_zoff_noblend_aless_zless_mipmap_smooth_untextured, + FB_triangle_zoff_noblend_aless_zless_mipmap_smooth_textured, + FB_triangle_zoff_noblend_aless_zless_mipmap_smooth_perspective + } + } + } + }, + { + { + { + { + FB_triangle_zoff_noblend_amore_znone_nearest_white_untextured, + FB_triangle_zoff_noblend_amore_znone_nearest_white_textured, + FB_triangle_zoff_noblend_amore_znone_nearest_white_perspective + }, + { + FB_triangle_zoff_noblend_amore_znone_nearest_flat_untextured, + FB_triangle_zoff_noblend_amore_znone_nearest_flat_textured, + FB_triangle_zoff_noblend_amore_znone_nearest_flat_perspective + }, + { + FB_triangle_zoff_noblend_amore_znone_nearest_smooth_untextured, + FB_triangle_zoff_noblend_amore_znone_nearest_smooth_textured, + FB_triangle_zoff_noblend_amore_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_noblend_amore_znone_mipmap_white_untextured, + FB_triangle_zoff_noblend_amore_znone_mipmap_white_textured, + FB_triangle_zoff_noblend_amore_znone_mipmap_white_perspective + }, + { + FB_triangle_zoff_noblend_amore_znone_mipmap_flat_untextured, + FB_triangle_zoff_noblend_amore_znone_mipmap_flat_textured, + FB_triangle_zoff_noblend_amore_znone_mipmap_flat_perspective + }, + { + FB_triangle_zoff_noblend_amore_znone_mipmap_smooth_untextured, + FB_triangle_zoff_noblend_amore_znone_mipmap_smooth_textured, + FB_triangle_zoff_noblend_amore_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zoff_noblend_amore_zless_nearest_white_untextured, + FB_triangle_zoff_noblend_amore_zless_nearest_white_textured, + FB_triangle_zoff_noblend_amore_zless_nearest_white_perspective + }, + { + FB_triangle_zoff_noblend_amore_zless_nearest_flat_untextured, + FB_triangle_zoff_noblend_amore_zless_nearest_flat_textured, + FB_triangle_zoff_noblend_amore_zless_nearest_flat_perspective + }, + { + FB_triangle_zoff_noblend_amore_zless_nearest_smooth_untextured, + FB_triangle_zoff_noblend_amore_zless_nearest_smooth_textured, + FB_triangle_zoff_noblend_amore_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_noblend_amore_zless_mipmap_white_untextured, + FB_triangle_zoff_noblend_amore_zless_mipmap_white_textured, + FB_triangle_zoff_noblend_amore_zless_mipmap_white_perspective + }, + { + FB_triangle_zoff_noblend_amore_zless_mipmap_flat_untextured, + FB_triangle_zoff_noblend_amore_zless_mipmap_flat_textured, + FB_triangle_zoff_noblend_amore_zless_mipmap_flat_perspective + }, + { + FB_triangle_zoff_noblend_amore_zless_mipmap_smooth_untextured, + FB_triangle_zoff_noblend_amore_zless_mipmap_smooth_textured, + FB_triangle_zoff_noblend_amore_zless_mipmap_smooth_perspective + } + } + } + } + }, + { + { + { + { + { + FB_triangle_zoff_blend_anone_znone_nearest_white_untextured, + FB_triangle_zoff_blend_anone_znone_nearest_white_textured, + FB_triangle_zoff_blend_anone_znone_nearest_white_perspective + }, + { + FB_triangle_zoff_blend_anone_znone_nearest_flat_untextured, + FB_triangle_zoff_blend_anone_znone_nearest_flat_textured, + FB_triangle_zoff_blend_anone_znone_nearest_flat_perspective + }, + { + FB_triangle_zoff_blend_anone_znone_nearest_smooth_untextured, + FB_triangle_zoff_blend_anone_znone_nearest_smooth_textured, + FB_triangle_zoff_blend_anone_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_blend_anone_znone_mipmap_white_untextured, + FB_triangle_zoff_blend_anone_znone_mipmap_white_textured, + FB_triangle_zoff_blend_anone_znone_mipmap_white_perspective + }, + { + FB_triangle_zoff_blend_anone_znone_mipmap_flat_untextured, + FB_triangle_zoff_blend_anone_znone_mipmap_flat_textured, + FB_triangle_zoff_blend_anone_znone_mipmap_flat_perspective + }, + { + FB_triangle_zoff_blend_anone_znone_mipmap_smooth_untextured, + FB_triangle_zoff_blend_anone_znone_mipmap_smooth_textured, + FB_triangle_zoff_blend_anone_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zoff_blend_anone_zless_nearest_white_untextured, + FB_triangle_zoff_blend_anone_zless_nearest_white_textured, + FB_triangle_zoff_blend_anone_zless_nearest_white_perspective + }, + { + FB_triangle_zoff_blend_anone_zless_nearest_flat_untextured, + FB_triangle_zoff_blend_anone_zless_nearest_flat_textured, + FB_triangle_zoff_blend_anone_zless_nearest_flat_perspective + }, + { + FB_triangle_zoff_blend_anone_zless_nearest_smooth_untextured, + FB_triangle_zoff_blend_anone_zless_nearest_smooth_textured, + FB_triangle_zoff_blend_anone_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_blend_anone_zless_mipmap_white_untextured, + FB_triangle_zoff_blend_anone_zless_mipmap_white_textured, + FB_triangle_zoff_blend_anone_zless_mipmap_white_perspective + }, + { + FB_triangle_zoff_blend_anone_zless_mipmap_flat_untextured, + FB_triangle_zoff_blend_anone_zless_mipmap_flat_textured, + FB_triangle_zoff_blend_anone_zless_mipmap_flat_perspective + }, + { + FB_triangle_zoff_blend_anone_zless_mipmap_smooth_untextured, + FB_triangle_zoff_blend_anone_zless_mipmap_smooth_textured, + FB_triangle_zoff_blend_anone_zless_mipmap_smooth_perspective + } + } + } + }, + { + { + { + { + FB_triangle_zoff_blend_aless_znone_nearest_white_untextured, + FB_triangle_zoff_blend_aless_znone_nearest_white_textured, + FB_triangle_zoff_blend_aless_znone_nearest_white_perspective + }, + { + FB_triangle_zoff_blend_aless_znone_nearest_flat_untextured, + FB_triangle_zoff_blend_aless_znone_nearest_flat_textured, + FB_triangle_zoff_blend_aless_znone_nearest_flat_perspective + }, + { + FB_triangle_zoff_blend_aless_znone_nearest_smooth_untextured, + FB_triangle_zoff_blend_aless_znone_nearest_smooth_textured, + FB_triangle_zoff_blend_aless_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_blend_aless_znone_mipmap_white_untextured, + FB_triangle_zoff_blend_aless_znone_mipmap_white_textured, + FB_triangle_zoff_blend_aless_znone_mipmap_white_perspective + }, + { + FB_triangle_zoff_blend_aless_znone_mipmap_flat_untextured, + FB_triangle_zoff_blend_aless_znone_mipmap_flat_textured, + FB_triangle_zoff_blend_aless_znone_mipmap_flat_perspective + }, + { + FB_triangle_zoff_blend_aless_znone_mipmap_smooth_untextured, + FB_triangle_zoff_blend_aless_znone_mipmap_smooth_textured, + FB_triangle_zoff_blend_aless_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zoff_blend_aless_zless_nearest_white_untextured, + FB_triangle_zoff_blend_aless_zless_nearest_white_textured, + FB_triangle_zoff_blend_aless_zless_nearest_white_perspective + }, + { + FB_triangle_zoff_blend_aless_zless_nearest_flat_untextured, + FB_triangle_zoff_blend_aless_zless_nearest_flat_textured, + FB_triangle_zoff_blend_aless_zless_nearest_flat_perspective + }, + { + FB_triangle_zoff_blend_aless_zless_nearest_smooth_untextured, + FB_triangle_zoff_blend_aless_zless_nearest_smooth_textured, + FB_triangle_zoff_blend_aless_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_blend_aless_zless_mipmap_white_untextured, + FB_triangle_zoff_blend_aless_zless_mipmap_white_textured, + FB_triangle_zoff_blend_aless_zless_mipmap_white_perspective + }, + { + FB_triangle_zoff_blend_aless_zless_mipmap_flat_untextured, + FB_triangle_zoff_blend_aless_zless_mipmap_flat_textured, + FB_triangle_zoff_blend_aless_zless_mipmap_flat_perspective + }, + { + FB_triangle_zoff_blend_aless_zless_mipmap_smooth_untextured, + FB_triangle_zoff_blend_aless_zless_mipmap_smooth_textured, + FB_triangle_zoff_blend_aless_zless_mipmap_smooth_perspective + } + } + } + }, + { + { + { + { + FB_triangle_zoff_blend_amore_znone_nearest_white_untextured, + FB_triangle_zoff_blend_amore_znone_nearest_white_textured, + FB_triangle_zoff_blend_amore_znone_nearest_white_perspective + }, + { + FB_triangle_zoff_blend_amore_znone_nearest_flat_untextured, + FB_triangle_zoff_blend_amore_znone_nearest_flat_textured, + FB_triangle_zoff_blend_amore_znone_nearest_flat_perspective + }, + { + FB_triangle_zoff_blend_amore_znone_nearest_smooth_untextured, + FB_triangle_zoff_blend_amore_znone_nearest_smooth_textured, + FB_triangle_zoff_blend_amore_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_blend_amore_znone_mipmap_white_untextured, + FB_triangle_zoff_blend_amore_znone_mipmap_white_textured, + FB_triangle_zoff_blend_amore_znone_mipmap_white_perspective + }, + { + FB_triangle_zoff_blend_amore_znone_mipmap_flat_untextured, + FB_triangle_zoff_blend_amore_znone_mipmap_flat_textured, + FB_triangle_zoff_blend_amore_znone_mipmap_flat_perspective + }, + { + FB_triangle_zoff_blend_amore_znone_mipmap_smooth_untextured, + FB_triangle_zoff_blend_amore_znone_mipmap_smooth_textured, + FB_triangle_zoff_blend_amore_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zoff_blend_amore_zless_nearest_white_untextured, + FB_triangle_zoff_blend_amore_zless_nearest_white_textured, + FB_triangle_zoff_blend_amore_zless_nearest_white_perspective + }, + { + FB_triangle_zoff_blend_amore_zless_nearest_flat_untextured, + FB_triangle_zoff_blend_amore_zless_nearest_flat_textured, + FB_triangle_zoff_blend_amore_zless_nearest_flat_perspective + }, + { + FB_triangle_zoff_blend_amore_zless_nearest_smooth_untextured, + FB_triangle_zoff_blend_amore_zless_nearest_smooth_textured, + FB_triangle_zoff_blend_amore_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_blend_amore_zless_mipmap_white_untextured, + FB_triangle_zoff_blend_amore_zless_mipmap_white_textured, + FB_triangle_zoff_blend_amore_zless_mipmap_white_perspective + }, + { + FB_triangle_zoff_blend_amore_zless_mipmap_flat_untextured, + FB_triangle_zoff_blend_amore_zless_mipmap_flat_textured, + FB_triangle_zoff_blend_amore_zless_mipmap_flat_perspective + }, + { + FB_triangle_zoff_blend_amore_zless_mipmap_smooth_untextured, + FB_triangle_zoff_blend_amore_zless_mipmap_smooth_textured, + FB_triangle_zoff_blend_amore_zless_mipmap_smooth_perspective + } + } + } + } + }, + { + { + { + { + { + FB_triangle_zoff_nocolor_anone_znone_nearest_white_untextured, + FB_triangle_zoff_nocolor_anone_znone_nearest_white_textured, + FB_triangle_zoff_nocolor_anone_znone_nearest_white_perspective + }, + { + FB_triangle_zoff_nocolor_anone_znone_nearest_flat_untextured, + FB_triangle_zoff_nocolor_anone_znone_nearest_flat_textured, + FB_triangle_zoff_nocolor_anone_znone_nearest_flat_perspective + }, + { + FB_triangle_zoff_nocolor_anone_znone_nearest_smooth_untextured, + FB_triangle_zoff_nocolor_anone_znone_nearest_smooth_textured, + FB_triangle_zoff_nocolor_anone_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_nocolor_anone_znone_mipmap_white_untextured, + FB_triangle_zoff_nocolor_anone_znone_mipmap_white_textured, + FB_triangle_zoff_nocolor_anone_znone_mipmap_white_perspective + }, + { + FB_triangle_zoff_nocolor_anone_znone_mipmap_flat_untextured, + FB_triangle_zoff_nocolor_anone_znone_mipmap_flat_textured, + FB_triangle_zoff_nocolor_anone_znone_mipmap_flat_perspective + }, + { + FB_triangle_zoff_nocolor_anone_znone_mipmap_smooth_untextured, + FB_triangle_zoff_nocolor_anone_znone_mipmap_smooth_textured, + FB_triangle_zoff_nocolor_anone_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zoff_nocolor_anone_zless_nearest_white_untextured, + FB_triangle_zoff_nocolor_anone_zless_nearest_white_textured, + FB_triangle_zoff_nocolor_anone_zless_nearest_white_perspective + }, + { + FB_triangle_zoff_nocolor_anone_zless_nearest_flat_untextured, + FB_triangle_zoff_nocolor_anone_zless_nearest_flat_textured, + FB_triangle_zoff_nocolor_anone_zless_nearest_flat_perspective + }, + { + FB_triangle_zoff_nocolor_anone_zless_nearest_smooth_untextured, + FB_triangle_zoff_nocolor_anone_zless_nearest_smooth_textured, + FB_triangle_zoff_nocolor_anone_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_nocolor_anone_zless_mipmap_white_untextured, + FB_triangle_zoff_nocolor_anone_zless_mipmap_white_textured, + FB_triangle_zoff_nocolor_anone_zless_mipmap_white_perspective + }, + { + FB_triangle_zoff_nocolor_anone_zless_mipmap_flat_untextured, + FB_triangle_zoff_nocolor_anone_zless_mipmap_flat_textured, + FB_triangle_zoff_nocolor_anone_zless_mipmap_flat_perspective + }, + { + FB_triangle_zoff_nocolor_anone_zless_mipmap_smooth_untextured, + FB_triangle_zoff_nocolor_anone_zless_mipmap_smooth_textured, + FB_triangle_zoff_nocolor_anone_zless_mipmap_smooth_perspective + } + } + } + }, + { + { + { + { + FB_triangle_zoff_nocolor_aless_znone_nearest_white_untextured, + FB_triangle_zoff_nocolor_aless_znone_nearest_white_textured, + FB_triangle_zoff_nocolor_aless_znone_nearest_white_perspective + }, + { + FB_triangle_zoff_nocolor_aless_znone_nearest_flat_untextured, + FB_triangle_zoff_nocolor_aless_znone_nearest_flat_textured, + FB_triangle_zoff_nocolor_aless_znone_nearest_flat_perspective + }, + { + FB_triangle_zoff_nocolor_aless_znone_nearest_smooth_untextured, + FB_triangle_zoff_nocolor_aless_znone_nearest_smooth_textured, + FB_triangle_zoff_nocolor_aless_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_nocolor_aless_znone_mipmap_white_untextured, + FB_triangle_zoff_nocolor_aless_znone_mipmap_white_textured, + FB_triangle_zoff_nocolor_aless_znone_mipmap_white_perspective + }, + { + FB_triangle_zoff_nocolor_aless_znone_mipmap_flat_untextured, + FB_triangle_zoff_nocolor_aless_znone_mipmap_flat_textured, + FB_triangle_zoff_nocolor_aless_znone_mipmap_flat_perspective + }, + { + FB_triangle_zoff_nocolor_aless_znone_mipmap_smooth_untextured, + FB_triangle_zoff_nocolor_aless_znone_mipmap_smooth_textured, + FB_triangle_zoff_nocolor_aless_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zoff_nocolor_aless_zless_nearest_white_untextured, + FB_triangle_zoff_nocolor_aless_zless_nearest_white_textured, + FB_triangle_zoff_nocolor_aless_zless_nearest_white_perspective + }, + { + FB_triangle_zoff_nocolor_aless_zless_nearest_flat_untextured, + FB_triangle_zoff_nocolor_aless_zless_nearest_flat_textured, + FB_triangle_zoff_nocolor_aless_zless_nearest_flat_perspective + }, + { + FB_triangle_zoff_nocolor_aless_zless_nearest_smooth_untextured, + FB_triangle_zoff_nocolor_aless_zless_nearest_smooth_textured, + FB_triangle_zoff_nocolor_aless_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_nocolor_aless_zless_mipmap_white_untextured, + FB_triangle_zoff_nocolor_aless_zless_mipmap_white_textured, + FB_triangle_zoff_nocolor_aless_zless_mipmap_white_perspective + }, + { + FB_triangle_zoff_nocolor_aless_zless_mipmap_flat_untextured, + FB_triangle_zoff_nocolor_aless_zless_mipmap_flat_textured, + FB_triangle_zoff_nocolor_aless_zless_mipmap_flat_perspective + }, + { + FB_triangle_zoff_nocolor_aless_zless_mipmap_smooth_untextured, + FB_triangle_zoff_nocolor_aless_zless_mipmap_smooth_textured, + FB_triangle_zoff_nocolor_aless_zless_mipmap_smooth_perspective + } + } + } + }, + { + { + { + { + FB_triangle_zoff_nocolor_amore_znone_nearest_white_untextured, + FB_triangle_zoff_nocolor_amore_znone_nearest_white_textured, + FB_triangle_zoff_nocolor_amore_znone_nearest_white_perspective + }, + { + FB_triangle_zoff_nocolor_amore_znone_nearest_flat_untextured, + FB_triangle_zoff_nocolor_amore_znone_nearest_flat_textured, + FB_triangle_zoff_nocolor_amore_znone_nearest_flat_perspective + }, + { + FB_triangle_zoff_nocolor_amore_znone_nearest_smooth_untextured, + FB_triangle_zoff_nocolor_amore_znone_nearest_smooth_textured, + FB_triangle_zoff_nocolor_amore_znone_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_nocolor_amore_znone_mipmap_white_untextured, + FB_triangle_zoff_nocolor_amore_znone_mipmap_white_textured, + FB_triangle_zoff_nocolor_amore_znone_mipmap_white_perspective + }, + { + FB_triangle_zoff_nocolor_amore_znone_mipmap_flat_untextured, + FB_triangle_zoff_nocolor_amore_znone_mipmap_flat_textured, + FB_triangle_zoff_nocolor_amore_znone_mipmap_flat_perspective + }, + { + FB_triangle_zoff_nocolor_amore_znone_mipmap_smooth_untextured, + FB_triangle_zoff_nocolor_amore_znone_mipmap_smooth_textured, + FB_triangle_zoff_nocolor_amore_znone_mipmap_smooth_perspective + } + } + }, + { + { + { + FB_triangle_zoff_nocolor_amore_zless_nearest_white_untextured, + FB_triangle_zoff_nocolor_amore_zless_nearest_white_textured, + FB_triangle_zoff_nocolor_amore_zless_nearest_white_perspective + }, + { + FB_triangle_zoff_nocolor_amore_zless_nearest_flat_untextured, + FB_triangle_zoff_nocolor_amore_zless_nearest_flat_textured, + FB_triangle_zoff_nocolor_amore_zless_nearest_flat_perspective + }, + { + FB_triangle_zoff_nocolor_amore_zless_nearest_smooth_untextured, + FB_triangle_zoff_nocolor_amore_zless_nearest_smooth_textured, + FB_triangle_zoff_nocolor_amore_zless_nearest_smooth_perspective + } + }, + { + { + FB_triangle_zoff_nocolor_amore_zless_mipmap_white_untextured, + FB_triangle_zoff_nocolor_amore_zless_mipmap_white_textured, + FB_triangle_zoff_nocolor_amore_zless_mipmap_white_perspective + }, + { + FB_triangle_zoff_nocolor_amore_zless_mipmap_flat_untextured, + FB_triangle_zoff_nocolor_amore_zless_mipmap_flat_textured, + FB_triangle_zoff_nocolor_amore_zless_mipmap_flat_perspective + }, + { + FB_triangle_zoff_nocolor_amore_zless_mipmap_smooth_untextured, + FB_triangle_zoff_nocolor_amore_zless_mipmap_smooth_textured, + FB_triangle_zoff_nocolor_amore_zless_mipmap_smooth_perspective + } + } + } + } + } + } +}; diff --git a/panda/src/tinydisplay/ztriangle_table.h b/panda/src/tinydisplay/ztriangle_table.h new file mode 100755 index 0000000000..2dffdcbc0d --- /dev/null +++ b/panda/src/tinydisplay/ztriangle_table.h @@ -0,0 +1,3 @@ +/* This file is generated code--do not edit. See ztriangle.py. */ + +extern const ZB_fillTriangleFunc fill_tri_funcs[2][3][3][2][2][3][3]; diff --git a/panda/src/tinydisplay/ztriangle_two.h b/panda/src/tinydisplay/ztriangle_two.h index 6b080ea97c..26e404414f 100644 --- a/panda/src/tinydisplay/ztriangle_two.h +++ b/panda/src/tinydisplay/ztriangle_two.h @@ -1,5 +1,34 @@ -void FNAME(ZB_fillTriangleFlat) (ZBuffer *zb, - ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) +static void FNAME(white_untextured) (ZBuffer *zb, + ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) +{ +#define INTERP_Z + +#define EARLY_OUT() \ + { \ + } + +#define DRAW_INIT() \ + { \ + if (!ACMP(zb, p2->a)) { \ + return; \ + } \ + } + +#define PUT_PIXEL(_a) \ + { \ + zz=z >> ZB_POINT_Z_FRAC_BITS; \ + if (ZCMP(pz[_a], zz)) { \ + STORE_PIX(pp[_a], 0xffffffffUL, 0xffffUL, 0xffffUL, 0xffffUL, 0xffffUL); \ + STORE_Z(pz[_a], zz); \ + } \ + z+=dzdx; \ + } + +#include "ztriangle.h" +} + +static void FNAME(flat_untextured) (ZBuffer *zb, + ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { int color; int or0, og0, ob0, oa0; @@ -40,8 +69,8 @@ void FNAME(ZB_fillTriangleFlat) (ZBuffer *zb, * The code below is very tricky :) */ -void FNAME(ZB_fillTriangleSmooth) (ZBuffer *zb, - ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) +static void FNAME(smooth_untextured) (ZBuffer *zb, + ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { #define INTERP_Z #define INTERP_RGB @@ -54,7 +83,7 @@ void FNAME(ZB_fillTriangleSmooth) (ZBuffer *zb, c2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a); \ if (c0 == c1 && c0 == c2) { \ /* It's really a flat-shaded triangle. */ \ - FNAME(ZB_fillTriangleFlat)(zb, p0, p1, p2); \ + FNAME(flat_untextured)(zb, p0, p1, p2); \ return; \ } \ } @@ -82,10 +111,10 @@ void FNAME(ZB_fillTriangleSmooth) (ZBuffer *zb, #include "ztriangle.h" } -void FNAME(ZB_fillTriangleMapping) (ZBuffer *zb, - ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) +static void FNAME(white_textured) (ZBuffer *zb, + ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { - ZTexture *texture; + ZTextureLevel *texture_levels; #define INTERP_Z #define INTERP_ST @@ -96,14 +125,14 @@ void FNAME(ZB_fillTriangleMapping) (ZBuffer *zb, #define DRAW_INIT() \ { \ - texture = &zb->current_texture; \ + texture_levels = zb->current_texture; \ } #define PUT_PIXEL(_a) \ { \ zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ - tmp = ZB_LOOKUP_TEXTURE(texture, s, t); \ + tmp = ZB_LOOKUP_TEXTURE(texture_levels, s, t, mipmap_level); \ if (ACMP(zb, PIXEL_A(tmp))) { \ STORE_PIX(pp[_a], tmp, PIXEL_R(tmp), PIXEL_G(tmp), PIXEL_B(tmp), PIXEL_A(tmp)); \ STORE_Z(pz[_a], zz); \ @@ -117,10 +146,10 @@ void FNAME(ZB_fillTriangleMapping) (ZBuffer *zb, #include "ztriangle.h" } -void FNAME(ZB_fillTriangleMappingFlat) (ZBuffer *zb, - ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) +static void FNAME(flat_textured) (ZBuffer *zb, + ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { - ZTexture *texture; + ZTextureLevel *texture_levels; int or0, og0, ob0, oa0; #define INTERP_Z @@ -132,7 +161,7 @@ void FNAME(ZB_fillTriangleMappingFlat) (ZBuffer *zb, #define DRAW_INIT() \ { \ - texture = &zb->current_texture; \ + texture_levels = zb->current_texture; \ or0 = p2->r; \ og0 = p2->g; \ ob0 = p2->b; \ @@ -143,7 +172,7 @@ void FNAME(ZB_fillTriangleMappingFlat) (ZBuffer *zb, { \ zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ - tmp = ZB_LOOKUP_TEXTURE(texture, s, t); \ + tmp = ZB_LOOKUP_TEXTURE(texture_levels, s, t, mipmap_level); \ int a = oa0 * PIXEL_A(tmp) >> 16; \ if (ACMP(zb, a)) { \ STORE_PIX(pp[_a], \ @@ -166,10 +195,10 @@ void FNAME(ZB_fillTriangleMappingFlat) (ZBuffer *zb, #include "ztriangle.h" } -void FNAME(ZB_fillTriangleMappingSmooth) (ZBuffer *zb, - ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) +static void FNAME(smooth_textured) (ZBuffer *zb, + ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { - ZTexture *texture; + ZTextureLevel *texture_levels; #define INTERP_Z #define INTERP_ST @@ -185,24 +214,24 @@ void FNAME(ZB_fillTriangleMappingSmooth) (ZBuffer *zb, /* It's really a flat-shaded triangle. */ \ if (c0 == 0xffffffff) { \ /* Actually, it's a white triangle. */ \ - FNAME(ZB_fillTriangleMapping)(zb, p0, p1, p2); \ + FNAME(white_textured)(zb, p0, p1, p2); \ return; \ } \ - FNAME(ZB_fillTriangleMappingFlat)(zb, p0, p1, p2); \ + FNAME(flat_textured)(zb, p0, p1, p2); \ return; \ } \ } #define DRAW_INIT() \ { \ - texture = &zb->current_texture; \ + texture_levels = zb->current_texture; \ } #define PUT_PIXEL(_a) \ { \ zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ - tmp = ZB_LOOKUP_TEXTURE(texture, s, t); \ + tmp = ZB_LOOKUP_TEXTURE(texture_levels, s, t, mipmap_level); \ int a = oa1 * PIXEL_A(tmp) >> 16; \ if (ACMP(zb, a)) { \ STORE_PIX(pp[_a], \ @@ -234,10 +263,10 @@ void FNAME(ZB_fillTriangleMappingSmooth) (ZBuffer *zb, * We use the gradient method to make less divisions. * TODO: pipeline the division */ -void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb, - ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) +static void FNAME(white_perspective) (ZBuffer *zb, + ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { - ZTexture *texture; + ZTextureLevel *texture_levels; float fdzdx,fndzdx,ndszdx,ndtzdx; #define INTERP_Z @@ -251,7 +280,7 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb, #define DRAW_INIT() \ { \ - texture = &zb->current_texture; \ + texture_levels = zb->current_texture; \ fdzdx=(float)dzdx; \ fndzdx=NB_INTERP * fdzdx; \ ndszdx=NB_INTERP * dszdx; \ @@ -263,7 +292,7 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb, { \ zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ - tmp = ZB_LOOKUP_TEXTURE(texture, s, t); \ + tmp = ZB_LOOKUP_TEXTURE(texture_levels, s, t, mipmap_level); \ if (ACMP(zb, PIXEL_A(tmp))) { \ STORE_PIX(pp[_a], tmp, PIXEL_R(tmp), PIXEL_G(tmp), PIXEL_B(tmp), PIXEL_A(tmp)); \ STORE_Z(pz[_a], zz); \ @@ -298,6 +327,7 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb, t=(unsigned int) tt; \ dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \ dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \ + CALC_MIPMAP_LEVEL; \ fz+=fndzdx; \ zinv=1.0f / fz; \ } \ @@ -323,6 +353,7 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb, t=(unsigned int) tt; \ dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \ dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \ + CALC_MIPMAP_LEVEL; \ } \ while (n>=0) { \ PUT_PIXEL(0); \ @@ -339,10 +370,10 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb, * Flat shaded triangle, with perspective-correct mapping. */ -void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb, - ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) +static void FNAME(flat_perspective) (ZBuffer *zb, + ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { - ZTexture *texture; + ZTextureLevel *texture_levels; float fdzdx,fndzdx,ndszdx,ndtzdx; int or0, og0, ob0, oa0; @@ -357,7 +388,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb, #define DRAW_INIT() \ { \ - texture = &zb->current_texture; \ + texture_levels = zb->current_texture; \ fdzdx=(float)dzdx; \ fndzdx=NB_INTERP * fdzdx; \ ndszdx=NB_INTERP * dszdx; \ @@ -372,7 +403,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb, { \ zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ - tmp = ZB_LOOKUP_TEXTURE(texture, s, t); \ + tmp = ZB_LOOKUP_TEXTURE(texture_levels, s, t, mipmap_level); \ int a = oa0 * PIXEL_A(tmp) >> 16; \ if (ACMP(zb, a)) { \ STORE_PIX(pp[_a], \ @@ -421,6 +452,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb, t=(unsigned int) tt; \ dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \ dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \ + CALC_MIPMAP_LEVEL; \ fz+=fndzdx; \ zinv=1.0f / fz; \ } \ @@ -446,6 +478,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb, t=(unsigned int) tt; \ dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \ dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \ + CALC_MIPMAP_LEVEL; \ } \ while (n>=0) { \ PUT_PIXEL(0); \ @@ -462,10 +495,10 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb, * Smooth filled triangle, with perspective-correct mapping. */ -void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb, - ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) +static void FNAME(smooth_perspective) (ZBuffer *zb, + ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { - ZTexture *texture; + ZTextureLevel *texture_levels; float fdzdx,fndzdx,ndszdx,ndtzdx; #define INTERP_Z @@ -482,17 +515,17 @@ void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb, /* It's really a flat-shaded triangle. */ \ if (c0 == 0xffffffff) { \ /* Actually, it's a white triangle. */ \ - FNAME(ZB_fillTriangleMappingPerspective)(zb, p0, p1, p2); \ + FNAME(white_perspective)(zb, p0, p1, p2); \ return; \ } \ - FNAME(ZB_fillTriangleMappingPerspectiveFlat)(zb, p0, p1, p2); \ + FNAME(flat_perspective)(zb, p0, p1, p2); \ return; \ } \ } #define DRAW_INIT() \ { \ - texture = &zb->current_texture; \ + texture_levels = zb->current_texture; \ fdzdx=(float)dzdx; \ fndzdx=NB_INTERP * fdzdx; \ ndszdx=NB_INTERP * dszdx; \ @@ -503,7 +536,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb, { \ zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ - tmp = ZB_LOOKUP_TEXTURE(texture, s, t); \ + tmp = ZB_LOOKUP_TEXTURE(texture_levels, s, t, mipmap_level); \ int a = oa1 * PIXEL_A(tmp) >> 16; \ if (ACMP(zb, a)) { \ STORE_PIX(pp[_a], \ @@ -556,6 +589,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb, t=(unsigned int) tt; \ dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \ dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \ + CALC_MIPMAP_LEVEL; \ fz+=fndzdx; \ zinv=1.0f / fz; \ } \ @@ -581,6 +615,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb, t=(unsigned int) tt; \ dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \ dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \ + CALC_MIPMAP_LEVEL; \ } \ while (n>=0) { \ PUT_PIXEL(0); \ @@ -598,3 +633,7 @@ void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb, #undef STORE_PIX #undef STORE_Z #undef FNAME +#undef INTERP_MIPMAP +#undef CALC_MIPMAP_LEVEL +#undef ZB_LOOKUP_TEXTURE +