1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/*
* (C) Gražvydas "notaz" Ignotas, 2011
*
* This work is licensed under the terms of any of these licenses
* (at your option):
* - GNU GPL, version 2 or later.
* - GNU LGPL, version 2.1 or later.
* See the COPYING file in the top-level directory.
*/
#include <stdio.h>
extern const unsigned char cmd_lengths[256];
#define command_lengths cmd_lengths
static unsigned int *ex_regs;
#define PCSX
#define SET_Ex(r, v) \
ex_regs[r] = v
#include "psx_gpu/psx_gpu.c"
#include "psx_gpu/psx_gpu_parse.c"
#include "../gpulib/gpu.h"
static psx_gpu_struct egpu __attribute__((aligned(256)));
int do_cmd_list(uint32_t *list, int count, int *last_cmd)
{
int ret;
if (gpu.state.enhancement_active)
ret = gpu_parse_enhanced(&egpu, list, count * 4, (u32 *)last_cmd);
else
ret = gpu_parse(&egpu, list, count * 4, (u32 *)last_cmd);
ex_regs[1] &= ~0x1ff;
ex_regs[1] |= egpu.texture_settings & 0x1ff;
return ret;
}
int renderer_init(void)
{
initialize_psx_gpu(&egpu, gpu.vram);
ex_regs = gpu.ex_regs;
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);
}
void renderer_update_caches(int x, int y, int w, int h)
{
update_texture_cache_region(&egpu, x, y, x + w - 1, y + h - 1);
}
void renderer_flush_queues(void)
{
flush_render_block_buffer(&egpu);
}
void renderer_set_interlace(int enable, int is_odd)
{
egpu.render_mode &= ~(RENDER_INTERLACE_ENABLED|RENDER_INTERLACE_ODD);
if (enable)
egpu.render_mode |= RENDER_INTERLACE_ENABLED;
if (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)
{
disable_main_render = cbs->gpu_neon.enhancement_no_main;
}
|