ta_fifo_polygon_converter: properly calculate ta_next_opb_offset

The main issue with the previous code:

  constexpr uint32_t tiles = (640 / 32) * (320 / 32);

Should have been:

  constexpr uint32_t tiles = (640 / 32) * (480 / 32);

The consequence of this is some OPBs were being overwritten by
TA_NEXT_OPB, causing corruption (missing triangles, incomplete
drawings) in some tiles.
This commit is contained in:
Zack Buhman 2023-12-25 21:53:11 +08:00
parent 03aa9b27f0
commit 54f09bad01
3 changed files with 16 additions and 13 deletions

View File

@ -242,8 +242,6 @@ void main()
, .punch_through = 0 , .punch_through = 0
}; };
constexpr uint32_t tiles = (640 / 32) * (320 / 32);
holly.SOFTRESET = softreset::pipeline_soft_reset holly.SOFTRESET = softreset::pipeline_soft_reset
| softreset::ta_soft_reset; | softreset::ta_soft_reset;
holly.SOFTRESET = 0; holly.SOFTRESET = 0;
@ -262,8 +260,10 @@ void main()
}; };
while (1) { while (1) {
ta_polygon_converter_init(opb_size.total() * tiles, ta_alloc, ta_polygon_converter_init(opb_size.total(),
640, 480); ta_alloc,
640 / 32,
480 / 32);
lights[0].x = cos(theta) * 10; lights[0].x = cos(theta) * 10;
lights[0].z = sin(theta) * 10; lights[0].z = sin(theta) * 10;

View File

@ -12,16 +12,19 @@
#include "ta_fifo_polygon_converter.hpp" #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 ta_alloc,
uint32_t width, // in pixels uint32_t tile_width, // in tile units (e.g: (640 / 32))
uint32_t height) // in pixels 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 = softreset::ta_soft_reset;
holly.SOFTRESET = 0; holly.SOFTRESET = 0;
holly.TA_GLOB_TILE_CLIP = ta_glob_tile_clip::tile_y_num((height / 32) - 1) holly.TA_GLOB_TILE_CLIP = ta_glob_tile_clip::tile_y_num(tile_height - 1)
| ta_glob_tile_clip::tile_x_num((width / 32) - 1); | ta_glob_tile_clip::tile_x_num(tile_width - 1);
holly.TA_ALLOC_CTRL = ta_alloc_ctrl::opb_mode::increasing_addresses holly.TA_ALLOC_CTRL = ta_alloc_ctrl::opb_mode::increasing_addresses
| ta_alloc; | 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_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_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)) 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; holly.TA_LIST_INIT = ta_list_init::list_init;

View File

@ -2,10 +2,10 @@
#include <cstdint> #include <cstdint>
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 ta_alloc,
uint32_t width, // in pixels uint32_t tile_width, // in tile units (e.g: (640 / 32))
uint32_t height); // in pixels uint32_t tile_height); // in tile units (e.g: (480 / 32))
void ta_polygon_converter_cont(uint32_t ol_base_offset, void ta_polygon_converter_cont(uint32_t ol_base_offset,
uint32_t ta_alloc); uint32_t ta_alloc);
void ta_polygon_converter_transfer(volatile uint32_t * buf, uint32_t size); void ta_polygon_converter_transfer(volatile uint32_t * buf, uint32_t size);