First post, by fr500
I'm looking for some help to solve horrible screen tearing (I have an horizontal line running across the screen at vertical scrolling in games like jazz jackrabbit).
I didn't write this core, I just cleaned it up and rebased it on top of DOSBox-SVN so it's easier to maintain.
Anyway, our whole rendering code is quite simplistic, it's basically this:
#include <string.h>
#include "libretro.h"
#include "dosbox.h"
#include "video.h"
Bit8u RDOSGFXbuffer[1024*768*4];
Bitu RDOSGFXwidth, RDOSGFXheight, RDOSGFXpitch;
unsigned RDOSGFXcolorMode = RETRO_PIXEL_FORMAT_0RGB1555;
void* RDOSGFXhaveFrame;
Bitu GFX_GetBestMode(Bitu flags)
{
return GFX_CAN_32 | GFX_RGBONLY;
}
Bitu GFX_GetRGB(Bit8u red,Bit8u green,Bit8u blue)
{
return (red << 16) | (green << 8) | (blue << 0);
}
Bitu GFX_SetSize(Bitu width,Bitu height,Bitu flags,double scalex,double scaley,GFX_CallBack_t cb)
{
memset(RDOSGFXbuffer, 0, sizeof(RDOSGFXbuffer));
RDOSGFXwidth = width;
RDOSGFXheight = height;
RDOSGFXpitch = width * 4;
if(RDOSGFXwidth > 1024 || RDOSGFXheight > 768)
return 0;
return GFX_GetBestMode(0);
}
bool GFX_StartUpdate(Bit8u * & pixels,Bitu & pitch)
{
pixels = RDOSGFXbuffer;
pitch = RDOSGFXpitch;
return true;
}
void GFX_EndUpdate( const Bit16u *changedLines )
{
RDOSGFXhaveFrame = RDOSGFXbuffer;
}
// Stubs
void GFX_SetTitle(Bit32s cycles,Bits frameskip,bool paused){}
void GFX_ShowMsg(char const* format,...){}
void GFX_Events(){}
void GFX_SetPalette(Bitu start,Bitu count,GFX_PalEntry * entries){}
We're basically getting a pointer to the framebuffer and blitting that. AS IS. I see that whoever wrote this is not doing anything with changedlines, so I thought that may be the problem so that's one possibility.
The libretro core is leveraging a co-threading library (libco), so basically dosbox is running in a co-thread and we're escaping to the libretro thread on every T interval to get a finished frame. Maybe we're not doing it when the actual frame is complete so that's another possibility.
I'm not very savvy on the codebase, I tried to leave most things untouched, so I thought I'd ask for some feedback.