From 3bd28fd814567bb75b653d8259294948054d4c76 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Thu, 22 May 2025 04:39:44 -0500 Subject: [PATCH] example/macaw: unrot --- example/macaw.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/example/macaw.cpp b/example/macaw.cpp index e0c7391..7465982 100644 --- a/example/macaw.cpp +++ b/example/macaw.cpp @@ -43,11 +43,10 @@ constexpr uint32_t strip_length = (sizeof (strip_vertices)) / (sizeof (struct ve static float theta = 0; constexpr float half_degree = 0.01745329f / 2.f; -uint32_t transform(uint32_t * ta_parameter_buf, - const vertex * strip_vertices, - const uint32_t strip_length) +void transform(ta_parameter_writer& writer, + const vertex * strip_vertices, + const uint32_t strip_length) { - auto parameter = ta_parameter_writer(ta_parameter_buf); const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume | para_control::list_type::opaque | obj_control::col_type::packed_color @@ -67,7 +66,7 @@ uint32_t transform(uint32_t * ta_parameter_buf, | texture_control_word::scan_order::non_twiddled | texture_control_word::texture_address(texture_address / 8); - parameter.append() = + writer.append() = ta_global_parameter::polygon_type_0(parameter_control_word, isp_tsp_instruction_word, tsp_instruction_word, @@ -92,7 +91,7 @@ uint32_t transform(uint32_t * ta_parameter_buf, z = 1.f / (z + 10.f); bool end_of_strip = i == strip_length - 1; - parameter.append() = + writer.append() = ta_vertex_parameter::polygon_type_3(polygon_vertex_parameter_control_word(end_of_strip), x, y, z, strip_vertices[i].u, @@ -102,9 +101,7 @@ uint32_t transform(uint32_t * ta_parameter_buf, ); } - parameter.append() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list); - - return parameter.offset; + writer.append() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list); } void init_texture_memory(const struct opb_size& opb_size) @@ -131,17 +128,15 @@ void copy_macaw_texture() } } -uint32_t _ta_parameter_buf[((32 * (strip_length + 2)) + 32) / 4]; +// The address of `ta_parameter_buf` must be a multiple of 32 bytes. +// This is mandatory for ch2-dma to the ta fifo polygon converter. +uint32_t ta_parameter_buf[((32 * (strip_length + 2)) + 32) / 4] __attribute__((aligned(32))); void main() { video_output::set_mode_vga(); copy_macaw_texture(); - // The address of `ta_parameter_buf` must be a multiple of 32 bytes. - // This is mandatory for ch2-dma to the ta fifo polygon converter. - uint32_t * ta_parameter_buf = align_32byte(_ta_parameter_buf); - constexpr uint32_t ta_alloc = ta_alloc_ctrl::pt_opb::no_list | ta_alloc_ctrl::tm_opb::no_list | ta_alloc_ctrl::t_opb::no_list @@ -165,13 +160,18 @@ void main() uint32_t frame_ix = 0; uint32_t frame = 0; + ta_parameter_writer writer = ta_parameter_writer(ta_parameter_buf, (sizeof (ta_parameter_buf))); + while (true) { ta_polygon_converter_init(opb_size.total(), ta_alloc, 640 / 32, 480 / 32); - uint32_t ta_parameter_size = transform(ta_parameter_buf, strip_vertices, strip_length); - ta_polygon_converter_transfer(ta_parameter_buf, ta_parameter_size); + + writer.offset = 0; + transform(writer, strip_vertices, strip_length); + ta_polygon_converter_writeback(writer.buf, writer.offset); + ta_polygon_converter_transfer(writer.buf, writer.offset); ta_wait_opaque_list(); core_start_render(frame_ix);