aboutsummaryrefslogtreecommitdiff
path: root/plugins/gpu_neon
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/gpu_neon')
-rw-r--r--plugins/gpu_neon/psx_gpu/psx_gpu.c17
-rw-r--r--plugins/gpu_neon/psx_gpu/psx_gpu.h5
-rw-r--r--plugins/gpu_neon/psx_gpu/psx_gpu_parse.c17
-rw-r--r--plugins/gpu_neon/psx_gpu_if.c25
4 files changed, 46 insertions, 18 deletions
diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu.c b/plugins/gpu_neon/psx_gpu/psx_gpu.c
index 28ebcf5..092125b 100644
--- a/plugins/gpu_neon/psx_gpu/psx_gpu.c
+++ b/plugins/gpu_neon/psx_gpu/psx_gpu.c
@@ -3118,14 +3118,6 @@ static void render_triangle_p(psx_gpu_struct *psx_gpu,
}
}
}
- if(psx_gpu->render_mode & RENDER_DOUBLE_MODE)
- {
- u32 i;
- for(i = 0; i < psx_gpu->num_spans; i++)
- {
- psx_gpu->span_edge_data[i].y *= 2;
- }
- }
u32 render_state = flags &
(RENDER_FLAGS_MODULATE_TEXELS | RENDER_FLAGS_BLEND |
@@ -4519,6 +4511,9 @@ void render_block_fill_enh(psx_gpu_struct *psx_gpu, u32 color, u32 x, u32 y,
if((width == 0) || (height == 0))
return;
+ if(width > 1024)
+ width = 1024;
+
u32 r = color & 0xFF;
u32 g = (color >> 8) & 0xFF;
u32 b = (color >> 16) & 0xFF;
@@ -4526,9 +4521,9 @@ void render_block_fill_enh(psx_gpu_struct *psx_gpu, u32 color, u32 x, u32 y,
psx_gpu->mask_msb;
u32 color_32bpp = color_16bpp | (color_16bpp << 16);
- u32 *vram_ptr = (u32 *)(psx_gpu->vram_out_ptr + x + (y * 2048));
+ u32 *vram_ptr = (u32 *)(psx_gpu->vram_out_ptr + x + (y * 1024));
- u32 pitch = 2048 / 2 - (width / 2);
+ u32 pitch = 1024 / 2 - (width / 2);
u32 num_width;
while(height)
@@ -4671,6 +4666,8 @@ void initialize_psx_gpu(psx_gpu_struct *psx_gpu, u16 *vram)
psx_gpu->dither_table[3] = dither_table_row(3, -1, 2, -2);
psx_gpu->primitive_type = PRIMITIVE_TYPE_UNKNOWN;
+
+ psx_gpu->enhancement_x_threshold = 256;
}
u64 get_us(void)
diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu.h b/plugins/gpu_neon/psx_gpu/psx_gpu.h
index 7252dc2..fc5b566 100644
--- a/plugins/gpu_neon/psx_gpu/psx_gpu.h
+++ b/plugins/gpu_neon/psx_gpu/psx_gpu.h
@@ -57,7 +57,6 @@ typedef enum
{
RENDER_INTERLACE_ENABLED = 0x1,
RENDER_INTERLACE_ODD = 0x2,
- RENDER_DOUBLE_MODE = 0x4,
} render_mode_enum;
typedef struct
@@ -183,6 +182,8 @@ typedef struct
// enhancement stuff
u16 *enhancement_buf_ptr;
+ u16 *enhancement_current_buf_ptr;
+ u32 enhancement_x_threshold;
s16 saved_viewport_start_x;
s16 saved_viewport_start_y;
s16 saved_viewport_end_x;
@@ -190,7 +191,7 @@ typedef struct
// Align up to 64 byte boundary to keep the upcoming buffers cache line
// aligned, also make reachable with single immediate addition
- u8 reserved_a[236];
+ u8 reserved_a[228];
// 8KB
block_struct blocks[MAX_BLOCKS_PER_ROW];
diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c
index 1c449ea..54f5614 100644
--- a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c
+++ b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c
@@ -750,23 +750,30 @@ breakloop:
return list - list_start;
}
+#define select_enhancement_buf(psx_gpu) { \
+ u32 _x, _b; \
+ _x = psx_gpu->saved_viewport_start_x + 8; \
+ for (_b = 0; _x >= psx_gpu->enhancement_x_threshold; _b++) \
+ _x -= psx_gpu->enhancement_x_threshold; \
+ psx_gpu->enhancement_current_buf_ptr = \
+ psx_gpu->enhancement_buf_ptr + _b * 1024 * 1024; \
+}
+
#define enhancement_disable() { \
psx_gpu->vram_out_ptr = psx_gpu->vram_ptr; \
psx_gpu->viewport_start_x = psx_gpu->saved_viewport_start_x; \
psx_gpu->viewport_start_y = psx_gpu->saved_viewport_start_y; \
psx_gpu->viewport_end_x = psx_gpu->saved_viewport_end_x; \
psx_gpu->viewport_end_y = psx_gpu->saved_viewport_end_y; \
- psx_gpu->render_mode &= ~RENDER_DOUBLE_MODE; \
psx_gpu->uvrgb_phase = 0x8000; \
}
#define enhancement_enable() { \
- psx_gpu->vram_out_ptr = psx_gpu->enhancement_buf_ptr; \
+ psx_gpu->vram_out_ptr = psx_gpu->enhancement_current_buf_ptr; \
psx_gpu->viewport_start_x = psx_gpu->saved_viewport_start_x * 2; \
psx_gpu->viewport_start_y = psx_gpu->saved_viewport_start_y * 2; \
psx_gpu->viewport_end_x = psx_gpu->saved_viewport_end_x * 2; \
psx_gpu->viewport_end_y = psx_gpu->saved_viewport_end_y * 2; \
- psx_gpu->render_mode |= RENDER_DOUBLE_MODE; \
psx_gpu->uvrgb_phase = 0x1000; \
}
@@ -913,6 +920,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c
psx_gpu->saved_viewport_start_y = psx_gpu->viewport_start_y;
psx_gpu->saved_viewport_end_x = psx_gpu->viewport_end_x;
psx_gpu->saved_viewport_end_y = psx_gpu->viewport_end_y;
+ select_enhancement_buf(psx_gpu);
for(; list < list_end; list += 1 + command_length)
{
@@ -944,7 +952,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c
do_fill(psx_gpu, x, y, width, height, color);
- psx_gpu->vram_out_ptr = psx_gpu->enhancement_buf_ptr;
+ psx_gpu->vram_out_ptr = psx_gpu->enhancement_current_buf_ptr;
x *= 2;
y *= 2;
width *= 2;
@@ -1357,6 +1365,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c
psx_gpu->viewport_start_y = (list[0] >> 10) & 0x1FF;
psx_gpu->saved_viewport_start_x = psx_gpu->viewport_start_x;
psx_gpu->saved_viewport_start_y = psx_gpu->viewport_start_y;
+ select_enhancement_buf(psx_gpu);
#ifdef TEXTURE_CACHE_4BPP
psx_gpu->viewport_mask =
diff --git a/plugins/gpu_neon/psx_gpu_if.c b/plugins/gpu_neon/psx_gpu_if.c
index d42f83a..250aa8c 100644
--- a/plugins/gpu_neon/psx_gpu_if.c
+++ b/plugins/gpu_neon/psx_gpu_if.c
@@ -43,10 +43,27 @@ int renderer_init(void)
{
initialize_psx_gpu(&egpu, gpu.vram);
ex_regs = gpu.ex_regs;
- gpu.state.enhancement_available = 1;
+
+ if (gpu.enhancement_bufer == NULL) {
+ // currently we use 4x 1024*1024 buffers instead of single 2048*1024
+ // to be able to reuse 1024-width code better (triangle setup,
+ // dithering phase, lines).
+ gpu.enhancement_bufer = malloc(1024 * 1024 * 2 * 4);
+ if (gpu.enhancement_bufer == NULL)
+ printf("OOM for enhancement buffer\n");
+ }
+ egpu.enhancement_buf_ptr = gpu.enhancement_bufer;
+
return 0;
}
+void renderer_finish(void)
+{
+ free(gpu.enhancement_bufer);
+ gpu.enhancement_bufer = NULL;
+ egpu.enhancement_buf_ptr = NULL;
+}
+
void renderer_sync_ecmds(uint32_t *ecmds)
{
gpu_parse(&egpu, ecmds + 1, 6 * 4, NULL);
@@ -71,10 +88,14 @@ void renderer_set_interlace(int enable, int is_odd)
egpu.render_mode |= RENDER_INTERLACE_ODD;
}
+void renderer_notify_res_change(void)
+{
+ egpu.enhancement_x_threshold = gpu.screen.hres;
+}
+
#include "../../frontend/plugin_lib.h"
void renderer_set_config(const struct rearmed_cbs *cbs)
{
- egpu.enhancement_buf_ptr = gpu.enhancement_bufer;
disable_main_render = cbs->gpu_neon.enhancement_no_main;
}