return 0;
}
+void renderer_finish(void)
+{
+}
+
+void renderer_notify_res_change(void)
+{
+}
+
extern const unsigned char cmd_lengths[256];
int do_cmd_list(unsigned int *list, int list_len, int *last_cmd)
return 0;
}
+void renderer_finish(void)
+{
+}
+
+void renderer_notify_res_change(void)
+{
+}
+
extern const unsigned char cmd_lengths[256];
// XXX: mostly dupe code from soft peops
}
}
}
- 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 |
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;
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)
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)
{
RENDER_INTERLACE_ENABLED = 0x1,
RENDER_INTERLACE_ODD = 0x2,
- RENDER_DOUBLE_MODE = 0x4,
} render_mode_enum;
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;
// 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];
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; \
}
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)
{
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;
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 =
{
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);
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;
}
return 0;
}
+void renderer_finish(void)
+{
+}
+
+void renderer_notify_res_change(void)
+{
+}
+
extern const unsigned char cmd_lengths[256];
int do_cmd_list(unsigned int *list, int list_len, int *last_cmd)
*/
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include "gpu.h"
{
int ret;
ret = vout_init();
-
- gpu.state.enhancement_available = 0;
ret |= renderer_init();
- if (gpu.state.enhancement_available) {
- if (gpu.enhancement_bufer == NULL)
- gpu.enhancement_bufer = malloc(2048 * 1024 * 2 + 1024 * 512 * 2);
- if (gpu.enhancement_bufer == NULL)
- gpu_log("OOM for enhancement buffer\n");
- }
- else if (gpu.enhancement_bufer != NULL) {
- free(gpu.enhancement_bufer);
- gpu.enhancement_bufer = NULL;
- }
-
gpu.state.frame_count = &gpu.zero;
gpu.state.hcnt = &gpu.zero;
gpu.frameskip.active = 0;
long GPUshutdown(void)
{
+ renderer_finish();
return vout_finish();
}
gpu.screen.vres = vres[(gpu.status.reg >> 19) & 3];
update_width();
update_height();
+ renderer_notify_res_change();
break;
default:
if ((cmd & 0xf0) == 0x10)
uint32_t old_interlace:1;
uint32_t allow_interlace:2;
uint32_t blanked:1;
- uint32_t enhancement_available:1;
uint32_t enhancement_enable:1;
uint32_t enhancement_active:1;
uint32_t *frame_count;
uint32_t last_flip_frame;
uint32_t pending_fill[3];
} frameskip;
- void *enhancement_bufer;
+ uint16_t *enhancement_bufer;
};
extern struct psx_gpu gpu;
struct rearmed_cbs;
int renderer_init(void);
+void renderer_finish(void);
void renderer_sync_ecmds(uint32_t * ecmds);
void renderer_update_caches(int x, int y, int w, int h);
void renderer_flush_queues(void);
void renderer_set_interlace(int enable, int is_odd);
void renderer_set_config(const struct rearmed_cbs *config);
+void renderer_notify_res_change(void);
int vout_init(void);
int vout_finish(void);
uint8_t *dest;
dest = (uint8_t *)screen_buf;
- if (dest == NULL)
+ if (dest == NULL || w == 0 || stride == 0)
return;
if (gpu.state.enhancement_active) {
- vram = gpu.enhancement_bufer;
+ // this layout is gpu_neon specific..
+ vram = gpu.enhancement_bufer +
+ (x + 8) / stride * 1024 * 1024;
x *= 2;
y *= 2;
w *= 2;
h *= 2;
stride *= 2;
- vram_stride = 2048;
- vram_mask = 2048 * 1024 - 1;
+ vram_mask = 1024 * 1024 - 1;
}
fb_offs = y * vram_stride + x;