gpu: move enhacement logic out of vout_pl
authornotaz <notasas@gmail.com>
Mon, 22 Oct 2012 21:34:30 +0000 (00:34 +0300)
committernotaz <notasas@gmail.com>
Tue, 23 Oct 2012 22:10:16 +0000 (01:10 +0300)
plugins/gpu_neon/psx_gpu_if.c
plugins/gpulib/gpu.h
plugins/gpulib/vout_pl.c

index 62c4f9e..3ce9c1c 100644 (file)
@@ -43,17 +43,34 @@ int do_cmd_list(uint32_t *list, int count, int *last_cmd)
 
 #define ENHANCEMENT_BUF_SIZE (1024 * 1024 * 2 * 4 + 4096 * 2)
 
 
 #define ENHANCEMENT_BUF_SIZE (1024 * 1024 * 2 * 4 + 4096 * 2)
 
+static uint16_t *get_enhancement_bufer(int *x, int *y, int *w, int *h,
+ int *stride, int *mask)
+{
+  uint16_t *ret = select_enhancement_buf_ptr(&egpu, *x);
+
+  *x *= 2;
+  *y *= 2;
+  *w = *w * 2;
+  *h = *h * 2;
+  *stride *= 2;
+  *mask = 1024 * 1024 - 1;
+  return ret;
+}
+
 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).
 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).
-  gpu.enhancement_bufer = gpu.mmap(ENHANCEMENT_BUF_SIZE);
-  if (gpu.enhancement_bufer == NULL)
+  egpu.enhancement_buf_ptr = gpu.mmap(ENHANCEMENT_BUF_SIZE);
+  if (egpu.enhancement_buf_ptr == NULL) {
     fprintf(stderr, "failed to map enhancement buffer\n");
     fprintf(stderr, "failed to map enhancement buffer\n");
-  else
-    gpu.enhancement_bufer += 4096 / 2;
-  egpu.enhancement_buf_ptr = gpu.enhancement_bufer;
+    gpu.get_enhancement_bufer = NULL;
+  }
+  else {
+    egpu.enhancement_buf_ptr += 4096 / 2;
+    gpu.get_enhancement_bufer = get_enhancement_bufer;
+  }
 }
 
 int renderer_init(void)
 }
 
 int renderer_init(void)
@@ -63,7 +80,7 @@ int renderer_init(void)
     initialized = 1;
   }
 
     initialized = 1;
   }
 
-  if (gpu.mmap != NULL && gpu.enhancement_bufer == NULL)
+  if (gpu.mmap != NULL && egpu.enhancement_buf_ptr == NULL)
     map_enhancement_buffer();
 
   ex_regs = gpu.ex_regs;
     map_enhancement_buffer();
 
   ex_regs = gpu.ex_regs;
@@ -72,11 +89,10 @@ int renderer_init(void)
 
 void renderer_finish(void)
 {
 
 void renderer_finish(void)
 {
-  if (gpu.enhancement_bufer != NULL) {
-    gpu.enhancement_bufer -= 4096 / 2;
-    gpu.munmap(gpu.enhancement_bufer, ENHANCEMENT_BUF_SIZE);
+  if (egpu.enhancement_buf_ptr != NULL) {
+    egpu.enhancement_buf_ptr -= 4096 / 2;
+    gpu.munmap(egpu.enhancement_buf_ptr, ENHANCEMENT_BUF_SIZE);
   }
   }
-  gpu.enhancement_bufer = NULL;
   egpu.enhancement_buf_ptr = NULL;
   egpu.enhancement_current_buf_ptr = NULL;
   initialized = 0;
   egpu.enhancement_buf_ptr = NULL;
   egpu.enhancement_current_buf_ptr = NULL;
   initialized = 0;
@@ -165,6 +181,6 @@ void renderer_set_config(const struct rearmed_cbs *cbs)
     initialized = 1;
   }
 
     initialized = 1;
   }
 
-  if (gpu.enhancement_bufer == NULL)
+  if (gpu.mmap != NULL && egpu.enhancement_buf_ptr == NULL)
     map_enhancement_buffer();
 }
     map_enhancement_buffer();
 }
index 78a8990..ea5051e 100644 (file)
@@ -88,7 +88,8 @@ struct psx_gpu {
     uint32_t last_flip_frame;
     uint32_t pending_fill[3];
   } frameskip;
     uint32_t last_flip_frame;
     uint32_t pending_fill[3];
   } frameskip;
-  uint16_t *enhancement_bufer;
+  uint16_t *(*get_enhancement_bufer)
+    (int *x, int *y, int *w, int *h, int *stride, int *mask);
   void *(*mmap)(unsigned int size);
   void  (*munmap)(void *ptr, unsigned int size);
 };
   void *(*mmap)(unsigned int size);
   void  (*munmap)(void *ptr, unsigned int size);
 };
index 6e2764c..9a84432 100644 (file)
@@ -35,7 +35,7 @@ static void check_mode_change(void)
   int h = gpu.screen.h;
 
   gpu.state.enhancement_active =
   int h = gpu.screen.h;
 
   gpu.state.enhancement_active =
-    gpu.enhancement_bufer != NULL && gpu.state.enhancement_enable
+    gpu.get_enhancement_bufer != NULL && gpu.state.enhancement_enable
     && w <= 512 && h <= 256 && !gpu.status.rgb24;
 
   if (gpu.state.enhancement_active) {
     && w <= 512 && h <= 256 && !gpu.status.rgb24;
 
   if (gpu.state.enhancement_active) {
@@ -71,17 +71,9 @@ static void blit(void)
   if (dest == NULL || w == 0 || stride == 0)
     return;
 
   if (dest == NULL || w == 0 || stride == 0)
     return;
 
-  if (gpu.state.enhancement_active) {
-    // this layout is gpu_neon specific..
-    vram = gpu.enhancement_bufer +
-      (x + 8) / stride * 1024 * 1024;
-    x *= 2;
-    y *= 2;
-    w = w * 2;
-    h = h * 2;
-    stride *= 2;
-    vram_mask = 1024 * 1024 - 1;
-  }
+  if (gpu.state.enhancement_active)
+    vram = gpu.get_enhancement_bufer(&x, &y, &w, &h, &stride, &vram_mask);
+
   fb_offs = y * vram_stride + x;
 
   // only do centering, at least for now
   fb_offs = y * vram_stride + x;
 
   // only do centering, at least for now