mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 23:33:00 +00:00
- work on separating DFrameBuffer from DCanvas.
2D works in D3D backend, but 3D crashes because not all pointers have been rerouted yet.
This commit is contained in:
parent
377aa95e34
commit
bb9283a9af
18 changed files with 84 additions and 149 deletions
|
@ -174,10 +174,7 @@ OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height,
|
|||
NeedGammaUpdate = false;
|
||||
NeedPalUpdate = false;
|
||||
|
||||
if (MemBuffer == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
RenderBuffer = new DSimpleCanvas(Width, Height, bgra);
|
||||
|
||||
memcpy(SourcePalette, GPalette.BaseColors, sizeof(PalEntry) * 256);
|
||||
|
||||
|
@ -780,7 +777,8 @@ void OpenGLSWFrameBuffer::Present()
|
|||
|
||||
void OpenGLSWFrameBuffer::SetInitialState()
|
||||
{
|
||||
if (gl.es) UseMappedMemBuffer = false;
|
||||
//if (gl.es) re-enable later! First the basics must work.
|
||||
UseMappedMemBuffer = false;
|
||||
|
||||
AlphaBlendEnabled = false;
|
||||
AlphaBlendOp = GL_FUNC_ADD;
|
||||
|
@ -1125,6 +1123,8 @@ bool OpenGLSWFrameBuffer::Lock(bool buffered)
|
|||
}
|
||||
assert(!In2D);
|
||||
Accel2D = vid_hw2d;
|
||||
|
||||
#if 0 // temporarily disabled. Must be fixed later
|
||||
if (UseMappedMemBuffer)
|
||||
{
|
||||
if (!MappedMemBuffer)
|
||||
|
@ -1140,8 +1140,11 @@ bool OpenGLSWFrameBuffer::Lock(bool buffered)
|
|||
Buffer = (uint8_t*)MappedMemBuffer;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
Buffer = MemBuffer;
|
||||
#if 0
|
||||
//Buffer = MemBuffer;
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1165,7 +1168,9 @@ void OpenGLSWFrameBuffer::Unlock()
|
|||
}
|
||||
else if (--m_Lock == 0)
|
||||
{
|
||||
#if 0
|
||||
Buffer = nullptr;
|
||||
#endif
|
||||
|
||||
if (MappedMemBuffer)
|
||||
{
|
||||
|
@ -1263,7 +1268,9 @@ void OpenGLSWFrameBuffer::Update()
|
|||
//LOG1 ("cycles = %d\n", BlitCycles);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
Buffer = nullptr;
|
||||
#endif
|
||||
UpdatePending = false;
|
||||
}
|
||||
|
||||
|
@ -1286,7 +1293,7 @@ void OpenGLSWFrameBuffer::Flip()
|
|||
int clientHeight = ViewportScaledHeight(GetClientWidth(), GetClientHeight());
|
||||
if (clientWidth > 0 && clientHeight > 0 && (Width != clientWidth || Height != clientHeight))
|
||||
{
|
||||
Resize(clientWidth, clientHeight);
|
||||
RenderBuffer->Resize(clientWidth, clientHeight);
|
||||
|
||||
TrueHeight = Height;
|
||||
PixelDoubling = 0;
|
||||
|
@ -1375,6 +1382,7 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d)
|
|||
int pixelsize = IsBgra() ? 4 : 1;
|
||||
int size = Width * Height * pixelsize;
|
||||
|
||||
auto MemBuffer = RenderBuffer->GetPixels();
|
||||
uint8_t *dest = (uint8_t*)MapBuffer(GL_PIXEL_UNPACK_BUFFER, size);
|
||||
if (dest)
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@ class OpenGLSWFrameBuffer : public SDLGLFB
|
|||
typedef SDLGLFB Super; //[C]commented, DECLARE_CLASS defines this in linux
|
||||
#endif
|
||||
|
||||
DSimpleCanvas *RenderBuffer;
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ bool PolyTriangleDrawer::mirror;
|
|||
|
||||
void PolyTriangleDrawer::set_viewport(int x, int y, int width, int height, DCanvas *canvas)
|
||||
{
|
||||
dest = (uint8_t*)canvas->GetBuffer();
|
||||
dest = (uint8_t*)canvas->GetPixels();
|
||||
dest_width = canvas->GetWidth();
|
||||
dest_height = canvas->GetHeight();
|
||||
dest_pitch = canvas->GetPitch();
|
||||
|
@ -554,7 +554,7 @@ void DrawRectCommand::Execute(DrawerThread *thread)
|
|||
thread_data.num_cores = thread->num_cores;
|
||||
|
||||
auto renderTarget = PolyRenderer::Instance()->RenderTarget;
|
||||
const void *destOrg = renderTarget->GetBuffer();
|
||||
const void *destOrg = renderTarget->GetPixels();
|
||||
int destWidth = renderTarget->GetWidth();
|
||||
int destHeight = renderTarget->GetHeight();
|
||||
int destPitch = renderTarget->GetPitch();
|
||||
|
|
|
@ -70,12 +70,14 @@ void PolyRenderer::RenderView(player_t *player)
|
|||
|
||||
RenderActorView(player->mo, false);
|
||||
|
||||
#if 0
|
||||
// Apply special colormap if the target cannot do it
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->ShaderColormap() && RenderTarget->IsBgra() && !(r_shadercolormaps && screen->Accel2D))
|
||||
{
|
||||
Threads.MainThread()->DrawQueue->Push<ApplySpecialColormapRGBACommand>(cameraLight->ShaderColormap(), screen);
|
||||
}
|
||||
#endif
|
||||
|
||||
Threads.MainThread()->FlushDrawQueue();
|
||||
DrawerThreads::WaitForWorkers();
|
||||
|
|
|
@ -224,7 +224,7 @@ namespace swrenderer
|
|||
auto rendertarget = args.Viewport()->RenderTarget;
|
||||
if (rendertarget->IsBgra())
|
||||
{
|
||||
uint32_t *destorg = (uint32_t*)rendertarget->GetBuffer();
|
||||
uint32_t *destorg = (uint32_t*)rendertarget->GetPixels();
|
||||
uint32_t *dest = (uint32_t*)args.Dest();
|
||||
int offset = (int)(ptrdiff_t)(dest - destorg);
|
||||
x = offset % rendertarget->GetPitch();
|
||||
|
@ -232,7 +232,7 @@ namespace swrenderer
|
|||
}
|
||||
else
|
||||
{
|
||||
uint8_t *destorg = rendertarget->GetBuffer();
|
||||
uint8_t *destorg = rendertarget->GetPixels();
|
||||
uint8_t *dest = (uint8_t*)args.Dest();
|
||||
int offset = (int)(ptrdiff_t)(dest - destorg);
|
||||
x = offset % rendertarget->GetPitch();
|
||||
|
@ -246,7 +246,7 @@ namespace swrenderer
|
|||
auto rendertarget = args.Viewport()->RenderTarget;
|
||||
if (rendertarget->IsBgra())
|
||||
{
|
||||
uint32_t *destorg = (uint32_t*)rendertarget->GetBuffer();
|
||||
uint32_t *destorg = (uint32_t*)rendertarget->GetPixels();
|
||||
uint32_t *dest = (uint32_t*)args.Dest();
|
||||
int offset = (int)(ptrdiff_t)(dest - destorg);
|
||||
x = offset % rendertarget->GetPitch();
|
||||
|
@ -254,7 +254,7 @@ namespace swrenderer
|
|||
}
|
||||
else
|
||||
{
|
||||
uint8_t *destorg = rendertarget->GetBuffer();
|
||||
uint8_t *destorg = rendertarget->GetPixels();
|
||||
uint8_t *dest = (uint8_t*)args.Dest();
|
||||
int offset = (int)(ptrdiff_t)(dest - destorg);
|
||||
x = offset % rendertarget->GetPitch();
|
||||
|
|
|
@ -3074,7 +3074,7 @@ namespace swrenderer
|
|||
void DrawVoxelBlocksPalCommand::Execute(DrawerThread *thread)
|
||||
{
|
||||
int destpitch = args.Viewport()->RenderTarget->GetPitch();
|
||||
uint8_t *destorig = args.Viewport()->RenderTarget->GetBuffer();
|
||||
uint8_t *destorig = args.Viewport()->RenderTarget->GetPixels();
|
||||
const uint8_t *colormap = args.Colormap(args.Viewport());
|
||||
|
||||
for (int i = 0; i < blockcount; i++)
|
||||
|
|
|
@ -719,6 +719,7 @@ namespace swrenderer
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
ApplySpecialColormapRGBACommand::ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen)
|
||||
{
|
||||
buffer = screen->GetBuffer();
|
||||
|
@ -869,6 +870,7 @@ namespace swrenderer
|
|||
count--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -938,7 +940,7 @@ namespace swrenderer
|
|||
void DrawVoxelBlocksRGBACommand::Execute(DrawerThread *thread)
|
||||
{
|
||||
int pitch = args.Viewport()->RenderTarget->GetPitch();
|
||||
uint8_t *destorig = args.Viewport()->RenderTarget->GetBuffer();
|
||||
uint8_t *destorig = args.Viewport()->RenderTarget->GetPixels();
|
||||
|
||||
DrawSprite32Command drawer(args);
|
||||
drawer.args.dc_texturefracx = 0;
|
||||
|
|
|
@ -175,6 +175,7 @@ namespace swrenderer
|
|||
FString DebugInfo() override;
|
||||
};
|
||||
|
||||
#if 0
|
||||
class ApplySpecialColormapRGBACommand : public DrawerCommand
|
||||
{
|
||||
uint8_t *buffer;
|
||||
|
@ -193,6 +194,7 @@ namespace swrenderer
|
|||
void Execute(DrawerThread *thread) override;
|
||||
FString DebugInfo() override { return "ApplySpecialColormapRGBACommand"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename CommandType, typename BlendMode>
|
||||
class DrawerBlendCommand : public CommandType
|
||||
|
|
|
@ -225,7 +225,7 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi
|
|||
r_viewwindow = mScene.MainThread()->Viewport->viewwindow;
|
||||
}
|
||||
screen->GetFlashedPalette (palette);
|
||||
M_CreatePNG (file, pic->GetBuffer(), palette, SS_PAL, width, height, pic->GetPitch(), Gamma);
|
||||
M_CreatePNG (file, pic->GetPixels(), palette, SS_PAL, width, height, pic->GetPitch(), Gamma);
|
||||
delete pic;
|
||||
}
|
||||
|
||||
|
@ -300,24 +300,24 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
|
|||
|
||||
if (Canvas->IsBgra())
|
||||
{
|
||||
if (Pixels == Canvas->GetBuffer())
|
||||
if (Pixels == Canvas->GetPixels())
|
||||
{
|
||||
FTexture::FlipSquareBlockBgra((uint32_t*)Pixels, tex->GetWidth(), tex->GetHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
FTexture::FlipNonSquareBlockBgra((uint32_t*)Pixels, (const uint32_t*)Canvas->GetBuffer(), tex->GetWidth(), tex->GetHeight(), Canvas->GetPitch());
|
||||
FTexture::FlipNonSquareBlockBgra((uint32_t*)Pixels, (const uint32_t*)Canvas->GetPixels(), tex->GetWidth(), tex->GetHeight(), Canvas->GetPitch());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Pixels == Canvas->GetBuffer())
|
||||
if (Pixels == Canvas->GetPixels())
|
||||
{
|
||||
FTexture::FlipSquareBlockRemap(Pixels, tex->GetWidth(), tex->GetHeight(), GPalette.Remap);
|
||||
}
|
||||
else
|
||||
{
|
||||
FTexture::FlipNonSquareBlockRemap(Pixels, Canvas->GetBuffer(), tex->GetWidth(), tex->GetHeight(), Canvas->GetPitch(), GPalette.Remap);
|
||||
FTexture::FlipNonSquareBlockRemap(Pixels, Canvas->GetPixels(), tex->GetWidth(), tex->GetHeight(), Canvas->GetPitch(), GPalette.Remap);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -302,7 +302,7 @@ namespace swrenderer
|
|||
|
||||
if (viewport->RenderTarget->IsBgra())
|
||||
{
|
||||
uint32_t *dest = (uint32_t*)viewport->RenderTarget->GetBuffer() + x + Ytop * spacing;
|
||||
uint32_t *dest = (uint32_t*)viewport->RenderTarget->GetPixels() + x + Ytop * spacing;
|
||||
|
||||
uint32_t c = GPalette.BaseColors[color].d;
|
||||
for (int y = Ytop; y <= Ybottom; y++)
|
||||
|
@ -313,7 +313,7 @@ namespace swrenderer
|
|||
}
|
||||
else
|
||||
{
|
||||
uint8_t *dest = viewport->RenderTarget->GetBuffer() + x + Ytop * spacing;
|
||||
uint8_t *dest = viewport->RenderTarget->GetPixels() + x + Ytop * spacing;
|
||||
|
||||
for (int y = Ytop; y <= Ybottom; y++)
|
||||
{
|
||||
|
|
|
@ -103,13 +103,13 @@ namespace swrenderer
|
|||
{
|
||||
if (!viewport->RenderTarget->IsBgra())
|
||||
{
|
||||
memset(viewport->RenderTarget->GetBuffer(), clearcolor, viewport->RenderTarget->GetPitch() * viewport->RenderTarget->GetHeight());
|
||||
memset(viewport->RenderTarget->GetPixels(), clearcolor, viewport->RenderTarget->GetPitch() * viewport->RenderTarget->GetHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t bgracolor = GPalette.BaseColors[clearcolor].d;
|
||||
int size = viewport->RenderTarget->GetPitch() * viewport->RenderTarget->GetHeight();
|
||||
uint32_t *dest = (uint32_t *)viewport->RenderTarget->GetBuffer();
|
||||
uint32_t *dest = (uint32_t *)viewport->RenderTarget->GetPixels();
|
||||
for (int i = 0; i < size; i++)
|
||||
dest[i] = bgracolor;
|
||||
}
|
||||
|
@ -118,12 +118,14 @@ namespace swrenderer
|
|||
RenderActorView(player->mo);
|
||||
|
||||
// Apply special colormap if the target cannot do it
|
||||
#if 0
|
||||
if (CameraLight::Instance()->ShaderColormap() && viewport->RenderTarget->IsBgra() && !(r_shadercolormaps && screen->Accel2D))
|
||||
{
|
||||
auto queue = std::make_shared<DrawerCommandQueue>(MainThread()->FrameMemory.get());
|
||||
queue->Push<ApplySpecialColormapRGBACommand>(CameraLight::Instance()->ShaderColormap(), screen);
|
||||
DrawerThreads::Execute(queue);
|
||||
}
|
||||
#endif
|
||||
|
||||
DrawerWaitCycles.Clock();
|
||||
DrawerThreads::WaitForWorkers();
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace swrenderer
|
|||
|
||||
int pitch = RenderTarget->GetPitch();
|
||||
int pixelsize = RenderTarget->IsBgra() ? 4 : 1;
|
||||
return RenderTarget->GetBuffer() + (x + y * pitch) * pixelsize;
|
||||
return RenderTarget->GetPixels() + (x + y * pitch) * pixelsize;
|
||||
}
|
||||
|
||||
void RenderViewport::InitTextureMapping()
|
||||
|
|
|
@ -121,7 +121,7 @@ void FCanvasTexture::MakeTexture (FRenderStyle) // This ignores the render style
|
|||
}
|
||||
else
|
||||
{
|
||||
Pixels = (uint8_t*)Canvas->GetBuffer();
|
||||
Pixels = (uint8_t*)Canvas->GetPixels();
|
||||
bPixelsAllocated = false;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ void FCanvasTexture::MakeTextureBgra()
|
|||
}
|
||||
else
|
||||
{
|
||||
PixelsBgra = (uint32_t*)CanvasBgra->GetBuffer();
|
||||
PixelsBgra = (uint32_t*)CanvasBgra->GetPixels();
|
||||
bPixelsAllocatedBgra = false;
|
||||
}
|
||||
|
||||
|
|
121
src/v_video.cpp
121
src/v_video.cpp
|
@ -199,8 +199,6 @@ int NewWidth, NewHeight, NewBits;
|
|||
DCanvas::DCanvas (int _width, int _height, bool _bgra)
|
||||
{
|
||||
// Init member vars
|
||||
Buffer = NULL;
|
||||
LockCount = 0;
|
||||
Width = _width;
|
||||
Height = _height;
|
||||
Bgra = _bgra;
|
||||
|
@ -527,7 +525,7 @@ void DFrameBuffer::CalcGamma (float gamma, uint8_t gammalookup[256])
|
|||
DSimpleCanvas::DSimpleCanvas (int width, int height, bool bgra)
|
||||
: DCanvas (width, height, bgra)
|
||||
{
|
||||
MemBuffer = nullptr;
|
||||
PixelBuffer = nullptr;
|
||||
Resize(width, height);
|
||||
}
|
||||
|
||||
|
@ -536,10 +534,10 @@ void DSimpleCanvas::Resize(int width, int height)
|
|||
Width = width;
|
||||
Height = height;
|
||||
|
||||
if (MemBuffer != NULL)
|
||||
if (PixelBuffer != NULL)
|
||||
{
|
||||
delete[] MemBuffer;
|
||||
MemBuffer = NULL;
|
||||
delete[] PixelBuffer;
|
||||
PixelBuffer = NULL;
|
||||
}
|
||||
|
||||
// Making the pitch a power of 2 is very bad for performance
|
||||
|
@ -578,8 +576,8 @@ void DSimpleCanvas::Resize(int width, int height)
|
|||
}
|
||||
}
|
||||
int bytes_per_pixel = Bgra ? 4 : 1;
|
||||
MemBuffer = new uint8_t[Pitch * height * bytes_per_pixel];
|
||||
memset (MemBuffer, 0, Pitch * height * bytes_per_pixel);
|
||||
PixelBuffer = new uint8_t[Pitch * height * bytes_per_pixel];
|
||||
memset (PixelBuffer, 0, Pitch * height * bytes_per_pixel);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -590,10 +588,10 @@ void DSimpleCanvas::Resize(int width, int height)
|
|||
|
||||
DSimpleCanvas::~DSimpleCanvas ()
|
||||
{
|
||||
if (MemBuffer != NULL)
|
||||
if (PixelBuffer != NULL)
|
||||
{
|
||||
delete[] MemBuffer;
|
||||
MemBuffer = NULL;
|
||||
delete[] PixelBuffer;
|
||||
PixelBuffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -607,7 +605,7 @@ DSimpleCanvas::~DSimpleCanvas ()
|
|||
//==========================================================================
|
||||
|
||||
DFrameBuffer::DFrameBuffer (int width, int height, bool bgra)
|
||||
: DSimpleCanvas (ViewportScaledWidth(width, height), ViewportScaledHeight(width, height), bgra)
|
||||
: DCanvas (ViewportScaledWidth(width, height), ViewportScaledHeight(width, height), bgra)
|
||||
{
|
||||
LastMS = LastSec = FrameCount = LastCount = LastTic = 0;
|
||||
Accel2D = false;
|
||||
|
@ -616,70 +614,6 @@ DFrameBuffer::DFrameBuffer (int width, int height, bool bgra)
|
|||
VideoHeight = height;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DFrameBuffer :: PostprocessBgra
|
||||
//
|
||||
// Copies data to destination buffer while performing gamma and flash.
|
||||
// This is only needed if a target cannot do this with shaders.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void DFrameBuffer::CopyWithGammaBgra(void *output, int pitch, const uint8_t *gammared, const uint8_t *gammagreen, const uint8_t *gammablue, PalEntry flash, int flash_amount)
|
||||
{
|
||||
const uint8_t *gammatables[3] = { gammared, gammagreen, gammablue };
|
||||
|
||||
if (flash_amount > 0)
|
||||
{
|
||||
uint16_t inv_flash_amount = 256 - flash_amount;
|
||||
uint16_t flash_red = flash.r * flash_amount;
|
||||
uint16_t flash_green = flash.g * flash_amount;
|
||||
uint16_t flash_blue = flash.b * flash_amount;
|
||||
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
uint8_t *dest = (uint8_t*)output + y * pitch;
|
||||
uint8_t *src = MemBuffer + y * Pitch * 4;
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
uint16_t fg_red = src[2];
|
||||
uint16_t fg_green = src[1];
|
||||
uint16_t fg_blue = src[0];
|
||||
uint16_t red = (fg_red * inv_flash_amount + flash_red) >> 8;
|
||||
uint16_t green = (fg_green * inv_flash_amount + flash_green) >> 8;
|
||||
uint16_t blue = (fg_blue * inv_flash_amount + flash_blue) >> 8;
|
||||
|
||||
dest[0] = gammatables[2][blue];
|
||||
dest[1] = gammatables[1][green];
|
||||
dest[2] = gammatables[0][red];
|
||||
dest[3] = 0xff;
|
||||
|
||||
dest += 4;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
uint8_t *dest = (uint8_t*)output + y * pitch;
|
||||
uint8_t *src = MemBuffer + y * Pitch * 4;
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
dest[0] = gammatables[2][src[0]];
|
||||
dest[1] = gammatables[1][src[1]];
|
||||
dest[2] = gammatables[0][src[2]];
|
||||
dest[3] = 0xff;
|
||||
|
||||
dest += 4;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DFrameBuffer :: DrawRateStuff
|
||||
|
@ -726,38 +660,15 @@ void DFrameBuffer::DrawRateStuff ()
|
|||
// draws little dots on the bottom of the screen
|
||||
if (ticker)
|
||||
{
|
||||
int64_t i = I_GetTime();
|
||||
int64_t tics = i - LastTic;
|
||||
uint8_t *buffer = GetBuffer();
|
||||
int64_t t = I_GetTime();
|
||||
int64_t tics = t - LastTic;
|
||||
|
||||
LastTic = i;
|
||||
LastTic = t;
|
||||
if (tics > 20) tics = 20;
|
||||
|
||||
// Buffer can be NULL if we're doing hardware accelerated 2D
|
||||
if (buffer != NULL)
|
||||
{
|
||||
if (IsBgra())
|
||||
{
|
||||
uint32_t *buffer32 = (uint32_t*)buffer;
|
||||
buffer32 += (GetHeight() - 1) * GetPitch();
|
||||
|
||||
for (i = 0; i < tics * 2; i += 2) buffer32[i] = 0xffffffff;
|
||||
for (; i < 20 * 2; i += 2) buffer32[i] = 0xff000000;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer += (GetHeight() - 1) * GetPitch();
|
||||
|
||||
for (i = 0; i < tics * 2; i += 2) buffer[i] = 0xff;
|
||||
for (; i < 20 * 2; i += 2) buffer[i] = 0x00;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < tics*2; i += 2) Clear(i, Height-1, i+1, Height, 255, 0);
|
||||
for ( ; i < 20*2; i += 2) Clear(i, Height-1, i+1, Height, 0, 0);
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < tics*2; i += 2) Clear(i, Height-1, i+1, Height, 255, 0);
|
||||
for ( ; i < 20*2; i += 2) Clear(i, Height-1, i+1, Height, 0, 0);
|
||||
}
|
||||
|
||||
// draws the palette for debugging
|
||||
|
|
|
@ -206,7 +206,8 @@ public:
|
|||
virtual ~DCanvas ();
|
||||
|
||||
// Member variable access
|
||||
inline uint8_t *GetBuffer () const { return Buffer; }
|
||||
//inline uint8_t *GetBuffer () const { return Buffer; }
|
||||
inline uint8_t *GetPixels () const { return PixelBuffer; }
|
||||
inline int GetWidth () const { return Width; }
|
||||
inline int GetHeight () const { return Height; }
|
||||
inline int GetPitch () const { return Pitch; }
|
||||
|
@ -214,11 +215,10 @@ public:
|
|||
|
||||
|
||||
protected:
|
||||
uint8_t *Buffer;
|
||||
uint8_t *PixelBuffer;
|
||||
int Width;
|
||||
int Height;
|
||||
int Pitch;
|
||||
int LockCount;
|
||||
bool Bgra;
|
||||
int clipleft = 0, cliptop = 0, clipwidth = -1, clipheight = -1;
|
||||
|
||||
|
@ -236,11 +236,9 @@ class DSimpleCanvas : public DCanvas
|
|||
public:
|
||||
DSimpleCanvas (int width, int height, bool bgra);
|
||||
~DSimpleCanvas ();
|
||||
|
||||
protected:
|
||||
void Resize(int width, int height);
|
||||
|
||||
uint8_t *MemBuffer;
|
||||
private:
|
||||
|
||||
DSimpleCanvas() {}
|
||||
};
|
||||
|
@ -270,9 +268,10 @@ public:
|
|||
// for actually implementing this. Built on top of SimpleCanvas, because it
|
||||
// needs a system memory buffer when buffered output is enabled.
|
||||
|
||||
class DFrameBuffer : public DSimpleCanvas
|
||||
class DFrameBuffer : public DCanvas
|
||||
{
|
||||
typedef DSimpleCanvas Super;
|
||||
|
||||
protected:
|
||||
void DrawTextureV(FTexture *img, double x, double y, uint32_t tag, va_list tags) = delete;
|
||||
virtual void DrawTextureParms(FTexture *img, DrawParms &parms);
|
||||
|
@ -281,6 +280,7 @@ protected:
|
|||
bool ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, bool fortext) const;
|
||||
void DrawTextCommon(FFont *font, int normalcolor, double x, double y, const char *string, DrawParms &parms);
|
||||
|
||||
int LockCount = 0;
|
||||
|
||||
public:
|
||||
DFrameBuffer (int width, int height, bool bgra);
|
||||
|
@ -448,7 +448,6 @@ public:
|
|||
protected:
|
||||
void DrawRateStuff ();
|
||||
void CopyFromBuff (uint8_t *src, int srcPitch, int width, int height, uint8_t *dest);
|
||||
void CopyWithGammaBgra(void *output, int pitch, const uint8_t *gammared, const uint8_t *gammagreen, const uint8_t *gammablue, PalEntry flash, int flash_amount);
|
||||
|
||||
DFrameBuffer () {}
|
||||
|
||||
|
|
|
@ -261,10 +261,8 @@ D3DFB::D3DFB (UINT adapter, int width, int height, bool bgra, bool fullscreen)
|
|||
NeedGammaUpdate = false;
|
||||
NeedPalUpdate = false;
|
||||
|
||||
if (MemBuffer == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
RenderBuffer = new DSimpleCanvas(width, height, bgra);
|
||||
Pitch = RenderBuffer->GetPitch(); // should be removed, but still needed as long as DFrameBuffer inherits from DCanvas
|
||||
|
||||
memcpy(SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
|
||||
|
||||
|
@ -930,7 +928,9 @@ bool D3DFB::Lock (bool buffered)
|
|||
}
|
||||
assert (!In2D);
|
||||
Accel2D = vid_hw2d;
|
||||
#if 0
|
||||
Buffer = MemBuffer;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -955,7 +955,9 @@ void D3DFB::Unlock ()
|
|||
}
|
||||
else if (--LockCount == 0)
|
||||
{
|
||||
#if 0
|
||||
Buffer = NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1060,7 +1062,9 @@ void D3DFB::Update ()
|
|||
BlitCycles.Unclock();
|
||||
//LOG1 ("cycles = %d\n", BlitCycles);
|
||||
|
||||
#if 0
|
||||
Buffer = NULL;
|
||||
#endif
|
||||
UpdatePending = false;
|
||||
}
|
||||
|
||||
|
@ -1111,7 +1115,7 @@ void D3DFB::Flip()
|
|||
GetClientRect(Window, &box);
|
||||
if (box.right > 0 && box.bottom > 0 && (Width != box.right || Height != box.bottom))
|
||||
{
|
||||
Resize(box.right, box.bottom);
|
||||
RenderBuffer->Resize(box.right, box.bottom);
|
||||
|
||||
TrueHeight = Height;
|
||||
PixelDoubling = 0;
|
||||
|
@ -1208,6 +1212,7 @@ void D3DFB::Draw3DPart(bool copy3d)
|
|||
{
|
||||
if (IsBgra() && FBFormat == D3DFMT_A8R8G8B8)
|
||||
{
|
||||
auto MemBuffer = RenderBuffer->GetPixels();
|
||||
if (lockrect.Pitch == Pitch * sizeof(uint32_t) && Pitch == Width)
|
||||
{
|
||||
memcpy(lockrect.pBits, MemBuffer, Width * Height * sizeof(uint32_t));
|
||||
|
@ -1228,17 +1233,17 @@ void D3DFB::Draw3DPart(bool copy3d)
|
|||
{
|
||||
if (lockrect.Pitch == Pitch && Pitch == Width)
|
||||
{
|
||||
memcpy(lockrect.pBits, MemBuffer, Width * Height);
|
||||
memcpy(lockrect.pBits, RenderBuffer->GetPixels(), Width * Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t *dest = (uint8_t *)lockrect.pBits;
|
||||
uint8_t *src = (uint8_t *)MemBuffer;
|
||||
uint8_t *src = RenderBuffer->GetPixels();
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
memcpy(dest, src, Width);
|
||||
dest = reinterpret_cast<uint8_t*>(reinterpret_cast<uint8_t*>(dest) + lockrect.Pitch);
|
||||
src += Pitch;
|
||||
src += RenderBuffer->GetPitch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1169,7 +1169,7 @@ void Win32GLFrameBuffer::SetGammaTable(uint16_t *tbl)
|
|||
bool Win32GLFrameBuffer::Lock(bool buffered)
|
||||
{
|
||||
m_Lock++;
|
||||
Buffer = MemBuffer;
|
||||
//Buffer = MemBuffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ extern HANDLE FPSLimitEvent;
|
|||
class D3DFB : public BaseWinFB
|
||||
{
|
||||
typedef BaseWinFB Super;
|
||||
|
||||
DSimpleCanvas *RenderBuffer = nullptr;
|
||||
|
||||
public:
|
||||
D3DFB (UINT adapter, int width, int height, bool bgra, bool fullscreen);
|
||||
~D3DFB ();
|
||||
|
|
Loading…
Reference in a new issue