I checked the "Texture" output (that one introduced for SDL2 only on DOSBox patch I use for SDL2), and yes, autoscaling works. So probably that it by logic.
But they're definitely something wrong. I experience a big slowdown, random lockups, and all that stuff if I just use "texture" output. It can be of course and SDL2 code related to the "SCREEN_TEXTURE" case in the DosBOX's code itself, but it somehow .. somehow like the same slowdown when used with "OpenGL" output...
It just like earth and sky in comparison with "software" output, which is fast and good. But once I use "texture", it's the same slow as I use "OpenGL", and the same freezes often. And does not matter if I use "compositing" or "software" renderer.
EDIT: yeah strange things happen. If I just set: output=surface in DOSBox, then when I run it all works fine and stable.
But, once I set output "texture", and "render" be "compositing", or "software" - does not matter, then bad things start happens. Like often freezes and slowness.
But what difference between using software output (which uses compositing renderer automatically in sdl2, right? or not?), and texture output with renderer set to compositing and/or software?
I mean isn't it the same when output=surface and when output=texture + render=software? Or like when output=surface and output=texture+compositing? Just when only "texture" is involved, everything start to be bad. But seeing code of DOSBox in case SCREEN_TEXTURE it surely different in compare with plain case SCREEN_SURFACE.
Sadly that with Texture it only freezes on me most of time without any crashlog, so cant' even see where/what.
EDIT2: I found that to have the same speed as with "output=surface" but with "output=texture" and "renderer=compositing" is to hit few times "enter" in dosbox window, then make window be inactive, and then again active, and speed back.
And it freezes really randomly. But only when "texture" is used. Probably something weird in the DOSBox's SDL2 code in terms of SCREEN_TEXTURE handling, maybe it didn't free resources as need it, and for each run trash memory..
Edited by kas1e on 2020/2/12 6:56:58 Edited by kas1e on 2020/2/12 7:00:16 Edited by kas1e on 2020/2/12 7:01:45 Edited by kas1e on 2020/2/12 8:55:16 Edited by kas1e on 2020/2/12 8:57:31 Edited by kas1e on 2020/2/12 9:02:36
Just to clarify that by freeze you mean a total system lockup? Does it happen with window, fullscreen or both?
DB calls SDL_LockTexture in one function and SDL_UnlockTexture in another and draws in-between those. If DB happens to log something (printf) something between Lock/Unlock calls then it would explain the freeze, _except_ not in SW mode where the texture bitmap is UserPrivate and doesn't require locking so it doesn't seem to be that cause.
DB seems to use some kind of clipping calculations. If there is some issue, it might write outside the bitmap and potentially over some system structures.
Just to clarify that by freeze you mean a total system lockup?
Yes, no crash, nothing on serial about problems, just usual debug output.
Quote:
Does it happen with window, fullscreen or both?
It may happen at any time anywhere. Usually, it happens when I just start to do something. Pure running almost never freezes, but it can when I do some alt+enter switches, another time it will survive 20 alt+enters, and then still works, and lockup later.
Should to add that old DOSBox (sdl1 version) lockup on me quite often too, while others say that it works for them fine, need to investigate wtf.
Edited by kas1e on 2020/2/13 12:06:30 Edited by kas1e on 2020/2/13 12:07:40
@Capehill Omg, i was able to install on fresh partition public x5000 iso, and then tried step by step to find out why old SDL1 version of dosbox fail on me now (this time i check SDL1, as freezes there happens right away, just once i run anything with even pure surface usage).
So, firstly checked with all default libs: all fine. It works. Then, i just replaced sobjs:libsdl_1.2.so from x5000 iso, on latest one from repo : bah! freezes starts!
Then, i got one from os4depot (so one which i didn't build myself, and which is in "release" mode) => same freeze.
I revert back then to original from x5000 iso (it is 1.2.13 1.4 (19.08.2012) : no freezes.
And those freezes looks exactly like ones i have with SDL2 build, when use "texture" output. It can be that some code shared between both SDLs which can cause that (maybe usage of new graphics.library functions or something..). Because as i see with SDL1 freezes , it happens or when something should start draws on screen, or when something stop draws on screen (like running some bench graphic tool (rare), or exit from(almost always) ).
@Capehill To track down issues, I made 2 versions of DOSBox for SDL1 and SDL2 to works over shared versions (so you can test it too with any libs or debug added) packed it up nicely (so you need nothing to install/change/etc, just unpack and run).
So, there SDL1 version (that one not my build, but 10 years old Corto's one, without jit, so not be surprised it will be a little slow):
All you need it's unpack those 2 archives to 2 different directories, then go inside of any of them you want to test, then type "DOSBox", and once it runs in DOSBox's window type "cd PCPBench" and then "PCPBench.exe"
Now, with the SDL1 version and our last SOBJ you will freeze 5-10% of times when you run a benchmark, and 70-80% of times when you will hit any key to exit from (with the original version from x5000 iso you will not have those freezes).
With the SDL2 version, I set up everything that goes through "Texture", so it will use "compositing" renderer, and it the same as with SDL1: you will freezes on Benchmark, or once you start it, or once you exit from. Or, sometime you will be able run/exit few times before freeze. Sometime you even will be able to do some alt+enter before freeze. But at least on my x5000 config, it's easier to reproduce that with the SDL1 version. Also if roots of freezes are the same, then with SDL1 version it can be easy to debug maybe.
Interestingly that I have absolutely nothing on serial, not with SDL1, not with SDL2. I mean no crash log, nothing, just some usual debug output before it dies (and it always different too). Like for SDL2 version when I tried to run benchmark and freezes:
[OS4_CreateRenderer] Creating renderer for 'DOSBox SVN, CPU speed: 3000 cycles, Frameskip 0, Program: DOSBOX' (flags 0x2) [OS4_CreateRenderer] VSYNC: off [SDL_CreateMutex] Created mutex 0x6FFA9600 [OS4_ActivateRenderer] Allocating VRAM bitmap 1024*768*32 for renderer
Or for SDL1 version, when I able to run it, but once hit "ESC" to exit:
[os4video_CheckPointerInWindow] Pointer outside of window [os4video_CheckPointerInWindow] Pointer outside of window [os4video_CheckPointerInWindow] Pointer outside of window [os4video_CheckPointerInWindow] Pointer inside window [os4video_HandleEnterLeaveWindow] Pointer entered window
But probably, it all happens on the allocation/deallocation of video memory. Through can't be sure at the moment.
And, as I say, the same issue happens and on the latest beta, and on a public version of x5000 iso, just with swapped libSDL1 in SOBJs:
Once I use the old version of libSDL.so, I have no freezes in that test does not matter how hard I try. But it all can be because of the different sizes of .so, memory placing, etc, so need to confirm that you can reproduce it too.
SDL1 version freezes even with pure "surface", while SDL2 version freezes only when we use "texture". Maybe for SDL2 the surface part was fixed somehow in the process... Or maybe it 2 independent issues...
PS. I also expirience the same kind of "silent freeze" for some SDL2/Ogles2 game, so maybe it's all related. I just hope on your side you will have actual crashes. Maybe also those silent freezes I have in Diablo also can be related?
Tested SDL2 build. As suspected earlier, it freezes after bitmap locking. So DosBox never unlocks bitmap. Something wrong happens between locking and unlocking the texture.
Lock was gained successfully, I added some debug into SDL2 to prove that.
On my serial:
Quote:
[OS4_UnlockTexture] Called [OS4_LockTexture] Called text 0x647E86F0, rect 0x66F7F4A8, pix 0x66F7F4EC, pitch 0x66F7F4E8 [OS4_LockTexture] x 0, y 0, w 640, h 400 [OS4_LockTexture] pitch 2560, pixels 0x815E3100 [OS4_UnlockTexture] Called [OS4_LockTexture] Called text 0x647E86F0, rect 0x66F7D368, pix 0x66F7D3AC, pitch 0x66F7D3A8 [OS4_LockTexture] x 0, y 0, w 640, h 400 [OS4_LockTexture] pitch 2560, pixels 0x815E3100 [OS4_UnlockTexture] Called [OS4_LockTexture] Called text 0x647E86F0, rect 0x66F7D368, pix 0x66F7D3AC, pitch 0x66F7D3A8 [OS4_LockTexture] x 0, y 0, w 640, h 400 [OS4_LockTexture] pitch 2560, pixels 0x815E3100
You need to start adding serial debug to DB to see where the freeze happens exactly.
EDIT: did some more debugging:
Quote:
[OS4_LockTexture] Called text 0x635746F0, rect 0x67588368, pix 0x675883AC, pitch 0x675883A8 [OS4_LockTexture] x 0, y 0, w 640, h 400 [OS4_LockTexture] pitch 2816, pixels 0x8135B004 [OS4_PumpEvents] Here [OS4_PumpEvents] Here [OS4_PumpEvents] Here [OS4_UnlockTexture] Called [OS4_PumpEvents] Here [OS4_PumpEvents] Here [OS4_PumpEvents] Here [OS4_PumpEvents] Here [OS4_PumpEvents] Here [OS4_LockTexture] Called text 0x635746F0, rect 0x67588368, pix 0x675883AC, pitch 0x675883A8 [OS4_LockTexture] x 0, y 0, w 640, h 400 [OS4_LockTexture] pitch 2816, pixels 0x8135B004 [OS4_PumpEvents] Here [OS4_PumpEvents] Here [OS4_PumpEvents] Here [OS4_PumpEvents] Here [OS4_PumpEvents] Here [OS4_PumpEvents] Here
DB goes handling user events while holding the (texture) bitmap lock! Not good.
I think you can place some serial prints for these return statements:
bool GFX_StartUpdate(Bit8u * & pixels,Bitu & pitch) {
#if SDL_VERSION_ATLEAST(2,0,0)
if (!sdl.update_display_contents) {
dprintf("GFX_StartUpdate: if (!sdl.update_display_contents)\n");
IDOS->Delay(5);
return false;
}
#endif
if (!sdl.active || sdl.updating) {
dprintf("GFX_StartUpdate: if (!sdl.active || sdl.updating) {\n");
IDOS->Delay(5);
return false;
}
And like this:
void GFX_EndUpdate( const Bit16u *changedLines ) {
#if C_DDRAW
int ret;
#endif
#if SDL_VERSION_ATLEAST(2,0,0)
if (!sdl.update_display_contents) {
dprintf("GFX_EndUpdate: if (!sdl.update_display_contents)\n");
IDOS->Delay(5);
return;
}
#endif
if (!sdl.updating) {
dprintf("GFX_EndUpdate: if (!sdl.updating)\n");
IDOS->Delay(5);
return;
}
sdl.updating=false;
And nothing have in output about when i crashes. I.e. that what i have when i run it :
[_OS4_INIT] IExec 0x021B28D4
[SDL_CreateMutex] Created mutex 0x6FFA9480
[OS4_InitThreadSubSystem] Main task 0x6646D1A0
[OS4_InitThreadSubSystem] Children mutex 0x6FFA94A0, waiters mutex 0x6FFA94C0
[OS4_OpenLibrary] Opening 'dos.library' version 50 succeeded (address 0x6FEFE948)
[OS4_GetInterface] Getting interface for libbase 0x6FEFE948 succeeded (address 0x6F8E1740)
[OS4_InitThreadSubSystem] dosBase 0x6FEFE948, iDos 0x6F8E1740
[OS4_InitTimerSubSystem] Called
[OS4_InitTimerSubSystem] ITimer 0x6FF9E400
[OS4_InitTimerSubSystem] Timer frequency 24937500 Hz
[OS4_TimerCreate] Creating timer 0x63201410 for task 0x6646D1A0
[SDL_CreateMutex] Created mutex 0x6FFA94E0
[SDL_CreateMutex] Created mutex 0x6FFA9500
[OS4_InitThreadSubSystem] Already initialized
[OS4_CreateDevice] *** SDL 2.0.11 video initialization starts ***
[OS4_CreateDevice] Build date: 12.2.2020
[OS4_AllocSystemResources] Called
[OS4_OpenLibraries] Opening libraries
[OS4_OpenLibrary] Opening 'graphics.library' version 54 succeeded (address 0x6FFA3420)
[OS4_OpenLibrary] Opening 'layers.library' version 53 succeeded (address 0x6FFFE4F0)
[OS4_OpenLibrary] Opening 'intuition.library' version 51 succeeded (address 0x6FF5D4D0)
[OS4_OpenLibrary] Opening 'icon.library' version 51 succeeded (address 0x689700CC)
[OS4_OpenLibrary] Opening 'workbench.library' version 51 succeeded (address 0x6FF0F80C)
[OS4_OpenLibrary] Opening 'keymap.library' version 51 succeeded (address 0x6FF777A0)
[OS4_OpenLibrary] Opening 'textclip.library' version 51 succeeded (address 0x67B64CDC)
[OS4_OpenLibrary] Opening 'dos.library' version 51 succeeded (address 0x6FEFE948)
[OS4_GetInterface] Getting interface for libbase 0x6FFA3420 succeeded (address 0x6FFFF800)
[OS4_GetInterface] Getting interface for libbase 0x6FFFE4F0 succeeded (address 0x6FF51140)
[OS4_GetInterface] Getting interface for libbase 0x6FF5D4D0 succeeded (address 0x6FF08000)
[OS4_GetInterface] Getting interface for libbase 0x689700CC succeeded (address 0x689E7110)
[OS4_GetInterface] Getting interface for libbase 0x6FF0F80C succeeded (address 0x689E7A70)
[OS4_GetInterface] Getting interface for libbase 0x6FF777A0 succeeded (address 0x6FF9F3C0)
[OS4_GetInterface] Getting interface for libbase 0x67B64CDC succeeded (address 0x67DF98B0)
[OS4_GetInterface] Getting interface for libbase 0x6FEFE948 succeeded (address 0x6F8E1740)
[OS4_OpenLibraries] All library interfaces OK
[OS4_FindApplicationName] GetCliProgramName: 'dosbox'
[OS4_FindApplicationName] Application name: 'dosbox'
[OS4_GetInterface] Getting interface for libbase 0x6FF779EC succeeded (address 0x6FF8B9B0)
[OS4_VideoInit] Called
[OS4_InitModes] Called
[OS4_LockPubScreen] Locking public screen
[OS4_LockPubScreen] Public screen 0x67E67388 locked
[OS4_GetDisplayMode] RTG mode 1342509824: w=1920, h=1080, bits=24
[OS4_CreateDefaultCursor] 0x614D59F0
[OS4_CreateHiddenCursor] Called
[OS4_CreateCursor] Surface 0x614D5A18, cursor 0x614D5AF8, hot_x 0, hot_y 0
[OS4_CopyImageData] Copying cursor data 1*1 from surface 0x614D5A18 to buffer 0x614D5B20
[OS4_GetDoubleClickTimeInMillis] Doubleclick time 1500 ms
[OS4_OpenAhiDevice] ahi.device opened
[OS4_OpenAhiDevice] IO requests created
[OS4_OpenAhiDevice] deviceOpen = 1
[OS4_CloseAhiDevice] Closing device
[OS4_CloseAhiDevice] Freeing I/O requests
[OS4_CloseAhiDevice] Deleting message port
[OS4_CloseAhiDevice] Device closed
[OS4_AudioAvailable] AHI is available
[SDL_CreateMutex] Created mutex 0x6FFA9520
[OS4_InitThreadSubSystem] Already initialized
[SDL_CreateMutex] Created mutex 0x6FFA9540
[OS4_InitThreadSubSystem] Already initialized
[AMIGAINPUT_OpenLibrary] Called
[OS4_OpenLibrary] Opening 'AmigaInput.library' version 51 succeeded (address 0x64B1A4F8)
[OS4_GetInterface] Getting interface for libbase 0x64B1A4F8 succeeded (address 0x64941340)
[AMIGAINPUT_EnumerateJoysticks] ENUMJOY: id=1663045524, type=1, axes=2, buttons=3
[AMIGAINPUT_EnumerateJoysticks] ENUMJOY: id=1663045524, type=3, axes=0, buttons=4
[AMIGAINPUT_EnumerateJoysticks] Joystick 'PCI_GamePort' (AI ID=3328) has no axes/buttons - ignoring.
[AMIGAINPUT_EnumerateJoysticks] ENUMJOY: id=1663045524, type=3, axes=0, buttons=8
[AMIGAINPUT_EnumerateJoysticks] Joystick 'PCI_HornetGP' (AI ID=7936) has no axes/buttons - ignoring.
[AMIGAINPUT_EnumerateJoysticks] ENUMJOY: id=1663045524, type=3, axes=0, buttons=4
[AMIGAINPUT_EnumerateJoysticks] Joystick 'PCI_sblive' (AI ID=3840) has no axes/buttons - ignoring.
[AMIGAINPUT_JoystickInit] EnumDevices returned 0
[AMIGAINPUT_JoystickInit] Found 0 joysticks
[OS4_GetIDCMPFlags] Called
[OS4_GetWindowFlags] Called
[OS4_GetScreenForWindow] Window mode (public screen)
[OS4_CenterWindow] X centered
[OS4_CenterWindow] Y centered
[OS4_CreateSystemWindow] Opening window '(null)' at (640,340) of size (640x400) on screen 0x67E67388
[OS4_CreateSystemWindow] Window address 0x6F8766E8
[OS4_SetupWindowData] '(null)' dimensions 640*400
[OS4_CreateIconifyGadget] Called
[OS4_CreateIconifyGadget] Image 0x6F876AE4 for gadget created
[OS4_CreateIconifyGadget] Gadget 0x6F876C54 created and added
[OS4_ShowWindow] Showing window ''
[OS4_RefreshCursorState] Mouse shown 1
[OS4_CreateWindowFramebuffer] Native format 6, SDL format 372645892 (SDL_PIXELFORMAT_ARGB8888)
[OS4_CreateWindowFramebuffer] Allocating 640*400*32 bitmap)
[SDL_CreateMutex] Created mutex 0x6FFA9560
[OS4_OpenDevice] handle 0x00000000, devname (null), iscapture 0
[OS4_OpenDevice] New format = 0x9010
[OS4_OpenDevice] Buffer size = 4096
[SDL_CreateSemaphore] Created semaphore 0x60BF9660 with count 0
[SDL_SYS_CreateThread] Node 0x6493B080
[SDL_SYS_CreateThread] Created new thread 'SDLAudioP2' (task 0x614AA0C0, args 0x60BF9648)
[OS4_RunThread] This task 0x614AA0C0, node 0x6493B080, args 0x60BF9648
[OS4_TimerCreate] Creating timer 0x6493B094 for task 0x614AA0C0
[SDL_SemPost] Signalling task 0x6646D1A0 for semaphore 0x60BF9660
[SDL_SemPost] Semaphore 0x60BF9660 value 1
[SDL_SYS_SetThreadPriority] Changed task 0x614AA0C0 priority from 0 to 10
[OS4_ThreadInit] Called
[OS4_OpenAhiDevice] ahi.device opened
[OS4_OpenAhiDevice] IO requests created
[OS4_OpenAhiDevice] deviceOpen = 1
[SDL_SemWaitTimeout] Semaphore 0x60BF9660 got signal 0x8000
[SDL_DestroySemaphore] Destroying semaphore 0x60BF9660
[OS4_InitThreadSubSystem] Already initialized
[SDL_CreateMutex] Created mutex 0x6FFA9580
[SDL_CreateMutex] Created mutex 0x6FFA95A0
[void GFX_EndUpdate(const Bit16u*)] GFX_EndUpdate: if (!sdl.updating)
[OS4_HideWindow] Ignore hide request, window 'DOSBox SVN, CPU speed: 3000 cycles, Frameskip 0, Program: DOSBOX' is destroying
[OS4_SetWindowGrabPrivate] Window 0x6F8766E8 ('DOSBox SVN, CPU speed: 3000 cycles, Frameskip 0, Program: DOSBOX') input was released
[OS4_DestroyWindowFramebuffer] Freeing bitmap 0x64956B98
[OS4_DestroyWindow] Called for 'DOSBox SVN, CPU speed: 3000 cycles, Frameskip 0, Program: DOSBOX' (flags 0x8)
[OS4_RemoveAppWindow] Removing AppWindow
[OS4_CloseSystemWindow] Closing window 'DOSBox SVN, CPU speed: 3000 cycles, Frameskip 0, Program: DOSBOX' (address 0x6F8766E8)
[OS4_CloseScreen] Public screen, not closing
[OS4_CloseWindow] Disposing gadget 0x6F876C54
[OS4_CloseWindow] Disposing gadget image 0x6F876AE4
[OS4_GetIDCMPFlags] Called
[OS4_GetWindowFlags] Called
[OS4_GetScreenForWindow] Window mode (public screen)
[OS4_CenterWindow] X centered
[OS4_CenterWindow] Y centered
[OS4_CreateSystemWindow] Opening window '(null)' at (448,156) of size (1024x768) on screen 0x67E67388
[OS4_CreateSystemWindow] Window address 0x6F8766E8
[OS4_SetupWindowData] '(null)' dimensions 1024*768
[OS4_CreateIconifyGadget] Called
[OS4_CreateIconifyGadget] Image 0x6F876AE4 for gadget created
[OS4_CreateIconifyGadget] Gadget 0x6F876C54 created and added
[OS4_ShowWindow] Showing window ''
[OS4_RefreshCursorState] Mouse shown 1
[OS4_CreateRenderer] Creating renderer for 'DOSBox SVN, CPU speed: 3000 cycles, Frameskip 0, Program: DOSBOX' (flags 0x2)
[OS4_CreateRenderer] VSYNC: off
[SDL_CreateMutex] Created mutex 0x6FFA95C0
[OS4_ActivateRenderer] Allocating VRAM bitmap 1024*768*32 for renderer
[OS4_WindowEvent] Called with event 10
[OS4_WindowEvent] Called with event 11
I only see there one time "[void GFX_EndUpdate(const Bit16u*)] GFX_EndUpdate: if (!sdl.updating)", and it happens when i run dosbox and do nothing.
Then, while i can operate in it, nothing new on serial. Then i run pcpbench, and crashes , and serial didn't bring me anything new :(
Also it interesting, why SDL1 version didn't freezes like this before, but start freezes with latest versions of SDL1.. But that one probabaly for later while didn't get wtf with SDL2 build..
EDIT: was lucky enough to not crash from first run, and then can see in log, that when i run bench and it didn't crashes, it show me "[void GFX_EndUpdate(const Bit16u*)] GFX_EndUpdate: if (!sdl.updating)". But i never have returns from startupdate() in those !checks.
Will try to put debugs everywhere in those 2 functions.
EDIT2: put printfs everywhere didn't help much, i.e:
#if SDL_VERSION_ATLEAST(2,0,0)
case SCREEN_TEXTURE:
{
void * texPixels;
int texPitch;
dprintf("before SDL_LockTexture\n");
if (SDL_LockTexture(sdl.texture.texture, NULL, &texPixels, &texPitch) < 0) {
dprintf("we in case SCREEN_TEXTURE, if (SDL_LockTexture(sdl.texture.texture, NULL, &texPixels, &texPitch) < 0)\n");
IDOS->Delay(0);
return false;
}
[void GFX_EndUpdate(const Bit16u*)] before SDL_UnlockTexture() [void GFX_EndUpdate(const Bit16u*)] after SDL_UnlockTexture() [void GFX_EndUpdate(const Bit16u*)] after SDL_RenderClear(); [void GFX_EndUpdate(const Bit16u*)] after SDL_RenderCopy(); [void GFX_EndUpdate(const Bit16u*)] after SDL_RenderPresent() [bool GFX_StartUpdate(Bit8u*&, Bitu&)] before SDL_LockTexture [bool GFX_StartUpdate(Bit8u*&, Bitu&)] after SDL_LockTexture [bool GFX_StartUpdate(Bit8u*&, Bitu&)] after pixels = (Bit8u *)texPixels; [bool GFX_StartUpdate(Bit8u*&, Bitu&)] after pitch = texPitch; [void GFX_EndUpdate(const Bit16u*)] before SDL_UnlockTexture() [void GFX_EndUpdate(const Bit16u*)] after SDL_UnlockTexture() [void GFX_EndUpdate(const Bit16u*)] after SDL_RenderClear(); [void GFX_EndUpdate(const Bit16u*)] after SDL_RenderCopy(); [void GFX_EndUpdate(const Bit16u*)] after SDL_RenderPresent() [bool GFX_StartUpdate(Bit8u*&, Bitu&)] before SDL_LockTexture [bool GFX_StartUpdate(Bit8u*&, Bitu&)] after SDL_LockTexture [bool GFX_StartUpdate(Bit8u*&, Bitu&)] after pixels = (Bit8u *)texPixels; [bool GFX_StartUpdate(Bit8u*&, Bitu&)] after pitch = texPitch;
Like, it do return true; after locking texture, and die somewhere after, but before unlocking part. Maybe it SDL_LockTexture() itself, just die a bit later.
Edited by kas1e on 2020/2/13 21:31:49 Edited by kas1e on 2020/2/13 21:37:28
I in meantime may try for example build version-by-version since working one to find commit when things start to be bad and maybe it will point us on some direction with sdl2 version too ?
1) SDL1: never use HWSURFACE, this avoids locking them and eventually deadlock.
2) SDL2: let DB use a surface, and just before rendering the frame upload it to texture. In other words, remove using of Lock/Unlock texture.
3) Common: if setting the window title is the only cause for deadlock, then it would be possible postpone it so that title will be updated after DB has unlocked the bitmap. Store the string, set some flag, and if flag set, then update when it's safe.
SDL1 didn't support HWSURFACE in window mode until March 13th 2018. That's the likely reason it works with older SDL1 because SWSURFACEs don't require locking.
@Capehill Commenting out "SDL_SetWindowTitle(sdl.window,title);" in GFX_SetTitle() show that freezes gone in SDL2 version when "texture" output is used. Yeah!
Question is: is it bug in DOSBox then? Or it is specific to our OS and how it handle HW surfaces? I mean, why our OS is the first one that catches issues because of calling that after locking? Should it be reported to DOSBox authors, so they can fix it?
I didn't check SDL1 version at moment, but probably that it as well.
Next things i want to understand, is : are the environment SDL_RENDER_DRIVER have higher priority that SDL_Hint from code?
What i mean, is that if i do set SDL_RENDER_DRIVER to opengles2, then option to set renderer from dosbox didn't works, and "opengles2" still used as set in environment.
Edited by kas1e on 2020/2/14 15:27:03 Edited by kas1e on 2020/2/14 15:28:32 Edited by kas1e on 2020/2/14 15:29:16 Edited by kas1e on 2020/2/14 15:38:53
I don't know enough about DosBox regarding what is normal and intended. It's possibly not a bug to change window title and "AmigaOS rules" are "AmigaOS rules".
But I find it odd that when DB promises to start updating texture by locking it, then afterwards it calls at least SDL_GetTicks, SDL_PollEvent and SDL_SetWindowTitle. GetTicks and PollEvent could have something todo with emulation parts but SetWindowTitle clearly doesn't.
You can ask DB team is behaviour OK. If it is, then fine, we can work around it many ways.
Now, probabaly last issue is white screen when used opengl. In the archive i upload for sdl2 version, you may change in dosbox.conf:
output=texture renderer=opengl
Then run dosbox and will see all white. But everything still works (so you still can close it, through that fix about removing context not here, so will bring you that watchog_timeout), but while all works all white, etc.
renderer=opengles2 works fine in that terms, just all blue as you know (was it issue in warp3dnova or in ogles2 ?).
with renderer=opengl all white not only when i use minigl, but also if i build my own sdl2 with replaced minigl on gl4es. So its something about opengl code in whole.
EDIT: damn, it freezes even with disable SetWindow_Tittle() :( Just not in pcpbench, and much rare, but still.
EDIT2: Also what worry me, is that i have the same deadlock-freezes with latest Diablo compiled for SDL2 too.
Edited by kas1e on 2020/2/14 19:28:40 Edited by kas1e on 2020/2/14 20:32:24
@capehill On of devs says that yep, work between lock/unlock should be minimized, but he also says that maybe even better to not use lock/unlock texture, but use SDL_updatetexture() and give that link: https://forums.libsdl.org/viewtopic.php?t=9728
But then, I do not know if on our side updatetexture() will not do internal locking, as in the case with SDL1 and HW_SURFACE.
I do not know if on our side updatetexture() will not do internal locking, as in the case with SDL1 and HW_SURFACE.
Of course graphics.library shall lock the bitmap internally but the point is that DB cannot do random things _during_ SDL_UpdateTexture is called. So there cannot be deadlock.
@Capehill In meantime do some more debugging (while is not clear if they will rewrite it now to SDL_UpdateTexture way), so far commented out all SDL_SetWindowTitle() calls as well as all calls to function which call that call :) and deadlock still here.
Its even not necessary to switch to fullscreen. It just deadlocks even in window, just now more rare.
Also interesting is why SDL1 version deadlocks on new sdl1 almost right after you run dosbox, but SDL2, when using pure surface are not. But for pure surface SDL2 also use SurfaceLock as SDL1 , and it probabaly the same HW_SURFACE?. Or for SDL2 there is no SW/HW surface anymore, and if one use surface in SDL2 it mean "SW" surface ? If so that can explain why SDL2 version with pure surface didnt' deadlocks
while is not clear if they will rewrite it now to SDL_UpdateTexture way
We don't have to wait for them.
1) Create SDL_Surface similar (width, height, format) to SDL_Texture 2) Remove SDL_LockTexture, give DB pixels and pitch to the surface 3) Remove SDL_UnlockTexture, call SDL_UpdateTexture instead of 4) When SDL_Texture is destroyed, remember to destroy SDL_Surface too
So it runs (didn't crashes at least), but each frame ends in black color. I.e. i can see how frames shown, then ends with black color. Then if i hit enter, i again can see it, but then end with black color.
I through was able to run pcpbench, and it also renders fine, but offten black areas shows there and there.
/* SDL_PIXELFORMAT_ARGB8888 is possible with most
rendering drivers, "opengles" being a notable exception */
sdl.texture.texture = SDL_CreateTexture(sdl.renderer, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, width, height);
/* SDL_PIXELFORMAT_ABGR8888 (not RGB) is the
only supported format for the "opengles" driver */
if (!sdl.texture.texture) {
if (flags & GFX_RGBONLY) goto dosurface;
sdl.texture.texture = SDL_CreateTexture(sdl.renderer, SDL_PIXELFORMAT_ABGR8888,
SDL_TEXTUREACCESS_STREAMING, width, height);
}
And :
#if SDL_VERSION_ATLEAST(2,0,0)
case SCREEN_TEXTURE:
{
void * texPixels;
int texPitch;