Various API/SDK questions
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Daytona675x
    Posts: 109 from 2013/12/5
    @BSzili
    Thanks for pointing me to that and thanks to bigfoot for writing! Works :-)
  • »20.12.13 - 16:55
    Profile Visit Website
  • MorphOS Developer
    bigfoot
    Posts: 510 from 2003/4/11
    Quote:

    Daytona675x wrote:
    Damn! So, what am I supposed to do to get the desired behaviour (= without black border)?
    Shall I use GL_CLAMP_TO_EDGE although it produces artifacts on some machines right now?
    Or is there a reliable glGetString I can use to select the appropriate wrap-mode depending on driver-version and card-type?


    It will be fixed starting with MorphOS 3.5, so you could do something like...
    Code:

    struct Resident *morphos;

    morphos = FindResident("MorphOS");
    if (morphos && (morphos->rt_Flags&RTF_EXTENDED) && morphos->rt_Version == 3 && morphos->rt_Revision <= 4)
    {
    /* Set flag here that makes your code swap GL_CLAMP and GL_CLAMP_TO_EDGE */
    }


    Quote:

    9. TinyGL IV:
    GLASetSync has no effect. No matter if I use a screen-context or window-context and no matter when I call GLASetSync, it has zero effect, the GL output is always not vsynced. Is this a known limitation/bug on my Radeon9000-system? Or is there some additional setup I need to do?
    As a workaround I tried WaitTOF, but this seems to misbehave just like it does on AmigaOS4/RadeonHD: it doesn't do a real vsync but just seems to wait for some 1/70 seconds or so (you can spot a nice tearing moving down the screen), not useful at all.


    Make sure that you actually create a screen context, otherwise it won't work. Some copy/paste from Quake 3:
    Code:

    struct TagItem tgltags[] =
    {
    { 0, 0 },
    { TGL_CONTEXT_STENCIL, TRUE },
    { TAG_DONE }
    };

    [...]

    if (screen)
    {
    tgltags[0].ti_Tag = TGL_CONTEXT_SCREEN;
    tgltags[0].ti_Data = (ULONG)screen;
    }
    else
    {
    tgltags[0].ti_Tag = TGL_CONTEXT_WINDOW;
    tgltags[0].ti_Data = (ULONG)window;
    }

    r = GLAInitializeContext(__tglContext, tgltags);


    (Sorry, Morphzone strips all indention)
    I rarely log in to MorphZone which means that I often miss private messages sent on here. If you wish to contact me, please email me at [username]@asgaard.morphos-team.net, where [username] is my username here on MorphZone.
  • »20.12.13 - 17:22
    Profile Visit Website
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Daytona675x
    Posts: 109 from 2013/12/5
    @bigfoot
    Quote:

    It will be fixed starting with MorphOS 3.5, so you could do something like...

    But I thought only the R200-driver was buggy? Such a snippet would toggle the behaviour on all systems ver 3.0 - 3.4.

    Quote:

    Make sure that you actually create a screen context, otherwise it won't work.

    Unfortunately it definitely is a correct screen-context :-(
    But besides the fact that GLASetSync seems to be broken on my system: so for window-contexts GLASetSync should indeed have no effect and one is supposed to use WaitTOF or so instead?

    [ Editiert durch Daytona675x 20.12.2013 - 17:59 ]
  • »20.12.13 - 17:59
    Profile Visit Website
  • MorphOS Developer
    bigfoot
    Posts: 510 from 2003/4/11
    Quote:

    Quote:

    It will be fixed starting with MorphOS 3.5, so you could do something like...

    But I thought only the R200-driver was buggy? Such a snippet would toggle the behaviour on all systems ver 3.0 - 3.4.


    Well, it does look like I managed to replicate that behaviour in the R300 driver too :)

    Quote:

    Quote:

    Make sure that you actually create a screen context, otherwise it won't work.

    Unfortunately it definitely is a correct screen-context :-(
    But besides the fact that GLASetSync seems to be broken on my system: so for window-contexts GLASetSync should indeed have no effect and one is supposed to use WaitTOF or so instead?


    Well, basically, full screen double buffering is always vsynced. However, TinyGL has the possibility to not wait for a buffer to have been fully displayed before swapping to the next buffer, which removes the waiting for benchmark purposes, but isn't the same as non-vsync on f.ex. Linux or Windows. To make it clear: you don't have to do anything extra to get vsync on a fullscreen context. The one exception is if you happen to have an env variable with the name 'TGLSYNC', which can be used to force vsync off.

    You should never, ever use WaitTOF(). Never. If you really must, then use WaitBOVP(), but that doesn't in any way guarantee anything, since anything can happen between the WaitBOVP() call returning and your program doing whatever it does afterwards. I think that Enhanced Layers has some fancy way to ensure vsynced updates to window contents, but I'm not sure, and I have no idea how it works. Jacadcaps should fill in the blanks here :)


    [ Edited by bigfoot 20.12.2013 - 18:13 ]
    I rarely log in to MorphZone which means that I often miss private messages sent on here. If you wish to contact me, please email me at [username]@asgaard.morphos-team.net, where [username] is my username here on MorphZone.
  • »20.12.13 - 18:10
    Profile Visit Website
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Daytona675x
    Posts: 109 from 2013/12/5
    @bigfoot
    Quote:

    Well, it does look like I managed to replicate that behaviour in the R300 driver too :)

    :) I see. So it is consistent among all TinyGL-supporting devices then? That would be good news!

    Quote:

    Well, basically, full screen double buffering is always vsynced.

    Damn. Wonder what I'm missing here. TGLSYNC is not set here.

    Quote:

    You should never, ever use WaitTOF().

    Indeed, apparently it does nothing else than slowing down my system :-P

    Quote:

    I think that Enhanced Layers has some fancy way to ensure vsynced updates to window contents

    Would be interesting to know, but for now I'll simply live with un-synced windows.
  • »20.12.13 - 18:23
    Profile Visit Website
  • MorphOS Developer
    itix
    Posts: 1520 from 2003/2/24
    From: Finland
    Quote:

    Daytona675x wrote:
    10. ASL screen mode requester
    ASLSM_MinDepth is ignored on my system. I explicitely request screen-modes with a depth of at least 16 bits through that attribute, but the requester also shows 8 bit palette modes. System bug?



    System bug. It looks like ASLSM_MinDepth only sets minimum depth to the depth slider. It does not filter any screenmodes according to MinDepth/MaxDepth setting. It seems to be a bug in MUI screenmodepanel class.

    Quote:


    11. Mouse Capture
    Is there a better way to capture the mouse to stay inside the application's main window than to reposition it via DoIO? At least on my system this results in a huge performance penalty (in fullscreen mode this is not needed and therefore no issue, luckily).
    Answer: Install an interrupt-handler to catch the IECLASS_RAWMOUSE events before they are delivered to the normal event-handler. Extract the x/y deltas and then set the event's coordinates to zero, which will effectively cancel any mouse-pointer movement. Check FodQuake sources, file in_morphos.c



    There is another solution that might be useful to you: WM_ObtainEvents/WM_ReleaseEvents in intuition/intuition.h

    Quote:


    #define WM_ObtainEvents (WM_Dummy + 2)
    /* BOOL. Obtains the events for the screen the window is at.
    ** This is an equivalent of installing your own, high priority
    ** inputhandler to capture input events. All IDCMPs will
    ** be sent to your window. Clicking outside of your window
    ** will not send events to other windows or cause their activation.
    ** Intuition menus will not be opened. The mouse pointer will use
    ** whatever your window has set, even if your window was not
    ** active when you obtained the pointer. Use this solely for the
    ** purpose of letting user pick a window, mark some area for
    ** snapshoting, etc. Will return FALSE if another window
    ** currently owns the events or your window already owns them.
    ** If the method returns true, you are the pointer owner and
    ** MUST match the call with WM_ReleaseEvents after you are done.
    ** For security reasons, if your application crashes or refuses
    ** to reply to IDCMP messages, the event ownership might be
    ** silently revoked. If a new window opens or gets activated
    ** while you have the ownership, it will be revoked and you
    ** will receive an IDCMP_INACTIVEWINDOW idcmp (even if your window
    ** is still active or was inactive before obtaining the pointer).
    ** The IDCMPS that your window will actually capture are:
    ** IDCMP_MOUSEMOVE, IDCMP_MOUSEBUTTON, IDCMP_RAWKEY,
    ** IDCMP_VANILLAKEY, IDCMP_INTUITICKS */

    #define WM_ReleaseEvents (WM_Dummy + 3)
    /* void. Releases the events obtained with WM_ObtainEvents. You MUST
    ** always call it after WM_ObtainEvents returned TRUE. It is safe
    ** to call it in case your events ownership was revoked by the
    ** system */

    1 + 1 = 3 with very large values of 1
  • »20.12.13 - 21:24
    Profile
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Daytona675x
    Posts: 109 from 2013/12/5
    @itix
    Quote:

    System bug. It looks like ASLSM_MinDepth only sets minimum depth to the depth slider. It does not filter any screenmodes according to MinDepth/MaxDepth setting.

    Thanks for the clarification! I'll try a filter-function instead then.

    Quote:

    There is another solution that might be useful to you: WM_ObtainEvents/WM_ReleaseEvents in intuition/intuition.h

    Sounds interesting! For now I'll stick with the interrupt-handler, since it seems to work well. However, reading the sentence "For security reasons, if your application crashes or refuses to reply to IDCMP messages, the event ownership might be silently revoked." it's probably a good idea to implement it that way...

    [ Editiert durch Daytona675x 21.12.2013 - 05:28 ]
  • »21.12.13 - 05:25
    Profile Visit Website
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Daytona675x
    Posts: 109 from 2013/12/5
    @bigfoot
    Quote:

    Make sure that you actually create a screen context, otherwise it won't work.

    Yes... I did... but I forgot to not call GLAReinitializeContextWindowed afterwards, so it became a window-context again :-P
    Now vsync works perfectly.

    But... :-)
    Disabling vsync via GLASetSync essentially works, the context doesn't get synced anymore, but it also produces massive black-triangle-shaped-flickering and is therefore unusable.
    As a workaround I can of course do as I did before by accident: use a window-context in fullscreen mode.
    (EDIT: I just did so, works)

    But it would be interesting to know, if that's a known problem of GLASetSync in combination with a screen-context.

    [ Editiert durch Daytona675x 22.12.2013 - 12:54 ]
  • »22.12.13 - 11:30
    Profile Visit Website
  • MorphOS Developer
    bigfoot
    Posts: 510 from 2003/4/11
    Quote:

    Disabling vsync via GLASetSync essentially works, the context doesn't get synced anymore, but it also produces massive black-triangle-shaped-flickering and is therefore unusable.
    As a workaround I can of course do as I did before by accident: use a window-context in fullscreen mode. [...] But it would be interesting to know, if that's a known problem of GLASetSync in combination with a screen-context.


    As I explained in an earlier post...

    Quote:

    Well, basically, full screen double buffering is always vsynced. However, TinyGL has the possibility to not wait for a buffer to have been fully displayed before swapping to the next buffer, which removes the waiting for benchmark purposes, but isn't the same as non-vsync on f.ex. Linux or Windows.


    I can only repeat: In fullscreen mode there is only vsync. Buffers are always swapped at the vertical blank. What happens when you disable the synchronisation in this case is that you'll end up rendering to the buffer that's currently being displayed, which is why you're seeing graphical artifacts. Also, you should keep in mind that using a window-style context incurs a performance hit you wouldn't see with a normal screen context due to rendering to an off-screen bitmap and blitting the result on top of the screen.
    I rarely log in to MorphZone which means that I often miss private messages sent on here. If you wish to contact me, please email me at [username]@asgaard.morphos-team.net, where [username] is my username here on MorphZone.
  • »22.12.13 - 18:16
    Profile Visit Website
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Daytona675x
    Posts: 109 from 2013/12/5
    @bigfoot:
    Your answer was clear and I got everything working.

    I just ask myself, why GLASetSync isn't doing something useful ;-)

    As it looks now that whole command is useless:
    - with a screen-context it produces garbage when turning off vsync.
    - and with a window-context it has zero effect.

    It is simply misleading. If you start MorphOS-programming like me and you find that command in the headers you expect it to do what it says, and do it in a useful way.

    Either it should do something like I did manually now - or be removed ;-)

    Quote:

    Also, you should keep in mind that using a window-style context incurs a performance hit

    Yes, of course. But if people decide to turn off vsync in fullscreen-mode this is normally because they got a slow machine that can't deliver the frames fast enough for proper vsync, and in such a case turning of vsync will usually speed up things - trading tearing for speed :-)
    That's actually the only reason why I wanted to have that switch.

    [ Editiert durch Daytona675x 22.12.2013 - 18:49 ]
  • »22.12.13 - 18:29
    Profile Visit Website
  • MorphOS Developer
    bigfoot
    Posts: 510 from 2003/4/11
    Quote:

    I just ask myself, why GLASetSync isn't doing something useful


    It does do something useful. It makes benchmarking possible ;)

    Quote:

    Yes, of course. But if people decide to turn off vsync in fullscreen-mode this is normally because they got a slow machine that can't deliver the frames fast enough for proper vsync, and in such a case turning of vsync will usually speed up things - trading tearing for speed
    That's actually the only reason why I wanted to have that switch.


    In that case you might as well remove it. Disabling vsync doesn't improve speed on any machine, slow or fast, and using a window context in fullscreen gives you ugly tearing and poor performance.
    I rarely log in to MorphZone which means that I often miss private messages sent on here. If you wish to contact me, please email me at [username]@asgaard.morphos-team.net, where [username] is my username here on MorphZone.
  • »22.12.13 - 19:55
    Profile Visit Website
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Daytona675x
    Posts: 109 from 2013/12/5
    @bigfoot
    Quote:

    It does do something useful. It makes benchmarking possible ;)

    :-)

    Quote:

    Disabling vsync doesn't improve speed on any machine, slow or fast

    In my case here it does. Fullscreen-vsynced is significantly slower than Fullscreen-Window-not-synced under certain circumstances.
    Although this is rather academic: if the game runs that slow it won't become really playable by that. Nevertheless here it makes the difference between about 25 fps (unplayable synced) and about 35 fps (a bit less unplayable, unsynced ;-) ) when I torture my antique Mac with the highest quality settings.

    EDIT: bullshit, I mixed up fps-data from two different rendering-paths :-P

    [ Editiert durch Daytona675x 22.12.2013 - 21:22 ]
  • »22.12.13 - 20:21
    Profile Visit Website
  • MorphOS Developer
    bigfoot
    Posts: 510 from 2003/4/11
    Quote:

    In my case here it does. Fullscreen-vsynced is significantly slower than Fullscreen-Window-not-synced under certain circumstances.


    The only time vsync will be 'slower' than non-vsync is if your hardware is capable of running the game faster than the screen's refresh rate.

    Quote:

    Although this is rather academic: if the game runs that slow it won't become really playable by that. Nevertheless here it makes the difference between about 25 fps (unplayable synced) and about 35 fps (a bit less unplayable, unsynced ) when I torture my antique Mac with the highest quality settings.


    Then I'm going to suggest that there's something funny going on ;) MorphOS uses a triple buffered display for OpenGL programs, so the only time there will be a 'slowdown' from vsync is if you're able to render faster than your refresh rate.
    I rarely log in to MorphZone which means that I often miss private messages sent on here. If you wish to contact me, please email me at [username]@asgaard.morphos-team.net, where [username] is my username here on MorphZone.
  • »22.12.13 - 20:45
    Profile Visit Website
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Daytona675x
    Posts: 109 from 2013/12/5
    @bigfoot
    Ooops, you're right :-) Apparently I mixed up some fps data.

    Great, so now the game has a feature nobody needs...

    Well, almost at least: performance in window-mode is the same under those circumstances and you got at least lower latency than with triple-buffering then :-)

    [ Editiert durch Daytona675x 23.12.2013 - 08:27 ]
  • »22.12.13 - 21:05
    Profile Visit Website
  • Paladin of the Pegasos
    Paladin of the Pegasos
    Jupp3
    Posts: 1193 from 2003/2/24
    From: Helsinki, Finland
    itix,
    Quote:

    In SDL I am calling GLAReinitializeContextWindowed() on window resize.

    kiero recommended to simply delete the old context & create new one on window resize. Not sure why :-).

    Works for me, keeps textures etc. exactly like I assumed it would not :-D
  • »29.12.13 - 10:13
    Profile Visit Website