macaw_multipass: fix example
The prior issue with this example was almost certainly related to OPB overflow, due to an incorrect tile area calculation.
This commit is contained in:
parent
ae7f35191d
commit
3a92dd070c
@ -1,17 +1,20 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include "align.hpp"
|
#include "align.hpp"
|
||||||
#include "holly/video_output.hpp"
|
|
||||||
|
|
||||||
#include "holly/texture_memory_alloc.hpp"
|
#include "holly/texture_memory_alloc.hpp"
|
||||||
#include "holly.hpp"
|
#include "holly/holly.hpp"
|
||||||
#include "holly/core.hpp"
|
#include "holly/core.hpp"
|
||||||
#include "holly/core_bits.hpp"
|
#include "holly/core_bits.hpp"
|
||||||
#include "holly/ta_fifo_polygon_converter.hpp"
|
#include "holly/ta_fifo_polygon_converter.hpp"
|
||||||
#include "holly/ta_parameter.hpp"
|
#include "holly/ta_parameter.hpp"
|
||||||
|
#include "holly/ta_global_parameter.hpp"
|
||||||
|
#include "holly/ta_vertex_parameter.hpp"
|
||||||
#include "holly/ta_bits.hpp"
|
#include "holly/ta_bits.hpp"
|
||||||
#include "holly/background.hpp"
|
#include "holly/isp_tsp.hpp"
|
||||||
#include "holly/region_array.hpp"
|
#include "holly/region_array.hpp"
|
||||||
|
#include "holly/background.hpp"
|
||||||
|
#include "holly/video_output.hpp"
|
||||||
#include "memorymap.hpp"
|
#include "memorymap.hpp"
|
||||||
|
|
||||||
#include "macaw.hpp"
|
#include "macaw.hpp"
|
||||||
@ -43,13 +46,58 @@ uint32_t transform(uint32_t * ta_parameter_buf,
|
|||||||
const uint32_t render_pass)
|
const uint32_t render_pass)
|
||||||
{
|
{
|
||||||
auto parameter = ta_parameter_writer(ta_parameter_buf);
|
auto parameter = ta_parameter_writer(ta_parameter_buf);
|
||||||
uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
|
|
||||||
|
const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::greater
|
||||||
|
| isp_tsp_instruction_word::culling_mode::no_culling;
|
||||||
|
|
||||||
if (render_pass == 0) {
|
if (render_pass == 0) {
|
||||||
// textured
|
// textured
|
||||||
parameter.append<global_polygon_type_0>() = global_polygon_type_0(texture_address);
|
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
|
||||||
|
| obj_control::texture;
|
||||||
|
|
||||||
|
const uint32_t tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
|
||||||
|
| tsp_instruction_word::dst_alpha_instr::zero
|
||||||
|
| tsp_instruction_word::fog_control::no_fog
|
||||||
|
| tsp_instruction_word::texture_u_size::from_int(128)
|
||||||
|
| tsp_instruction_word::texture_v_size::from_int(128);
|
||||||
|
|
||||||
|
const uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture));
|
||||||
|
const uint32_t texture_control_word = texture_control_word::pixel_format::_565
|
||||||
|
| texture_control_word::scan_order::non_twiddled
|
||||||
|
| texture_control_word::texture_address(texture_address / 8);
|
||||||
|
|
||||||
|
parameter.append<ta_global_parameter::polygon_type_0>() =
|
||||||
|
ta_global_parameter::polygon_type_0(parameter_control_word,
|
||||||
|
isp_tsp_instruction_word,
|
||||||
|
tsp_instruction_word,
|
||||||
|
texture_control_word,
|
||||||
|
0, // data_size_for_sort_dma
|
||||||
|
0 // next_address_for_sort_dma
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// untextured
|
// untextured
|
||||||
parameter.append<global_polygon_type_0>() = global_polygon_type_0();
|
const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume
|
||||||
|
| para_control::list_type::translucent
|
||||||
|
| obj_control::col_type::packed_color
|
||||||
|
| obj_control::gouraud;
|
||||||
|
|
||||||
|
const uint32_t tsp_instruction_word = tsp_instruction_word::src_alpha_instr::src_alpha
|
||||||
|
| tsp_instruction_word::dst_alpha_instr::src_alpha
|
||||||
|
| tsp_instruction_word::fog_control::no_fog
|
||||||
|
| tsp_instruction_word::use_alpha;
|
||||||
|
|
||||||
|
const uint32_t texture_control_word = 0;
|
||||||
|
|
||||||
|
parameter.append<ta_global_parameter::polygon_type_0>() =
|
||||||
|
ta_global_parameter::polygon_type_0(parameter_control_word,
|
||||||
|
isp_tsp_instruction_word,
|
||||||
|
tsp_instruction_word,
|
||||||
|
texture_control_word,
|
||||||
|
0, // data_size_for_sort_dma
|
||||||
|
0 // next_address_for_sort_dma
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < strip_length; i++) {
|
for (uint32_t i = 0; i < strip_length; i++) {
|
||||||
@ -69,15 +117,17 @@ uint32_t transform(uint32_t * ta_parameter_buf,
|
|||||||
y += 240.f;
|
y += 240.f;
|
||||||
z = 1.f / (z + 10.f);
|
z = 1.f / (z + 10.f);
|
||||||
|
|
||||||
parameter.append<vertex_polygon_type_3>() =
|
parameter.append<ta_vertex_parameter::polygon_type_3>() =
|
||||||
vertex_polygon_type_3(x, y, z,
|
ta_vertex_parameter::polygon_type_3(polygon_vertex_parameter_control_word(end_of_strip),
|
||||||
strip_vertices[i].u,
|
x, y, z,
|
||||||
strip_vertices[i].v,
|
strip_vertices[i].u,
|
||||||
strip_vertices[i].color,
|
strip_vertices[i].v,
|
||||||
end_of_strip);
|
strip_vertices[i].color,
|
||||||
|
0 // offset color
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter.append<global_end_of_list>() = global_end_of_list();
|
parameter.append<ta_global_parameter::end_of_list>() = ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
|
||||||
|
|
||||||
return parameter.offset;
|
return parameter.offset;
|
||||||
}
|
}
|
||||||
@ -86,7 +136,7 @@ void init_texture_memory(uint32_t render_passes)
|
|||||||
{
|
{
|
||||||
auto mem = reinterpret_cast<volatile texture_memory_alloc *>(texture_memory32);
|
auto mem = reinterpret_cast<volatile texture_memory_alloc *>(texture_memory32);
|
||||||
|
|
||||||
background_parameter(mem->background);
|
background_parameter(mem->background, 0xff00ff00);
|
||||||
|
|
||||||
region_array_multipass(mem->region_array,
|
region_array_multipass(mem->region_array,
|
||||||
(offsetof (struct texture_memory_alloc, object_list)),
|
(offsetof (struct texture_memory_alloc, object_list)),
|
||||||
@ -163,13 +213,17 @@ void main()
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// first render pass
|
// first render pass
|
||||||
ta_polygon_converter_init((opb_size[0].total() + opb_size[1].total()) * tiles, ta_alloc[0]);
|
ta_polygon_converter_init(opb_size[0].total() + opb_size[1].total(),
|
||||||
|
ta_alloc[0],
|
||||||
|
640 / 32,
|
||||||
|
480 / 32);
|
||||||
ta_parameter_size[0] = transform(ta_parameter_buf, strip_vertices, strip_length, 0);
|
ta_parameter_size[0] = transform(ta_parameter_buf, strip_vertices, strip_length, 0);
|
||||||
ta_polygon_converter_transfer(ta_parameter_buf, ta_parameter_size[0]);
|
ta_polygon_converter_transfer(ta_parameter_buf, ta_parameter_size[0]);
|
||||||
ta_wait_opaque_list();
|
ta_wait_opaque_list();
|
||||||
|
|
||||||
// second render pass
|
// second render pass
|
||||||
ta_polygon_converter_cont(opb_size[0].total() * tiles, ta_alloc[1]);
|
ta_polygon_converter_cont(opb_size[0].total() * tiles,
|
||||||
|
ta_alloc[1]);
|
||||||
ta_parameter_size[1] = transform(ta_parameter_buf, strip_vertices, strip_length, 1);
|
ta_parameter_size[1] = transform(ta_parameter_buf, strip_vertices, strip_length, 1);
|
||||||
ta_polygon_converter_transfer(ta_parameter_buf, ta_parameter_size[1]);
|
ta_polygon_converter_transfer(ta_parameter_buf, ta_parameter_size[1]);
|
||||||
ta_wait_translucent_list();
|
ta_wait_translucent_list();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user