Welcome, Guest. Please login or register.

Author Topic: Warp3d synchro/double-triply bufferging  (Read 18677 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline kas1eTopic starter

Warp3d synchro/double-triply bufferging
« on: February 11, 2005, 12:34:18 AM »
Hi 2 all. I have a lame question about syncro in warp3d. I using voodoo3/aos3.9/m68k and want to do some truecolor animation. So:

I draw 640x480x32bit picture on screen (this picture = 6 textures), and try to scroll on this picture some sprite (128x512x32) with transparency. So, if i just move sprite (witchout redrawing some areas (textures) of my backscreen) it work nice with WaitTOF() only. BUT. If i moving sprite, and trying redrawing part of backscreen (two 256x256 textures), (do it animation i mean), i have some bugs on screen. Not big bugs, but some UPpers areas of my screen is 'blinking'. If i drawing in 'low' part of screen, it is work fine.. I don't know what is it, maybe problem with WaitTOF() or need do it somethink else ..

Well, next, i read some docs (graphics/intuition/warp3ddev), and found some worlds about 'double buffering'. It is allow to me rendering all data to 'invisible' scren, and flip with 'main' screen. But i do not understand HOW it can be help me. If WaitTOF() can't do it good synchro, how buffer fliping can give me good synchro ?

So, if i understand correctly, double-buffering can solve my 'some blinking UPpears areas'. (i am right?) And as i reading, here is 2 ways for it :

1. ScreenBuffer (alloc/change/free).
2. ScrollVPort + WaitBOVP.

Well, i just to try this code (only for 'flip' picture from 'invisibli' part, to 'main' part):

// ... create screen/window/warp3d context ...

   vp=screen->ViewPort;

  // draw to 'invisibli' screen.
   W3D_SetDrawRegion(context,bm,480,&s);
   vp->RasInfo->RyOffset=0;
   ScrollVPort(vp);
   WaitBOVP(vp);
   W3D_SetScissor(context, &s);

   // draw my pict, to 'invisibli' buffer, and do it some wait.
   draw_pict(context,1.0f);
   Delay(10);

   // flip to 'main' screen
   W3D_SetDrawRegion(context,bm,0,&s);
   vp->RasInfo->RyOffset=0;
   ScrollVPort(vp);
   WaitBOVP(vp);
   W3D_SetScissor(context,&s);  


And nothink to happened .. Picture was drawing on 'invisibly' part, and can't flip.


Next, i try to use ScreenBuffers:

// creating 2 ScreenBuffer. 'main' and 'invisible'.

  if(!(buf1=AllocScreenBuffer(screen, NULL, SB_SCREEN_BITMAP)))
     { printf ("failed to allocate screenbuffer\n"); goto panic;};

  if(!(buf2=AllocScreenBuffer(screen, NULL, SB_SCREEN_BITMAP)))
     { printf ("failed to allocate screenbuffer2\n"); goto panic;};

// BitMap for Warp3d context creating
  buf1->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort = NULL;
  bm = buf1->sb_BitMap;

  context = W3D_CreateContextTags(&CError,
          W3D_CC_MODEID,       ModeID,
          W3D_CC_BITMAP,       bm,
          W3D_CC_YOFFSET,      0,
          W3D_CC_DRIVERTYPE,   W3D_DRIVER_BEST,
          W3D_CC_FAST,         TRUE,
          W3D_CC_DOUBLEHEIGHT, TRUE,
          TAG_DONE);


 // ... skip some setstates/etc ...

 for(i=250;i>0; i-=5)
    {
       ChangeScreenBuffer(screen,buf2);   // draw to invisible buffer
       Draw_Sprite(context,i);
       ChangeScreenBuffer(screen, buf1);  // flip ScreenBuffers.
    };

And agayn, i have not a good synchro ;(


Well, here is questions:

1. Where best way for work with synchro on warp3d. If anyone have some sources it is will be very good.

2. How do it normal hi-rez animation on warp3d.

Any docs/link/sources/talks/help will be very good.


sorry for poor english, hope anyone can help me with it, thanks.
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #1 on: February 11, 2005, 01:32:37 AM »
Karlos, thanks for answer.

So, i must use ScreenBuffer, and get to trash all thinks about ScrollVPort ? ok.

What about WaitBOVP(&(screen->ViewPort)) and W3D_SetDrawRegion(), as you can see in my examples, i use it already, but it is not give me good synchro.

btw, maybe you can explain more complete, what i must to do 'step-by-step' ?

I just do not understand, WHY i must use double-buffering ? Where is + ? And how i can use it ? For example:

1. i setup invisibli buffer for render:

W3D_Scissor s = {0,0,640,480};
W3D_SetDrawRegion(context,bm,480,&s),

2. draw data to this buffer.

draw_my_pict();

3. here i want to flip this buffer to main. how ?

ps. and what about YOFFSET in context creating, must i use it or not ?
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #2 on: February 11, 2005, 03:24:20 PM »
Do i must for ScreenBuffer techniqe use double Height screen/window ? I mean if i use 640x480 screen, can i use SA_Height/WA_Height with 480, or need 960 ? Do i need set W3D_CC_DOUBLEHEIGHT in TRUE for warp3d context ?

So, i just try to use this (with Height 480) code:

//.. open screen/window
buffer[0] = AllocScreenBuffer(screen, NULL, SB_SCREEN_BITMAP);
buffer[1] = AllocScreenBuffer(screen, NULL, 0);  drawBuffer = 1;    

// bitmap for context creating
buffer[0]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort =NULL;
 bm = buffer[0]->sb_BitMap;  

// ..create context, set some states

for(i=250;i>0; i-=1)

{

buffer[drawBuffer]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=0;
while (!ChangeScreenBuffer(screen, buffer[drawBuffer]));
drawBuffer ^= 1;
WaitBOVP(&(screen)->ViewPort);
W3D_SetDrawRegion(context, buffer[drawBuffer]->sb_BitMap,0, &s);


     W3D_LockHardware(context);
     W3D_DrawTriStrip(context,&tris4); // 256x256
     W3D_DrawTriStrip(context,&tris);  // 256x256
     W3D_UnLockHardware(context);

}                      

// ..close all libs/buffers/etc
 

And i can wath as flip my buffers ! i mean for(i=250;i>0; i-=1) i can wath some time as 'flip' my buffers .. but as i understand my triangles must be not flicking, as in case if i use WaitBOVP(&(screen)->ViewPort); or WaitTOF(); only. Maybe some more initialization need it for warp3d himself, or for buffer-switching ?

First, i think maybe problem with my 040/33 (too slow), but it work the same for ppc too! i compile it for warp-os/warp3dppc and it work the same :(

ps. if you have some time, can i send to you my code/binary for test ? maybe problem in my hardware ..
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #3 on: February 11, 2005, 03:58:08 PM »
to Framiga:
but what about some Demos for example ? i mean ppc/warp3d demos like mawi/encore/universe ? the same problem or work fine ?
ps. warptest work fine for me.
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #4 on: February 11, 2005, 04:28:09 PM »
@Framiga

Well, maybe normal project (like games kind of payback,etc) use other techniqe then ScrollVPort (in warptest is it), and i think not only ScreenBuffer .. Maybe 3x-buffering in here ?
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #5 on: February 11, 2005, 05:13:05 PM »
2framiga:
well, it work good with warp3d synchro too. so, i have only one question to all, how exactly it work ?:) where good example ?

ps. if you interesting in warp3d demos like ByNight from Encore, watch this:

Potion:
1. Planet Potion (work only on 15bit screens, can't work for voodoo, but it is the best)
2. Future Vision (the same).

MadWizards demos (work for me nice):

1. CruelKarma Forms (2001/the best)
2. Cull bazaar (2001).
3. another dream away (2002)
4. new dawn fades (2002)
5. heavy traffic (2002/very nice too)
6. third eye conqueror (2002/can't work on my voodoo, but it must work on CV).
7. fate fits karma (2003)
8. till i feel you (2003)

Encore:

1. Sulaco
2. ByNight
3. Kheshkhash (can't work on voodoo)

and some from CreativeMinds and Universe.

And in all GOOD SYNCHRO :)
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #6 on: February 14, 2005, 10:58:24 PM »
@Piru

but what about MiniGL sources ? i founding these strings in mglDisplaySwitch:

Code: [Select]


context->BufNr++;
if (context->BufNr == context->NumBuffers)context->BufNr = 0;

context->Buffers[nowbuf]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=NULL;
while(!ChangeScreenBuffer(context->w3dScreen,context->Buffers[nowbuf]));

W3D_SetDrawRegion(context->w3dContext,context->Buffers[context->BufNr]->sb_BitMap,0,&(context->scissor));

if (context->DoSync) // if Sync in GL = TRUE, do SYNC.
{
struct ViewPort *vp = &(context->w3dScreen->ViewPort);
WaitBOVP(vp);
};



it's too bad ?
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #7 on: February 14, 2005, 11:52:25 PM »
But in this examples ScreenBuffers combinate with WaitBOVP, but it is a ScreenBuffers anyway. Do you mean just using WaitBlit(), instead WaitBOVP(), maybe ?
 
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #8 on: February 15, 2005, 03:51:36 AM »
mess :)

2piru: can you write func base on dbi_DispMessage, witchout
WaitTOF/WaitBOVP under Warp3D ?:)

2entzilla: why do not create 'W3D_Sync' for upcoming warp3d (if it will be) releases ?
 
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #9 on: February 16, 2005, 01:51:26 AM »
@piru

Well, i try to use your case here:

Code: [Select]


    DBIport[0] = CreateMsgPort();
    DBIport[1] = CreateMsgPort();

    myScreenbuffer1 = AllocScreenBuffer(screen,NULL, SB_SCREEN_BITMAP);
    myScreenbuffer2 = AllocScreenBuffer(screen,NULL, 0);

    myScreenbuffer1->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort = DBIport[0];
    myScreenbuffer1->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort = DBIport[1];
    myScreenbuffer2->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort = DBIport[0];
    myScreenbuffer2->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort = DBIport[1];  


 ..create context/open screen...


while(1)
{
   // ...do some matrix/etc stuff
 
  while(!ChangeScreenBuffer(screen, myScreenbuffer2));
 
  if (! SafeToWrite)
      while(! GetMsg(DBIport[0])) Wait(1l<<(DBIport[0]->mp_SigBit));
      SafeToWrite=TRUE;

  W3D_LockHardware(context);
  W3D_ClearDrawRegion(context,0x00000000);  // fill screen with black color
  W3D_DrawTriStrip(context,&tris);
  W3D_UnLockHardware(context);


  if (! SafeToChange)
      while(! GetMsg(DBIport[1])) Wait(1l<<(DBIport[1]->mp_SigBit));
      SafeToChange=TRUE;
  while(!ChangeScreenBuffer(screen, myScreenbuffer1));
  SafeToChange=FALSE;
  SafeToWrite=FALSE;
}


     
In this case, after running, system halt, and only reboot can help me. If i adding WaitBOVP() in loop, it working, but problem anyway here - blinking of my object.

I just try this:

Code: [Select]


ChangeScreenBuffer(screen, myScreenbuffer2);
myScreenbuffer2->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=0;

  W3D_LockHardware(context);
  W3D_ClearDrawRegion(context,0x00000000);  // fill screen with black color
  W3D_DrawTriStrip(context,&tris);
  W3D_UnLockHardware(context);


 myScreenbuffer2->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=0;
ChangeScreenBuffer(screen, myScreenbuffer1);              



or just:

Code: [Select]


 ChangeScreenBuffer(screen, myScreenbuffer2);
 DBIport[0]=0;

  W3D_LockHardware(context);
  W3D_ClearDrawRegion(context,0x00000000);  // fill screen with black color
  W3D_DrawTriStrip(context,&tris);
  W3D_UnLockHardware(context);


 DBIport[1]=0;
 ChangeScreenBuffer(screen, myScreenbuffer1);      



Result the same. Just halt. If adding WaitBOVP(&(screen)->ViewPort); it works, but the same problem - blinking.
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #10 on: September 14, 2007, 05:35:39 AM »
Want to up, this old thread. What about this kinds of double-bufferings over WarpOS ? Will be here some kind of slowdowns in fact of context switching ? If yes, how it possible to avoid them ?
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #11 on: September 14, 2007, 09:44:22 AM »
Hey Karlos, you still alive ?:) I tryed to write you some time ago, but looks like you cnahge email ..

Well, W3D_LockHardware based on Warp3dPPCBase will also have context switching you mean ? (why? i think it will be, if i will use warp3d.library (not ppc ones) from wos application, but with warp3dppc.library, here is must be no context switching, right ?)

Also context swtitching in fact of idcmp, will be have big slowdown or not so ? At this moment, i see really slowndowns if compare it with 68k version - in SwitchBuffer function. I dunno why, in fact of only WaitTOF(); or in fact all of this 68k fuctnions like ChangeScreenBuffer and WaitTOF.

As i understand, i just need to create fucntion like this:

void SwithDisplay_WarpOS(W3D_Context *context, struct Screen *screen)
{
  Run68k(here is an old 68k fucntions)
}

?
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #12 on: September 17, 2007, 05:51:20 AM »
Karlos, question for you ;) If i remember correctly, you know Bvision driver very well ? So, maybe you can give me a hint/point about what i can do with it: i have a w3d request, with 15/16/24 bit modes on bvision. If i choice 15/16 modes - gfx looks ok. If i choice 24bit modes, i have strange corruption.

here is 15-16 bit example:

here is 24bit example:

sources are the same, and works fine on a1/peg/winuae/a1200/a4000(voodoo/radeon/cybervision). Only on bvision this kind of corruption.

Modes for texture is: RGB565, ARGB1555.
States: Gouraud only.

Have any idea maybe ?
It's not so matter of course, but i am just in interest what is it and how i can avoid it
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #13 on: September 17, 2007, 06:11:59 AM »
Karlos, latest public version with latest patchs. I tryed it on 3 different setup. (ppc/040-33/bvision , ppc/040-25/bvision and my ppc/060/bvision). In all case result with 24bits are the same.
 

Offline kas1eTopic starter

Re: Warp3d synchro/double-triply bufferging
« Reply #14 on: September 17, 2007, 06:38:41 AM »
Karlos, it's fullscreen mode, i just open 640x480 screen and open 640x480 window on it. For W3D_RequestModeTags: aslsm_minDepth:15, aslsm_maxdepth:32. For openscreen:
SA_Depth: 32. Why is here 32: becouse if i will setup 16, double-buffering just do not works for voodoo3. (but on voodoo3 only 16bit modes can be choiced, stange a bit).