gpu-gles: add gpulib code
[pcsx_rearmed.git] / plugins / gpu-gles / gpulib_if.c
1 /***************************************************************************
2     begin                : Sun Mar 08 2009
3     copyright            : (C) 1999-2009 by Pete Bernert
4     email                : BlackDove@addcom.de
5
6     PCSX rearmed rework (C) notaz, 2012
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version. See also the license.txt file for *
15  *   additional informations.                                              *
16  *                                                                         *
17  ***************************************************************************/
18
19 #include "gpuDraw.c"
20 #include "gpuTexture.c"
21 #include "gpuPrim.c"
22
23 static const short dispWidths[8] = {256,320,512,640,368,384,512,640};
24 short g_m1,g_m2,g_m3;
25 short DrawSemiTrans;
26
27 short          ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3;        // global psx vertex coords
28 long           GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP;
29 long           GlobalTextREST,GlobalTextABR,GlobalTextPAGE;
30
31 unsigned long dwGPUVersion;
32 int           iGPUHeight=512;
33 int           iGPUHeightMask=511;
34 int           GlobalTextIL;
35
36 unsigned char  *psxVub;
37 unsigned short *psxVuw;
38
39 GLfloat         gl_z=0.0f;
40 BOOL            bNeedInterlaceUpdate;
41 BOOL            bNeedRGB24Update;
42 BOOL            bChangeWinMode;
43 long            lGPUstatusRet;
44 unsigned long   ulGPUInfoVals[16];
45 VRAMLoad_t      VRAMWrite;
46 VRAMLoad_t      VRAMRead;
47 int             iDataWriteMode;
48 int             iDataReadMode;
49
50 long            lClearOnSwap;
51 long            lClearOnSwapColor;
52 BOOL            bSkipNextFrame;
53
54 PSXDisplay_t    PSXDisplay;
55 PSXDisplay_t    PreviousPSXDisplay;
56 TWin_t          TWin;
57 BOOL            bDisplayNotSet;
58 BOOL            bNeedWriteUpload;
59 int             iLastRGB24;
60
61 // don't do GL vram read
62 void CheckVRamRead(int x, int y, int dx, int dy, bool bFront)
63 {
64 }
65
66 void CheckVRamReadEx(int x, int y, int dx, int dy)
67 {
68 }
69
70 void SetFixes(void)
71 {
72 }
73
74 static void PaintBlackBorders(void)
75 {
76  short s;
77  glDisable(GL_SCISSOR_TEST); glError();
78  if(bTexEnabled) {glDisable(GL_TEXTURE_2D);bTexEnabled=FALSE;} glError();
79  if(bOldSmoothShaded) {glShadeModel(GL_FLAT);bOldSmoothShaded=FALSE;} glError();
80  if(bBlendEnable)     {glDisable(GL_BLEND);bBlendEnable=FALSE;} glError();
81  glDisable(GL_ALPHA_TEST); glError();
82
83  glEnable(GL_ALPHA_TEST); glError();
84  glEnable(GL_SCISSOR_TEST); glError();
85 }
86
87 void updateDisplay(void)
88 {
89  bFakeFrontBuffer=FALSE;
90  bRenderFrontBuffer=FALSE;
91
92  if(PSXDisplay.RGB24)// && !bNeedUploadAfter)         // (mdec) upload wanted?
93  {
94   PrepareFullScreenUpload(-1);
95   UploadScreen(PSXDisplay.Interlaced);                // -> upload whole screen from psx vram
96   bNeedUploadTest=FALSE;
97   bNeedInterlaceUpdate=FALSE;
98   bNeedUploadAfter=FALSE;
99   bNeedRGB24Update=FALSE;
100  }
101  else
102  if(bNeedInterlaceUpdate)                             // smaller upload?
103  {
104   bNeedInterlaceUpdate=FALSE;
105   xrUploadArea=xrUploadAreaIL;                        // -> upload this rect
106   UploadScreen(TRUE);
107  }
108
109  if(dwActFixes&512) bCheckFF9G4(NULL);                // special game fix for FF9 
110
111  if(PSXDisplay.Disabled)                              // display disabled?
112  {
113   // moved here
114   glDisable(GL_SCISSOR_TEST); glError();                       
115   glClearColor(0,0,0,128); glError();                 // -> clear whole backbuffer
116   glClear(uiBufferBits); glError();
117   glEnable(GL_SCISSOR_TEST); glError();                       
118   gl_z=0.0f;
119   bDisplayNotSet = TRUE;
120  }
121
122  if(iDrawnSomething)
123   eglSwapBuffers(display, surface);
124  iDrawnSomething=0;
125
126  if(lClearOnSwap)                                     // clear buffer after swap?
127  {
128   GLclampf g,b,r;
129
130   if(bDisplayNotSet)                                  // -> set new vals
131    SetOGLDisplaySettings(1);
132
133   g=((GLclampf)GREEN(lClearOnSwapColor))/255.0f;      // -> get col
134   b=((GLclampf)BLUE(lClearOnSwapColor))/255.0f;
135   r=((GLclampf)RED(lClearOnSwapColor))/255.0f;
136   glDisable(GL_SCISSOR_TEST); glError();                       
137   glClearColor(r,g,b,128); glError();                 // -> clear 
138   glClear(uiBufferBits); glError();
139   glEnable(GL_SCISSOR_TEST); glError();                       
140   lClearOnSwap=0;                                     // -> done
141  }
142  else 
143  {
144   if(iZBufferDepth)                                   // clear zbuffer as well (if activated)
145    {
146     glDisable(GL_SCISSOR_TEST); glError();
147     glClear(GL_DEPTH_BUFFER_BIT); glError();
148     glEnable(GL_SCISSOR_TEST); glError();
149    }
150  }
151  gl_z=0.0f;
152
153  // additional uploads immediatly after swapping
154  if(bNeedUploadAfter)                                 // upload wanted?
155  {
156   bNeedUploadAfter=FALSE;                           
157   bNeedUploadTest=FALSE;
158   UploadScreen(-1);                                   // -> upload
159  }
160
161  if(bNeedUploadTest)
162  {
163   bNeedUploadTest=FALSE;
164   if(PSXDisplay.InterlacedTest &&
165      //iOffscreenDrawing>2 &&
166      PreviousPSXDisplay.DisplayPosition.x==PSXDisplay.DisplayPosition.x &&
167      PreviousPSXDisplay.DisplayEnd.x==PSXDisplay.DisplayEnd.x &&
168      PreviousPSXDisplay.DisplayPosition.y==PSXDisplay.DisplayPosition.y &&
169      PreviousPSXDisplay.DisplayEnd.y==PSXDisplay.DisplayEnd.y)
170    {
171     PrepareFullScreenUpload(TRUE);
172     UploadScreen(TRUE);
173    }
174  }
175 }
176
177 void updateFrontDisplay(void)
178 {
179  if(PreviousPSXDisplay.Range.x0||
180     PreviousPSXDisplay.Range.y0)
181   PaintBlackBorders();
182
183  bFakeFrontBuffer=FALSE;
184  bRenderFrontBuffer=FALSE;
185
186  if(iDrawnSomething)                                  // linux:
187   eglSwapBuffers(display, surface);
188 }
189
190 static void ChangeDispOffsetsX(void)                  // CENTER X
191 {
192 long lx,l;short sO;
193
194 if(!PSXDisplay.Range.x1) return;                      // some range given?
195
196 l=PSXDisplay.DisplayMode.x;
197
198 l*=(long)PSXDisplay.Range.x1;                         // some funky calculation
199 l/=2560;lx=l;l&=0xfffffff8;
200
201 if(l==PreviousPSXDisplay.Range.x1) return;            // some change?
202
203 sO=PreviousPSXDisplay.Range.x0;                       // store old
204
205 if(lx>=PSXDisplay.DisplayMode.x)                      // range bigger?
206  {
207   PreviousPSXDisplay.Range.x1=                        // -> take display width
208    PSXDisplay.DisplayMode.x;
209   PreviousPSXDisplay.Range.x0=0;                      // -> start pos is 0
210  }
211 else                                                  // range smaller? center it
212  {
213   PreviousPSXDisplay.Range.x1=l;                      // -> store width (8 pixel aligned)
214    PreviousPSXDisplay.Range.x0=                       // -> calc start pos
215    (PSXDisplay.Range.x0-500)/8;
216   if(PreviousPSXDisplay.Range.x0<0)                   // -> we don't support neg. values yet
217    PreviousPSXDisplay.Range.x0=0;
218
219   if((PreviousPSXDisplay.Range.x0+lx)>                // -> uhuu... that's too much
220      PSXDisplay.DisplayMode.x)
221    {
222     PreviousPSXDisplay.Range.x0=                      // -> adjust start
223      PSXDisplay.DisplayMode.x-lx;
224     PreviousPSXDisplay.Range.x1+=lx-l;                // -> adjust width
225    }                   
226  }
227
228 if(sO!=PreviousPSXDisplay.Range.x0)                   // something changed?
229  {
230   bDisplayNotSet=TRUE;                                // -> recalc display stuff
231  }
232 }
233
234 ////////////////////////////////////////////////////////////////////////
235
236 static void ChangeDispOffsetsY(void)                  // CENTER Y
237 {
238 int iT;short sO;                                      // store previous y size
239
240 if(PSXDisplay.PAL) iT=48; else iT=28;                 // different offsets on PAL/NTSC
241
242 if(PSXDisplay.Range.y0>=iT)                           // crossed the security line? :)
243  {
244   PreviousPSXDisplay.Range.y1=                        // -> store width
245    PSXDisplay.DisplayModeNew.y;
246   
247   sO=(PSXDisplay.Range.y0-iT-4)*PSXDisplay.Double;    // -> calc offset
248   if(sO<0) sO=0;
249
250   PSXDisplay.DisplayModeNew.y+=sO;                    // -> add offset to y size, too
251  }
252 else sO=0;                                            // else no offset
253
254 if(sO!=PreviousPSXDisplay.Range.y0)                   // something changed?
255  {
256   PreviousPSXDisplay.Range.y0=sO;
257   bDisplayNotSet=TRUE;                                // -> recalc display stuff
258  }
259 }
260
261 static void updateDisplayIfChanged(void)
262 {
263 BOOL bUp;
264
265 if ((PSXDisplay.DisplayMode.y == PSXDisplay.DisplayModeNew.y) && 
266     (PSXDisplay.DisplayMode.x == PSXDisplay.DisplayModeNew.x))
267  {
268   if((PSXDisplay.RGB24      == PSXDisplay.RGB24New) && 
269      (PSXDisplay.Interlaced == PSXDisplay.InterlacedNew)) 
270      return;                                          // nothing has changed? fine, no swap buffer needed
271  }
272 else                                                  // some res change?
273  {
274   glLoadIdentity(); glError();
275   glOrtho(0,PSXDisplay.DisplayModeNew.x,              // -> new psx resolution
276             PSXDisplay.DisplayModeNew.y, 0, -1, 1); glError();
277   if(bKeepRatio) SetAspectRatio();
278  }
279
280 bDisplayNotSet = TRUE;                                // re-calc offsets/display area
281
282 bUp=FALSE;
283 if(PSXDisplay.RGB24!=PSXDisplay.RGB24New)             // clean up textures, if rgb mode change (usually mdec on/off)
284  {
285   PreviousPSXDisplay.RGB24=0;                         // no full 24 frame uploaded yet
286   ResetTextureArea(FALSE);
287   bUp=TRUE;
288  }
289
290 PSXDisplay.RGB24         = PSXDisplay.RGB24New;       // get new infos
291 PSXDisplay.DisplayMode.y = PSXDisplay.DisplayModeNew.y;
292 PSXDisplay.DisplayMode.x = PSXDisplay.DisplayModeNew.x;
293 PSXDisplay.Interlaced    = PSXDisplay.InterlacedNew;
294
295 PSXDisplay.DisplayEnd.x=                              // calc new ends
296  PSXDisplay.DisplayPosition.x+ PSXDisplay.DisplayMode.x;
297 PSXDisplay.DisplayEnd.y=
298  PSXDisplay.DisplayPosition.y+ PSXDisplay.DisplayMode.y+PreviousPSXDisplay.DisplayModeNew.y;
299 PreviousPSXDisplay.DisplayEnd.x=
300  PreviousPSXDisplay.DisplayPosition.x+ PSXDisplay.DisplayMode.x;
301 PreviousPSXDisplay.DisplayEnd.y=
302  PreviousPSXDisplay.DisplayPosition.y+ PSXDisplay.DisplayMode.y+PreviousPSXDisplay.DisplayModeNew.y;
303
304 ChangeDispOffsetsX();
305 if(bUp) updateDisplay();                              // yeah, real update (swap buffer)
306 }
307
308 #define GPUwriteStatus_ext GPUwriteStatus_ext // for gpulib to see this
309 void GPUwriteStatus_ext(unsigned long gdata)
310 {
311 switch((gdata>>24)&0xff)
312  {
313   case 0x00:
314    PSXDisplay.Disabled=1;
315    PSXDisplay.DrawOffset.x=PSXDisplay.DrawOffset.y=0;
316    drawX=drawY=0;drawW=drawH=0;
317    sSetMask=0;lSetMask=0;bCheckMask=FALSE;iSetMask=0;
318    usMirror=0;
319    GlobalTextAddrX=0;GlobalTextAddrY=0;
320    GlobalTextTP=0;GlobalTextABR=0;
321    PSXDisplay.RGB24=FALSE;
322    PSXDisplay.Interlaced=FALSE;
323    bUsingTWin = FALSE;
324    return;
325
326   case 0x03:  
327    PreviousPSXDisplay.Disabled = PSXDisplay.Disabled;
328    PSXDisplay.Disabled = (gdata & 1);
329
330    if (iOffscreenDrawing==4 &&
331         PreviousPSXDisplay.Disabled && 
332        !(PSXDisplay.Disabled))
333     {
334
335      if(!PSXDisplay.RGB24)
336       {
337        PrepareFullScreenUpload(TRUE);
338        UploadScreen(TRUE); 
339        updateDisplay();
340       }
341     }
342    return;
343
344   case 0x05: 
345    {
346     short sx=(short)(gdata & 0x3ff);
347     short sy;
348
349     sy = (short)((gdata>>10)&0x3ff);             // really: 0x1ff, but we adjust it later
350     if (sy & 0x200) 
351      {
352       sy|=0xfc00;
353       PreviousPSXDisplay.DisplayModeNew.y=sy/PSXDisplay.Double;
354       sy=0;
355      }
356     else PreviousPSXDisplay.DisplayModeNew.y=0;
357
358     if(sx>1000) sx=0;
359
360     if(dwActFixes&8) 
361      {
362       if((!PSXDisplay.Interlaced) &&
363          PreviousPSXDisplay.DisplayPosition.x == sx  &&
364          PreviousPSXDisplay.DisplayPosition.y == sy)
365        return;
366
367       PSXDisplay.DisplayPosition.x = PreviousPSXDisplay.DisplayPosition.x;
368       PSXDisplay.DisplayPosition.y = PreviousPSXDisplay.DisplayPosition.y;
369       PreviousPSXDisplay.DisplayPosition.x = sx;
370       PreviousPSXDisplay.DisplayPosition.y = sy;
371      }
372     else
373      {
374       if((!PSXDisplay.Interlaced) &&
375          PSXDisplay.DisplayPosition.x == sx  &&
376          PSXDisplay.DisplayPosition.y == sy)
377        return;
378       PreviousPSXDisplay.DisplayPosition.x = PSXDisplay.DisplayPosition.x;
379       PreviousPSXDisplay.DisplayPosition.y = PSXDisplay.DisplayPosition.y;
380       PSXDisplay.DisplayPosition.x = sx;
381       PSXDisplay.DisplayPosition.y = sy;
382      }
383
384     PSXDisplay.DisplayEnd.x=
385      PSXDisplay.DisplayPosition.x+ PSXDisplay.DisplayMode.x;
386     PSXDisplay.DisplayEnd.y=
387      PSXDisplay.DisplayPosition.y+ PSXDisplay.DisplayMode.y+PreviousPSXDisplay.DisplayModeNew.y;
388
389     PreviousPSXDisplay.DisplayEnd.x=
390      PreviousPSXDisplay.DisplayPosition.x+ PSXDisplay.DisplayMode.x;
391     PreviousPSXDisplay.DisplayEnd.y=
392      PreviousPSXDisplay.DisplayPosition.y+ PSXDisplay.DisplayMode.y+PreviousPSXDisplay.DisplayModeNew.y;
393
394     bDisplayNotSet = TRUE;
395
396     if (!(PSXDisplay.Interlaced))
397      {
398       updateDisplay();
399      }
400     else
401     if(PSXDisplay.InterlacedTest && 
402        ((PreviousPSXDisplay.DisplayPosition.x != PSXDisplay.DisplayPosition.x)||
403         (PreviousPSXDisplay.DisplayPosition.y != PSXDisplay.DisplayPosition.y)))
404      PSXDisplay.InterlacedTest--;
405     return;
406    }
407
408   case 0x06:
409    PSXDisplay.Range.x0=gdata & 0x7ff;      //0x3ff;
410    PSXDisplay.Range.x1=(gdata>>12) & 0xfff;//0x7ff;
411
412    PSXDisplay.Range.x1-=PSXDisplay.Range.x0;
413
414    ChangeDispOffsetsX();
415    return;
416
417   case 0x07:
418    PreviousPSXDisplay.Height = PSXDisplay.Height;
419
420    PSXDisplay.Range.y0=gdata & 0x3ff;
421    PSXDisplay.Range.y1=(gdata>>10) & 0x3ff;
422
423    PSXDisplay.Height = PSXDisplay.Range.y1 - 
424                        PSXDisplay.Range.y0 +
425                        PreviousPSXDisplay.DisplayModeNew.y;
426
427    if (PreviousPSXDisplay.Height != PSXDisplay.Height)
428     {
429      PSXDisplay.DisplayModeNew.y=PSXDisplay.Height*PSXDisplay.Double;
430      ChangeDispOffsetsY();
431      updateDisplayIfChanged();
432     }
433    return;
434
435   case 0x08:
436    PSXDisplay.DisplayModeNew.x = dispWidths[(gdata & 0x03) | ((gdata & 0x40) >> 4)];
437
438    if (gdata&0x04) PSXDisplay.Double=2;
439    else            PSXDisplay.Double=1;
440    PSXDisplay.DisplayModeNew.y = PSXDisplay.Height*PSXDisplay.Double;
441
442    ChangeDispOffsetsY();
443  
444    PSXDisplay.PAL           = (gdata & 0x08)?TRUE:FALSE; // if 1 - PAL mode, else NTSC
445    PSXDisplay.RGB24New      = (gdata & 0x10)?TRUE:FALSE; // if 1 - TrueColor
446    PSXDisplay.InterlacedNew = (gdata & 0x20)?TRUE:FALSE; // if 1 - Interlace
447
448    PreviousPSXDisplay.InterlacedNew=FALSE;
449    if (PSXDisplay.InterlacedNew)
450     {
451      if(!PSXDisplay.Interlaced)
452       {
453        PSXDisplay.InterlacedTest=2;
454        PreviousPSXDisplay.DisplayPosition.x = PSXDisplay.DisplayPosition.x;
455        PreviousPSXDisplay.DisplayPosition.y = PSXDisplay.DisplayPosition.y;
456        PreviousPSXDisplay.InterlacedNew=TRUE;
457       }
458     }
459    else 
460     {
461      PSXDisplay.InterlacedTest=0;
462     }
463    updateDisplayIfChanged();
464    return;
465  }
466 }
467
468 /////////////////////////////////////////////////////////////////////////////
469
470 #include <stdint.h>
471
472 #include "../gpulib/gpu.c"
473
474 static int is_opened;
475
476 int renderer_init(void)
477 {
478  psxVub=(void *)gpu.vram;
479  psxVuw=(unsigned short *)psxVub;
480
481  PSXDisplay.RGB24        = FALSE;                      // init some stuff
482  PSXDisplay.Interlaced   = FALSE;
483  PSXDisplay.DrawOffset.x = 0;
484  PSXDisplay.DrawOffset.y = 0;
485  PSXDisplay.DisplayMode.x= 320;
486  PSXDisplay.DisplayMode.y= 240;
487  PSXDisplay.Disabled     = FALSE;
488  PSXDisplay.Range.x0=0;
489  PSXDisplay.Range.x1=0;
490  PSXDisplay.Double = 1;
491
492  lGPUstatusRet = 0x14802000;
493
494  return 0;
495 }
496
497 extern const unsigned char cmd_lengths[256];
498
499 void do_cmd_list(unsigned int *list, int list_len)
500 {
501   unsigned int cmd, len;
502
503   unsigned int *list_end = list + list_len;
504
505   for (; list < list_end; list += 1 + len)
506   {
507     cmd = *list >> 24;
508     len = cmd_lengths[cmd];
509
510     primTableJ[cmd]((void *)list);
511
512     switch(cmd)
513     {
514       case 0x48 ... 0x4F:
515       {
516         uint32_t num_vertexes = 1;
517         uint32_t *list_position = &(list[2]);
518
519         while(1)
520         {
521           if((*list_position & 0xf000f000) == 0x50005000 || list_position >= list_end)
522             break;
523
524           list_position++;
525           num_vertexes++;
526         }
527
528         if(num_vertexes > 2)
529           len += (num_vertexes - 2);
530
531         break;
532       }
533
534       case 0x58 ... 0x5F:
535       {
536         uint32_t num_vertexes = 1;
537         uint32_t *list_position = &(list[2]);
538
539         while(1)
540         {
541           if((*list_position & 0xf000f000) == 0x50005000 || list_position >= list_end)
542             break;
543
544           list_position += 2;
545           num_vertexes++;
546         }
547
548         if(num_vertexes > 2)
549           len += (num_vertexes - 2) * 2;
550
551         break;
552       }
553
554 #ifdef TEST
555       case 0xA0:          //  sys -> vid
556       {
557         short *slist = (void *)list;
558         uint32_t load_width = slist[4];
559         uint32_t load_height = slist[5];
560         uint32_t load_size = load_width * load_height;
561
562         len += load_size / 2;
563         break;
564       }
565 #endif
566     }
567   }
568 }
569
570 void renderer_sync_ecmds(uint32_t *ecmds)
571 {
572   cmdTexturePage((unsigned char *)&ecmds[1]);
573   cmdTextureWindow((unsigned char *)&ecmds[2]);
574   cmdDrawAreaStart((unsigned char *)&ecmds[3]);
575   cmdDrawAreaEnd((unsigned char *)&ecmds[4]);
576   cmdDrawOffset((unsigned char *)&ecmds[5]);
577   cmdSTP((unsigned char *)&ecmds[6]);
578 }
579
580 void renderer_update_caches(int x, int y, int w, int h)
581 {
582  VRAMWrite.x = x;
583  VRAMWrite.y = y;
584  VRAMWrite.Width = w;
585  VRAMWrite.Height = h;
586  if(is_opened)
587   CheckWriteUpdate();
588 }
589
590 void renderer_flush_queues(void)
591 {
592 }
593
594 void renderer_set_interlace(int enable, int is_odd)
595 {
596 }
597
598 int vout_init(void)
599 {
600   return 0;
601 }
602
603 int vout_finish(void)
604 {
605   return 0;
606 }
607
608 void vout_update(void)
609 {
610  if(PSXDisplay.Interlaced)                            // interlaced mode?
611  {
612   if(PSXDisplay.DisplayMode.x>0 && PSXDisplay.DisplayMode.y>0)
613    {
614     updateDisplay();                                  // -> swap buffers (new frame)
615    }
616  }
617  else if(bRenderFrontBuffer)                          // no interlace mode? and some stuff in front has changed?
618  {
619   updateFrontDisplay();                               // -> update front buffer
620  }
621 }
622
623 long GPUopen(void **dpy)
624 {
625  iResX = 800; iResY = 480;
626  rRatioRect.left   = rRatioRect.top=0;
627  rRatioRect.right  = iResX;
628  rRatioRect.bottom = iResY;
629
630  bDisplayNotSet = TRUE; 
631  bSetClip = TRUE;
632  CSTEXTURE = CSVERTEX = CSCOLOR = 0;
633
634  InitializeTextureStore();                             // init texture mem
635  is_opened = 1;
636
637  return GLinitialize();
638 }
639
640 long GPUclose(void)
641 {
642  is_opened = 0;
643
644  GLcleanup();                                          // close OGL
645  return 0;
646 }
647
648 //#include "../../frontend/plugin_lib.h"
649
650 static const struct rearmed_cbs *cbs;
651
652 /* acting as both renderer and vout handler here .. */
653 void renderer_set_config(const struct rearmed_cbs *cbs_)
654 {
655  cbs = cbs_;
656
657  iOffscreenDrawing = 0;
658  iZBufferDepth = 0;
659  iFrameReadType = 0;
660  bKeepRatio = TRUE;
661
662  dwActFixes = cbs->gpu_peopsgl.dwActFixes;
663  bDrawDither = cbs->gpu_peopsgl.bDrawDither;
664  iFilterType = cbs->gpu_peopsgl.iFilterType;
665  iFrameTexType = cbs->gpu_peopsgl.iFrameTexType;
666  iUseMask = cbs->gpu_peopsgl.iUseMask;
667  bOpaquePass = cbs->gpu_peopsgl.bOpaquePass;
668  bAdvancedBlend = cbs->gpu_peopsgl.bAdvancedBlend;
669  bUseFastMdec = cbs->gpu_peopsgl.bUseFastMdec;
670  iTexGarbageCollection = cbs->gpu_peopsgl.iTexGarbageCollection;
671  iVRamSize = cbs->gpu_peopsgl.iVRamSize;
672 }
673
674 void vout_set_config(const struct rearmed_cbs *cbs)
675 {
676 }
677
678 void SetAspectRatio(void)
679 {
680  cbs->pl_get_layer_pos(&rRatioRect.left, &rRatioRect.top, &rRatioRect.right, &rRatioRect.bottom);
681
682  glScissor(rRatioRect.left,
683            iResY-(rRatioRect.top+rRatioRect.bottom),
684            rRatioRect.right,rRatioRect.bottom);
685  glViewport(rRatioRect.left,
686            iResY-(rRatioRect.top+rRatioRect.bottom),
687            rRatioRect.right,rRatioRect.bottom);
688  glError();
689 }