X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fgpu_neon%2Fpsx_gpu%2Fpsx_gpu.c;h=98aacc3439775ddaa7ddc90ffd810bc9fcdb7c21;hb=d81b8e972678928ffece2d38213de8048f5e872d;hp=7c1503bcc397d584d500ce7a8320329784b7f359;hpb=6c4a10c497c1262acc05b15ffacb57acfffa409c;p=pcsx_rearmed.git diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu.c b/plugins/gpu_neon/psx_gpu/psx_gpu.c index 7c1503bc..98aacc34 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu.c +++ b/plugins/gpu_neon/psx_gpu/psx_gpu.c @@ -244,6 +244,58 @@ u32 invalidate_texture_cache_region_viewport(psx_gpu_struct *psx_gpu, u32 x1, return mask; } +void update_texture_cache_region(psx_gpu_struct *psx_gpu, u32 x1, u32 y1, + u32 x2, u32 y2) +{ + u32 mask = texture_region_mask(x1, y1, x2, y2); + u32 texture_page; + u8 *texture_page_ptr; + u16 *vram_ptr; + u32 texel_block; + u32 sub_x, sub_y; + + psx_gpu->dirty_textures_8bpp_mask |= mask; + psx_gpu->dirty_textures_8bpp_alternate_mask |= mask; + + if ((psx_gpu->dirty_textures_4bpp_mask & mask) == 0 && + (x1 & 3) == 0 && (y1 & 15) == 0 && x2 - x1 < 4 && y2 - y1 < 16) + { + texture_page = ((x1 / 64) & 15) + (y1 / 256) * 16; + texture_page_ptr = psx_gpu->texture_4bpp_cache[texture_page]; + texture_page_ptr += (x1 / 4 & 15) * 16*16 + (y1 / 16 & 15) * 16*16*16; + vram_ptr = psx_gpu->vram_ptr + x1 + y1 * 1024; + sub_x = 4; + sub_y = 16; + + while(sub_y) + { + while(sub_x) + { + texel_block = *vram_ptr; + + texture_page_ptr[0] = texel_block & 0xF; + texture_page_ptr[1] = (texel_block >> 4) & 0xF; + texture_page_ptr[2] = (texel_block >> 8) & 0xF; + texture_page_ptr[3] = texel_block >> 12; + + vram_ptr++; + texture_page_ptr += 4; + + sub_x--; + } + + vram_ptr -= 4; + sub_x = 4; + + sub_y--; + vram_ptr += 1024; + } + } + else + { + psx_gpu->dirty_textures_4bpp_mask |= mask; + } +} void update_texture_8bpp_cache_slice(psx_gpu_struct *psx_gpu, u32 texture_page); @@ -401,6 +453,48 @@ void setup_blocks_shaded_untextured_undithered_unswizzled_indirect( void flush_render_block_buffer(psx_gpu_struct *psx_gpu) { + if((psx_gpu->interlace_mode & RENDER_INTERLACE_ENABLED) && + (psx_gpu->primitive_type == PRIMITIVE_TYPE_SPRITE)) + { + u32 num_blocks_dest = 0; + block_struct *block_src = psx_gpu->blocks; + block_struct *block_dest = psx_gpu->blocks; + + u16 *vram_ptr = psx_gpu->vram_ptr; + u32 i; + + if(psx_gpu->interlace_mode & RENDER_INTERLACE_ODD) + { + for(i = 0; i < psx_gpu->num_blocks; i++) + { + u32 fb_offset = (u32)((u8 *)block_src->fb_ptr - (u8 *)vram_ptr); + if(fb_offset & (1 << 11)) + { + *block_dest = *block_src; + num_blocks_dest++; + block_dest++; + } + block_src++; + } + } + else + { + for(i = 0; i < psx_gpu->num_blocks; i++) + { + u32 fb_offset = (u32)((u8 *)block_src->fb_ptr - (u8 *)vram_ptr); + if((fb_offset & (1 << 11)) == 0) + { + *block_dest = *block_src; + num_blocks_dest++; + block_dest++; + } + block_src++; + } + } + + psx_gpu->num_blocks = num_blocks_dest; + } + if(psx_gpu->num_blocks) { render_block_handler_struct *render_block_handler = @@ -760,7 +854,7 @@ void compute_all_gradients(psx_gpu_struct *psx_gpu, vertex_struct *a, \ dup_2x32b(edge_shifts, edge_shift); \ sub_2x32b(heights_b, heights, c_0x01); \ - shr_2x32b(height_reciprocals, edge_shifts, 12); \ + shr_2x32b(height_reciprocals, edge_shifts, 10); \ \ mla_2x32b(heights_b, x_starts, heights); \ bic_immediate_4x16b(vector_cast(vec_4x16u, edge_shifts), 0xE0); \ @@ -789,8 +883,8 @@ void compute_all_gradients(psx_gpu_struct *psx_gpu, vertex_struct *a, sub_2x32b(widths, x_ends, x_starts); \ width_alt = x_c - start_c; \ \ - shr_2x32b(height_reciprocals, edge_shifts, 12); \ - height_reciprocal_alt = edge_shift_alt >> 12; \ + shr_2x32b(height_reciprocals, edge_shifts, 10); \ + height_reciprocal_alt = edge_shift_alt >> 10; \ \ bic_immediate_4x16b(vector_cast(vec_4x16u, edge_shifts), 0xE0); \ edge_shift_alt &= 0x1F; \ @@ -2876,7 +2970,7 @@ void render_triangle(psx_gpu_struct *psx_gpu, vertex_struct *vertexes, vertex_swap(a, b); } - if((c->x - a->x) >= 1024) + if((c->x - psx_gpu->offset_x) >= 1024 || (c->x - a->x) >= 1024) { #ifdef PROFILE trivial_rejects++; @@ -2987,6 +3081,28 @@ void render_triangle(psx_gpu_struct *psx_gpu, vertex_struct *vertexes, spans += psx_gpu->num_spans; #endif + if(psx_gpu->interlace_mode & RENDER_INTERLACE_ENABLED) + { + u32 i; + + if(psx_gpu->interlace_mode & RENDER_INTERLACE_ODD) + { + for(i = 0; i < psx_gpu->num_spans; i++) + { + if((psx_gpu->span_edge_data[i].y & 1) == 0) + psx_gpu->span_edge_data[i].num_blocks = 0; + } + } + else + { + for(i = 0; i < psx_gpu->num_spans; i++) + { + if(psx_gpu->span_edge_data[i].y & 1) + psx_gpu->span_edge_data[i].num_blocks = 0; + } + } + } + u32 render_state = flags & (RENDER_FLAGS_MODULATE_TEXELS | RENDER_FLAGS_BLEND | RENDER_FLAGS_TEXTURE_MAP | RENDER_FLAGS_SHADE); @@ -4410,12 +4526,12 @@ void initialize_reciprocal_table(void) { shift = __builtin_clz(height); height_normalized = height << shift; - height_reciprocal = ((1ULL << 50) + (height_normalized - 1)) / + height_reciprocal = ((1ULL << 52) + (height_normalized - 1)) / height_normalized; - shift = 32 - (50 - shift); + shift = 32 - (52 - shift); - reciprocal_table[height] = (height_reciprocal << 12) | shift; + reciprocal_table[height] = (height_reciprocal << 10) | shift; } } @@ -4457,6 +4573,8 @@ void initialize_psx_gpu(psx_gpu_struct *psx_gpu, u16 *vram) psx_gpu->texture_mask_width = 0xFF; psx_gpu->texture_mask_height = 0xFF; + psx_gpu->interlace_mode = 0; + memset(psx_gpu->vram_ptr, 0, sizeof(u16) * 1024 * 512); initialize_reciprocal_table();