- 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 = mmap(NULL, ENHANCEMENT_BUF_SIZE,
- PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- if (gpu.enhancement_bufer == MAP_FAILED) {
- printf("OOM for enhancement buffer\n");
- gpu.enhancement_bufer = NULL;
- }
+static void map_enhancement_buffer(void)
+{
+ // 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).
+ egpu.enhancement_buf_ptr = gpu.mmap(ENHANCEMENT_BUF_SIZE);
+ if (egpu.enhancement_buf_ptr == NULL) {
+ fprintf(stderr, "failed to map enhancement buffer\n");
+ gpu.get_enhancement_bufer = NULL;
+ }
+ else {
+ egpu.enhancement_buf_ptr += 4096 / 2;
+ gpu.get_enhancement_bufer = get_enhancement_bufer;
+ }
+}
+
+int renderer_init(void)
+{
+ if (gpu.vram != NULL) {
+ initialize_psx_gpu(&egpu, gpu.vram);
+ initialized = 1;