X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fgpu_neon%2Fpsx_gpu%2Fpsx_gpu_parse.c;h=53f33e4c5d3a2160986f0c92f3dc5082550f9ee5;hb=4a1885e228806b41cf881ed1fc9860ad5f59f6e1;hp=af26fa37c568c4d5b8ffe2275a0eb525ee5e6b60;hpb=c296224f47ceebab4d6fbd071959bff294e80293;p=pcsx_rearmed.git diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c index af26fa37..53f33e4c 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c +++ b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c @@ -200,21 +200,14 @@ static void do_fill(psx_gpu_struct *psx_gpu, u32 x, u32 y, } } -#define sign_extend_12bit(value) \ - (((s32)((value) << 20)) >> 20) \ - #define sign_extend_11bit(value) \ (((s32)((value) << 21)) >> 21) \ -#define sign_extend_10bit(value) \ - (((s32)((value) << 22)) >> 22) \ - - #define get_vertex_data_xy(vertex_number, offset16) \ vertexes[vertex_number].x = \ - sign_extend_12bit(list_s16[offset16]) + psx_gpu->offset_x; \ + sign_extend_11bit(list_s16[offset16]) + psx_gpu->offset_x; \ vertexes[vertex_number].y = \ - sign_extend_12bit(list_s16[(offset16) + 1]) + psx_gpu->offset_y; \ + sign_extend_11bit(list_s16[(offset16) + 1]) + psx_gpu->offset_y; \ #define get_vertex_data_uv(vertex_number, offset16) \ vertexes[vertex_number].u = list_s16[offset16] & 0xFF; \ @@ -252,10 +245,11 @@ static void do_fill(psx_gpu_struct *psx_gpu, u32 x, u32 y, #endif u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, - s32 *cpu_cycles_out, u32 *last_command) + s32 *cpu_cycles_sum_out, s32 *cpu_cycles_last, u32 *last_command) { vertex_struct vertexes[4] __attribute__((aligned(16))) = {}; - u32 current_command = 0, command_length, cpu_cycles = 0; + u32 current_command = 0, command_length; + u32 cpu_cycles_sum = 0, cpu_cycles = *cpu_cycles_last; u32 *list_start = list; u32 *list_end = list + (size / 4); @@ -284,7 +278,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 color = list[0] & 0xFFFFFF; do_fill(psx_gpu, x, y, width, height, color); - cpu_cycles += gput_fill(width, height); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_fill(width, height)); break; } @@ -297,7 +291,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy(2, 6); render_triangle(psx_gpu, vertexes, current_command); - cpu_cycles += gput_poly_base(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base()); break; } @@ -312,7 +306,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy_uv(2, 10); render_triangle(psx_gpu, vertexes, current_command); - cpu_cycles += gput_poly_base_t(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base_t()); break; } @@ -327,7 +321,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_triangle(psx_gpu, vertexes, current_command); render_triangle(psx_gpu, &(vertexes[1]), current_command); - cpu_cycles += gput_quad_base(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base()); break; } @@ -344,7 +338,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_triangle(psx_gpu, vertexes, current_command); render_triangle(psx_gpu, &(vertexes[1]), current_command); - cpu_cycles += gput_quad_base_t(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_t()); break; } @@ -355,7 +349,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy_rgb(2, 8); render_triangle(psx_gpu, vertexes, current_command); - cpu_cycles += gput_poly_base_g(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base_g()); break; } @@ -369,7 +363,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy_uv_rgb(2, 12); render_triangle(psx_gpu, vertexes, current_command); - cpu_cycles += gput_poly_base_gt(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base_gt()); break; } @@ -382,7 +376,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_triangle(psx_gpu, vertexes, current_command); render_triangle(psx_gpu, &(vertexes[1]), current_command); - cpu_cycles += gput_quad_base_g(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_g()); break; } @@ -398,7 +392,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_triangle(psx_gpu, vertexes, current_command); render_triangle(psx_gpu, &(vertexes[1]), current_command); - cpu_cycles += gput_quad_base_gt(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_gt()); break; } @@ -410,7 +404,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, vertexes[1].y = list_s16[5] + psx_gpu->offset_y; render_line(psx_gpu, vertexes, current_command, list[0], 0); - cpu_cycles += gput_line(0); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0)); break; } @@ -432,7 +426,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, vertexes[1].y = (xy >> 16) + psx_gpu->offset_y; render_line(psx_gpu, vertexes, current_command, list[0], 0); - cpu_cycles += gput_line(0); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0)); list_position++; num_vertexes++; @@ -467,7 +461,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, vertexes[1].y = list_s16[7] + psx_gpu->offset_y; render_line(psx_gpu, vertexes, current_command, 0, 0); - cpu_cycles += gput_line(0); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0)); break; } @@ -498,7 +492,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, vertexes[1].y = (xy >> 16) + psx_gpu->offset_y; render_line(psx_gpu, vertexes, current_command, 0, 0); - cpu_cycles += gput_line(0); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0)); list_position += 2; num_vertexes++; @@ -527,7 +521,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, 0, 0, &width, &height, current_command, list[0]); - cpu_cycles += gput_sprite(width, height); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height)); break; } @@ -543,7 +537,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, uv & 0xFF, (uv >> 8) & 0xFF, &width, &height, current_command, list[0]); - cpu_cycles += gput_sprite(width, height); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height)); break; } @@ -555,7 +549,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, 0, 0, &width, &height, current_command, list[0]); - cpu_cycles += gput_sprite(1, 1); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(1, 1)); break; } @@ -567,7 +561,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, 0, 0, &width, &height, current_command, list[0]); - cpu_cycles += gput_sprite(width, height); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height)); break; } @@ -582,7 +576,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, uv & 0xFF, (uv >> 8) & 0xFF, &width, &height, current_command, list[0]); - cpu_cycles += gput_sprite(width, height); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height)); break; } @@ -594,7 +588,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, 0, 0, &width, &height, current_command, list[0]); - cpu_cycles += gput_sprite(width, height); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height)); break; } @@ -609,7 +603,7 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, uv & 0xFF, (uv >> 8) & 0xFF, &width, &height, current_command, list[0]); - cpu_cycles += gput_sprite(width, height); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height)); break; } @@ -789,7 +783,8 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, } breakloop: - *cpu_cycles_out += cpu_cycles; + *cpu_cycles_sum_out += cpu_cycles_sum; + *cpu_cycles_last = cpu_cycles; *last_command = current_command; return list - list_start; } @@ -1016,8 +1011,6 @@ void scale2x_tiles8(void *dst, const void *src, int w8, int h) } #endif -static int disable_main_render; - // simple check for a case where no clipping is used // - now handled by adjusting the viewport static int check_enhanced_range(psx_gpu_struct *psx_gpu, int x, int y) @@ -1063,6 +1056,7 @@ static void patch_v(vertex_struct *vertex_ptrs, int count, int old, int new) vertex_ptrs[i].v = new; } +// this sometimes does more harm than good, like in PE2 static void uv_hack(vertex_struct *vertex_ptrs, int vertex_count) { int i, u[4], v[4]; @@ -1101,7 +1095,7 @@ static void do_triangle_enhanced(psx_gpu_struct *psx_gpu, if (!prepare_triangle(psx_gpu, vertexes, vertex_ptrs)) return; - if (!disable_main_render) + if (!psx_gpu->hack_disable_main) render_triangle_p(psx_gpu, vertex_ptrs, current_command); if (!check_enhanced_range(psx_gpu, vertex_ptrs[0]->x, vertex_ptrs[2]->x)) @@ -1202,10 +1196,11 @@ static void do_sprite_enhanced(psx_gpu_struct *psx_gpu, int x, int y, #endif u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, - s32 *cpu_cycles_out, u32 *last_command) + s32 *cpu_cycles_sum_out, s32 *cpu_cycles_last, u32 *last_command) { vertex_struct vertexes[4] __attribute__((aligned(16))) = {}; - u32 current_command = 0, command_length, cpu_cycles = 0; + u32 current_command = 0, command_length; + u32 cpu_cycles_sum = 0, cpu_cycles = *cpu_cycles_last; u32 *list_start = list; u32 *list_end = list + (size / 4); @@ -1244,7 +1239,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, x &= ~0xF; width = ((width + 0xF) & ~0xF); - cpu_cycles += gput_fill(width, height); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_fill(width, height)); if (width == 0 || height == 0) break; @@ -1275,7 +1270,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy(2, 6); do_triangle_enhanced(psx_gpu, vertexes, current_command); - cpu_cycles += gput_poly_base(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base()); break; } @@ -1290,7 +1285,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy_uv(2, 10); do_triangle_enhanced(psx_gpu, vertexes, current_command); - cpu_cycles += gput_poly_base_t(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base_t()); break; } @@ -1304,7 +1299,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy(3, 8); do_quad_enhanced(psx_gpu, vertexes, current_command); - cpu_cycles += gput_quad_base(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base()); break; } @@ -1319,9 +1314,10 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy_uv(2, 10); get_vertex_data_xy_uv(3, 14); - uv_hack(vertexes, 4); + if (psx_gpu->hack_texture_adj) + uv_hack(vertexes, 4); do_quad_enhanced(psx_gpu, vertexes, current_command); - cpu_cycles += gput_quad_base_t(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_t()); break; } @@ -1332,7 +1328,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy_rgb(2, 8); do_triangle_enhanced(psx_gpu, vertexes, current_command); - cpu_cycles += gput_poly_base_g(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base_g()); break; } @@ -1346,7 +1342,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy_uv_rgb(2, 12); do_triangle_enhanced(psx_gpu, vertexes, current_command); - cpu_cycles += gput_poly_base_gt(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base_gt()); break; } @@ -1358,7 +1354,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy_rgb(3, 12); do_quad_enhanced(psx_gpu, vertexes, current_command); - cpu_cycles += gput_quad_base_g(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_g()); break; } @@ -1372,9 +1368,10 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy_uv_rgb(2, 12); get_vertex_data_xy_uv_rgb(3, 18); - uv_hack(vertexes, 4); + if (psx_gpu->hack_texture_adj) + uv_hack(vertexes, 4); do_quad_enhanced(psx_gpu, vertexes, current_command); - cpu_cycles += gput_quad_base_gt(); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_gt()); break; } @@ -1388,7 +1385,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_line(psx_gpu, vertexes, current_command, list[0], 0); if (enhancement_enable(psx_gpu)) render_line(psx_gpu, vertexes, current_command, list[0], 1); - cpu_cycles += gput_line(0); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0)); break; } @@ -1413,7 +1410,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_line(psx_gpu, vertexes, current_command, list[0], 0); if (enhancement_enable(psx_gpu)) render_line(psx_gpu, vertexes, current_command, list[0], 1); - cpu_cycles += gput_line(0); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0)); list_position++; num_vertexes++; @@ -1450,7 +1447,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_line(psx_gpu, vertexes, current_command, 0, 0); if (enhancement_enable(psx_gpu)) render_line(psx_gpu, vertexes, current_command, 0, 1); - cpu_cycles += gput_line(0); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0)); break; } @@ -1484,7 +1481,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_line(psx_gpu, vertexes, current_command, 0, 0); if (enhancement_enable(psx_gpu)) render_line(psx_gpu, vertexes, current_command, 0, 1); - cpu_cycles += gput_line(0); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0)); list_position += 2; num_vertexes++; @@ -1513,10 +1510,13 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, 0, 0, &width, &height, current_command, list[0]); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height)); - if (check_enhanced_range(psx_gpu, x, x + width)) + if (check_enhanced_range(psx_gpu, x, x + width)) { + width = list_s16[4] & 0x3FF; + height = list_s16[5] & 0x1FF; do_sprite_enhanced(psx_gpu, x, y, 0, 0, width, height, list[0]); - cpu_cycles += gput_sprite(width, height); + } break; } @@ -1533,10 +1533,13 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, u, v, &width, &height, current_command, list[0]); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height)); - if (check_enhanced_range(psx_gpu, x, x + width)) + if (check_enhanced_range(psx_gpu, x, x + width)) { + width = list_s16[6] & 0x3FF; + height = list_s16[7] & 0x1FF; do_sprite_enhanced(psx_gpu, x, y, u, v, width, height, list[0]); - cpu_cycles += gput_sprite(width, height); + } break; } @@ -1548,10 +1551,10 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, 0, 0, &width, &height, current_command, list[0]); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(1, 1)); if (check_enhanced_range(psx_gpu, x, x + 1)) - do_sprite_enhanced(psx_gpu, x, y, 0, 0, width, height, list[0]); - cpu_cycles += gput_sprite(1, 1); + do_sprite_enhanced(psx_gpu, x, y, 0, 0, 1, 1, list[0]); break; } @@ -1563,10 +1566,10 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, 0, 0, &width, &height, current_command, list[0]); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height)); if (check_enhanced_range(psx_gpu, x, x + 8)) - do_sprite_enhanced(psx_gpu, x, y, 0, 0, width, height, list[0]); - cpu_cycles += gput_sprite(width, height); + do_sprite_enhanced(psx_gpu, x, y, 0, 0, 8, 8, list[0]); break; } @@ -1582,10 +1585,10 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, u, v, &width, &height, current_command, list[0]); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height)); if (check_enhanced_range(psx_gpu, x, x + 8)) - do_sprite_enhanced(psx_gpu, x, y, u, v, width, height, list[0]); - cpu_cycles += gput_sprite(width, height); + do_sprite_enhanced(psx_gpu, x, y, u, v, 8, 8, list[0]); break; } @@ -1597,10 +1600,10 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, 0, 0, &width, &height, current_command, list[0]); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height)); if (check_enhanced_range(psx_gpu, x, x + 16)) - do_sprite_enhanced(psx_gpu, x, y, 0, 0, width, height, list[0]); - cpu_cycles += gput_sprite(width, height); + do_sprite_enhanced(psx_gpu, x, y, 0, 0, 16, 16, list[0]); break; } @@ -1616,10 +1619,10 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, render_sprite(psx_gpu, x, y, u, v, &width, &height, current_command, list[0]); + gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height)); if (check_enhanced_range(psx_gpu, x, x + 16)) - do_sprite_enhanced(psx_gpu, x, y, u, v, width, height, list[0]); - cpu_cycles += gput_sprite(width, height); + do_sprite_enhanced(psx_gpu, x, y, u, v, 16, 16, list[0]); break; } @@ -1736,10 +1739,8 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, case 0xE5: { - s32 offset_x = list[0] << 21; - s32 offset_y = list[0] << 10; - psx_gpu->offset_x = offset_x >> 21; - psx_gpu->offset_y = offset_y >> 21; + psx_gpu->offset_x = sign_extend_11bit(list[0]); + psx_gpu->offset_y = sign_extend_11bit(list[0] >> 11); SET_Ex(5, list[0]); break; @@ -1773,7 +1774,8 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, enhancement_disable(); breakloop: - *cpu_cycles_out += cpu_cycles; + *cpu_cycles_sum_out += cpu_cycles_sum; + *cpu_cycles_last = cpu_cycles; *last_command = current_command; return list - list_start; }