diff --git a/example/icosphere.cpp b/example/icosphere.cpp index a050a59..1d7ae30 100644 --- a/example/icosphere.cpp +++ b/example/icosphere.cpp @@ -242,8 +242,6 @@ void main() , .punch_through = 0 }; - constexpr uint32_t tiles = (640 / 32) * (320 / 32); - holly.SOFTRESET = softreset::pipeline_soft_reset | softreset::ta_soft_reset; holly.SOFTRESET = 0; @@ -262,8 +260,10 @@ void main() }; while (1) { - ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc, - 640, 480); + ta_polygon_converter_init(opb_size.total(), + ta_alloc, + 640 / 32, + 480 / 32); lights[0].x = cos(theta) * 10; lights[0].z = sin(theta) * 10; diff --git a/holly/ta_fifo_polygon_converter.cpp b/holly/ta_fifo_polygon_converter.cpp index 61c5ef7..904a6d2 100644 --- a/holly/ta_fifo_polygon_converter.cpp +++ b/holly/ta_fifo_polygon_converter.cpp @@ -12,16 +12,19 @@ #include "ta_fifo_polygon_converter.hpp" -void ta_polygon_converter_init(uint32_t opb_total_size, // for all render passes +void ta_polygon_converter_init(uint32_t opb_total_size, // for one tile, for all render passes uint32_t ta_alloc, - uint32_t width, // in pixels - uint32_t height) // in pixels + uint32_t tile_width, // in tile units (e.g: (640 / 32)) + uint32_t tile_height) // in tile units (e.g: (480 / 32)) { + // opb_size is the total size of all OPBs for all passes + const uint32_t ta_next_opb_offset = opb_total_size * tile_width * tile_height; + holly.SOFTRESET = softreset::ta_soft_reset; holly.SOFTRESET = 0; - holly.TA_GLOB_TILE_CLIP = ta_glob_tile_clip::tile_y_num((height / 32) - 1) - | ta_glob_tile_clip::tile_x_num((width / 32) - 1); + holly.TA_GLOB_TILE_CLIP = ta_glob_tile_clip::tile_y_num(tile_height - 1) + | ta_glob_tile_clip::tile_x_num(tile_width - 1); holly.TA_ALLOC_CTRL = ta_alloc_ctrl::opb_mode::increasing_addresses | ta_alloc; @@ -31,7 +34,7 @@ void ta_polygon_converter_init(uint32_t opb_total_size, // for all render passes holly.TA_OL_BASE = (offsetof (struct texture_memory_alloc, object_list)); holly.TA_OL_LIMIT = (offsetof (struct texture_memory_alloc, _res0)); // the end of the object_list holly.TA_NEXT_OPB_INIT = (offsetof (struct texture_memory_alloc, object_list)) - + opb_total_size; // opb_size is the total size of all OPBs for all passes + + ta_next_opb_offset; holly.TA_LIST_INIT = ta_list_init::list_init; diff --git a/holly/ta_fifo_polygon_converter.hpp b/holly/ta_fifo_polygon_converter.hpp index 58a26e5..29f36d2 100644 --- a/holly/ta_fifo_polygon_converter.hpp +++ b/holly/ta_fifo_polygon_converter.hpp @@ -2,10 +2,10 @@ #include -void ta_polygon_converter_init(uint32_t opb_total_size, // total OPB size for all render passes +void ta_polygon_converter_init(uint32_t opb_total_size, // for one tile, for all render passes uint32_t ta_alloc, - uint32_t width, // in pixels - uint32_t height); // in pixels + uint32_t tile_width, // in tile units (e.g: (640 / 32)) + uint32_t tile_height); // in tile units (e.g: (480 / 32)) void ta_polygon_converter_cont(uint32_t ol_base_offset, uint32_t ta_alloc); void ta_polygon_converter_transfer(volatile uint32_t * buf, uint32_t size);